]> git.saurik.com Git - wxWidgets.git/blobdiff - src/motif/window.cpp
Improvements for notebooks on various versions of GTK
[wxWidgets.git] / src / motif / window.cpp
index dad35a5234344fd5b9fe71a96e0414ba633e24ec..568974519d799814fad15b0f36d30f3ec2eb2bee 100644 (file)
@@ -52,7 +52,7 @@ 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,
+static void wxScrollBarCallback(Widget widget, XtPointer clientData,
                         XmScaleCallbackStruct *cbs);
 void wxPanelItemEventHandler (Widget    wid,
                               XtPointer client_data,
@@ -746,7 +746,11 @@ bool wxWindow::Show(bool show)
        }
        else
        {
-           XtMapWidget((Widget) GetTopWidget());
+           WXWidget topWidget = GetTopWidget();
+           if (GetTopWidget())
+             XtMapWidget((Widget) GetTopWidget());
+           else if (GetMainWidget())
+             XtMapWidget((Widget) GetMainWidget());
        }
     }
     else
@@ -759,7 +763,10 @@ bool wxWindow::Show(bool show)
        }
        else
        {
-           XtUnmapWidget((Widget) GetTopWidget());
+           if (GetTopWidget())
+             XtUnmapWidget((Widget) GetTopWidget());
+           else if (GetMainWidget())
+             XtUnmapWidget((Widget) GetMainWidget());
        }
     }
 
@@ -2217,6 +2224,30 @@ void wxCanvasInputEvent (Widget drawingArea, XtPointer data, XmDrawingAreaCallba
 
   local_event = *(cbs->event); // We must keep a copy!
 
+  /*
+  switch (local_event.xany.type)
+    {
+    case EnterNotify:
+      cout << "EnterNotify\n";
+      break;
+    case LeaveNotify:
+      cout << "LeaveNotify\n";
+      break;
+    case ButtonPress:
+      cout << "ButtonPress\n";
+      break;
+    case ButtonRelease:
+      cout << "ButtonRelease\n";
+      break;
+    case MotionNotify:
+      cout << "MotionNotify\n";
+      break;
+    default:
+      cout << "Something else\n";
+      break;
+  }
+  */
+
   switch (local_event.xany.type)
     {
     case EnterNotify:
@@ -2735,7 +2766,7 @@ void wxPanelItemEventHandler (Widget    wid,
   *continueToDispatch = True;
 }
 
-void wxScrollBarCallback(Widget scrollbar, XtPointer clientData,
+static void wxScrollBarCallback(Widget scrollbar, XtPointer clientData,
                         XmScaleCallbackStruct *cbs)
 {
     Widget scrolledWindow = XtParent (scrollbar);
@@ -3111,3 +3142,72 @@ void wxWindow::ClearUpdateRects()
     }
     m_updateRects.Clear();
 }
+
+bool wxWindow::ProcessAccelerator(wxKeyEvent& event)
+{
+    if (!m_acceleratorTable.Ok())
+        return FALSE;
+
+    int count = m_acceleratorTable.GetCount();
+    wxAcceleratorEntry* entries = m_acceleratorTable.GetEntries();
+    int i;
+    for (i = 0; i < count; i++)
+    {
+        wxAcceleratorEntry* entry = & (entries[i]);
+        if (entry->MatchesEvent(event))
+        {
+            // Bingo, we have a match. Now find a control
+            // that matches the entry command id.
+
+            // Need to go up to the top of the window hierarchy,
+            // since it might be e.g. a menu item
+            wxWindow* parent = this;
+            while (parent && !parent->IsKindOf(CLASSINFO(wxFrame)) && !parent->IsKindOf(CLASSINFO(wxDialog)))
+                parent = parent->GetParent();
+
+            if (!parent)
+                return FALSE;
+
+            if (parent->IsKindOf(CLASSINFO(wxFrame)))
+            {
+                // Try for a menu command
+                wxFrame* frame = (wxFrame*) parent;
+                if (frame->GetMenuBar())
+                {
+                    wxMenuItem* item = frame->GetMenuBar()->FindItemForId(entry->GetCommand());
+                    if (item)
+                    {
+                        wxCommandEvent commandEvent(wxEVT_COMMAND_MENU_SELECTED, entry->GetCommand());
+                        commandEvent.SetEventObject(frame);
+
+                        // If ProcessEvent returns TRUE (it was handled), then
+                        // the calling code will skip the event handling.
+                        return frame->GetEventHandler()->ProcessEvent(commandEvent);
+                    }
+                }
+            }
+
+            // Find a child matching the command id
+            wxWindow* child = parent->FindWindow(entry->GetCommand());
+
+            // No such child
+            if (!child)
+                return FALSE;
+
+            // Now we process those kinds of windows that we can.
+            // For now, only buttons.
+            if (child->IsKindOf(CLASSINFO(wxButton)))
+            {
+                wxCommandEvent commandEvent (wxEVT_COMMAND_BUTTON_CLICKED, child->GetId());
+                commandEvent.SetEventObject(child);
+                return child->GetEventHandler()->ProcessEvent(commandEvent);
+            }
+
+            return FALSE;
+        } // matches event
+    }// for
+
+    // We didn't match the key event against an accelerator.
+    return FALSE;
+}
+