]> git.saurik.com Git - wxWidgets.git/commitdiff
Misc. Motif; removed duplicate wxICON; variant compile fix; added wxString form
authorJulian Smart <julian@anthemion.co.uk>
Fri, 16 Oct 1998 14:38:52 +0000 (14:38 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Fri, 16 Oct 1998 14:38:52 +0000 (14:38 +0000)
of wxStripMenuCodes

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@843 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

18 files changed:
include/wx/icon.h
include/wx/motif/app.h
include/wx/motif/dcclient.h
include/wx/motif/setup.h
include/wx/motif/statbox.h
include/wx/motif/window.h
include/wx/utils.h
src/common/utilscmn.cpp
src/common/variant.cpp
src/motif/app.cpp
src/motif/bmpbuttn.cpp
src/motif/cursor.cpp
src/motif/scrolbar.cpp
src/motif/statbox.cpp
src/motif/stattext.cpp
src/motif/utils.cpp
src/motif/window.cpp
src/msw/menu.cpp

index 4de7f27e5d1b423b4914dfe7f41d5570748abdce..4fa9b5d22500aca5fdbb55b5521aa9dd5d054d56 100644 (file)
@@ -1,15 +1,13 @@
 #ifndef _WX_ICON_H_BASE_
 #define _WX_ICON_H_BASE_
 
+/* Commenting out since duplicated in gdicmn.h
 // this is for Unix (i.e. now for anything other than MSW)
 #undef  wxICON
 #define wxICON(icon_name)   wxIcon(icon_name##_xpm)
+*/
 
 #if defined(__WXMSW__)
-  // under Windows, icon name is the ressource id (string)
-  #undef wxICON
-  #define wxICON(icon_name)   wxIcon(#icon_name)
-
   #include "wx/msw/icon.h"
 #elif defined(__WXMOTIF__)
   #include "wx/motif/icon.h"
index 1c7035aa08f99d1ceba0fae1f112d0b065abe2da..c36e03233d6ec586a7e093e098b7ac368172e8d1 100644 (file)
@@ -138,6 +138,7 @@ public:
   inline WXAppContext   GetAppContext() const { return m_appContext; }
   inline WXWidget       GetTopLevelWidget() const { return m_topLevelWidget; }
   WXColormap            GetMainColormap(WXDisplay* display) ;
+  WXDisplay*            GetInitialDisplay() const { return m_initialDisplay; }
   inline long           GetMaxRequestSize() const { return m_maxRequestSize; }
 
   // This handler is called when a property change event occurs
@@ -154,6 +155,7 @@ protected:
   WXAppContext          m_appContext;
   WXWidget              m_topLevelWidget;
   WXColormap            m_mainColormap;
+  WXDisplay*            m_initialDisplay;
   long                  m_maxRequestSize;
 
 DECLARE_EVENT_TABLE()
index 030010dfeee14251a7c53946aff5bf015a274c43..38c9b2d5ec21b25dccbc293345ba557df4323bd4 100644 (file)
@@ -96,6 +96,10 @@ class WXDLLEXPORT wxWindowDC: public wxDC
     // Motif-specific
     void SetDCClipping (); // Helper function for setting clipping
 
+    inline WXGC GetGC() const { return m_gc; }
+    inline bool GetAutoSetting() const { return m_autoSetting; }
+    inline void SetAutoSetting(bool flag) { m_autoSetting = flag; }
+
 protected:
     WXGC         m_gc;
     WXGC         m_gcBacking;
index 5b26b6c6be6a756f518993dba8f192840261c6c1..74e0dbb668aa3622e367d3b11e16b8354273dab9 100644 (file)
@@ -86,6 +86,8 @@
 #define wxUSE_GLOBAL_MEMORY_OPERATORS 0
                                   // In debug mode, cause new and delete to be redefined globally.
                                   // If this causes problems (e.g. link errors), set this to 0.
+                                  // In wxMotif, causes an 'all bets are off'
+                                  // memory error (generated by wxWindows)
 
 #define REMOVE_UNUSED_ARG 1
                                   // Set this to 0 if your compiler can't cope
index e16cd330d204aad6b7deaa735aeaafcd0d2e68ac..288b1857483de2e517e6866eeb07d0bf92589f88 100644 (file)
@@ -26,7 +26,7 @@ class WXDLLEXPORT wxStaticBox: public wxControl
   DECLARE_DYNAMIC_CLASS(wxStaticBox)
 
  public:
-  inline wxStaticBox() {}
+  wxStaticBox();
   inline wxStaticBox(wxWindow *parent, wxWindowID id,
            const wxString& label,
            const wxPoint& pos = wxDefaultPosition,
@@ -49,8 +49,18 @@ class WXDLLEXPORT wxStaticBox: public wxControl
 
   void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
   void SetLabel(const wxString& label);
+  wxString GetLabel() const;
+
+  // Motif-specific
+  WXWidget GetTopWidget() const { return m_formWidget; }
+  WXWidget GetLabelWidget() const { return m_labelWidget; }
 
 DECLARE_EVENT_TABLE()
+
+protected:
+  // Motif-specific
+  WXWidget  m_formWidget;
+  WXWidget  m_labelWidget;
 };
 
 #endif
index e369869d9e36b8337cb72e06dac6bf41c77b66f6..80a794fa4310af6376546e41fe76ebe14f392e50 100644 (file)
@@ -465,6 +465,8 @@ public:
 
   // Get main widget for this window, e.g. a text widget
   virtual WXWidget GetMainWidget() const;
+  // Get the widget that supports font setting
+  virtual WXWidget GetLabelWidget() const { return GetMainWidget(); }
   // Get the client widget for this window (something we can
   // create other windows on)
   virtual WXWidget GetClientWidget() const;
@@ -561,13 +563,14 @@ protected:
   bool                  m_winCaptured;
   bool                  m_hScroll;
   bool                  m_vScroll;
-  bool                  m_hScrollingEnabled;
-  bool                  m_vScrollingEnabled;
   WXPixmap              m_backingPixmap;
   int                   m_pixmapWidth;
   int                   m_pixmapHeight;
   int                   m_pixmapOffsetX;
   int                   m_pixmapOffsetY;
+  int                   m_scrollPosX; // Store the last scroll pos,
+  int                   m_scrollPosY; // since in wxWin the pos isn't
+                                      // set automatically by system
 
 DECLARE_EVENT_TABLE()
 };
index 3d9a31ddb35a6d0e722b375c9548d7543871d0b2..e92325e6903ffd6951343529c646ad24ec62b175 100644 (file)
@@ -144,6 +144,7 @@ bool WXDLLEXPORT wxGetUserName(char *buf, int maxSize);
  * Strip out any menu codes
  */
 char* WXDLLEXPORT wxStripMenuCodes(char *in, char *out = (char *) NULL);
+wxString WXDLLEXPORT wxStripMenuCodes(const wxString& str);
 
 // Find the window/widget with the given title or label.
 // Pass a parent to begin the search from, or NULL to look through
index 55fbb4463026c0079f1442e79afbcddcbf0326f3..d845ed71da1df03f7503839075bbe8ba81b8f6e7 100644 (file)
@@ -390,6 +390,14 @@ char *wxStripMenuCodes (char *in, char *out)
   return tmpOut;
 }
 
+wxString wxStripMenuCodes(const wxString& str)
+{
+    char *buf = new char[str.Length() + 1];
+    wxStripMenuCodes((char*) (const char*) str, buf);
+    wxString str1(buf);
+    delete[] buf;
+    return str1;
+}
 
 /*
  * Window search functions
index e01fd101fd5e1534fd072efff316338afa7574fd..02fa4772739059b00a2f99665d15f07dec0241c2 100644 (file)
@@ -677,7 +677,7 @@ bool wxVariantDataString::Write(ostream& str) const
 
 bool wxVariantDataString::Write(wxOutputStream& str) const
 {
-    str << m_value;
+    str << (const char*) m_value;
     return TRUE;
 }
 
index f57ac149c8c02cfc689eeae391c4f70932a6a57c..94e652a549e893a503a77db586c21463b5ed71d1 100644 (file)
@@ -247,6 +247,7 @@ wxApp::wxApp()
     m_appContext = (WXAppContext) NULL;
     m_topLevelWidget = (WXWidget) NULL;
     m_maxRequestSize = 0;
+    m_initialDisplay = (WXDisplay*) 0;
 }
 
 bool wxApp::Initialized()
@@ -460,6 +461,8 @@ bool wxApp::OnInitGui()
       cerr << "wxWindows could not open display for " << wxTheApp->GetClassName() << ": exiting.\n";
       exit(-1);
     }
+    m_initialDisplay = (WXDisplay*) dpy;
+
     wxTheApp->m_topLevelWidget = (WXWidget) XtAppCreateShell((String)NULL, (const char*) wxTheApp->GetClassName(),
                                      applicationShellWidgetClass,dpy,
                                      NULL,0) ;
index 96bb57b2b6658ba0c4110a4fd9f384ccb7b86a83..fa758ff084aa51e0bd3db48984e6427d12a8b2c7 100644 (file)
@@ -30,8 +30,8 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
     SetValidator(validator);
     parent->AddChild(this);
 
-    m_backgroundColour = parent->GetDefaultBackgroundColour() ;
-    m_foregroundColour = parent->GetDefaultForegroundColour() ;
+    m_backgroundColour = parent->GetBackgroundColour() ;
+    m_foregroundColour = parent->GetForegroundColour() ;
     m_windowStyle = style;
     m_marginX = 0;
     m_marginY = 0;
index 24c94be559871dd43c2d9bc53262307d50e05ffd..829a616a5b24fb1c5d78e7c8a837b8ead0caf057 100644 (file)
@@ -188,8 +188,13 @@ wxCursor::wxCursor(wxStockCursor id)
 {
     m_refData = new wxCursorRefData;
     M_CURSORDATA->m_cursorId = id;
+    M_CURSORDATA->m_ok = TRUE;
 
-    WXCursor cursor = GetXCursor(wxGetDisplay());
+    WXDisplay* display = wxGetDisplay();
+    if (!display)
+      return;
+
+    WXCursor cursor = GetXCursor(display);
     if (cursor)
     {
         wxXCursor* c = new wxXCursor;
index 99e5316bebb7a604df58cf712292726f5f253628..84fa92fe64f9fd644ecc97ad1d280af696263e84 100644 (file)
 
 #include "wx/scrolbar.h"
 
+#include <X11/IntrinsicP.h>
+#include <Xm/Xm.h>
+#include <Xm/RowColumn.h>
+#include <Xm/ScrollBar.h>
+
+#include <wx/motif/private.h>
+
+void wxScrollBarCallback(Widget widget, XtPointer clientData,
+                        XmScaleCallbackStruct *cbs);
+
 #if !USE_SHARED_LIBRARY
 IMPLEMENT_DYNAMIC_CLASS(wxScrollBar, wxControl)
-
 #endif
 
 // Scrollbar
@@ -40,7 +49,50 @@ bool wxScrollBar::Create(wxWindow *parent, wxWindowID id,
     else
            m_windowId = id;
 
-    // TODO create scrollbar
+    int x = pos.x;
+    int y = pos.y;
+    int width = size.x;
+    int height = size.y;
+
+    if (width == -1)
+    {
+      if (style & wxHORIZONTAL)
+        width = 140;
+      else
+        width = 12;
+    }
+    if (height == -1)
+    {
+      if (style & wxVERTICAL)
+        height = 140;
+      else
+        height = 12;
+    }
+
+    Widget parentWidget = (Widget) parent->GetClientWidget();
+    int direction = (style & wxHORIZONTAL) ? XmHORIZONTAL: XmVERTICAL;
+
+    Widget scrollBarWidget = XtVaCreateManagedWidget("scrollBarWidget",
+                  xmScrollBarWidgetClass,  parentWidget,
+                  XmNorientation,      direction,
+                  NULL);
+
+    m_mainWidget = (Widget) scrollBarWidget;
+
+    // This will duplicate other events
+    //    XtAddCallback(scrollBarWidget, XmNvalueChangedCallback, (XtCallbackProc)wxScrollBarCallback, (XtPointer)this);
+    XtAddCallback(scrollBarWidget, XmNdragCallback, (XtCallbackProc)wxScrollBarCallback, (XtPointer)this);
+    XtAddCallback(scrollBarWidget, XmNdecrementCallback, (XtCallbackProc)wxScrollBarCallback, (XtPointer)this);
+    XtAddCallback(scrollBarWidget, XmNincrementCallback, (XtCallbackProc)wxScrollBarCallback, (XtPointer)this);
+    XtAddCallback(scrollBarWidget, XmNpageDecrementCallback, (XtCallbackProc)wxScrollBarCallback, (XtPointer)this);
+    XtAddCallback(scrollBarWidget, XmNpageIncrementCallback, (XtCallbackProc)wxScrollBarCallback, (XtPointer)this);
+    XtAddCallback(scrollBarWidget, XmNtoTopCallback, (XtCallbackProc)wxScrollBarCallback, (XtPointer)this);
+    XtAddCallback(scrollBarWidget, XmNtoBottomCallback, (XtCallbackProc)wxScrollBarCallback, (XtPointer)this);
+
+    SetCanAddEventHandler(TRUE);
+    AttachWidget (parent, m_mainWidget, (WXWidget) NULL, x, y, width, height);
+    ChangeColour(m_mainWidget);
+
     return TRUE;
 }
 
@@ -48,15 +100,27 @@ wxScrollBar::~wxScrollBar()
 {
 }
 
-void wxScrollBar::SetPosition(int viewStart)
+void wxScrollBar::SetPosition(int pos)
 {
-    // TODO
+       if (m_mainWidget)
+       {
+               XtVaSetValues ((Widget) m_mainWidget,
+                               XmNvalue, pos,
+                               NULL);
+       }
 }
 
 int wxScrollBar::GetPosition() const
 {
-    // TODO
-    return 0;
+       if (m_mainWidget)
+       {
+        int pos;
+        XtVaGetValues((Widget) m_mainWidget,
+            XmNvalue, &pos, NULL);
+        return pos;
+    }
+    else
+        return 0;
 }
 
 void wxScrollBar::SetScrollbar(int position, int thumbSize, int range, int pageSize,
@@ -66,9 +130,19 @@ void wxScrollBar::SetScrollbar(int position, int thumbSize, int range, int pageS
     m_pageSize = thumbSize;
     m_objectSize = range;
 
-    // TODO
-}
+    if (range == 0)
+      range = 1;
+    if (thumbSize == 0)
+      thumbSize = 1;
 
+    XtVaSetValues((Widget) m_mainWidget,
+         XmNvalue, position,
+         XmNminimum, 0,
+         XmNmaximum, range,
+         XmNsliderSize, thumbSize,
+         XmNpageIncrement, pageSize,
+         NULL);
+}
 
 void wxScrollBar::Command(wxCommandEvent& event)
 {
@@ -76,3 +150,71 @@ void wxScrollBar::Command(wxCommandEvent& event)
     ProcessCommand(event);
 }
 
+void wxScrollBarCallback(Widget widget, XtPointer clientData,
+                        XmScaleCallbackStruct *cbs)
+{
+    wxScrollBar *scrollBar = (wxScrollBar *)clientData;
+
+    wxEventType eventType = wxEVT_NULL;
+    switch (cbs->reason)
+    {
+        case XmCR_INCREMENT:
+        {
+            eventType = wxEVT_SCROLL_LINEDOWN;
+            break;
+        }
+        case XmCR_DECREMENT:
+        {
+            eventType = wxEVT_SCROLL_LINEUP;
+            break;
+        }
+        case XmCR_DRAG:
+        {
+            eventType = wxEVT_SCROLL_THUMBTRACK;
+            break;
+        }
+        case XmCR_VALUE_CHANGED:
+        {
+            // TODO: Should this be intercepted too, or will it cause
+            // duplicate events?
+            eventType = wxEVT_SCROLL_THUMBTRACK;
+            break;
+        }
+        case XmCR_PAGE_INCREMENT:
+        {
+            eventType = wxEVT_SCROLL_PAGEDOWN;
+            break;
+        }
+        case XmCR_PAGE_DECREMENT:
+        {
+            eventType = wxEVT_SCROLL_PAGEUP;
+            break;
+        }
+        case XmCR_TO_TOP:
+        {
+            eventType = wxEVT_SCROLL_TOP;
+            break;
+        }
+        case XmCR_TO_BOTTOM:
+        {
+            eventType = wxEVT_SCROLL_BOTTOM;
+            break;
+        }
+        default:
+        {
+            // Should never get here
+            wxFAIL_MSG("Unknown scroll event.");
+            break;
+        }
+    }
+
+    wxScrollEvent event(eventType, scrollBar->GetId());
+    event.SetEventObject(scrollBar);
+    event.SetPosition(cbs->value);
+    scrollBar->GetEventHandler()->ProcessEvent(event);
+/*
+    if (!scrollBar->inSetValue)
+      scrollBar->ProcessCommand(event);
+*/
+}
+
index 9b46697f96b0415ec125a9717c9caa6d842e2762..b695120c8f4a4c8015ab40a1178be5ffad6c31d2 100644 (file)
 #endif
 
 #include "wx/statbox.h"
+#include "wx/utils.h"
+
+#include <Xm/Frame.h>
+#include <Xm/Form.h>
+#include <Xm/Label.h>
+#include <Xm/LabelG.h>
+
+#include <wx/motif/private.h>
 
 #if !USE_SHARED_LIBRARY
 IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
@@ -28,6 +36,12 @@ END_EVENT_TABLE()
  * Static box
  */
  
+wxStaticBox::wxStaticBox()
+{
+    m_formWidget = (WXWidget) 0;
+    m_labelWidget = (WXWidget) 0;
+}
+
 bool wxStaticBox::Create(wxWindow *parent, wxWindowID id,
            const wxString& label,
            const wxPoint& pos,
@@ -35,6 +49,9 @@ bool wxStaticBox::Create(wxWindow *parent, wxWindowID id,
            long style,
            const wxString& name)
 {
+    m_formWidget = (WXWidget) 0;
+    m_labelWidget = (WXWidget) 0;
+
     SetName(name);
 
     if (parent) parent->AddChild(this);
@@ -46,17 +63,119 @@ bool wxStaticBox::Create(wxWindow *parent, wxWindowID id,
 
     m_windowStyle = style;
 
-    // TODO: create static box
-    return FALSE;
+    bool hasLabel = (!label.IsNull() && !label.IsEmpty()) ;
+
+    Widget parentWidget = (Widget) parent->GetClientWidget();
+
+    Widget formWidget = XtVaCreateManagedWidget ((char*) (const char*) name,
+                                       xmFormWidgetClass, parentWidget,
+                                       XmNmarginHeight, 0,
+                                       XmNmarginWidth, 0,
+                                       NULL);
+
+
+    if (hasLabel)
+    {
+        wxString label1(wxStripMenuCodes(label));
+        XmString text = XmStringCreateSimple ((char*) (const char*) label1);
+        m_labelWidget = (WXWidget) XtVaCreateManagedWidget ((char*) (const char*) label1,
+                                            xmLabelWidgetClass, formWidget,
+                                            XmNlabelString, text,
+                                            NULL);
+        XmStringFree (text);
+    }
+
+    Widget frameWidget = XtVaCreateManagedWidget ("frame",
+                                       xmFrameWidgetClass, formWidget,
+                                        XmNshadowType, XmSHADOW_IN,
+//                                     XmNmarginHeight, 0,
+//                                     XmNmarginWidth, 0,
+                                       NULL);
+
+    if (hasLabel)
+        XtVaSetValues ((Widget) m_labelWidget,
+                      XmNtopAttachment, XmATTACH_FORM,
+                      XmNleftAttachment, XmATTACH_FORM,
+                      XmNrightAttachment, XmATTACH_FORM,
+                      XmNalignment, XmALIGNMENT_BEGINNING,
+                      NULL);
+
+    XtVaSetValues (frameWidget,
+           XmNtopAttachment, hasLabel ? XmATTACH_WIDGET : XmATTACH_FORM,
+                    XmNtopWidget, hasLabel ? (Widget) m_labelWidget : formWidget,
+                    XmNbottomAttachment, XmATTACH_FORM,
+                    XmNleftAttachment, XmATTACH_FORM,
+                    XmNrightAttachment, XmATTACH_FORM,
+                    NULL);
+
+    m_mainWidget = (Widget) formWidget;
+
+    SetCanAddEventHandler(TRUE);
+    AttachWidget (parent, m_mainWidget, (WXWidget) frameWidget, pos.x, pos.y, size.x, size.y);
+    ChangeColour(m_mainWidget);
+
+    return TRUE;
 }
 
 void wxStaticBox::SetLabel(const wxString& label)
 {
-    // TODO
+    if (!m_labelWidget)
+        return;
+
+    if (!label.IsNull())
+    {
+        wxString label1(wxStripMenuCodes(label));
+
+        XmString text = XmStringCreateSimple ((char*) (const char*) label1);
+        XtVaSetValues ((Widget) m_labelWidget,
+                    XmNlabelString, text,
+                    XmNlabelType, XmSTRING,
+                    NULL);
+        XmStringFree (text);
+    }
+}
+
+wxString wxStaticBox::GetLabel() const
+{
+    if (!m_labelWidget)
+        return wxEmptyString;
+
+    XmString text = 0;
+    char *s;
+    XtVaGetValues ((Widget) m_labelWidget,
+                XmNlabelString, &text,
+                NULL);
+
+    if (!text)
+        return wxEmptyString;
+
+    if (XmStringGetLtoR (text, XmSTRING_DEFAULT_CHARSET, &s))
+    {
+        wxString str(s);
+        XtFree (s);
+        return str;
+    }
+    else
+    {
+        return wxEmptyString;
+    }
 }
 
 void wxStaticBox::SetSize(int x, int y, int width, int height, int sizeFlags)
 {
-    // TODO
+    wxControl::SetSize (x, y, width, height, sizeFlags);
+
+    if (m_labelWidget)
+    {
+        Dimension xx, yy;
+        XtVaGetValues ((Widget) m_labelWidget, XmNwidth, &xx, XmNheight, &yy, NULL);
+
+        if (width > -1)
+            XtVaSetValues ((Widget) m_mainWidget, XmNwidth, width,
+                   NULL);
+        if (height > -1)
+            XtVaSetValues ((Widget) m_mainWidget, XmNheight, height - yy,
+                   NULL);
+    }
 }
 
index cc0aa547f0ca0801a72c1ff6b8d18a30f70fcfd7..fbe223dd149428233ebd0b7572390601cfa5ba09 100644 (file)
@@ -36,8 +36,8 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
   SetName(name);
   if (parent) parent->AddChild(this);
 
-  SetBackgroundColour(parent->GetDefaultBackgroundColour()) ;
-  SetForegroundColour(parent->GetDefaultForegroundColour()) ;
+  SetBackgroundColour(parent->GetBackgroundColour()) ;
+  SetForegroundColour(parent->GetForegroundColour()) ;
 
   if ( id == -1 )
        m_windowId = (int)NewControlId();
index afb8709ae0c3ff16d39f74ee625e9d382433a1c0..b8d38a52823918896cbe94cb13473c44bb930c3a 100644 (file)
@@ -290,7 +290,12 @@ WXDisplay *wxGetDisplay()
   if (gs_currentDisplay)
     return gs_currentDisplay;
 
-  return XtDisplay ((Widget) wxTheApp->GetTopLevelWidget());
+  if (wxTheApp && wxTheApp->GetTopLevelWidget())
+    return XtDisplay ((Widget) wxTheApp->GetTopLevelWidget());
+  else if (wxTheApp)
+    return wxTheApp->GetInitialDisplay();
+  else
+    return (WXDisplay*) NULL;
 }
 
 bool wxSetDisplay(const wxString& display_name)
index edb62407c7ece20f07d4b394ea7739bc14fd75df..2aaf9006d6d286daa06ecc456476d18b8b5e7e55 100644 (file)
@@ -52,6 +52,8 @@ void wxCanvasRepaintProc (Widget, XtPointer, XmDrawingAreaCallbackStruct * cbs);
 void wxCanvasInputEvent (Widget drawingArea, XtPointer data, XmDrawingAreaCallbackStruct * cbs);
 void wxCanvasMotionEvent (Widget, XButtonEvent * event);
 void wxCanvasEnterLeave (Widget drawingArea, XtPointer clientData, XCrossingEvent * event);
+void wxScrollBarCallback(Widget widget, XtPointer clientData,
+                        XmScaleCallbackStruct *cbs);
 void wxPanelItemEventHandler (Widget    wid,
                               XtPointer client_data,
                               XEvent*   event,
@@ -121,8 +123,6 @@ wxWindow::wxWindow()
     m_drawingArea = (WXWidget) 0;
     m_hScroll = FALSE;
     m_vScroll = FALSE;
-    m_hScrollingEnabled = FALSE;
-    m_vScrollingEnabled = FALSE;
     m_backingPixmap = (WXPixmap) 0;
     m_pixmapWidth = 0;
     m_pixmapHeight = 0;
@@ -131,6 +131,8 @@ wxWindow::wxWindow()
     m_lastTS = 0;
     m_lastButton = 0;
     m_canAddEventHandler = FALSE;
+    m_scrollPosX = 0;
+    m_scrollPosY = 0;
     m_paintRegion = (WXRegion) 0;
 }
 
@@ -296,13 +298,13 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id,
     m_drawingArea = (WXWidget) 0;
     m_hScroll = FALSE;
     m_vScroll = FALSE;
-    m_hScrollingEnabled = FALSE;
-    m_vScrollingEnabled = FALSE;
     m_backingPixmap = (WXPixmap) 0;
     m_pixmapWidth = 0;
     m_pixmapHeight = 0;
     m_pixmapOffsetX = 0;
     m_pixmapOffsetY = 0;
+    m_scrollPosX = 0;
+    m_scrollPosY = 0;
     m_paintRegion = (WXRegion) 0;
 
     if (!parent)
@@ -322,7 +324,6 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id,
     // m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW) ; ;
     m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE) ;
     m_foregroundColour = *wxBLACK;
-    m_defaultForegroundColour = *wxBLACK ;
 
     m_windowStyle = style;
 
@@ -418,6 +419,62 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id,
   XtAddEventHandler ((Widget) m_drawingArea, PointerMotionHintMask | EnterWindowMask | LeaveWindowMask | FocusChangeMask,
     False, (XtEventHandler) wxCanvasEnterLeave, (XtPointer) this);
 
+  // Add scrollbars if required
+  if (m_windowStyle & wxHSCROLL)
+  {
+      Widget hScrollBar = XtVaCreateManagedWidget ("hsb",
+                                    xmScrollBarWidgetClass, (Widget) m_scrolledWindow,
+                                               XmNorientation, XmHORIZONTAL,
+                                               NULL);
+      //         XtAddCallback (hScrollBar, XmNvalueChangedCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL);
+         XtAddCallback (hScrollBar, XmNdragCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL);
+         XtAddCallback (hScrollBar, XmNincrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL);
+         XtAddCallback (hScrollBar, XmNdecrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL);
+         XtAddCallback (hScrollBar, XmNpageIncrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL);
+         XtAddCallback (hScrollBar, XmNpageDecrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL);
+         XtAddCallback (hScrollBar, XmNtoTopCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL);
+         XtAddCallback (hScrollBar, XmNtoBottomCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL);
+
+      XtVaSetValues (hScrollBar,
+                    XmNincrement, 1,
+                    XmNvalue, 0,
+                    NULL);
+
+      m_hScrollBar = (WXWidget) hScrollBar;
+      m_hScroll = TRUE;
+  }
+  if (m_windowStyle & wxVSCROLL)
+  {
+      Widget vScrollBar = XtVaCreateManagedWidget ("vsb",
+                                    xmScrollBarWidgetClass, (Widget) m_scrolledWindow,
+                                               XmNorientation, XmVERTICAL,
+                                               NULL);
+      //         XtAddCallback (vScrollBar, XmNvalueChangedCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
+         XtAddCallback (vScrollBar, XmNdragCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
+         XtAddCallback (vScrollBar, XmNincrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
+         XtAddCallback (vScrollBar, XmNdecrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
+         XtAddCallback (vScrollBar, XmNpageIncrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
+         XtAddCallback (vScrollBar, XmNpageDecrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
+         XtAddCallback (vScrollBar, XmNtoTopCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
+         XtAddCallback (vScrollBar, XmNtoBottomCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
+
+      XtVaSetValues (vScrollBar,
+                    XmNincrement, 1,
+                    XmNvalue, 0,
+                    NULL);
+
+      m_vScrollBar = (WXWidget) vScrollBar;
+      m_vScroll = TRUE;
+  }
+
+  if (m_hScrollBar || m_vScrollBar)
+    XmScrolledWindowSetAreas ((Widget) m_scrolledWindow, (Widget) m_hScrollBar, (Widget) m_vScrollBar, (Widget) m_drawingArea);
+
+  if (m_hScrollBar)
+       XtRealizeWidget ((Widget) m_hScrollBar);
+  if (m_vScrollBar)
+       XtRealizeWidget ((Widget) m_vScrollBar);
+
   SetSize(pos.x, pos.y, size.x, size.y);
 
   return TRUE;
@@ -540,7 +597,15 @@ void wxWindow::GetPosition(int *x, int *y) const
 
 void wxWindow::ScreenToClient(int *x, int *y) const
 {
-    // TODO
+  Widget widget = (Widget) GetClientWidget();
+  Display *display = XtDisplay((Widget) GetMainWidget());
+  Window rootWindow = RootWindowOfScreen(XtScreen(widget));
+  Window thisWindow = XtWindow(widget);
+
+  Window childWindow;
+  int xx = *x;
+  int yy = *y;
+  XTranslateCoordinates(display, rootWindow, thisWindow, xx, yy, x, y, &childWindow);
 }
 
 void wxWindow::ClientToScreen(int *x, int *y) const
@@ -548,15 +613,7 @@ void wxWindow::ClientToScreen(int *x, int *y) const
   Widget widget = (Widget) GetClientWidget();
   Display *display = XtDisplay(widget);
   Window rootWindow = RootWindowOfScreen(XtScreen(widget));
-  Window thisWindow;
-  if (this->IsKindOf(CLASSINFO(wxFrame)))
-  {
-    wxFrame *fr = (wxFrame *)this;
-    // TODO
-    //    thisWindow = XtWindow(fr->m_clientArea);
-  }
-  else
-    thisWindow = XtWindow((Widget)widget);
+  Window thisWindow = XtWindow(widget);
 
   Window childWindow;
   int xx = *x;
@@ -569,14 +626,12 @@ void wxWindow::SetCursor(const wxCursor& cursor)
   m_windowCursor = cursor;
   if (m_windowCursor.Ok())
   {
-    /* TODO when wxCursor implemented
     WXDisplay *dpy = GetXDisplay();
-    Cursor x_cursor = cursor.GetXCursor(dpy);
+    WXCursor x_cursor = ((wxCursor&)cursor).GetXCursor(dpy);
 
     Widget w = (Widget) GetMainWidget();
     Window win = XtWindow(w);
-    XDefineCursor((Display*) dpy, win, x_cursor);
-    */
+    XDefineCursor((Display*) dpy, win, (Cursor) x_cursor);
   }
 }
 
@@ -584,7 +639,7 @@ void wxWindow::SetCursor(const wxCursor& cursor)
 // Get size *available for subwindows* i.e. excluding menu bar etc.
 void wxWindow::GetClientSize(int *x, int *y) const
 {
-  Widget widget = (Widget) GetTopWidget();
+  Widget widget = (Widget) GetClientWidget();
   Dimension xx, yy;
   XtVaGetValues(widget, XmNwidth, &xx, XmNheight, &yy, NULL);
   *x = xx; *y = yy;
@@ -708,24 +763,77 @@ bool wxWindow::IsShown() const
 
 int wxWindow::GetCharHeight() const
 {
-    // TODO
+  if (!m_windowFont.Ok())
     return 0;
+
+  WXFontStructPtr pFontStruct = m_windowFont.GetFontStruct(1.0, GetXDisplay());
+
+  int direction, ascent, descent;
+  XCharStruct overall;
+  XTextExtents ((XFontStruct*) pFontStruct, "x", 1, &direction, &ascent,
+        &descent, &overall);
+//  return (overall.ascent + overall.descent);
+  return (ascent + descent);
 }
 
 int wxWindow::GetCharWidth() const
 {
-    // TODO
+  if (!m_windowFont.Ok())
     return 0;
+
+  WXFontStructPtr pFontStruct = m_windowFont.GetFontStruct(1.0, GetXDisplay());
+
+  int direction, ascent, descent;
+  XCharStruct overall;
+  XTextExtents ((XFontStruct*) pFontStruct, "x", 1, &direction, &ascent,
+        &descent, &overall);
+  return overall.width;
+}
+
+/* Helper function for 16-bit fonts */
+static int str16len(const char *s)
+{
+  int count = 0;
+
+  while (s[0] && s[1]) {
+    count++;
+    s += 2;
+  }
+
+  return count;
 }
 
 void wxWindow::GetTextExtent(const wxString& string, int *x, int *y,
-                           int *descent, int *externalLeading, const wxFont *theFont, bool) const
+                           int *descent, int *externalLeading, const wxFont *theFont, bool use16) const
 {
   wxFont *fontToUse = (wxFont *)theFont;
   if (!fontToUse)
     fontToUse = (wxFont *) & m_windowFont;
 
-    // TODO
+  if (!fontToUse->Ok())
+    return;
+
+  WXFontStructPtr pFontStruct = theFont->GetFontStruct(1.0, GetXDisplay());
+
+  int direction, ascent, descent2;
+  XCharStruct overall;
+  int slen;
+  
+  if (use16) slen = str16len(string); else slen = strlen(string);
+
+  if (use16)
+    XTextExtents16((XFontStruct*) pFontStruct, (XChar2b *) (char*) (const char*) string, slen, &direction,
+           &ascent, &descent2, &overall);
+  else
+     XTextExtents((XFontStruct*) pFontStruct, (char*) (const char*) string, slen, &direction,
+         &ascent, &descent2, &overall);
+
+  *x = (overall.width);
+  *y = (ascent + descent2);
+  if (descent)
+    *descent = descent2;
+  if (externalLeading)
+    *externalLeading = 0;
 }
 
 void wxWindow::Refresh(bool eraseBack, const wxRectangle *rect)
@@ -859,21 +967,20 @@ void wxWindow::SetSizeHints(int minW, int minH, int maxW, int maxH, int incW, in
       return;
 
     wxFrame *frame = (wxFrame *)this;
+    Widget widget = (Widget) frame->GetShellWidget();
 
-    /* Uncomment when wxFrame implemented
     if (minW > -1)
-      XtVaSetValues((Widget) frame->m_frameShell, XmNminWidth, minW, NULL);
+      XtVaSetValues(widget, XmNminWidth, minW, NULL);
     if (minH > -1)
-      XtVaSetValues((Widget) frame->m_frameShell, XmNminHeight, minH, NULL);
+      XtVaSetValues(widget, XmNminHeight, minH, NULL);
     if (maxW > -1)
-      XtVaSetValues((Widget) frame->m_frameShell, XmNmaxWidth, maxW, NULL);
+      XtVaSetValues(widget, XmNmaxWidth, maxW, NULL);
     if (maxH > -1)
-      XtVaSetValues((Widget) frame->m_frameShell, XmNmaxHeight, maxH, NULL);
+      XtVaSetValues(widget, XmNmaxHeight, maxH, NULL);
     if (incW > -1)
-      XtVaSetValues((Widget) frame->m_frameShell, XmNwidthInc, incW, NULL);
+      XtVaSetValues(widget, XmNwidthInc, incW, NULL);
     if (incH > -1)
-      XtVaSetValues((Widget) frame->m_frameShell, XmNheightInc, incH, NULL);
-      */
+      XtVaSetValues(widget, XmNheightInc, incH, NULL);
 }
 
 void wxWindow::Centre(int direction)
@@ -915,49 +1022,252 @@ void wxWindow::OnEraseBackground(wxEraseEvent& event)
 
 int wxWindow::GetScrollPos(int orient) const
 {
-    // TODO
-    return 0;
+    if (orient == wxHORIZONTAL)
+        return m_scrollPosX;
+    else
+        return m_scrollPosY;
+/*
+       Widget scrollBar = (Widget) ((orient == wxHORIZONTAL) ? m_hScrollBar : m_vScrollBar);
+       if (scrollBar)
+       {
+        int pos;
+        XtVaGetValues(scrollBar,
+            XmNvalue, &pos, NULL);
+        return pos;
+    }
+    else
+        return 0;
+*/
 }
 
 // This now returns the whole range, not just the number
 // of positions that we can scroll.
 int wxWindow::GetScrollRange(int orient) const
 {
-    // TODO
-    return 0;
+       Widget scrollBar = (Widget) ((orient == wxHORIZONTAL) ? m_hScrollBar : m_vScrollBar);
+       if (scrollBar)
+       {
+        int range;
+        XtVaGetValues(scrollBar,
+            XmNmaximum, &range, NULL);
+        return range;
+    }
+    else
+        return 0;
 }
 
 int wxWindow::GetScrollThumb(int orient) const
 {
-    // TODO
-    return 0;
+       Widget scrollBar = (Widget) ((orient == wxHORIZONTAL) ? m_hScrollBar : m_vScrollBar);
+       if (scrollBar)
+       {
+        int thumb;
+        XtVaGetValues(scrollBar,
+            XmNsliderSize, &thumb, NULL);
+        return thumb;
+    }
+    else
+        return 0;
 }
 
-void wxWindow::SetScrollPos(int orient, int pos, bool refresh)
+void wxWindow::SetScrollPos(int orient, int pos, bool WXUNUSED(refresh))
 {
-    // TODO
-    return;
+       Widget scrollBar = (Widget) ((orient == wxHORIZONTAL) ? m_hScrollBar : m_vScrollBar);
+       if (scrollBar)
+       {
+               XtVaSetValues (scrollBar,
+                               XmNvalue, pos,
+                               NULL);
+       }
+        if (orient == wxHORIZONTAL)
+          m_scrollPosX = pos;
+        else
+          m_scrollPosY = pos;
+
 }
 
 // New function that will replace some of the above.
 void wxWindow::SetScrollbar(int orient, int pos, int thumbVisible,
-    int range, bool refresh)
+    int range, bool WXUNUSED(refresh))
 {
-    // TODO
+    Widget scrollBar = (Widget) ((orient == wxHORIZONTAL) ? m_hScrollBar : m_vScrollBar );
+    if (!scrollBar)
+        return;
+
+    if (range == 0)
+      range = 1;
+    if (thumbVisible == 0)
+      thumbVisible = 1;
+
+    XtVaSetValues(scrollBar,
+         XmNvalue, pos,
+         XmNminimum, 0,
+         XmNmaximum, range,
+         XmNsliderSize, thumbVisible,
+         NULL);
+
+    if (orient == wxHORIZONTAL)
+        m_scrollPosX = pos;
+    else
+        m_scrollPosY = pos;
 }
 
 // Does a physical scroll
 void wxWindow::ScrollWindow(int dx, int dy, const wxRectangle *rect)
 {
-    // TODO
-    return;
+//  cerr << "Scrolling. delta = " << dx << ", " << dy << endl;
+  int x, y, w, h;
+  if (rect)
+  {
+    // Use specified rectangle
+    x = rect->x; y = rect->y; w = rect->width; h = rect->height;
+  }
+  else
+  {
+    // Use whole client area
+    x = 0; y = 0;
+    GetClientSize(& w, & h);
+  }
+
+  int x1 = (dx >= 0) ? x : x - dx ;
+  int y1 = (dy >= 0) ? y : y - dy;
+  int w1 = w - abs(dx);
+  int h1 = h - abs(dy);
+  int x2 = (dx >= 0) ? x + dx : x;
+  int y2 = (dy >= 0) ? y + dy : y;
+
+  wxClientDC dc(this);
+
+  dc.SetLogicalFunction (wxCOPY);
+
+  Widget widget = (Widget) GetMainWidget();
+  Window window = XtWindow(widget);
+  Display* display = XtDisplay(widget);
+
+  XCopyArea(display, window,
+    window, (GC) dc.GetGC(),
+    x1, y1,
+    w1, h1,
+    x2, y2);
+
+  dc.SetAutoSetting(TRUE);
+  wxBrush brush(GetBackgroundColour(), wxSOLID);
+  dc.SetBrush(brush); // ??
+
+  // We'll add rectangles to the list of update rectangles
+  // according to which bits we've exposed.
+  wxList updateRects;
+       
+  if (dx > 0)
+  {
+    wxRect *rect = new wxRect;
+    rect->x = x;
+    rect->y = y;
+    rect->width = dx;
+    rect->height = h;
+
+    XFillRectangle(display, window,
+      (GC) dc.GetGC(), rect->x, rect->y, rect->width, rect->height);
+
+    rect->x = rect->x;
+    rect->y = rect->y;
+    rect->width = rect->width;
+    rect->height = rect->height;
+
+    updateRects.Append((wxObject*) rect);
+  }
+  else if (dx < 0)
+  {
+    wxRect *rect = new wxRect;
+
+    rect->x = x + w + dx;
+    rect->y = y;
+    rect->width = -dx;
+    rect->height = h;
+
+    XFillRectangle(display, window,
+      (GC) dc.GetGC(), rect->x, rect->y, rect->width,
+      rect->height);
+
+    rect->x = rect->x;
+    rect->y = rect->y;
+    rect->width = rect->width;
+    rect->height = rect->height;
+
+    updateRects.Append((wxObject*) rect);
+  }
+  if (dy > 0)
+  {
+    wxRect *rect = new wxRect;
+
+    rect->x = x;
+    rect->y = y;
+    rect->width = w;
+    rect->height = dy;
+
+    XFillRectangle(display, window,
+      (GC) dc.GetGC(), rect->x, rect->y, rect->width, rect->height);
+
+    rect->x = rect->x;
+    rect->y = rect->y;
+    rect->width = rect->width;
+    rect->height = rect->height;
+
+    updateRects.Append((wxObject*) rect);
+  }
+  else if (dy < 0)
+  {
+    wxRect *rect = new wxRect;
+
+    rect->x = x;
+    rect->y = y + h + dy;
+    rect->width = w;
+    rect->height = -dy;
+
+    XFillRectangle(display, window,
+      (GC) dc.GetGC(), rect->x, rect->y, rect->width, rect->height);
+
+    rect->x = rect->x;
+    rect->y = rect->y;
+    rect->width = rect->width;
+    rect->height = rect->height;
+
+    updateRects.Append((wxObject*) rect);
+  }
+  dc.SetBrush(wxNullBrush);
+
+  // Now send expose events
+
+  wxNode* node = updateRects.First();
+  while (node)
+  {
+    wxRect* rect = (wxRect*) node->Data();
+    XExposeEvent event;
+
+    event.type = Expose;
+    event.display = display;
+    event.send_event = True;
+    event.window = window;
+
+    event.x = rect->x;
+    event.y = rect->y;
+    event.width = rect->width;
+    event.height = rect->height;
+
+    event.count = 0;
+
+    XSendEvent(display, window, False, ExposureMask, (XEvent *)&event);
+
+    node = node->Next();
+
+  }
 }
 
 void wxWindow::SetFont(const wxFont& font)
 {
     m_windowFont = font;
 
-    Widget w = (Widget) GetMainWidget();
+    Widget w = (Widget) GetLabelWidget(); // Usually the main widget
     if (w && m_windowFont.Ok())
     {
         XtVaSetValues (w,
@@ -985,7 +1295,8 @@ void wxWindow::OnPaint(wxPaintEvent& event)
 
 bool wxWindow::IsEnabled() const
 {
-    // TODO
+    // TODO. Is this right?
+    // return XtGetSensitive((Widget) GetMainWidget());
     return FALSE;
 }
 
@@ -2420,6 +2731,74 @@ void wxPanelItemEventHandler (Widget    wid,
   *continueToDispatch = True;
 }
 
+void wxScrollBarCallback(Widget scrollbar, XtPointer clientData,
+                        XmScaleCallbackStruct *cbs)
+{
+    Widget scrolledWindow = XtParent (scrollbar);
+    wxWindow *win = (wxWindow *) wxWidgetHashTable->Get ((long) scrolledWindow);
+    int orientation = (int) clientData;
+
+    wxEventType eventType = wxEVT_NULL;
+    switch (cbs->reason)
+    {
+        case XmCR_INCREMENT:
+        {
+            eventType = wxEVT_SCROLL_LINEDOWN;
+            break;
+        }
+        case XmCR_DECREMENT:
+        {
+            eventType = wxEVT_SCROLL_LINEUP;
+            break;
+        }
+        case XmCR_DRAG:
+        {
+            eventType = wxEVT_SCROLL_THUMBTRACK;
+            break;
+        }
+        case XmCR_VALUE_CHANGED:
+        {
+            // TODO: Should this be intercepted too, or will it cause
+            // duplicate events?
+            eventType = wxEVT_SCROLL_THUMBTRACK;
+            break;
+        }
+        case XmCR_PAGE_INCREMENT:
+        {
+            eventType = wxEVT_SCROLL_PAGEDOWN;
+            break;
+        }
+        case XmCR_PAGE_DECREMENT:
+        {
+            eventType = wxEVT_SCROLL_PAGEUP;
+            break;
+        }
+        case XmCR_TO_TOP:
+        {
+            eventType = wxEVT_SCROLL_TOP;
+            break;
+        }
+        case XmCR_TO_BOTTOM:
+        {
+            eventType = wxEVT_SCROLL_BOTTOM;
+            break;
+        }
+        default:
+        {
+            // Should never get here
+            wxFAIL_MSG("Unknown scroll event.");
+            break;
+        }
+    }
+
+    wxScrollEvent event(eventType, win->GetId());
+    event.SetEventObject(win);
+    event.SetPosition(cbs->value);
+    event.SetOrientation( (orientation == XmHORIZONTAL) ? wxHORIZONTAL : wxVERTICAL );
+
+    win->GetEventHandler()->ProcessEvent(event);
+}
+
 bool wxTranslateMouseEvent(wxMouseEvent& wxevent, wxWindow *win, Widget widget, XEvent *xevent)
 {
   switch (xevent->xany.type)
@@ -2670,10 +3049,12 @@ void wxWindow::ChangeColour(WXWidget widget)
 
 void wxWindow::ChangeFont(WXWidget widget)
 {
-  /* TODO
-  if (widget && GetFont() && GetFont()->IsOk())
-    XtVaSetValues ((Widget) widget,
-                  XmNfontList, GetFont()->GetInternalFont (),
+  if (widget && GetFont() && GetFont()->Ok())
+  {
+    XmFontList fontList = (XmFontList) GetFont()->GetFontList(1.0, GetXDisplay());
+    if (fontList)
+        XtVaSetValues ((Widget) widget,
+                  XmNfontList, fontList,
                   NULL);
-  */
+  }
 }
index 570d92e727538b64df3b85b102a2dc58c746356f..73540e9d8305b80fcd3c2ce91e316f58e02fca47 100644 (file)
@@ -400,8 +400,9 @@ void wxMenu::SetLabel(int Id, const wxString& label)
   item->SetName(label);
 }
 
-wxString wxMenu::GetLabel(int Id) const
+wxString wxMenu::GetLabel(int id) const
 {
+/*
   static char tmp[128] ;
   int len;
   if (m_hMenu)
@@ -412,6 +413,13 @@ wxString wxMenu::GetLabel(int Id) const
     len = 0 ;
   tmp[len] = '\0' ;
   return wxString(tmp) ;
+
+*/
+    wxMenuItem *pItem = FindItemForId(id) ;
+    if (pItem)
+        return pItem->GetName() ;
+    else
+        return wxEmptyString;
 }
 
 bool wxMenu::MSWCommand(WXUINT WXUNUSED(param), WXWORD id)