X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/89c7e9622933c3ee7906c39bc3927a7d5616b94b..184b5d99a5382cd7a19888c85aff11f8a21af2f6:/src/motif/listbox.cpp?ds=sidebyside diff --git a/src/motif/listbox.cpp b/src/motif/listbox.cpp index 7425164595..3d864f49d5 100644 --- a/src/motif/listbox.cpp +++ b/src/motif/listbox.cpp @@ -40,7 +40,6 @@ wxListBox::wxListBox(): m_clientDataList(wxKEY_INTEGER) { m_noItems = 0; m_selected = 0; - m_inSetValue = FALSE; } bool wxListBox::Create(wxWindow *parent, wxWindowID id, @@ -51,10 +50,11 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, const wxValidator& validator, const wxString& name) { - m_inSetValue = FALSE; m_windowStyle = style; m_noItems = n; m_selected = 0; + m_backgroundColour = parent->GetBackgroundColour(); + m_foregroundColour = parent->GetForegroundColour(); SetName(name); SetValidator(validator); @@ -86,6 +86,8 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, m_mainWidget = (WXWidget) listWidget; + Set(n, choices); + XtManageChild (listWidget); long width = size.x; @@ -105,13 +107,12 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, XtAddCallback (listWidget, XmNdefaultActionCallback, (XtCallbackProc) wxListBoxDefaultActionProc, (XtPointer) this); - AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, width, height); + m_windowFont = parent->GetFont(); + ChangeFont(FALSE); - wxSystemSettings settings; - SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW)); + AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, width, height); - SetFont(* parent->GetFont()); - ChangeColour(m_mainWidget); + ChangeBackgroundColour(); return TRUE; } @@ -434,6 +435,8 @@ void wxListBox::SetClientData(int N, char *Client_data) wxNode *node = m_clientDataList.Find ((long) N); if (node) node->SetData ((wxObject *)Client_data); + else + node = m_clientDataList.Append((long) N, (wxObject*) Client_data); } // Return number of selections and an array of selected integers @@ -681,7 +684,7 @@ void wxListBoxCallback (Widget w, XtPointer clientData, wxListBox *item = (wxListBox *) clientData; - if (item->m_inSetValue) + if (item->InSetValue()) return; wxCommandEvent event (wxEVT_COMMAND_LISTBOX_SELECTED); @@ -737,3 +740,50 @@ WXWidget wxListBox::GetTopWidget() const { return (WXWidget) XtParent( (Widget) m_mainWidget ); } + +void wxListBox::ChangeFont(bool keepOriginalSize) +{ + wxWindow::ChangeFont(keepOriginalSize); +} + +void wxListBox::ChangeBackgroundColour() +{ + wxWindow::ChangeBackgroundColour(); + + Widget parent = XtParent ((Widget) m_mainWidget); + Widget hsb, vsb; + + XtVaGetValues (parent, + XmNhorizontalScrollBar, &hsb, + XmNverticalScrollBar, &vsb, + NULL); + + /* TODO: should scrollbars be affected? Should probably have separate + * function to change them (by default, taken from wxSystemSettings) + DoChangeBackgroundColour((WXWidget) hsb, m_backgroundColour, TRUE); + DoChangeBackgroundColour((WXWidget) vsb, m_backgroundColour, TRUE); + */ + + DoChangeBackgroundColour((WXWidget) parent, m_backgroundColour, TRUE); +} + +void wxListBox::ChangeForegroundColour() +{ + wxWindow::ChangeForegroundColour(); + + Widget parent = XtParent ((Widget) m_mainWidget); + Widget hsb, vsb; + + XtVaGetValues (parent, + XmNhorizontalScrollBar, &hsb, + XmNverticalScrollBar, &vsb, + NULL); + /* TODO: should scrollbars be affected? Should probably have separate + * function to change them (by default, taken from wxSystemSettings) + DoChangeForegroundColour((WXWidget) hsb, m_foregroundColour); + DoChangeForegroundColour((WXWidget) vsb, m_foregroundColour); + DoChangeForegroundColour((WXWidget) parent, m_foregroundColour); + */ +} + +