X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/02e8b2f9fbdfcd25080c42082d637da257c20094..c18ecb1164f8f8255b03374a15b381d14a096335:/src/motif/button.cpp diff --git a/src/motif/button.cpp b/src/motif/button.cpp index 455f2e17fb..3ff312878a 100644 --- a/src/motif/button.cpp +++ b/src/motif/button.cpp @@ -14,6 +14,7 @@ #endif #include "wx/button.h" +#include "wx/utils.h" #include #include @@ -37,6 +38,9 @@ bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label, SetName(name); SetValidator(validator); m_windowStyle = style; + m_backgroundColour = parent->GetBackgroundColour(); + m_foregroundColour = parent->GetForegroundColour(); + m_windowFont = parent->GetFont(); parent->AddChild((wxButton *)this); @@ -45,11 +49,13 @@ bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label, else m_windowId = id; - char* label1 = (label.IsNull() ? "" : (char*) (const char*) label); + wxString label1(wxStripMenuCodes(label)); - XmString text = XmStringCreateSimple (label1); + XmString text = XmStringCreateSimple ((char*) (const char*) label1); Widget parentWidget = (Widget) parent->GetClientWidget(); + XmFontList fontList = (XmFontList) m_windowFont.GetFontList(1.0, XtDisplay(parentWidget)); + /* * Patch Note (important) * There is no major reason to put a defaultButtonThickness here. @@ -62,6 +68,7 @@ bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label, m_mainWidget = (WXWidget) XtVaCreateManagedWidget ("button", xmPushButtonWidgetClass, parentWidget, + XmNfontList, fontList, XmNlabelString, text, // XmNdefaultButtonShadowThickness, 1, // See comment for wxButton::SetDefault NULL); @@ -71,12 +78,10 @@ bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label, XtAddCallback ((Widget) m_mainWidget, XmNactivateCallback, (XtCallbackProc) wxButtonCallback, (XtPointer) this); - SetCanAddEventHandler(TRUE); AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y); - SetFont(* parent->GetFont()); - ChangeColour(m_mainWidget); + ChangeBackgroundColour(); return TRUE; } @@ -120,7 +125,7 @@ void wxButton::Command (wxCommandEvent & event) ProcessCommand (event); } -void wxButtonCallback (Widget w, XtPointer clientData, XtPointer ptr) +void wxButtonCallback (Widget w, XtPointer clientData, XtPointer WXUNUSED(ptr)) { if (!wxGetWindowFromTable(w)) // Widget has been deleted! @@ -131,3 +136,19 @@ void wxButtonCallback (Widget w, XtPointer clientData, XtPointer ptr) event.SetEventObject(item); item->ProcessCommand (event); } + +void wxButton::ChangeFont(bool keepOriginalSize) +{ + wxWindow::ChangeFont(keepOriginalSize); +} + +void wxButton::ChangeBackgroundColour() +{ + DoChangeBackgroundColour(m_mainWidget, m_backgroundColour, TRUE); +} + +void wxButton::ChangeForegroundColour() +{ + wxWindow::ChangeForegroundColour(); +} +