FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How does one add a scoll bar?

 
Post new topic   Reply to topic     Forum Index -> gtkD
View previous topic :: View next topic  
Author Message
joelcnz



Joined: 23 Feb 2009
Posts: 76

PostPosted: Sat Mar 16, 2013 2:32 pm    Post subject: How does one add a scoll bar? Reply with quote

I don't know how to add scroll bars. My text box text goes through the bottom of the screen, and I can't bring the text up again.

I'm using a grid to lay out my widgets.
Back to top
View user's profile Send private message MSN Messenger
joelcnz



Joined: 23 Feb 2009
Posts: 76

PostPosted: Mon Mar 18, 2013 10:39 pm    Post subject: Reply with quote

I still haven't managed to add scroll bars to grid cells.

I tried using ScrolledWindow. But couldn't get it working.

So, how do you (can you?) add scrolling one Grid cell or more?
Back to top
View user's profile Send private message MSN Messenger
joelcnz



Joined: 23 Feb 2009
Posts: 76

PostPosted: Tue Mar 19, 2013 12:48 am    Post subject: Reply with quote

Yes! I got scroll bars. Thanks Mike Wey!

I've still got a problem with the text going off the edge of its cell some times.
Back to top
View user's profile Send private message MSN Messenger
Mike Wey



Joined: 07 May 2007
Posts: 428

PostPosted: Tue Mar 19, 2013 3:58 pm    Post subject: Reply with quote

Is the code available somewhere so i could take a look at whats going on?
Back to top
View user's profile Send private message
joelcnz



Joined: 23 Feb 2009
Posts: 76

PostPosted: Tue Mar 19, 2013 4:57 pm    Post subject: Reply with quote

Code:

   this() {
      super("Bible Gate ("~BibleVersion~") - Joel Christensen");

      _clipboard = new Clipboard(_gtkClipboard);
      move(0,0);
      setResizable(false);
      _grid = new Grid();
      add(_grid);

      _books = new ComboBoxText();
      _books.setWrapWidth(3);
      foreach(i; iota(22)) {
         _books.appendText(g_bible.m_books[i].m_bookTitle);
         _books.appendText(g_bible.m_books[i+22].m_bookTitle);
         _books.appendText(g_bible.m_books[i+44].m_bookTitle);
      }
      _grid.attach(_books,0,0,1,1);
      _books.addOnChanged( (books) {
         if  (books.getActiveText != null) {
            _refEntry.setText = books.getActiveText~" ";
         } else {
            _refEntry.setText = "Genesis ";
            writeln("Book textbox is empty.");
         }
         setFocus(_refEntry);
         int len = _refEntry.getText.length;
         _refEntry.selectRegion(len,len);
      } );

      _refLabel = new Label("Full Reference:");
      _refLabel.setAlignment(0.5f,1f);
      _grid.attach(_refLabel, 0,1,1,1);

      _refEntry = new Entry();
      _refEntry.setPlaceholderText("(reference here)");
      _grid.attach(_refEntry, 0,2,1,1);
      _refEntry.addOnActivate( (a) {
         convertRef();
      } );

      _convertRef = new Button("Look Up Reference", &convertRef);
      _grid.attach(_convertRef, 0,3,1,1);

      _statusLabel = new Label("Program running");
      _grid.attach(_statusLabel, 0,4,1,1);

      version(none) {
         char[200] doWidth;
         doWidth[] = '-';
         _grid.attach(new Label(doWidth.idup), 1,0,1,1);
      }

      _textTagTable = new TextTagTable();
      _textBuffer = new TextBuffer(_textTagTable);
      _textView = new TextView(_textBuffer);
      _textView.setWrapMode(GtkWrapMode.WORD_CHAR);
      //_textView.setLeftMargin(30); // spacing on the left
      //_textView.setRightMargin(30); // spacing on the right
      _textView.setJustification(Justification.JUSTIFY_FILL);
      //#resizing textView and adding scroll bars
      //_textView.setVscrollPolicy(ScrollablePolicy.NATURAL); //#no effect!
//#ScrollWindow
      _scWinMain = new ScrolledWindow(_textView);
      _scWinMain.setMinContentWidth(800);
      _scWinMain.setMinContentHeight(600);

      _grid.attach(_scWinMain, 1,0,1,200);
      writeln(_textView.getInputPurpose());

      _textRefsTagTable = new TextTagTable();
      _textRefsBuffer = new TextBuffer(_textRefsTagTable);
      _textRefs = new TextView(_textRefsBuffer);
      _textRefsBuffer.setText = loadTextFile("refscurrent");

      _scWinRefs = new ScrolledWindow(_textRefs);
      _grid.attach(_scWinRefs, 0,5,1,1);
      //_scWinRefs.setMinContentWidth(250);
      _scWinRefs.setMinContentHeight(150);

      _convertBatch = new Button("Convert Batch", &convertBatchRefs);
      _grid.attach(_convertBatch, 0,6,1,1);

         _notesLabel = new Label("Notes:");
      _grid.attach(_notesLabel, 0,7,1,1);

      _notesTagTable = new TextTagTable();
      _notesBuffer = new TextBuffer(_notesTagTable);
      _notesView = new TextView(_notesBuffer);
      _notesView.setWrapMode(GtkWrapMode.WORD_CHAR);
      _notesBuffer.setText = loadTextFile("notescurrent")~"\n\n";
      _scWinNotes = new ScrolledWindow(_notesView);
      //_scWinNotes.setMinContentWidth(800);
      _scWinNotes.setMinContentHeight(150);
      _grid.attach(_scWinNotes, 0,8,1,1);

      _saveNotesCurrent = new Button("Save Notes", &saveNotesCurrent);
      _grid.attach(_saveNotesCurrent, 0,9,1,1);

      showAll();
   }


Each verse ends with a new line.

I haven't gotten clipboard stuff working.

I want to get GtkD working on OSX too, since it's portable, not like Windows I have trouble with.
Back to top
View user's profile Send private message MSN Messenger
joelcnz



Joined: 23 Feb 2009
Posts: 76

PostPosted: Wed Mar 20, 2013 3:54 pm    Post subject: Reply with quote

I've stopped text for going passed the end on the right. I used setRightMargin.

I don't see any thing about a OS X installer file for Gtk that was mentioned. I had a go at getting Gtk to work on OS X and it was no good. Now I've got stuff I don't know how to get rid of.
Back to top
View user's profile Send private message MSN Messenger
Mike Wey



Joined: 07 May 2007
Posts: 428

PostPosted: Thu Mar 21, 2013 3:14 pm    Post subject: Reply with quote

Quote:
I haven't gotten clipboard stuff working.


I haven't used the clipboard functions myself, but are there any problems you are running into?

joelcnz wrote:
I've stopped text for going passed the end on the right. I used setRightMargin.


Great.

Quote:
I don't see any thing about a OS X installer file for Gtk that was mentioned. I had a go at getting Gtk to work on OS X and it was no good. Now I've got stuff I don't know how to get rid of.


I don't know why they no longer have an OSX installer/package, and the page they redirect you to doesn't look like much of an help either.

Maybe you can use MacPorts.
Back to top
View user's profile Send private message
joelcnz



Joined: 23 Feb 2009
Posts: 76

PostPosted: Fri Mar 22, 2013 2:02 am    Post subject: Reply with quote

I found I can set text to the clipboard, but not paste from it.

I can't work out this function for getting from the clipboard:

Code:

void requestText (GtkClipboardTextReceivedFunc callback, void* userData);
Back to top
View user's profile Send private message MSN Messenger
Mike Wey



Joined: 07 May 2007
Posts: 428

PostPosted: Fri Mar 22, 2013 1:38 pm    Post subject: Reply with quote

I think you could use:
Code:
string waitForText()


requestText requires a callback function to get the text.
Code:
extern(C) void getText(GtkClipbord* clipboard, char* text, void* userData)
{
    //Use to!string(text) and store it somewhere.
}


clipboard.requestText(&getText, null);
Back to top
View user's profile Send private message
joelcnz



Joined: 23 Feb 2009
Posts: 76

PostPosted: Sun Mar 24, 2013 1:05 am    Post subject: Reply with quote

Actually, it looks like I can't do any thing with Clipboard class. I guess just creating an object with it, though.

I get errors like this:

Quote:

(BibleGate.exe:6048): Gtk-CRITICAL **: gtk_clipboard_wait_for_text: assertion `clipboard != NULL' failed


Is this example right?

Code:

GtkClipboard* _gtkClipboard
Clipboard _clipboard;
..
_clipboard = new Clipboard(_gtkClipboard);


I've got Windows only clipboard functions that do both (with text) copy to clipboard and paste from clipboard. Some one helped me with that.

Could I get some more code to work with?
[/quote]
Back to top
View user's profile Send private message MSN Messenger
Mike Wey



Joined: 07 May 2007
Posts: 428

PostPosted: Sun Mar 24, 2013 5:03 pm    Post subject: Reply with quote

joelcnz wrote:
Actually, it looks like I can't do any thing with Clipboard class. I guess just creating an object with it, though.

I get errors like this:

Quote:

(BibleGate.exe:6048): Gtk-CRITICAL **: gtk_clipboard_wait_for_text: assertion `clipboard != NULL' failed


Is this example right?

Code:

GtkClipboard* _gtkClipboard
Clipboard _clipboard;
..
_clipboard = new Clipboard(_gtkClipboard);


I've got Windows only clipboard functions that do both (with text) copy to clipboard and paste from clipboard. Some one helped me with that.

Could I get some more code to work with?


I think you'll need to use the get function:

Code:
import gtk.Main;
import gtk.Clipboard;
import gdk.Atoms;
import std.stdio;

void main(string[] args)
{
   Main.init(args);

   Clipboard clip = Clipboard.get(atomIntern("CLIPBOARD", false));
   clip.setText("Testing");

   writefln(clip.waitForText());
}
Back to top
View user's profile Send private message
joelcnz



Joined: 23 Feb 2009
Posts: 76

PostPosted: Mon Mar 25, 2013 3:00 pm    Post subject: Reply with quote

Yay, thanks Mike. It seems to be working good now.
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> gtkD All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group