]> git.saurik.com Git - wxWidgets.git/blobdiff - src/motif/choice.cpp
fixes
[wxWidgets.git] / src / motif / choice.cpp
index d71587ca85b2b3446b5bb16486f020d43f9f567d..2585d18a6af6e5610f4439b508cdde4fea62c6b1 100644 (file)
@@ -125,9 +125,11 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id,
 
     XtVaSetValues((Widget) m_formWidget, XmNresizePolicy, XmRESIZE_NONE, NULL);
 
+    m_windowFont = parent->GetFont();
+    ChangeFont(FALSE);
+
     AttachWidget (parent, m_buttonWidget, m_formWidget, pos.x, pos.y, size.x, size.y);
 
-    SetFont(* parent->GetFont());
     ChangeBackgroundColour();
 
     return TRUE;
@@ -164,6 +166,8 @@ void wxChoice::Append(const wxString& item)
 #endif
                                      NULL);
 
+  DoChangeBackgroundColour((WXWidget) w, m_backgroundColour);
+
   if (m_windowFont.Ok())
     XtVaSetValues (w,
                   XmNfontList, (XmFontList) m_windowFont.GetFontList(1.0, XtDisplay((Widget) m_formWidget)),
@@ -171,9 +175,12 @@ void wxChoice::Append(const wxString& item)
 
   WXWidget *new_widgetList = new WXWidget[m_noStrings + 1];
   int i;
-  for (i = 0; i < m_noStrings; i++)
-    new_widgetList[i] = m_widgetList[i];
+  if (m_widgetList)
+    for (i = 0; i < m_noStrings; i++)
+      new_widgetList[i] = m_widgetList[i];
+
   new_widgetList[m_noStrings] = (WXWidget) w;
+
   if (m_widgetList)
     delete[] m_widgetList;
   m_widgetList = new_widgetList;
@@ -418,18 +425,49 @@ void wxChoiceCallback (Widget w, XtPointer clientData,
     }
 }
 
-void wxChoice::ChangeFont()
+void wxChoice::ChangeFont(bool keepOriginalSize)
 {
-    // TODO
+    // Note that this causes the widget to be resized back
+    // to its original size! We therefore have to set the size
+    // back again. TODO: a better way in Motif?
+    if (m_windowFont.Ok())
+    {
+        int width, height, width1, height1;
+        GetSize(& width, & height);
+
+        XmFontList fontList = (XmFontList) m_windowFont.GetFontList(1.0, XtDisplay((Widget) m_mainWidget));
+        XtVaSetValues ((Widget) m_mainWidget, XmNfontList, fontList, NULL);
+        XtVaSetValues ((Widget) m_buttonWidget, XmNfontList, fontList, NULL);
+
+        /* TODO: why does this cause a crash in XtWidgetToApplicationContext?
+        int i;
+        for (i = 0; i < m_noStrings; i++)
+            XtVaSetValues ((Widget) m_widgetList[i], XmNfontList, fontList, NULL);
+        */
+        GetSize(& width1, & height1);
+        if (keepOriginalSize && (width != width1 || height != height1))
+        {
+            SetSize(-1, -1, width, height);
+        }
+    }
 }
 
 void wxChoice::ChangeBackgroundColour()
 {
-    // TODO
+    DoChangeBackgroundColour(m_formWidget, m_backgroundColour);
+    DoChangeBackgroundColour(m_buttonWidget, m_backgroundColour);
+    DoChangeBackgroundColour(m_menuWidget, m_backgroundColour);
+    int i;
+    for (i = 0; i < m_noStrings; i++)
+        DoChangeBackgroundColour(m_widgetList[i], m_backgroundColour);
 }
 
 void wxChoice::ChangeForegroundColour()
 {
-    // TODO
+    DoChangeForegroundColour(m_formWidget, m_foregroundColour);
+    DoChangeForegroundColour(m_buttonWidget, m_foregroundColour);
+    DoChangeForegroundColour(m_menuWidget, m_foregroundColour);
+    int i;
+    for (i = 0; i < m_noStrings; i++)
+        DoChangeForegroundColour(m_widgetList[i], m_foregroundColour);
 }
-