From a8680e3e0e5066d35a8f4fd43294ba4bfcaf4ba7 Mon Sep 17 00:00:00 2001 From: Mattia Barbon Date: Mon, 14 Apr 2003 17:27:28 +0000 Subject: [PATCH] Code clanup: removed some useless/unused member variables/functions from wxWindow; used wxTranslateMouseEvent instead of duplicating its functionality. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@20217 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/motif/window.h | 49 ++---- src/motif/bmpbuttn.cpp | 4 +- src/motif/button.cpp | 2 - src/motif/checkbox.cpp | 1 - src/motif/choice.cpp | 18 +-- src/motif/combobox.cpp | 1 - src/motif/combobox_native.cpp | 1 - src/motif/dialog.cpp | 4 +- src/motif/filedlg.cpp | 14 +- src/motif/frame.cpp | 4 +- src/motif/gauge.cpp | 1 - src/motif/listbox.cpp | 13 +- src/motif/mdi.cpp | 1 - src/motif/radiobox.cpp | 5 +- src/motif/radiobut.cpp | 1 - src/motif/scrolbar.cpp | 1 - src/motif/slider.cpp | 1 - src/motif/statbmp.cpp | 2 - src/motif/statbox.cpp | 1 - src/motif/stattext.cpp | 1 - src/motif/textctrl.cpp | 7 +- src/motif/toolbar.cpp | 5 +- src/motif/window.cpp | 275 ++++++---------------------------- 23 files changed, 94 insertions(+), 318 deletions(-) diff --git a/include/wx/motif/window.h b/include/wx/motif/window.h index d0cb75935e..5f0e174557 100644 --- a/include/wx/motif/window.h +++ b/include/wx/motif/window.h @@ -110,7 +110,8 @@ public: // Get main widget for this window, e.g. a text widget virtual WXWidget GetMainWidget() const; - // Get the widget that corresponds to the label (for font setting, label setting etc.) + // Get the widget that corresponds to the label (for font setting, + // label setting etc.) virtual WXWidget GetLabelWidget() const; // Get the client widget for this window (something we can create other // windows on) @@ -124,20 +125,14 @@ public: WXWindow GetXWindow() const; WXDisplay *GetXDisplay() const; - // called from Motif callbacks - and should only be called from there - - void SetButton1(bool pressed) { m_button1Pressed = pressed; } - void SetButton2(bool pressed) { m_button2Pressed = pressed; } - void SetButton3(bool pressed) { m_button3Pressed = pressed; } - void SetLastClick(int button, long timestamp) { m_lastButton = button; m_lastTS = timestamp; } int GetLastClickedButton() const { return m_lastButton; } long GetLastClickTime() const { return m_lastTS; } - // Gives window a chance to do something in response to a size message, e.g. - // arrange status bar, toolbar etc. + // Gives window a chance to do something in response to a size message, + // e.g. arrange status bar, toolbar etc. virtual bool PreResize(); // Generates a paint event @@ -160,10 +155,6 @@ public: void ClearUpdateRegion() { m_updateRegion.Clear(); } void SetUpdateRegion(const wxRegion& region) { m_updateRegion = region; } - // sets the fore/background colour for the given widget - static void DoChangeForegroundColour(WXWidget widget, wxColour& foregroundColour); - static void DoChangeBackgroundColour(WXWidget widget, wxColour& backgroundColour, bool changeArmColour = FALSE); - // For implementation purposes - sometimes decorations make the client area // smaller virtual wxPoint GetClientAreaOrigin() const; @@ -172,9 +163,6 @@ protected: // event handlers (not virtual by design) void OnIdle(wxIdleEvent& event); - wxWindow *GetChild(int number) const - { return GetChildren().Item(number)->GetData(); } - // Responds to colour changes: passes event on to children. void OnSysColourChanged(wxSysColourChangedEvent& event); @@ -182,9 +170,6 @@ protected: void SetMainWidget(WXWidget w) { m_mainWidget = w; } - bool CanAddEventHandler() const { return m_canAddEventHandler; } - void SetCanAddEventHandler(bool flag) { m_canAddEventHandler = flag; } - // See src/motif/window.cpp, near the top, for an explanation // why this is necessary void CanvasSetSizeIntr(int x, int y, int width, int height, @@ -213,7 +198,8 @@ public: void SetPixmapHeight(int h) { m_pixmapHeight = h; } // Change properties - virtual void ChangeFont(bool keepOriginalSize = TRUE); // Change to the current font (often overridden) + // Change to the current font (often overridden) + virtual void ChangeFont(bool keepOriginalSize = TRUE); // Change background and foreground colour using current background colour // setting (Motif generates foreground based on background) @@ -246,8 +232,8 @@ protected: // unmanage and destroy an X widget f it's !NULL (passing NULL is ok) void UnmanageAndDestroy(WXWidget widget); - // map or unmap an X widget (passing NULL is ok), returns TRUE if widget was - // mapped/unmapped + // map or unmap an X widget (passing NULL is ok), + // returns TRUE if widget was mapped/unmapped bool MapOrUnmap(WXWidget widget, bool map); // scrolling stuff @@ -274,14 +260,10 @@ protected: // -------------------- bool m_needsRefresh:1; // repaint backing store? - bool m_canAddEventHandler:1; // ??? - bool m_button1Pressed:1; - bool m_button2Pressed:1; - bool m_button3Pressed:1; // For double-click detection - long m_lastTS; // last timestamp - int m_lastButton; // last pressed button + long m_lastTS; // last timestamp + unsigned m_lastButton:2; // last pressed button // List of wxRects representing damaged region wxRectList m_updateRects; @@ -293,17 +275,15 @@ protected: WXWidget m_borderWidget; WXWidget m_scrolledWindow; WXWidget m_drawingArea; - bool m_winCaptured; - bool m_hScroll; - bool m_vScroll; + bool m_winCaptured:1; WXPixmap m_backingPixmap; int m_pixmapWidth; int m_pixmapHeight; int m_pixmapOffsetX; int m_pixmapOffsetY; - // Store the last scroll pos, since in wxWin the pos isn't set automatically - // by system + // Store the last scroll pos, since in wxWin the pos isn't set + // automatically by system int m_scrollPosX; int m_scrollPosY; @@ -343,7 +323,8 @@ private: // undesired effects. // // Usage: create an instance of this class on the stack to disable the size -// optimisation, it will be reenabled as soon as the object goes out from scope. +// optimisation, it will be reenabled as soon as the object goes out +// from scope. // ---------------------------------------------------------------------------- class WXDLLEXPORT wxNoOptimize diff --git a/src/motif/bmpbuttn.cpp b/src/motif/bmpbuttn.cpp index aede52c9b0..721409d8a4 100644 --- a/src/motif/bmpbuttn.cpp +++ b/src/motif/bmpbuttn.cpp @@ -101,8 +101,6 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, XmNactivateCallback, (XtCallbackProc) wxButtonCallback, (XtPointer) this); - SetCanAddEventHandler(TRUE); - wxSize best = m_bmpNormal.Ok() ? GetBestSize() : wxSize(30, 30); if( size.x != -1 ) best.x = size.x; if( size.y != -1 ) best.y = size.y; @@ -266,7 +264,7 @@ void wxBitmapButton::DoSetBitmap() void wxBitmapButton::ChangeBackgroundColour() { - DoChangeBackgroundColour(m_mainWidget, m_backgroundColour, TRUE); + wxDoChangeBackgroundColour(m_mainWidget, m_backgroundColour, TRUE); // Must reset the bitmaps since the colours have changed. DoSetBitmap(); diff --git a/src/motif/button.cpp b/src/motif/button.cpp index 709a1a9ffc..5272ec5984 100644 --- a/src/motif/button.cpp +++ b/src/motif/button.cpp @@ -75,8 +75,6 @@ bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label, XmNactivateCallback, (XtCallbackProc) wxButtonCallback, (XtPointer) this); - SetCanAddEventHandler(TRUE); - wxSize best = GetBestSize(); if( size.x != -1 ) best.x = size.x; if( size.y != -1 ) best.y = size.y; diff --git a/src/motif/checkbox.cpp b/src/motif/checkbox.cpp index cd2b57c5b8..edd27d1c2b 100644 --- a/src/motif/checkbox.cpp +++ b/src/motif/checkbox.cpp @@ -70,7 +70,6 @@ bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, XmToggleButtonSetState ((Widget) m_mainWidget, FALSE, TRUE); - SetCanAddEventHandler(TRUE); AttachWidget( parent, m_mainWidget, (WXWidget)NULL, pos.x, pos.y, size.x, size.y ); diff --git a/src/motif/choice.cpp b/src/motif/choice.cpp index 3407965764..d8f2533de4 100644 --- a/src/motif/choice.cpp +++ b/src/motif/choice.cpp @@ -179,7 +179,7 @@ int wxChoice::DoAppend(const wxString& item) #endif NULL); - DoChangeBackgroundColour((WXWidget) w, m_backgroundColour); + wxDoChangeBackgroundColour((WXWidget) w, m_backgroundColour); if( m_font.Ok() ) wxDoChangeFont( w, m_font ); @@ -459,22 +459,22 @@ void wxChoice::ChangeFont(bool keepOriginalSize) void wxChoice::ChangeBackgroundColour() { - DoChangeBackgroundColour(m_formWidget, m_backgroundColour); - DoChangeBackgroundColour(m_buttonWidget, m_backgroundColour); - DoChangeBackgroundColour(m_menuWidget, m_backgroundColour); + wxDoChangeBackgroundColour(m_formWidget, m_backgroundColour); + wxDoChangeBackgroundColour(m_buttonWidget, m_backgroundColour); + wxDoChangeBackgroundColour(m_menuWidget, m_backgroundColour); size_t i; for (i = 0; i < m_noStrings; i++) - DoChangeBackgroundColour(m_widgetArray[i], m_backgroundColour); + wxDoChangeBackgroundColour(m_widgetArray[i], m_backgroundColour); } void wxChoice::ChangeForegroundColour() { - DoChangeForegroundColour(m_formWidget, m_foregroundColour); - DoChangeForegroundColour(m_buttonWidget, m_foregroundColour); - DoChangeForegroundColour(m_menuWidget, m_foregroundColour); + wxDoChangeForegroundColour(m_formWidget, m_foregroundColour); + wxDoChangeForegroundColour(m_buttonWidget, m_foregroundColour); + wxDoChangeForegroundColour(m_menuWidget, m_foregroundColour); size_t i; for (i = 0; i < m_noStrings; i++) - DoChangeForegroundColour(m_widgetArray[i], m_foregroundColour); + wxDoChangeForegroundColour(m_widgetArray[i], m_foregroundColour); } int wxChoice::GetCount() const diff --git a/src/motif/combobox.cpp b/src/motif/combobox.cpp index fb3e685bf1..ef51038de6 100644 --- a/src/motif/combobox.cpp +++ b/src/motif/combobox.cpp @@ -86,7 +86,6 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, XtAddCallback (buttonWidget, XmNvalueChangedCallback, (XtCallbackProc) wxComboBoxCallback, (XtPointer) this); - SetCanAddEventHandler(TRUE); AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y); ChangeBackgroundColour(); diff --git a/src/motif/combobox_native.cpp b/src/motif/combobox_native.cpp index 846d4e10f3..95294fe5f8 100644 --- a/src/motif/combobox_native.cpp +++ b/src/motif/combobox_native.cpp @@ -114,7 +114,6 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, if( size.x != -1 ) best.x = size.x; if( size.y != -1 ) best.y = size.y; - SetCanAddEventHandler(true); AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, best.x, best.y); diff --git a/src/motif/dialog.cpp b/src/motif/dialog.cpp index ab5c7eeccc..533cad7db5 100644 --- a/src/motif/dialog.cpp +++ b/src/motif/dialog.cpp @@ -445,11 +445,11 @@ void wxDialog::ChangeFont(bool keepOriginalSize) void wxDialog::ChangeBackgroundColour() { if (GetMainWidget()) - DoChangeBackgroundColour(GetMainWidget(), m_backgroundColour); + wxDoChangeBackgroundColour(GetMainWidget(), m_backgroundColour); } void wxDialog::ChangeForegroundColour() { if (GetMainWidget()) - DoChangeForegroundColour(GetMainWidget(), m_foregroundColour); + wxDoChangeForegroundColour(GetMainWidget(), m_foregroundColour); } diff --git a/src/motif/filedlg.cpp b/src/motif/filedlg.cpp index c4ea2a4f4e..27ad5f831f 100644 --- a/src/motif/filedlg.cpp +++ b/src/motif/filedlg.cpp @@ -188,12 +188,12 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message, static void wxChangeListBoxColours(wxWindow* WXUNUSED(win), Widget widget) { - wxWindow::DoChangeBackgroundColour((WXWidget) widget, *wxWHITE); + wxDoChangeBackgroundColour((WXWidget) widget, *wxWHITE); // Change colour of the scrolled areas of the listboxes Widget listParent = XtParent (widget); #if 0 - wxWindow::DoChangeBackgroundColour((WXWidget) listParent, *wxWHITE, TRUE); + wxDoChangeBackgroundColour((WXWidget) listParent, *wxWHITE, TRUE); #endif Widget hsb = (Widget) 0; @@ -207,8 +207,8 @@ static void wxChangeListBoxColours(wxWindow* WXUNUSED(win), Widget widget) * function to change them (by default, taken from wxSystemSettings) */ wxColour backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); - wxWindow::DoChangeBackgroundColour((WXWidget) hsb, backgroundColour, TRUE); - wxWindow::DoChangeBackgroundColour((WXWidget) vsb, backgroundColour, TRUE); + wxDoChangeBackgroundColour((WXWidget) hsb, backgroundColour, TRUE); + wxDoChangeBackgroundColour((WXWidget) vsb, backgroundColour, TRUE); if (hsb) XtVaSetValues (hsb, @@ -334,9 +334,9 @@ int wxFileDialog::ShowModal() XmNresizePolicy, XmRESIZE_NONE, NULL); #endif - // DoChangeBackgroundColour((WXWidget) fileSel, m_backgroundColour); - DoChangeBackgroundColour((WXWidget) filterWidget, *wxWHITE); - DoChangeBackgroundColour((WXWidget) selectionWidget, *wxWHITE); + // wxDoChangeBackgroundColour((WXWidget) fileSel, m_backgroundColour); + wxDoChangeBackgroundColour((WXWidget) filterWidget, *wxWHITE); + wxDoChangeBackgroundColour((WXWidget) selectionWidget, *wxWHITE); wxChangeListBoxColours(this, dirListWidget); wxChangeListBoxColours(this, fileListWidget); diff --git a/src/motif/frame.cpp b/src/motif/frame.cpp index f65136d32d..d6fc8327db 100644 --- a/src/motif/frame.cpp +++ b/src/motif/frame.cpp @@ -694,13 +694,13 @@ void wxFrame::ChangeFont(bool WXUNUSED(keepOriginalSize)) void wxFrame::ChangeBackgroundColour() { if (GetClientWidget()) - DoChangeBackgroundColour(GetClientWidget(), m_backgroundColour); + wxDoChangeBackgroundColour(GetClientWidget(), m_backgroundColour); } void wxFrame::ChangeForegroundColour() { if (GetClientWidget()) - DoChangeForegroundColour(GetClientWidget(), m_foregroundColour); + wxDoChangeForegroundColour(GetClientWidget(), m_foregroundColour); } /* MATTEW: Used to insure that hide-&-show within an event cycle works */ diff --git a/src/motif/gauge.cpp b/src/motif/gauge.cpp index 6a7f0fb2ba..23931f09d9 100644 --- a/src/motif/gauge.cpp +++ b/src/motif/gauge.cpp @@ -136,7 +136,6 @@ bool wxGauge::Create(wxWindow *parent, wxWindowID id, ChangeFont(FALSE); - SetCanAddEventHandler(TRUE); AttachWidget (parent, m_mainWidget, (WXWidget) NULL, x, y, best.x, best.y); diff --git a/src/motif/listbox.cpp b/src/motif/listbox.cpp index db682d40d4..e28473f615 100644 --- a/src/motif/listbox.cpp +++ b/src/motif/listbox.cpp @@ -149,7 +149,6 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, (XtCallbackProc) wxListBoxCallback, (XtPointer) this); - SetCanAddEventHandler(TRUE); AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, best.x, best.y); @@ -619,8 +618,8 @@ void wxListBox::ChangeBackgroundColour() * function to change them (by default, taken from wxSystemSettings) */ wxColour backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); - DoChangeBackgroundColour((WXWidget) hsb, backgroundColour, TRUE); - DoChangeBackgroundColour((WXWidget) vsb, backgroundColour, TRUE); + wxDoChangeBackgroundColour((WXWidget) hsb, backgroundColour, TRUE); + wxDoChangeBackgroundColour((WXWidget) vsb, backgroundColour, TRUE); XtVaSetValues (hsb, XmNtroughColor, backgroundColour.AllocColour(XtDisplay(hsb)), @@ -630,7 +629,7 @@ void wxListBox::ChangeBackgroundColour() NULL); // MBN: why change parent's background? It looks really ugly. - // DoChangeBackgroundColour((WXWidget) parent, m_backgroundColour, TRUE); + // wxDoChangeBackgroundColour((WXWidget) parent, m_backgroundColour, TRUE); } void wxListBox::ChangeForegroundColour() @@ -648,9 +647,9 @@ void wxListBox::ChangeForegroundColour() /* TODO: should scrollbars be affected? Should probably have separate function to change them (by default, taken from wxSystemSettings) - DoChangeForegroundColour((WXWidget) hsb, m_foregroundColour); - DoChangeForegroundColour((WXWidget) vsb, m_foregroundColour); - DoChangeForegroundColour((WXWidget) parent, m_foregroundColour); + wxDoChangeForegroundColour((WXWidget) hsb, m_foregroundColour); + wxDoChangeForegroundColour((WXWidget) vsb, m_foregroundColour); + wxDoChangeForegroundColour((WXWidget) parent, m_foregroundColour); */ } diff --git a/src/motif/mdi.cpp b/src/motif/mdi.cpp index daf09e2582..c4ad44a11a 100644 --- a/src/motif/mdi.cpp +++ b/src/motif/mdi.cpp @@ -391,7 +391,6 @@ bool wxMDIChildFrame::Create(wxMDIParentFrame *parent, XtAddEventHandler((Widget) m_mainWidget, ExposureMask,FALSE, wxUniversalRepaintProc, (XtPointer) this); - SetCanAddEventHandler(TRUE); AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y); ChangeBackgroundColour(); diff --git a/src/motif/radiobox.cpp b/src/motif/radiobox.cpp index 6659d3d324..6073ff07c3 100644 --- a/src/motif/radiobox.cpp +++ b/src/motif/radiobox.cpp @@ -168,7 +168,6 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title, XtManageChild (radioBoxWidget); XtManageChild ((Widget)m_mainWidget); - SetCanAddEventHandler(TRUE); AttachWidget (parent, m_mainWidget, NULL, pos.x, pos.y, size.x, size.y); ChangeBackgroundColour(); @@ -385,7 +384,7 @@ void wxRadioBox::ChangeBackgroundColour() { WXWidget radioButton = m_radioButtons[i]; - DoChangeBackgroundColour(radioButton, m_backgroundColour, TRUE); + wxDoChangeBackgroundColour(radioButton, m_backgroundColour, TRUE); XtVaSetValues ((Widget) radioButton, XmNselectColor, selectPixel, @@ -402,7 +401,7 @@ void wxRadioBox::ChangeForegroundColour() { WXWidget radioButton = m_radioButtons[i]; - DoChangeForegroundColour(radioButton, m_foregroundColour); + wxDoChangeForegroundColour(radioButton, m_foregroundColour); } } diff --git a/src/motif/radiobut.cpp b/src/motif/radiobut.cpp index 9dc0df98d8..87c20587a9 100644 --- a/src/motif/radiobut.cpp +++ b/src/motif/radiobut.cpp @@ -95,7 +95,6 @@ bool wxRadioButton::Create(wxWindow *parent, wxWindowID id, XtManageChild (radioButtonWidget); - SetCanAddEventHandler(TRUE); AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y); ChangeBackgroundColour(); diff --git a/src/motif/scrolbar.cpp b/src/motif/scrolbar.cpp index e0a15b4a4c..c882178a53 100644 --- a/src/motif/scrolbar.cpp +++ b/src/motif/scrolbar.cpp @@ -96,7 +96,6 @@ bool wxScrollBar::Create(wxWindow *parent, wxWindowID id, 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); ChangeBackgroundColour(); diff --git a/src/motif/slider.cpp b/src/motif/slider.cpp index 0cf3134f88..69d6efb92c 100644 --- a/src/motif/slider.cpp +++ b/src/motif/slider.cpp @@ -104,7 +104,6 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id, XtAddCallback (sliderWidget, XmNdragCallback, (XtCallbackProc) wxSliderCallback, (XtPointer) this); ChangeFont(FALSE); - SetCanAddEventHandler(TRUE); AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y); ChangeBackgroundColour(); diff --git a/src/motif/statbmp.cpp b/src/motif/statbmp.cpp index 43e55139ee..c10ac0d74a 100644 --- a/src/motif/statbmp.cpp +++ b/src/motif/statbmp.cpp @@ -75,8 +75,6 @@ bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id, m_font = parent->GetFont(); ChangeFont(FALSE); - SetCanAddEventHandler(TRUE); - wxSize actualSize(size); // work around the cases where the bitmap is a wxNull(Icon/Bitmap) if (actualSize.x == -1) diff --git a/src/motif/statbox.cpp b/src/motif/statbox.cpp index f836c53de3..3aad265153 100644 --- a/src/motif/statbox.cpp +++ b/src/motif/statbox.cpp @@ -121,7 +121,6 @@ bool wxStaticBox::Create(wxWindow *parent, wxWindowID id, NULL); } - SetCanAddEventHandler(TRUE); AttachWidget (parent, m_mainWidget, NULL, pos.x, pos.y, size.x, size.y); ChangeBackgroundColour(); diff --git a/src/motif/stattext.cpp b/src/motif/stattext.cpp index ead5cd99b5..4f9b14740c 100644 --- a/src/motif/stattext.cpp +++ b/src/motif/stattext.cpp @@ -117,7 +117,6 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id, m_mainWidget = borderWidget ? borderWidget : m_labelWidget; - SetCanAddEventHandler(TRUE); AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y); ChangeBackgroundColour (); diff --git a/src/motif/textctrl.cpp b/src/motif/textctrl.cpp index b518e2fe45..cb5b2b49a9 100644 --- a/src/motif/textctrl.cpp +++ b/src/motif/textctrl.cpp @@ -197,7 +197,6 @@ bool wxTextCtrl::Create(wxWindow *parent, if( size.x != -1 ) best.x = size.x; if( size.y != -1 ) best.y = size.y; - SetCanAddEventHandler(TRUE); AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, best.x, best.y); @@ -581,9 +580,9 @@ void wxTextCtrl::ChangeBackgroundColour() NULL); wxColour backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); if (hsb) - DoChangeBackgroundColour((WXWidget) hsb, backgroundColour, TRUE); + wxDoChangeBackgroundColour((WXWidget) hsb, backgroundColour, TRUE); if (vsb) - DoChangeBackgroundColour((WXWidget) vsb, backgroundColour, TRUE); + wxDoChangeBackgroundColour((WXWidget) vsb, backgroundColour, TRUE); // MBN: why change parent background? // DoChangeBackgroundColour((WXWidget) parent, m_backgroundColour, TRUE); @@ -611,7 +610,7 @@ void wxTextCtrl::ChangeForegroundColour() if (vsb) DoChangeForegroundColour((WXWidget) vsb, m_foregroundColour); */ - DoChangeForegroundColour((WXWidget) parent, m_foregroundColour); + wxDoChangeForegroundColour((WXWidget) parent, m_foregroundColour); } } diff --git a/src/motif/toolbar.cpp b/src/motif/toolbar.cpp index 0841393811..6bdc23d9cd 100644 --- a/src/motif/toolbar.cpp +++ b/src/motif/toolbar.cpp @@ -239,7 +239,6 @@ bool wxToolBar::Create(wxWindow *parent, if( rSize.x == -1 && GetParent() ) rSize.x = GetParent()->GetSize().x; - SetCanAddEventHandler(TRUE); AttachWidget (parent, m_mainWidget, (WXWidget) NULL, rPos.x, rPos.y, rSize.x, rSize.y); @@ -361,8 +360,8 @@ bool wxToolBar::Realize() if( !tool->GetButtonWidget() ) { - DoChangeBackgroundColour((WXWidget) button, - m_backgroundColour, TRUE); + wxDoChangeBackgroundColour((WXWidget) button, + m_backgroundColour, TRUE); tool->SetWidget(button); } diff --git a/src/motif/window.cpp b/src/motif/window.cpp index 17b3de81b2..cc55da5b8d 100644 --- a/src/motif/window.cpp +++ b/src/motif/window.cpp @@ -200,10 +200,6 @@ void wxWindow::Init() m_needsRefresh = TRUE; m_mainWidget = (WXWidget) 0; - m_button1Pressed = - m_button2Pressed = - m_button3Pressed = FALSE; - m_winCaptured = FALSE; m_isShown = TRUE; @@ -215,9 +211,6 @@ void wxWindow::Init() m_scrolledWindow = m_drawingArea = (WXWidget) 0; - m_hScroll = - m_vScroll = FALSE; - m_scrollPosX = m_scrollPosY = 0; @@ -230,7 +223,6 @@ void wxWindow::Init() m_lastTS = 0; m_lastButton = 0; - m_canAddEventHandler = FALSE; } // real construction (Init() must have been called before!) @@ -378,8 +370,8 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id, // Scrolled widget needs to have its colour changed or we get a little blue // square where the scrollbars abutt wxColour backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); - DoChangeBackgroundColour(m_scrolledWindow, backgroundColour, TRUE); - DoChangeBackgroundColour(m_drawingArea, backgroundColour, TRUE); + wxDoChangeBackgroundColour(m_scrolledWindow, backgroundColour, TRUE); + wxDoChangeBackgroundColour(m_drawingArea, backgroundColour, TRUE); XmScrolledWindowSetAreas( (Widget)m_scrolledWindow, @@ -529,7 +521,7 @@ void wxWindow::CreateScrollbar(wxOrientation orientation) m_hScrollBar = (WXWidget) hScrollBar; wxColour backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); - DoChangeBackgroundColour(m_hScrollBar, backgroundColour, TRUE); + wxDoChangeBackgroundColour(m_hScrollBar, backgroundColour, TRUE); XtRealizeWidget(hScrollBar); @@ -537,8 +529,6 @@ void wxWindow::CreateScrollbar(wxOrientation orientation) XmNhorizontalScrollBar, (Widget) m_hScrollBar, NULL); - m_hScroll = TRUE; - wxAddWindowToTable( hScrollBar, this ); } @@ -564,7 +554,7 @@ void wxWindow::CreateScrollbar(wxOrientation orientation) m_vScrollBar = (WXWidget) vScrollBar; wxColour backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); - DoChangeBackgroundColour(m_vScrollBar, backgroundColour, TRUE); + wxDoChangeBackgroundColour(m_vScrollBar, backgroundColour, TRUE); XtRealizeWidget(vScrollBar); @@ -572,8 +562,6 @@ void wxWindow::CreateScrollbar(wxOrientation orientation) XmNverticalScrollBar, (Widget) m_vScrollBar, NULL); - m_vScroll = TRUE; - wxAddWindowToTable( vScrollBar, this ); } @@ -594,7 +582,6 @@ void wxWindow::DestroyScrollbar(wxOrientation orientation) XtDestroyWidget((Widget) m_hScrollBar); } m_hScrollBar = (WXWidget) 0; - m_hScroll = FALSE; XtVaSetValues((Widget) m_scrolledWindow, XmNhorizontalScrollBar, (Widget) 0, @@ -610,7 +597,6 @@ void wxWindow::DestroyScrollbar(wxOrientation orientation) XtDestroyWidget((Widget) m_vScrollBar); } m_vScrollBar = (WXWidget) 0; - m_vScroll = FALSE; XtVaSetValues((Widget) m_scrolledWindow, XmNverticalScrollBar, (Widget) 0, @@ -1884,14 +1870,12 @@ bool wxWindow::AttachWidget (wxWindow* WXUNUSED(parent), WXWidget mainWidget, WXWidget formWidget, int x, int y, int width, int height) { wxAddWindowToTable((Widget) mainWidget, this); - if (CanAddEventHandler()) - { - XtAddEventHandler((Widget) mainWidget, - ButtonPressMask | ButtonReleaseMask | PointerMotionMask, // | KeyPressMask, - False, - wxPanelItemEventHandler, - (XtPointer) this); - } + XtAddEventHandler( (Widget) mainWidget, + ButtonPressMask | ButtonReleaseMask + | PointerMotionMask, + False, + wxPanelItemEventHandler, + (XtPointer) this); if (!formWidget) { @@ -1925,14 +1909,12 @@ bool wxWindow::AttachWidget (wxWindow* WXUNUSED(parent), WXWidget mainWidget, // Remove event handler, remove from hash table bool wxWindow::DetachWidget(WXWidget widget) { - if (CanAddEventHandler()) - { - XtRemoveEventHandler((Widget) widget, - ButtonPressMask | ButtonReleaseMask | PointerMotionMask, // | KeyPressMask, - False, - wxPanelItemEventHandler, - (XtPointer)this); - } + XtRemoveEventHandler( (Widget) widget, + ButtonPressMask | ButtonReleaseMask + | PointerMotionMask, + False, + wxPanelItemEventHandler, + (XtPointer)this); wxDeleteWindowFromTable((Widget) widget); return TRUE; @@ -2092,168 +2074,14 @@ static void wxCanvasInputEvent(Widget drawingArea, case ButtonPress: case ButtonRelease: case MotionNotify: + { + wxMouseEvent wxevent; + if(wxTranslateMouseEvent(wxevent, canvas, drawingArea, &local_event)) { - // FIXME: most of this mouse event code is more or less - // duplicated in wxTranslateMouseEvent - // - wxEventType eventType = wxEVT_NULL; - - if (local_event.xany.type == EnterNotify) - { - //if (local_event.xcrossing.mode!=NotifyNormal) - // return ; // Ignore grab events - eventType = wxEVT_ENTER_WINDOW; - // canvas->GetEventHandler()->OnSetFocus(); - } - else if (local_event.xany.type == LeaveNotify) - { - //if (local_event.xcrossingr.mode!=NotifyNormal) - // return ; // Ignore grab events - eventType = wxEVT_LEAVE_WINDOW; - // canvas->GetEventHandler()->OnKillFocus(); - } - else if (local_event.xany.type == MotionNotify) - { - eventType = wxEVT_MOTION; - } - - else if (local_event.xany.type == ButtonPress) - { - if (local_event.xbutton.button == Button1) - { - eventType = wxEVT_LEFT_DOWN; - canvas->SetButton1(TRUE); - } - else if (local_event.xbutton.button == Button2) - { - eventType = wxEVT_MIDDLE_DOWN; - canvas->SetButton2(TRUE); - } - else if (local_event.xbutton.button == Button3) - { - eventType = wxEVT_RIGHT_DOWN; - canvas->SetButton3(TRUE); - } - } - else if (local_event.xany.type == ButtonRelease) - { - if (local_event.xbutton.button == Button1) - { - eventType = wxEVT_LEFT_UP; - canvas->SetButton1(FALSE); - } - else if (local_event.xbutton.button == Button2) - { - eventType = wxEVT_MIDDLE_UP; - canvas->SetButton2(FALSE); - } - else if (local_event.xbutton.button == Button3) - { - eventType = wxEVT_RIGHT_UP; - canvas->SetButton3(FALSE); - } - } - - wxMouseEvent wxevent (eventType); - - wxevent.m_leftDown = ((eventType == wxEVT_LEFT_DOWN) - || (event_left_is_down (&local_event) - && (eventType != wxEVT_LEFT_UP))); - wxevent.m_middleDown = ((eventType == wxEVT_MIDDLE_DOWN) - || (event_middle_is_down (&local_event) - && (eventType != wxEVT_MIDDLE_UP))); - wxevent.m_rightDown = ((eventType == wxEVT_RIGHT_DOWN) - || (event_right_is_down (&local_event) - && (eventType != wxEVT_RIGHT_UP))); - - wxevent.m_shiftDown = local_event.xbutton.state & ShiftMask; - wxevent.m_controlDown = local_event.xbutton.state & ControlMask; - wxevent.m_altDown = local_event.xbutton.state & Mod3Mask; - wxevent.m_metaDown = local_event.xbutton.state & Mod1Mask; - wxevent.SetTimestamp(local_event.xbutton.time); - - if ( eventType == wxEVT_MOTION ) - { - if (local_event.xmotion.is_hint == NotifyHint) - { - Window root, child; - Display *dpy = XtDisplay (drawingArea); - - XQueryPointer (dpy, XtWindow (drawingArea), - &root, &child, - &local_event.xmotion.x_root, - &local_event.xmotion.y_root, - &local_event.xmotion.x, - &local_event.xmotion.y, - &local_event.xmotion.state); - } - else - { - } - } - - // Now check if we need to translate this event into a double click - if (TRUE) // canvas->doubleClickAllowed) - { - if (wxevent.ButtonDown()) - { - long dclickTime = XtGetMultiClickTime((Display*) wxGetDisplay()); - - // get button and time-stamp - int button = 0; - if (wxevent.LeftDown()) - button = 1; - else if (wxevent.MiddleDown()) - button = 2; - else if (wxevent.RightDown()) - button = 3; - long ts = wxevent.GetTimestamp(); - - // check, if single or double click - int buttonLast = canvas->GetLastClickedButton(); - long lastTS = canvas->GetLastClickTime(); - if ( buttonLast && buttonLast == button && (ts - lastTS) < dclickTime ) - { - // I have a dclick - canvas->SetLastClick(0, ts); - - wxEventType typeDouble; - if ( eventType == wxEVT_LEFT_DOWN ) - typeDouble = wxEVT_LEFT_DCLICK; - else if ( eventType == wxEVT_MIDDLE_DOWN ) - typeDouble = wxEVT_MIDDLE_DCLICK; - else if ( eventType == wxEVT_RIGHT_DOWN ) - typeDouble = wxEVT_RIGHT_DCLICK; - else - typeDouble = wxEVT_NULL; - - if ( typeDouble != wxEVT_NULL ) - { - wxevent.SetEventType(typeDouble); - } - } - else - { - // not fast enough or different button - canvas->SetLastClick(button, ts); - } - } - } - - wxevent.SetId(canvas->GetId()); - wxevent.SetEventObject(canvas); - wxevent.m_x = local_event.xbutton.x; - wxevent.m_y = local_event.xbutton.y; - canvas->GetEventHandler()->ProcessEvent (wxevent); -#if 0 - if (eventType == wxEVT_ENTER_WINDOW || - eventType == wxEVT_LEAVE_WINDOW || - eventType == wxEVT_MOTION - ) - return; -#endif // 0 - break; - } + canvas->GetEventHandler()->ProcessEvent(wxevent); + } + break; + } case KeyPress: { wxKeyEvent event (wxEVT_CHAR); @@ -2449,26 +2277,31 @@ void wxUniversalRepaintProc(Widget w, XtPointer WXUNUSED(c_data), XEvent *event, // TranslateXXXEvent() functions // ---------------------------------------------------------------------------- -bool wxTranslateMouseEvent(wxMouseEvent& wxevent, wxWindow *win, Widget widget, XEvent *xevent) +bool wxTranslateMouseEvent(wxMouseEvent& wxevent, wxWindow *win, + Widget widget, XEvent *xevent) { switch (xevent->xany.type) { - case EnterNotify: // never received here - yes ? MB - case LeaveNotify: // never received here - yes ? MB + case EnterNotify: + case LeaveNotify: +#if 0 + fprintf(stderr, "Widget 0x%p <-> window %p (%s), %s\n", + (WXWidget)widget, win, win->GetClassInfo()->GetClassName(), + (xevent->xany.type == EnterNotify ? "ENTER" : "LEAVE")); +#endif case ButtonPress: case ButtonRelease: case MotionNotify: { wxEventType eventType = wxEVT_NULL; - // FIXME: this is never true I think - MB - // if (xevent->xany.type == LeaveNotify) { - win->SetButton1(FALSE); - win->SetButton2(FALSE); - win->SetButton3(FALSE); - return FALSE; + eventType = wxEVT_LEAVE_WINDOW; + } + if (xevent->xany.type == EnterNotify) + { + eventType = wxEVT_ENTER_WINDOW; } else if (xevent->xany.type == MotionNotify) { @@ -2481,30 +2314,28 @@ bool wxTranslateMouseEvent(wxMouseEvent& wxevent, wxWindow *win, Widget widget, if (xevent->xbutton.button == Button1) { eventType = wxEVT_LEFT_DOWN; - win->SetButton1(TRUE); button = 1; } else if (xevent->xbutton.button == Button2) { eventType = wxEVT_MIDDLE_DOWN; - win->SetButton2(TRUE); button = 2; } else if (xevent->xbutton.button == Button3) { eventType = wxEVT_RIGHT_DOWN; - win->SetButton3(TRUE); button = 3; } // check for a double click // - long dclickTime = XtGetMultiClickTime((Display*) wxGetDisplay()); + long dclickTime = XtGetMultiClickTime(wxGlobalDisplay()); long ts = wxevent.GetTimestamp(); int buttonLast = win->GetLastClickedButton(); long lastTS = win->GetLastClickTime(); - if ( buttonLast && buttonLast == button && (ts - lastTS) < dclickTime ) + if ( buttonLast && buttonLast == button && + (ts - lastTS) < dclickTime ) { // I have a dclick win->SetLastClick(0, ts); @@ -2526,19 +2357,17 @@ bool wxTranslateMouseEvent(wxMouseEvent& wxevent, wxWindow *win, Widget widget, if (xevent->xbutton.button == Button1) { eventType = wxEVT_LEFT_UP; - win->SetButton1(FALSE); } else if (xevent->xbutton.button == Button2) { eventType = wxEVT_MIDDLE_UP; - win->SetButton2(FALSE); } else if (xevent->xbutton.button == Button3) { eventType = wxEVT_RIGHT_UP; - win->SetButton3(FALSE); } - else return FALSE; + else + return FALSE; } else { @@ -2706,30 +2535,16 @@ void wxWindow::ChangeBackgroundColour() { WXWidget mainWidget = GetMainWidget(); if ( mainWidget ) - DoChangeBackgroundColour(mainWidget, m_backgroundColour); + wxDoChangeBackgroundColour(mainWidget, m_backgroundColour); } void wxWindow::ChangeForegroundColour() { WXWidget mainWidget = GetMainWidget(); if ( mainWidget ) - DoChangeForegroundColour(mainWidget, m_foregroundColour); + wxDoChangeForegroundColour(mainWidget, m_foregroundColour); if ( m_scrolledWindow && mainWidget != m_scrolledWindow ) - DoChangeForegroundColour(m_scrolledWindow, m_foregroundColour); -} - -// Change a widget's foreground and background colours. -void wxWindow::DoChangeForegroundColour(WXWidget widget, - wxColour& foregroundColour) -{ - wxDoChangeForegroundColour( widget, foregroundColour ); -} - -void wxWindow::DoChangeBackgroundColour(WXWidget widget, - wxColour& backgroundColour, - bool changeArmColour) -{ - wxDoChangeBackgroundColour( widget, backgroundColour, changeArmColour ); + wxDoChangeForegroundColour(m_scrolledWindow, m_foregroundColour); } bool wxWindow::SetBackgroundColour(const wxColour& col) -- 2.45.2