]> git.saurik.com Git - wxWidgets.git/blobdiff - src/motif/frame.cpp
implemented menu drawing in the GTK theme
[wxWidgets.git] / src / motif / frame.cpp
index 54a0466fff14635b2c026e0c7f68cd1ba36beffb..14b660afe3491e0795b550137c7ed5e4f7758f6e 100644 (file)
     #pragma implementation "frame.h"
 #endif
 
-#include "wx/frame.h"
+
+#ifdef __VMS
+#define XtDisplay XTDISPLAY
+#define XtWindow XTWINDOW
+#define XtScreen XTSCREEN
+#endif
+
+# include "wx/frame.h"
 #include "wx/statusbr.h"
 #include "wx/toolbar.h"
 #include "wx/menuitem.h"
@@ -31,6 +38,7 @@
 #include "wx/settings.h"
 #include "wx/app.h"
 #include "wx/utils.h"
+#include "wx/log.h"
 
 #ifdef __VMS__
     #pragma message disable nosimpint
 // private functions
 // ----------------------------------------------------------------------------
 
+static void wxFrameEventHandler(Widget    wid,
+                             XtPointer WXUNUSED(client_data),
+                             XEvent*   event,
+                             Boolean*  continueToDispatch);
 static void wxCloseFrameCallback(Widget, XtPointer, XmAnyCallbackStruct *cbs);
 static void wxFrameFocusProc(Widget workArea, XtPointer clientData,
                             XmAnyCallbackStruct *cbs);
@@ -127,7 +139,7 @@ bool wxFrame::Create(wxWindow *parent,
                      const wxString& name)
 {
     if ( parent )
-        AddChild(this);
+        parent->AddChild(this);
     else
         wxTopLevelWindows.Append(this);
 
@@ -137,9 +149,9 @@ bool wxFrame::Create(wxWindow *parent,
 
     m_windowStyle = style;
 
-    m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE);
+    m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE);
     m_foregroundColour = *wxBLACK;
-    m_font = wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT);
+    m_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
 
     if ( id > -1 )
         m_windowId = id;
@@ -234,6 +246,12 @@ bool wxFrame::Create(wxWindow *parent,
     XtAddEventHandler((Widget) m_clientArea, ExposureMask,FALSE,
         wxUniversalRepaintProc, (XtPointer) this);
 
+    XtAddEventHandler((Widget) m_clientArea,
+        ButtonPressMask | ButtonReleaseMask | PointerMotionMask | KeyPressMask,
+        FALSE,
+        wxFrameEventHandler,
+        (XtPointer)this);
+
     XtVaSetValues((Widget) m_frameWidget,
         XmNworkWindow, (Widget) m_workArea,
         NULL);
@@ -242,6 +260,7 @@ bool wxFrame::Create(wxWindow *parent,
     XtManageChild((Widget) m_workArea);
 
     wxAddWindowToTable((Widget) m_workArea, this);
+    wxAddWindowToTable((Widget) m_clientArea, this);
 
     XtTranslations ptr;
 
@@ -331,8 +350,14 @@ wxFrame::~wxFrame()
     m_isBeingDeleted = TRUE;
 
     if (m_clientArea)
+    {
       XtRemoveEventHandler((Widget) m_clientArea, ExposureMask, FALSE,
           wxUniversalRepaintProc, (XtPointer) this);
+      XtRemoveEventHandler((Widget) m_clientArea, ButtonPressMask | ButtonReleaseMask | PointerMotionMask | KeyPressMask,
+          FALSE,
+          wxFrameEventHandler, (XtPointer) this);
+      wxDeleteWindowFromTable((Widget) m_clientArea);
+    }
 
     if (GetMainWidget())
         Show(FALSE);
@@ -664,7 +689,7 @@ void wxFrame::SetMenuBar(wxMenuBar *menuBar)
 // Responds to colour changes, and passes event on to children.
 void wxFrame::OnSysColourChanged(wxSysColourChangedEvent& event)
 {
-    SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE));
+    SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE));
     Refresh();
 
     if ( m_frameStatusBar )
@@ -853,3 +878,53 @@ void wxCloseFrameCallback(Widget WXUNUSED(widget), XtPointer client_data, XmAnyC
     frame->GetEventHandler()->ProcessEvent(closeEvent);
 }
 
+static void wxFrameEventHandler(Widget    wid,
+                             XtPointer WXUNUSED(client_data),
+                             XEvent*   event,
+                             Boolean*  continueToDispatch)
+{
+    wxFrame *frame = (wxFrame *)wxGetWindowFromTable(wid);
+    if (frame)
+    {
+        wxMouseEvent wxevent(wxEVT_NULL);
+        if (wxTranslateMouseEvent(wxevent, frame, wid, event))
+        {
+            wxevent.SetEventObject(frame);
+            wxevent.SetId(frame->GetId());
+            frame->GetEventHandler()->ProcessEvent(wxevent);
+        }
+        else
+        {
+            // An attempt to implement OnCharHook by calling OnCharHook first;
+            // if this returns TRUE, set continueToDispatch to False
+            // (don't continue processing).
+            // Otherwise set it to True and call OnChar.
+            wxKeyEvent keyEvent(wxEVT_CHAR);
+            if (wxTranslateKeyEvent(keyEvent, frame, wid, event))
+            {
+                keyEvent.SetEventObject(frame);
+                keyEvent.SetId(frame->GetId());
+                keyEvent.SetEventType(wxEVT_CHAR_HOOK);
+                if (frame->GetEventHandler()->ProcessEvent(keyEvent))
+                {
+                    *continueToDispatch = False;
+                    return;
+                }
+                else
+                {
+                    // For simplicity, OnKeyDown is the same as OnChar
+                    // TODO: filter modifier key presses from OnChar
+                    keyEvent.SetEventType(wxEVT_KEY_DOWN);
+
+                    // Only process OnChar if OnKeyDown didn't swallow it
+                    if (!frame->GetEventHandler()->ProcessEvent (keyEvent))
+                    {
+                        keyEvent.SetEventType(wxEVT_CHAR);
+                        frame->GetEventHandler()->ProcessEvent(keyEvent);
+                    }
+                }
+            }
+        }
+    }
+    *continueToDispatch = True;
+}