diff options
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/PlatGTK.cxx | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx index 00dc3d2a8..9ba18a8ce 100644 --- a/gtk/PlatGTK.cxx +++ b/gtk/PlatGTK.cxx @@ -1794,9 +1794,10 @@ public: } } virtual void SetFont(Font &font); - virtual void Create(Window &parent, int ctrlID, int lineHeight_, bool unicodeMode_); + virtual void Create(Window &parent, int ctrlID, Point location_, int lineHeight_, bool unicodeMode_); virtual void SetAverageCharWidth(int width); virtual void SetVisibleRows(int rows); + virtual int GetVisibleRows() const; virtual PRectangle GetDesiredRect(); virtual int CaretFromEdge(); virtual void Clear(); @@ -1812,6 +1813,7 @@ public: doubleClickAction = action; doubleClickActionData = data; } + virtual void SetList(const char* list, char separator, char typesep); }; ListBox *ListBox::Allocate() { @@ -1842,7 +1844,7 @@ static gboolean ButtonPress(GtkWidget *, GdkEventButton* ev, gpointer p) { return FALSE; } -void ListBoxX::Create(Window &, int, int, bool) { +void ListBoxX::Create(Window &, int, Point, int, bool) { id = gtk_window_new(GTK_WINDOW_POPUP); GtkWidget *frame = gtk_frame_new(NULL); @@ -1936,6 +1938,10 @@ void ListBoxX::SetVisibleRows(int rows) { desiredVisibleRows = rows; } +int ListBoxX::GetVisibleRows() const { + return desiredVisibleRows; +} + PRectangle ListBoxX::GetDesiredRect() { // Before any size allocated pretend its 100 wide so not scrolled PRectangle rc(0, 0, 100, 100); @@ -2280,6 +2286,36 @@ void ListBoxX::ClearRegisteredImages() { xset.Clear(); } +void ListBoxX::SetList(const char* list, char separator, char typesep) { + Clear(); + int count = strlen(list) + 1; + char *words = new char[count]; + if (words) { + memcpy(words, list, count); + char *startword = words; + char *numword = NULL; + int i = 0; + for (; words[i]; i++) { + if (words[i] == separator) { + words[i] = '\0'; + if (numword) + *numword = '\0'; + Append(startword, numword?atoi(numword + 1):-1); + startword = words + i + 1; + numword = NULL; + } else if (words[i] == typesep) { + numword = words + i; + } + } + if (startword) { + if (numword) + *numword = '\0'; + Append(startword, numword?atoi(numword + 1):-1); + } + delete []words; + } +} + Menu::Menu() : id(0) {} void Menu::CreatePopUp() { |