From 0d57be459406c2830f6abc9d99ae99166c6d133b Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Wed, 21 Oct 1998 21:43:20 +0000 Subject: [PATCH] More Motif stuff incl. beginnings of wxToolBar git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@895 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/latex/wx/activevt.tex | 2 +- docs/latex/wx/config.tex | 2 +- docs/motif/todo.txt | 15 +- include/wx/motif/bitmap.h | 2 +- include/wx/motif/button.h | 5 + include/wx/motif/checkbox.h | 5 + include/wx/motif/choice.h | 4 + include/wx/motif/colour.h | 10 ++ include/wx/motif/combobox.h | 5 + include/wx/motif/dialog.h | 5 +- include/wx/motif/frame.h | 6 +- include/wx/motif/gauge.h | 5 + include/wx/motif/listbox.h | 4 + include/wx/motif/mdi.h | 10 +- include/wx/motif/notebook.h | 5 + include/wx/motif/private.h | 2 + include/wx/motif/radiobox.h | 4 + include/wx/motif/radiobut.h | 4 + include/wx/motif/scrolbar.h | 5 + include/wx/motif/slider.h | 6 + include/wx/motif/spinbutt.h | 5 + include/wx/motif/statbmp.h | 5 + include/wx/motif/statbox.h | 5 +- include/wx/motif/stattext.h | 5 + include/wx/motif/textctrl.h | 7 +- include/wx/motif/timer.h | 2 + include/wx/motif/toolbar.h | 6 +- include/wx/motif/window.h | 17 ++- include/wx/toolbar.h | 4 +- samples/splitter/test.cpp | 20 ++- src/motif/app.cpp | 2 +- src/motif/bitmap.cpp | 37 +++++ src/motif/bmpbuttn.cpp | 2 +- src/motif/button.cpp | 20 ++- src/motif/checkbox.cpp | 20 ++- src/motif/choice.cpp | 20 ++- src/motif/combobox.cpp | 19 ++- src/motif/dcclient.cpp | 4 +- src/motif/dialog.cpp | 24 +++- src/motif/frame.cpp | 21 ++- src/motif/gauge.cpp | 19 ++- src/motif/listbox.cpp | 23 ++- src/motif/makefile.unx | 2 +- src/motif/mdi.cpp | 85 +++++++++-- src/motif/mdi/COPYRIGHT | 13 +- src/motif/mdi/config/MDI.tmpl | 7 + src/motif/mdi/doc/canvas.html | 2 +- src/motif/mdi/doc/mdi.html | 2 +- src/motif/mdi/doc/mwindow.html | 2 +- src/motif/mdi/lib/XsComponent.C | 10 +- src/motif/mdi/lib/XsComponent.h | 5 +- src/motif/mdi/lib/XsMDICanvas.C | 2 +- src/motif/mdi/lib/XsMDICanvas.h | 6 +- src/motif/mdi/lib/XsMDIWindow.C | 2 +- src/motif/mdi/lib/XsMDIWindow.h | 2 +- src/motif/mdi/lib/XsMotifWindow.C | 19 ++- src/motif/mdi/lib/XsMotifWindow.h | 2 +- src/motif/mdi/lib/XsMoveOutline.C | 2 +- src/motif/mdi/lib/XsMoveOutline.h | 2 +- src/motif/mdi/lib/XsOutline.C | 2 +- src/motif/mdi/lib/XsOutline.h | 2 +- src/motif/mdi/lib/XsResizeOutline.C | 2 +- src/motif/mdi/lib/XsResizeOutline.h | 2 +- src/motif/mdi/lib/xs_motif_icon.xbm | 2 +- src/motif/notebook.cpp | 15 ++ src/motif/radiobox.cpp | 19 ++- src/motif/radiobut.cpp | 19 ++- src/motif/scrolbar.cpp | 21 ++- src/motif/slider.cpp | 19 ++- src/motif/spinbutt.cpp | 15 ++ src/motif/statbmp.cpp | 19 ++- src/motif/statbox.cpp | 19 ++- src/motif/stattext.cpp | 21 ++- src/motif/textctrl.cpp | 19 ++- src/motif/timer.cpp | 51 ++++++- src/motif/toolbar.cpp | 192 +++++++++++++++++++++++-- src/motif/window.cpp | 213 ++++++++++++++-------------- 77 files changed, 979 insertions(+), 231 deletions(-) diff --git a/docs/latex/wx/activevt.tex b/docs/latex/wx/activevt.tex index 6eca563147..3ce87607ee 100644 --- a/docs/latex/wx/activevt.tex +++ b/docs/latex/wx/activevt.tex @@ -38,7 +38,7 @@ or a frame becomes inactivate resulting in all application frames being inactive \membersection{wxActivateEvent::wxActivateEvent} -\func{}{wxActivateEvent}{\param{WXTYPE }{eventType = 0}, \param{int }{id = 0}} +\func{}{wxActivateEvent}{\param{WXTYPE }{eventType = 0}, \param{bool}{ active = TRUE}, \param{int }{id = 0}} Constructor. diff --git a/docs/latex/wx/config.tex b/docs/latex/wx/config.tex index 95c0c13616..af679b31a5 100644 --- a/docs/latex/wx/config.tex +++ b/docs/latex/wx/config.tex @@ -545,7 +545,7 @@ Reads a double value, returning TRUE if the value was found. If the value was not found, {\it d} is not changed. \constfunc{bool}{Read}{\param{const wxString\& }{ key}, \param{double*}{ d}, -\param{double}{ defaultVal}} + \param{double}{ defaultVal}} Reads a double value, returning TRUE if the value was found. If the value was not found, {\it defaultVal} is used instead. diff --git a/docs/motif/todo.txt b/docs/motif/todo.txt index 6052c30117..1e7f001ba6 100644 --- a/docs/motif/todo.txt +++ b/docs/motif/todo.txt @@ -24,7 +24,14 @@ High Priority - Colour setting in widgets. -- Implementation of OnEraseBackground. +- Implementation of OnEraseBackground. How? Call OnEraseBackground + just before OnPaint? Will duplicate Xlib's own erase of the background. + However, this is usually OK, because the default wxWindow::OnEraseBackground + can do nothing (SetBackgroundColour will make the background look OK). + And if a custom OnEraseBackground uses the same colour as the window + background, no flicker will be seen. If it does something else, such as + painting a tiled bitmap, then a slight flicker might be seen unless + X can be persuaded not to repaint the window background by default. - wxBitmapCheckBox, wxBitmapRadioButton @@ -48,9 +55,11 @@ High Priority http://www.motifzone.com/tmd/articles/Kurt_Huhner/jun96.html. This article also explains how to implement tooltips. -- wxSystemSettings +- Find out why modal dialogs give a grab warning. + +- Find out why UI updates aren't working (probably an OnIdle failure). -- wxTimer +- wxSystemSettings - wxThread (hopefully, similar to wxGTK) diff --git a/include/wx/motif/bitmap.h b/include/wx/motif/bitmap.h index e36fc5ecf6..1fc2e134e6 100644 --- a/include/wx/motif/bitmap.h +++ b/include/wx/motif/bitmap.h @@ -198,7 +198,7 @@ public: inline WXDisplay* GetPixmap() const { return M_BITMAPDATA->m_pixmap; } virtual WXPixmap GetLabelPixmap(WXWidget w) ; virtual WXPixmap GetArmPixmap(WXWidget w) ; - virtual WXPixmap GetInsensPixmap(WXWidget w) ; + virtual WXPixmap GetInsensPixmap(WXWidget w = (WXWidget) 0) ; protected: static wxList sm_handlers; diff --git a/include/wx/motif/button.h b/include/wx/motif/button.h index ee31d5c7f1..bbfbb3bed2 100644 --- a/include/wx/motif/button.h +++ b/include/wx/motif/button.h @@ -44,6 +44,11 @@ class WXDLLEXPORT wxButton: public wxControl virtual void SetDefault(); virtual void Command(wxCommandEvent& event); + +// Implementation + virtual void ChangeFont(); + virtual void ChangeBackgroundColour(); + virtual void ChangeForegroundColour(); }; #endif diff --git a/include/wx/motif/checkbox.h b/include/wx/motif/checkbox.h index 71d0ea4a3f..4f795aa843 100644 --- a/include/wx/motif/checkbox.h +++ b/include/wx/motif/checkbox.h @@ -45,6 +45,11 @@ class WXDLLEXPORT wxCheckBox: public wxControl virtual void SetValue(bool); virtual bool GetValue() const ; virtual void Command(wxCommandEvent& event); + +// Implementation + virtual void ChangeFont(); + virtual void ChangeBackgroundColour(); + virtual void ChangeForegroundColour(); }; class WXDLLEXPORT wxBitmapCheckBox: public wxCheckBox diff --git a/include/wx/motif/choice.h b/include/wx/motif/choice.h index 321e5cfab3..f9f0c43be9 100644 --- a/include/wx/motif/choice.h +++ b/include/wx/motif/choice.h @@ -67,6 +67,10 @@ class WXDLLEXPORT wxChoice: public wxControl void SetFocus(); +// Implementation + virtual void ChangeFont(); + virtual void ChangeBackgroundColour(); + virtual void ChangeForegroundColour(); WXWidget GetTopWidget() const { return m_formWidget; } WXWidget GetMainWidget() const { return m_buttonWidget; } diff --git a/include/wx/motif/colour.h b/include/wx/motif/colour.h index 531d86085f..d9f1711983 100644 --- a/include/wx/motif/colour.h +++ b/include/wx/motif/colour.h @@ -22,6 +22,7 @@ // Colour class WXDLLEXPORT wxColour : public wxObject { +DECLARE_DYNAMIC_CLASS(wxColour) public: // ctors // default @@ -53,10 +54,17 @@ public: // accessors bool Ok() const {return m_isInit; } + unsigned char Red() const { return m_red; } + unsigned char Green() const { return m_green; } + unsigned char Blue() const { return m_blue; } int GetPixel() const { return m_pixel; }; void SetPixel(int pixel) { m_pixel = pixel; m_isInit = TRUE; }; + inline bool operator == (const wxColour& colour) { return (m_red == colour.m_red && m_green == colour.m_green && m_blue == colour.m_blue); } + + inline bool operator != (const wxColour& colour) { return (!(m_red == colour.m_red && m_green == colour.m_green && m_blue == colour.m_blue)); } + // Allocate a colour, or nearest colour, using the given display. // If realloc is TRUE, ignore the existing pixel, otherwise just return // the existing one. @@ -67,6 +75,8 @@ public: int AllocColour(WXDisplay* display, bool realloc = FALSE); + void InitFromName(const wxString& col); + private: bool m_isInit; unsigned char m_red; diff --git a/include/wx/motif/combobox.h b/include/wx/motif/combobox.h index 885d461be0..8f7e949f42 100644 --- a/include/wx/motif/combobox.h +++ b/include/wx/motif/combobox.h @@ -72,6 +72,11 @@ class WXDLLEXPORT wxComboBox: public wxChoice } virtual void SetSelection(long from, long to); virtual void SetEditable(bool editable); + +// Implementation + virtual void ChangeFont(); + virtual void ChangeBackgroundColour(); + virtual void ChangeForegroundColour(); }; #endif diff --git a/include/wx/motif/dialog.h b/include/wx/motif/dialog.h index 213e8420f4..594de2a305 100644 --- a/include/wx/motif/dialog.h +++ b/include/wx/motif/dialog.h @@ -93,7 +93,10 @@ public: // Responds to colour changes void OnSysColourChanged(wxSysColourChangedEvent& event); - //// Motif-specific +// Implementation + virtual void ChangeFont(); + virtual void ChangeBackgroundColour(); + virtual void ChangeForegroundColour(); inline WXWidget GetTopWidget() const { return m_mainWidget; } inline WXWidget GetClientWidget() const { return m_mainWidget; } diff --git a/include/wx/motif/frame.h b/include/wx/motif/frame.h index 951800935b..02723a313d 100644 --- a/include/wx/motif/frame.h +++ b/include/wx/motif/frame.h @@ -144,8 +144,10 @@ public: virtual void CaptureMouse(); virtual void ReleaseMouse(); - //// Motif-specific - +// Implementation + virtual void ChangeFont(); + virtual void ChangeBackgroundColour(); + virtual void ChangeForegroundColour(); WXWidget GetMenuBarWidget() const ; inline WXWidget GetShellWidget() const { return m_frameShell; } inline WXWidget GetWorkAreaWidget() const { return m_workArea; } diff --git a/include/wx/motif/gauge.h b/include/wx/motif/gauge.h index 13eddaecae..551aa00577 100644 --- a/include/wx/motif/gauge.h +++ b/include/wx/motif/gauge.h @@ -60,6 +60,11 @@ class WXDLLEXPORT wxGauge: public wxControl virtual void Command(wxCommandEvent& WXUNUSED(event)) {} ; +// Implementation + virtual void ChangeFont(); + virtual void ChangeBackgroundColour(); + virtual void ChangeForegroundColour(); + protected: int m_rangeMax; int m_gaugePos; diff --git a/include/wx/motif/listbox.h b/include/wx/motif/listbox.h index 0b938da821..77315ae0fe 100644 --- a/include/wx/motif/listbox.h +++ b/include/wx/motif/listbox.h @@ -89,6 +89,10 @@ class WXDLLEXPORT wxListBox: public wxControl void Command(wxCommandEvent& event); +// Implementation + virtual void ChangeFont(); + virtual void ChangeBackgroundColour(); + virtual void ChangeForegroundColour(); WXWidget GetTopWidget() const; protected: diff --git a/include/wx/motif/mdi.h b/include/wx/motif/mdi.h index d3ee46079d..bcffddeb6b 100644 --- a/include/wx/motif/mdi.h +++ b/include/wx/motif/mdi.h @@ -69,7 +69,7 @@ public: // toolbar(s), don't call SetToolBar. void GetClientSize(int *width, int *height) const; - // Get the active MDI child window (Windows only) + // Get the active MDI child window wxMDIChildFrame *GetActiveChild() const ; // Get the client window @@ -86,9 +86,13 @@ public: virtual void ActivateNext(); virtual void ActivatePrevious(); +// Implementation + inline void SetActiveChild(wxMDIChildFrame* child) { m_activeChild = child; } + protected: - wxMDIClientWindow *m_clientWindow; + wxMDIClientWindow* m_clientWindow; + wxMDIChildFrame* m_activeChild; DECLARE_EVENT_TABLE() }; @@ -144,6 +148,8 @@ public: void BuildClientArea(WXWidget parent); inline WXWidget GetTopWidget() const { return m_mainWidget; }; inline wxXsMDIWindow *GetMDIWindow() const { return m_mdiWindow; }; + virtual void OnRaise(); + virtual void OnLower(); protected: wxXsMDIWindow* m_mdiWindow ; diff --git a/include/wx/motif/notebook.h b/include/wx/motif/notebook.h index e5bd1d6c71..e4c93c3eea 100644 --- a/include/wx/motif/notebook.h +++ b/include/wx/motif/notebook.h @@ -162,6 +162,11 @@ public: virtual void SetConstraintSizes(bool recurse = TRUE); virtual bool DoPhase(int nPhase); +// Implementation + virtual void ChangeFont(); + virtual void ChangeBackgroundColour(); + virtual void ChangeForegroundColour(); + protected: // common part of all ctors void Init(); diff --git a/include/wx/motif/private.h b/include/wx/motif/private.h index 3a04b6df43..b5d91867a4 100644 --- a/include/wx/motif/private.h +++ b/include/wx/motif/private.h @@ -35,6 +35,8 @@ bool wxTranslateMouseEvent(wxMouseEvent& wxevent, wxWindow *win, Widget widget, bool wxTranslateKeyEvent(wxKeyEvent& wxevent, wxWindow *win, Widget widget, XEvent *xevent); int wxGetBestMatchingPixel(Display *display, XColor *desiredColor, Colormap cmap); Pixmap XCreateInsensitivePixmap( Display *display, Pixmap pixmap ); +extern XColor g_itemColors[]; +extern int wxComputeColours (Display *display, wxColour * back, wxColour * fore); #define wxNO_COLORS 0x00 #define wxBACK_COLORS 0x01 diff --git a/include/wx/motif/radiobox.h b/include/wx/motif/radiobox.h index 6f3a788f39..db1bdd3d8e 100644 --- a/include/wx/motif/radiobox.h +++ b/include/wx/motif/radiobox.h @@ -68,6 +68,10 @@ public: inline int GetNumberOfRowsOrCols() const { return m_noRowsOrCols; } inline void SetNumberOfRowsOrCols(int n) { m_noRowsOrCols = n; } +// Implementation + virtual void ChangeFont(); + virtual void ChangeBackgroundColour(); + virtual void ChangeForegroundColour(); WXWidget GetTopWidget() const { return m_formWidget; } WXWidget GetLabelWidget() const { return m_labelWidget; } inline WXWidget* GetRadioButtons() const { return m_radioButtons; } diff --git a/include/wx/motif/radiobut.h b/include/wx/motif/radiobut.h index a9b58d777e..80263ec117 100644 --- a/include/wx/motif/radiobut.h +++ b/include/wx/motif/radiobut.h @@ -48,6 +48,10 @@ public: void Command(wxCommandEvent& event); +// Implementation + virtual void ChangeFont(); + virtual void ChangeBackgroundColour(); + virtual void ChangeForegroundColour(); WXWidget GetTopWidget() const { return m_formWidget; } WXWidget GetLabelWidget() const { return m_labelWidget; } diff --git a/include/wx/motif/scrolbar.h b/include/wx/motif/scrolbar.h index 95343b50ca..60a09c34ab 100644 --- a/include/wx/motif/scrolbar.h +++ b/include/wx/motif/scrolbar.h @@ -56,6 +56,11 @@ public: void Command(wxCommandEvent& event); +// Implementation + virtual void ChangeFont(); + virtual void ChangeBackgroundColour(); + virtual void ChangeForegroundColour(); + protected: int m_pageSize; int m_viewSize; diff --git a/include/wx/motif/slider.h b/include/wx/motif/slider.h index d54c2772ea..c61f865c56 100644 --- a/include/wx/motif/slider.h +++ b/include/wx/motif/slider.h @@ -76,6 +76,12 @@ public: void SetTick(int tickPos) ; void Command(wxCommandEvent& event); + +// Implementation + virtual void ChangeFont(); + virtual void ChangeBackgroundColour(); + virtual void ChangeForegroundColour(); + protected: int m_rangeMin; int m_rangeMax; diff --git a/include/wx/motif/spinbutt.h b/include/wx/motif/spinbutt.h index ce5a75372c..6976f07e70 100644 --- a/include/wx/motif/spinbutt.h +++ b/include/wx/motif/spinbutt.h @@ -64,6 +64,11 @@ class WXDLLEXPORT wxSpinButton: public wxControl void Command(wxCommandEvent& event) { ProcessCommand(event); }; +// Implementation + virtual void ChangeFont(); + virtual void ChangeBackgroundColour(); + virtual void ChangeForegroundColour(); + protected: int m_min; int m_max; diff --git a/include/wx/motif/statbmp.h b/include/wx/motif/statbmp.h index a37e1c4a12..e4dcd4f9e2 100644 --- a/include/wx/motif/statbmp.h +++ b/include/wx/motif/statbmp.h @@ -56,6 +56,11 @@ class WXDLLEXPORT wxStaticBitmap: public wxControl // overriden base class virtuals virtual bool AcceptsFocus() const { return FALSE; } +// Implementation + virtual void ChangeFont(); + virtual void ChangeBackgroundColour(); + virtual void ChangeForegroundColour(); + protected: wxBitmap m_messageBitmap; diff --git a/include/wx/motif/statbox.h b/include/wx/motif/statbox.h index 288b185748..0cd45846a4 100644 --- a/include/wx/motif/statbox.h +++ b/include/wx/motif/statbox.h @@ -51,7 +51,10 @@ class WXDLLEXPORT wxStaticBox: public wxControl void SetLabel(const wxString& label); wxString GetLabel() const; - // Motif-specific +// Implementation + virtual void ChangeFont(); + virtual void ChangeBackgroundColour(); + virtual void ChangeForegroundColour(); WXWidget GetTopWidget() const { return m_formWidget; } WXWidget GetLabelWidget() const { return m_labelWidget; } diff --git a/include/wx/motif/stattext.h b/include/wx/motif/stattext.h index a1268cf7e1..f9e322e1b9 100644 --- a/include/wx/motif/stattext.h +++ b/include/wx/motif/stattext.h @@ -46,6 +46,11 @@ class WXDLLEXPORT wxStaticText: public wxControl // operations virtual void Command(wxCommandEvent& WXUNUSED(event)) {}; virtual void ProcessCommand(wxCommandEvent& WXUNUSED(event)) {}; + +// Implementation + virtual void ChangeFont(); + virtual void ChangeBackgroundColour(); + virtual void ChangeForegroundColour(); }; #endif diff --git a/include/wx/motif/textctrl.h b/include/wx/motif/textctrl.h index 518d8a1edf..165ef72006 100644 --- a/include/wx/motif/textctrl.h +++ b/include/wx/motif/textctrl.h @@ -124,11 +124,12 @@ public: void OnChar(wxKeyEvent& event); // void OnEraseBackground(wxEraseEvent& event); - // Implementation - // -------------- virtual void Command(wxCommandEvent& event); - //// Motif-specific +// Implementation + virtual void ChangeFont(); + virtual void ChangeBackgroundColour(); + virtual void ChangeForegroundColour(); inline void SetModified(bool mod) { m_modified = mod; } virtual WXWidget GetTopWidget() const; diff --git a/include/wx/motif/timer.h b/include/wx/motif/timer.h index 60a9f166ff..7065c19ca4 100644 --- a/include/wx/motif/timer.h +++ b/include/wx/motif/timer.h @@ -22,6 +22,8 @@ class WXDLLEXPORT wxTimer: public wxObject { DECLARE_DYNAMIC_CLASS(wxTimer) + friend void wxTimerCallback (wxTimer * timer); + public: wxTimer(); ~wxTimer(); diff --git a/include/wx/motif/toolbar.h b/include/wx/motif/toolbar.h index 4ccb016fb9..f3c98e8d1e 100644 --- a/include/wx/motif/toolbar.h +++ b/include/wx/motif/toolbar.h @@ -32,7 +32,9 @@ class WXDLLEXPORT wxToolBar: public wxToolBarBase inline wxToolBar(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxNO_BORDER|wxTB_HORIZONTAL, - const wxString& name = wxToolBarNameStr) + const wxString& name = wxToolBarNameStr): + m_widgets(wxKEY_INTEGER) + { Create(parent, id, pos, size, style, name); } @@ -69,6 +71,8 @@ class WXDLLEXPORT wxToolBar: public wxToolBarBase bool Realize() { return CreateTools(); }; protected: + // List of widgets in the toolbar, indexed by tool index + wxList m_widgets; DECLARE_EVENT_TABLE() }; diff --git a/include/wx/motif/window.h b/include/wx/motif/window.h index 8ba732f698..2a8bee3a32 100644 --- a/include/wx/motif/window.h +++ b/include/wx/motif/window.h @@ -311,11 +311,11 @@ public: void SetConstraints(wxLayoutConstraints *c); // Set/get window background colour - inline virtual void SetBackgroundColour(const wxColour& col); + virtual void SetBackgroundColour(const wxColour& col); inline virtual wxColour GetBackgroundColour() const; // Set/get window foreground colour - inline virtual void SetForegroundColour(const wxColour& col); + virtual void SetForegroundColour(const wxColour& col); inline virtual wxColour GetForegroundColour() const; // Get the default button, if there is one @@ -488,8 +488,15 @@ public: virtual WXRegion GetPaintRegion() const { return m_paintRegion; } // Change properties - virtual void ChangeColour(WXWidget widget); - virtual void ChangeFont(WXWidget widget); + virtual void ChangeFont(); // Change to the current font (often overridden) + virtual void DoChangeForegroundColour(WXWidget widget, wxColour& foregroundColour); + virtual void DoChangeBackgroundColour(WXWidget widget, wxColour& backgroundColour, bool changeArmColour = FALSE); + // These to be overridden as needed (may change several widgets) + virtual void ChangeBackgroundColour(); // Change background and foreground colour using current + // background colour setting (Motif generates + // foreground based on background) + virtual void ChangeForegroundColour(); // Change foreground colour using current + // foreground colour setting // Adds the widget to the hash table and adds event handlers. bool AttachWidget (wxWindow* parent, WXWidget mainWidget, @@ -595,9 +602,7 @@ inline wxEvtHandler *wxWindow::GetEventHandler() const { return m_windowEventHan inline void wxWindow::SetAutoLayout(bool a) { m_autoLayout = a; } inline bool wxWindow::GetAutoLayout() const { return m_autoLayout; } inline wxLayoutConstraints *wxWindow::GetConstraints() const { return m_constraints; } -inline void wxWindow::SetBackgroundColour(const wxColour& col) { m_backgroundColour = col; }; inline wxColour wxWindow::GetBackgroundColour() const { return m_backgroundColour; }; -inline void wxWindow::SetForegroundColour(const wxColour& col) { m_foregroundColour = col; }; inline wxColour wxWindow::GetForegroundColour() const { return m_foregroundColour; }; inline wxButton *wxWindow::GetDefaultItem() const { return m_defaultItem; } diff --git a/include/wx/toolbar.h b/include/wx/toolbar.h index 4bba52e5ac..86d2444de7 100644 --- a/include/wx/toolbar.h +++ b/include/wx/toolbar.h @@ -12,9 +12,7 @@ # define wxToolBar wxToolBarMSW # define sm_classwxToolBar sm_classwxToolBarMSW #elif defined(__WXMOTIF__) -# include "wx/tbarsmpl.h" -# define wxToolBar wxToolBarSimple -# define sm_classwxToolBar sm_classwxToolBarSimple +# include "wx/motif/toolbar.h" #elif defined(__WXGTK__) # include "wx/gtk/tbargtk.h" #elif defined(__WXQT__) diff --git a/samples/splitter/test.cpp b/samples/splitter/test.cpp index a32d2f0a12..7c842ee0cc 100644 --- a/samples/splitter/test.cpp +++ b/samples/splitter/test.cpp @@ -66,7 +66,7 @@ DECLARE_EVENT_TABLE() class MyCanvas: public wxScrolledWindow { public: - MyCanvas(wxWindow* parent, int x, int y, int w, int h); + MyCanvas(wxWindow* parent, wxWindowID id, int x, int y, int w, int h); virtual ~MyCanvas(); virtual void OnDraw(wxDC& dc); @@ -83,6 +83,12 @@ END_EVENT_TABLE() #define SPLIT_VERTICAL 3 #define SPLIT_UNSPLIT 4 +// Window ids +#define SPLITTER_WINDOW 100 +#define SPLITTER_FRAME 101 +#define CANVAS1 102 +#define CANVAS2 103 + IMPLEMENT_APP(MyApp) bool MyApp::OnInit(void) @@ -110,7 +116,7 @@ END_EVENT_TABLE() // My frame constructor MyFrame::MyFrame(wxFrame* frame, const wxString& title, const wxPoint& pos, const wxSize& size): - wxFrame(frame, -1, title, pos, size) + wxFrame(frame, SPLITTER_FRAME, title, pos, size) { // set the icon #ifdef __WXMSW__ @@ -131,16 +137,16 @@ MyFrame::MyFrame(wxFrame* frame, const wxString& title, const wxPoint& pos, cons SetMenuBar(menuBar); - splitter = new wxSplitterWindow(this, -1, wxPoint(0, 0), wxSize(400, 400), + splitter = new wxSplitterWindow(this, SPLITTER_WINDOW, wxPoint(0, 0), wxSize(400, 400), // wxSP_BORDER); wxSP_3D); // wxSP_NOBORDER); - leftCanvas = new MyCanvas(splitter, 0, 0, 400, 400); + leftCanvas = new MyCanvas(splitter, CANVAS1, 0, 0, 400, 400); leftCanvas->SetBackgroundColour(*wxRED); leftCanvas->SetScrollbars(20, 20, 50, 50); - rightCanvas = new MyCanvas(splitter, 0, 0, 400, 400); + rightCanvas = new MyCanvas(splitter, CANVAS2, 0, 0, 400, 400); rightCanvas->SetBackgroundColour(*wxCYAN); rightCanvas->SetScrollbars(20, 20, 50, 50); rightCanvas->Show(FALSE); @@ -212,8 +218,8 @@ void MyFrame::OnIdle(wxIdleEvent& event) wxFrame::OnIdle(event); } -MyCanvas::MyCanvas(wxWindow* parent, int x, int y, int w, int h) : - wxScrolledWindow(parent, -1, wxPoint(x, y), wxSize(w, h)) +MyCanvas::MyCanvas(wxWindow* parent, wxWindowID id, int x, int y, int w, int h) : + wxScrolledWindow(parent, id, wxPoint(x, y), wxSize(w, h)) { } diff --git a/src/motif/app.cpp b/src/motif/app.cpp index 94e652a549..ba176dce6f 100644 --- a/src/motif/app.cpp +++ b/src/motif/app.cpp @@ -302,7 +302,7 @@ int wxApp::MainLoop() XtDispatchEvent(&event); - DeletePendingObjects(); + ProcessIdle(); } } diff --git a/src/motif/bitmap.cpp b/src/motif/bitmap.cpp index 237b73924e..e2227b0c30 100644 --- a/src/motif/bitmap.cpp +++ b/src/motif/bitmap.cpp @@ -619,8 +619,17 @@ bool wxXPMFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long fla M_BITMAPHANDLERDATA->m_bitmapMask->SetPixmap((WXPixmap) mask); } + unsigned int depthRet; + int xRet, yRet; + unsigned int widthRet, heightRet, borderWidthRet; + Window rootWindowRet; + XGetGeometry(dpy, pixmap, &rootWindowRet, &xRet, &yRet, + &widthRet, &heightRet, &borderWidthRet, &depthRet); + M_BITMAPHANDLERDATA->m_width = xpmAttr.width; M_BITMAPHANDLERDATA->m_height = xpmAttr.height; + + /* if ( xpmAttr.npixels > 2 ) { M_BITMAPHANDLERDATA->m_depth = 8; // TODO: next time not just a guess :-) ... @@ -628,6 +637,9 @@ bool wxXPMFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long fla { M_BITMAPHANDLERDATA->m_depth = 1; // mono } + */ + + M_BITMAPHANDLERDATA->m_depth = depthRet; M_BITMAPHANDLERDATA->m_numColors = xpmAttr.npixels; @@ -714,6 +726,15 @@ bool wxXPMDataHandler::Create(wxBitmap *bitmap, void *data, long flags, int widt // Set attributes M_BITMAPHANDLERDATA->m_width = xpmAttr.width; M_BITMAPHANDLERDATA->m_height = xpmAttr.height; + + unsigned int depthRet; + int xRet, yRet; + unsigned int widthRet, heightRet, borderWidthRet; + Window rootWindowRet; + XGetGeometry(dpy, pixmap, &rootWindowRet, &xRet, &yRet, + &widthRet, &heightRet, &borderWidthRet, &depthRet); + + /* if ( xpmAttr.npixels > 2 ) { M_BITMAPHANDLERDATA->m_depth = 8; // next time not just a guess :-) ... @@ -721,6 +742,10 @@ bool wxXPMDataHandler::Create(wxBitmap *bitmap, void *data, long flags, int widt { M_BITMAPHANDLERDATA->m_depth = 1; // mono } + */ + + M_BITMAPHANDLERDATA->m_depth = depthRet; + M_BITMAPHANDLERDATA->m_numColors = xpmAttr.npixels; XpmFreeAttributes(&xpmAttr); M_BITMAPHANDLERDATA->m_ok = TRUE; @@ -846,6 +871,18 @@ WXPixmap wxBitmap::GetInsensPixmap (WXWidget w) { Display *dpy = (Display*) M_BITMAPDATA->m_display; + if (M_BITMAPDATA->m_insensPixmap) + return M_BITMAPDATA->m_insensPixmap; + + if (!w) + { + M_BITMAPDATA->m_insensPixmap = (WXPixmap) XCreateInsensitivePixmap(dpy, (Pixmap) M_BITMAPDATA->m_pixmap); + if (M_BITMAPDATA->m_insensPixmap) + return M_BITMAPDATA->m_insensPixmap; + else + return M_BITMAPDATA->m_pixmap; + } + if (M_BITMAPDATA->m_insensImage == (WXPixmap) 0) return M_BITMAPDATA->m_pixmap; diff --git a/src/motif/bmpbuttn.cpp b/src/motif/bmpbuttn.cpp index de4f6201b3..74a9f6f93e 100644 --- a/src/motif/bmpbuttn.cpp +++ b/src/motif/bmpbuttn.cpp @@ -116,7 +116,7 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit SetFont(* parent->GetFont()); - ChangeColour (m_mainWidget); + ChangeBackgroundColour (); return TRUE; diff --git a/src/motif/button.cpp b/src/motif/button.cpp index 8a8ae59c49..dccac3bfbb 100644 --- a/src/motif/button.cpp +++ b/src/motif/button.cpp @@ -38,6 +38,8 @@ bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label, SetName(name); SetValidator(validator); m_windowStyle = style; + m_backgroundColour = parent->GetBackgroundColour(); + m_foregroundColour = parent->GetForegroundColour(); parent->AddChild((wxButton *)this); @@ -77,7 +79,7 @@ bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label, AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y); SetFont(* parent->GetFont()); - ChangeColour(m_mainWidget); + ChangeBackgroundColour(); return TRUE; } @@ -132,3 +134,19 @@ void wxButtonCallback (Widget w, XtPointer clientData, XtPointer ptr) event.SetEventObject(item); item->ProcessCommand (event); } + +void wxButton::ChangeFont() +{ + // TODO +} + +void wxButton::ChangeBackgroundColour() +{ + // TODO +} + +void wxButton::ChangeForegroundColour() +{ + // TODO +} + diff --git a/src/motif/checkbox.cpp b/src/motif/checkbox.cpp index c71ed1a5ab..edf3f857fd 100644 --- a/src/motif/checkbox.cpp +++ b/src/motif/checkbox.cpp @@ -40,6 +40,8 @@ bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, SetName(name); SetValidator(validator); m_windowStyle = style; + m_backgroundColour = parent->GetBackgroundColour(); + m_foregroundColour = parent->GetForegroundColour(); if (parent) parent->AddChild(this); @@ -67,7 +69,7 @@ bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, SetCanAddEventHandler(TRUE); AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y); - ChangeColour(m_mainWidget); + ChangeBackgroundColour(); SetFont(* parent->GetFont()); return TRUE; @@ -148,3 +150,19 @@ void wxCheckBoxCallback (Widget w, XtPointer clientData, event.SetEventObject(item); item->ProcessCommand (event); } + +void wxCheckBox::ChangeFont() +{ + // TODO +} + +void wxCheckBox::ChangeBackgroundColour() +{ + // TODO +} + +void wxCheckBox::ChangeForegroundColour() +{ + // TODO +} + diff --git a/src/motif/choice.cpp b/src/motif/choice.cpp index 4c2f903f86..d71587ca85 100644 --- a/src/motif/choice.cpp +++ b/src/motif/choice.cpp @@ -64,6 +64,9 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id, else m_windowId = id; + m_backgroundColour = parent->GetBackgroundColour(); + m_foregroundColour = parent->GetForegroundColour(); + Widget parentWidget = (Widget) parent->GetClientWidget(); m_formWidget = (WXWidget) XtVaCreateManagedWidget ((char*) (const char*) name, @@ -125,7 +128,7 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id, AttachWidget (parent, m_buttonWidget, m_formWidget, pos.x, pos.y, size.x, size.y); SetFont(* parent->GetFont()); - ChangeColour(m_mainWidget); + ChangeBackgroundColour(); return TRUE; } @@ -415,3 +418,18 @@ void wxChoiceCallback (Widget w, XtPointer clientData, } } +void wxChoice::ChangeFont() +{ + // TODO +} + +void wxChoice::ChangeBackgroundColour() +{ + // TODO +} + +void wxChoice::ChangeForegroundColour() +{ + // TODO +} + diff --git a/src/motif/combobox.cpp b/src/motif/combobox.cpp index 305a39a2b9..f62a083330 100644 --- a/src/motif/combobox.cpp +++ b/src/motif/combobox.cpp @@ -40,6 +40,8 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, SetValidator(validator); m_noStrings = n; m_windowStyle = style; + m_backgroundColour = parent->GetBackgroundColour(); + m_foregroundColour = parent->GetForegroundColour(); if (parent) parent->AddChild(this); @@ -85,7 +87,7 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y); SetFont(* parent->GetFont()); - ChangeColour(m_mainWidget); + ChangeBackgroundColour(); return TRUE; } @@ -205,5 +207,20 @@ void wxComboBoxCallback (Widget w, XtPointer clientData, } } +void wxComboBox::ChangeFont() +{ + // TODO +} + +void wxComboBox::ChangeBackgroundColour() +{ + // TODO +} + +void wxComboBox::ChangeForegroundColour() +{ + // TODO +} + #endif diff --git a/src/motif/dcclient.cpp b/src/motif/dcclient.cpp index 8054aec456..6ab2bd156a 100644 --- a/src/motif/dcclient.cpp +++ b/src/motif/dcclient.cpp @@ -1855,7 +1855,9 @@ void wxWindowDC::SetBackground( const wxBrush &brush ) int pixel = m_backgroundBrush.GetColour().AllocColour(m_display); - XSetWindowBackground ((Display*) m_display, (Pixmap) m_pixmap, pixel); + // XSetWindowBackground doesn't work for non-Window pixmaps + if (!this->IsKindOf(CLASSINFO(wxMemoryDC))) + XSetWindowBackground ((Display*) m_display, (Pixmap) m_pixmap, pixel); // Necessary for ::DrawIcon, which use fg/bg pixel or the GC. // And Blit,... (Any fct that use XCopyPlane, in fact.) diff --git a/src/motif/dialog.cpp b/src/motif/dialog.cpp index 8154065c11..28b7db5b42 100644 --- a/src/motif/dialog.cpp +++ b/src/motif/dialog.cpp @@ -80,7 +80,7 @@ END_EVENT_TABLE() wxDialog::wxDialog() { m_modalShowing = FALSE; - SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); + m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE); } bool wxDialog::Create(wxWindow *parent, wxWindowID id, @@ -94,7 +94,9 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id, m_modalShowing = FALSE; m_dialogTitle = title; - SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); + m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE); + m_foregroundColour = *wxBLACK; + SetName(name); if (!parent) @@ -233,6 +235,8 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id, wxDialogBoxEventHandler, (XtPointer)this); + ChangeBackgroundColour(); + return TRUE; } @@ -739,3 +743,19 @@ static void wxUnmapBulletinBoard(Widget dialog, wxDialog *client,XtPointer call) client->m_isShown = FALSE; */ } + +void wxDialog::ChangeFont() +{ + // TODO +} + +void wxDialog::ChangeBackgroundColour() +{ + // TODO +} + +void wxDialog::ChangeForegroundColour() +{ + // TODO +} + diff --git a/src/motif/frame.cpp b/src/motif/frame.cpp index c0a24a49ef..bb2f47ac62 100644 --- a/src/motif/frame.cpp +++ b/src/motif/frame.cpp @@ -126,7 +126,8 @@ bool wxFrame::Create(wxWindow *parent, m_visibleStatus = TRUE; m_title = ""; - SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE)); + m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE); + m_foregroundColour = *wxBLACK; if ( id > -1 ) m_windowId = id; @@ -264,6 +265,8 @@ bool wxFrame::Create(wxWindow *parent, #endif #endif + ChangeBackgroundColour(); + PreResize(); wxSizeEvent sizeEvent(wxSize(width, height), GetId()); @@ -1037,6 +1040,21 @@ WXWidget wxFrame::GetClientWidget() const return m_clientArea; } +void wxFrame::ChangeFont() +{ + // TODO +} + +void wxFrame::ChangeBackgroundColour() +{ + // TODO +} + +void wxFrame::ChangeForegroundColour() +{ + // TODO +} + void wxCloseFrameCallback(Widget widget, XtPointer client_data, XmAnyCallbackStruct *cbs) { wxFrame *frame = (wxFrame *)client_data; @@ -1047,3 +1065,4 @@ void wxCloseFrameCallback(Widget widget, XtPointer client_data, XmAnyCallbackStr // May delete the frame (with delayed deletion) frame->GetEventHandler()->ProcessEvent(closeEvent); } + diff --git a/src/motif/gauge.cpp b/src/motif/gauge.cpp index e80910d276..4067322557 100644 --- a/src/motif/gauge.cpp +++ b/src/motif/gauge.cpp @@ -85,6 +85,8 @@ bool wxGauge::Create(wxWindow *parent, wxWindowID id, SetValidator(validator); m_rangeMax = range; m_windowStyle = style; + m_backgroundColour = parent->GetBackgroundColour(); + m_foregroundColour = parent->GetForegroundColour(); if (parent) parent->AddChild(this); @@ -125,7 +127,7 @@ bool wxGauge::Create(wxWindow *parent, wxWindowID id, AttachWidget (parent, m_mainWidget, (WXWidget) NULL, x, y, width, height); SetFont(* parent->GetFont()); - ChangeColour(m_mainWidget); + ChangeBackgroundColour(); return TRUE; } @@ -186,6 +188,21 @@ int wxGauge::GetValue() const // return m_gaugePos; } +void wxGauge::ChangeFont() +{ + // TODO +} + +void wxGauge::ChangeBackgroundColour() +{ + // TODO +} + +void wxGauge::ChangeForegroundColour() +{ + // TODO +} + //// PRIVATE DECLARATIONS FOR XMGAUGE #include diff --git a/src/motif/listbox.cpp b/src/motif/listbox.cpp index 8bf509bbbe..a964a11588 100644 --- a/src/motif/listbox.cpp +++ b/src/motif/listbox.cpp @@ -53,6 +53,8 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, m_windowStyle = style; m_noItems = n; m_selected = 0; + m_backgroundColour = parent->GetBackgroundColour(); + m_foregroundColour = parent->GetForegroundColour(); SetName(name); SetValidator(validator); @@ -107,11 +109,10 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, width, height); - wxSystemSettings settings; - SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW)); + m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW); SetFont(* parent->GetFont()); - ChangeColour(m_mainWidget); + ChangeBackgroundColour(); return TRUE; } @@ -739,3 +740,19 @@ WXWidget wxListBox::GetTopWidget() const { return (WXWidget) XtParent( (Widget) m_mainWidget ); } + +void wxListBox::ChangeFont() +{ + // TODO +} + +void wxListBox::ChangeBackgroundColour() +{ + // TODO +} + +void wxListBox::ChangeForegroundColour() +{ + // TODO +} + diff --git a/src/motif/makefile.unx b/src/motif/makefile.unx index cc4119e127..b525da7c7f 100644 --- a/src/motif/makefile.unx +++ b/src/motif/makefile.unx @@ -127,6 +127,7 @@ LIB_CPP_SRC=\ textctrl.cpp \ thread.cpp \ timer.cpp \ + toolbar.cpp \ utils.cpp \ utilsexc.cpp \ wave.cpp \ @@ -157,7 +158,6 @@ LIB_CPP_SRC=\ # listctrl.cpp \ # imaglist.cpp \ # statusbr.cpp \ -# toolbar.cpp \ LIB_C_SRC=\ \ diff --git a/src/motif/mdi.cpp b/src/motif/mdi.cpp index 0ecb45e87b..75a528cedb 100644 --- a/src/motif/mdi.cpp +++ b/src/motif/mdi.cpp @@ -88,7 +88,7 @@ public: // Generate wxSizeEvent here, I think. Maybe also restore, maximize // Probably don't need to generate size event here since work area - // is used + // is used (???) wxSizeEvent event(wxSize(w, h), m_childFrame->GetId()); event.SetEventObject(m_childFrame); m_childFrame->ProcessEvent(event); @@ -98,6 +98,16 @@ public: XsMotifWindow::close(); m_childFrame->Close(); } + virtual void raise() + { + XsMotifWindow::raise(); + m_childFrame->OnRaise(); + } + virtual void lower() + { + XsMotifWindow::lower(); + m_childFrame->OnLower(); + } virtual void _buildClientArea(Widget parent) { m_childFrame->BuildClientArea((WXWidget) parent); @@ -204,7 +214,8 @@ public: wxMDIParentFrame::wxMDIParentFrame() { - m_clientWindow = NULL; + m_clientWindow = (wxMDIClientWindow*) NULL; + m_activeChild = (wxMDIChildFrame*) NULL; } bool wxMDIParentFrame::Create(wxWindow *parent, @@ -215,7 +226,8 @@ bool wxMDIParentFrame::Create(wxWindow *parent, long style, const wxString& name) { - m_clientWindow = NULL; + m_clientWindow = (wxMDIClientWindow*) NULL; + m_activeChild = (wxMDIChildFrame*) NULL; bool success = wxFrame::Create(parent, id, title, pos, size, style, name); if (success) @@ -273,8 +285,7 @@ void wxMDIParentFrame::OnActivate(wxActivateEvent& event) // Returns the active MDI child window wxMDIChildFrame *wxMDIParentFrame::GetActiveChild() const { - // TODO - return NULL; + return m_activeChild; } // Create the client window class (don't Create the window, @@ -344,14 +355,32 @@ bool wxMDIChildFrame::Create(wxMDIParentFrame *parent, int x = pos.x; int y = pos.y; int width = size.x; int height = size.y; + if (width == -1) + width = 200; // TODO: give reasonable default + if (height == -1) + height = 200; // TODO: give reasonable default wxMDIClientWindow* clientWindow = parent->GetClientWindow(); if (!clientWindow) return FALSE; + // We're deactivating the old child + wxMDIChildFrame* oldActiveChild = parent->GetActiveChild(); + if (oldActiveChild) + { + wxActivateEvent event(wxEVT_ACTIVATE, FALSE, oldActiveChild->GetId()); + event.SetEventObject( oldActiveChild ); + oldActiveChild->GetEventHandler()->ProcessEvent(event); + } + m_mdiWindow = new wxXsMDIWindow("mdiChildWindow", this); clientWindow->GetMDICanvas()->add(m_mdiWindow); + + // This is the currently active child + parent->SetActiveChild((wxMDIChildFrame*) this); + m_mdiWindow->Show(); + #if 0 m_mainWidget = (WXWidget) (Widget) (*m_mdiWindow); @@ -411,10 +440,7 @@ bool wxMDIChildFrame::Create(wxMDIParentFrame *parent, PreResize(); - wxSizeEvent sizeEvent(wxSize(width, height), GetId()); - sizeEvent.SetEventObject(this); - - GetEventHandler()->ProcessEvent(sizeEvent); + m_mdiWindow->setSize(width, height); wxModelessWindows.Append(this); return TRUE; @@ -490,11 +516,50 @@ void wxMDIChildFrame::BuildClientArea(WXWidget parent) wxMDIChildFrame::~wxMDIChildFrame() { - wxMDIClientWindow* clientWindow = ((wxMDIParentFrame*)GetParent())->GetClientWindow(); + wxMDIParentFrame* parentFrame = (wxMDIParentFrame*) GetParent() ; + if (parentFrame->GetActiveChild() == this) + parentFrame->SetActiveChild((wxMDIChildFrame*) NULL); + + wxMDIClientWindow* clientWindow = parentFrame->GetClientWindow(); clientWindow->GetMDICanvas()->remove(m_mdiWindow); m_mainWidget = (WXWidget) 0; } +// Implementation: intercept and act upon raise and lower commands. +void wxMDIChildFrame::OnRaise() +{ + wxMDIParentFrame* parentFrame = (wxMDIParentFrame*) GetParent() ; + wxMDIChildFrame* oldActiveChild = parentFrame->GetActiveChild(); + parentFrame->SetActiveChild(this); + + if (oldActiveChild) + { + wxActivateEvent event(wxEVT_ACTIVATE, FALSE, oldActiveChild->GetId()); + event.SetEventObject( oldActiveChild ); + oldActiveChild->GetEventHandler()->ProcessEvent(event); + } + + wxActivateEvent event(wxEVT_ACTIVATE, TRUE, this->GetId()); + event.SetEventObject( this ); + this->GetEventHandler()->ProcessEvent(event); +} + +void wxMDIChildFrame::OnLower() +{ + wxMDIParentFrame* parentFrame = (wxMDIParentFrame*) GetParent() ; + wxMDIChildFrame* oldActiveChild = parentFrame->GetActiveChild(); + + if (oldActiveChild == this) + { + wxActivateEvent event(wxEVT_ACTIVATE, FALSE, oldActiveChild->GetId()); + event.SetEventObject( oldActiveChild ); + oldActiveChild->GetEventHandler()->ProcessEvent(event); + } + // TODO: unfortunately we don't now know which is the top-most child, + // so make the active child NULL. + parentFrame->SetActiveChild((wxMDIChildFrame*) NULL); +} + // Set the client size (i.e. leave the calculation of borders etc. // to wxWindows) void wxMDIChildFrame::SetClientSize(int width, int height) diff --git a/src/motif/mdi/COPYRIGHT b/src/motif/mdi/COPYRIGHT index 90071d4a76..0b8bc73586 100644 --- a/src/motif/mdi/COPYRIGHT +++ b/src/motif/mdi/COPYRIGHT @@ -1,4 +1,4 @@ -Copyright (c) 1996 Scott W. Sadler +Copyright (c) 1996, 1998 Scott W. Sadler All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy @@ -21,9 +21,8 @@ used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization. Scott W. Sadler -Software Engineer -International TechneGroup Incorporated -5303 DuPont Circle -Milford, OH 45150 -sws@iti-oh.com -http://www.iti-oh.com/~sws +Cisco Systems +7025 Kit Creek Road +P.O. Box 14987 +Research Triangle Park NC, 27709 +ssadler@cisco.com diff --git a/src/motif/mdi/config/MDI.tmpl b/src/motif/mdi/config/MDI.tmpl index dafc038c39..380e94e0b4 100644 --- a/src/motif/mdi/config/MDI.tmpl +++ b/src/motif/mdi/config/MDI.tmpl @@ -37,6 +37,13 @@ CC = $(CXX) #define FOUND_COMPILER #endif +#ifdef i386SVR4Architecture +CXX = CC +CC = $(CXX) +CCOPTIONS= +#define COMPILER_FOUND +#endif + #ifndef FOUND_COMPILER CXX = gcc CC = $(CXX) diff --git a/src/motif/mdi/doc/canvas.html b/src/motif/mdi/doc/canvas.html index 1ddbf3cdc4..d18faaf226 100644 --- a/src/motif/mdi/doc/canvas.html +++ b/src/motif/mdi/doc/canvas.html @@ -2,7 +2,7 @@ XsMDICanvas Class - +

diff --git a/src/motif/mdi/doc/mdi.html b/src/motif/mdi/doc/mdi.html index 1ee82529ec..0052c2da90 100644 --- a/src/motif/mdi/doc/mdi.html +++ b/src/motif/mdi/doc/mdi.html @@ -2,7 +2,7 @@ Motif Multi-Document Interface (MDI) - +
diff --git a/src/motif/mdi/doc/mwindow.html b/src/motif/mdi/doc/mwindow.html index effbdcda7e..8ea6cd8c81 100644 --- a/src/motif/mdi/doc/mwindow.html +++ b/src/motif/mdi/doc/mwindow.html @@ -2,7 +2,7 @@ XsMotifWindow Class - +

diff --git a/src/motif/mdi/lib/XsComponent.C b/src/motif/mdi/lib/XsComponent.C index a09ed87733..7ec41d7312 100644 --- a/src/motif/mdi/lib/XsComponent.C +++ b/src/motif/mdi/lib/XsComponent.C @@ -7,7 +7,7 @@ XsComponent.C History - 03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com) + 03-Mar-96 1.0; Scott W. Sadler (ssadler@cisco.com) Created */ @@ -62,8 +62,8 @@ void XsComponent::show ( ) { #ifndef NDEBUG - if (XtIsManaged (_base)) - cout << "Re-managing a widget:" << _name << endl; + // if (XtIsManaged (_base)) + // cout << "Re-managing a widget:" << _name << endl; #endif // Make sure the _destroyHandler was installed @@ -80,8 +80,8 @@ void XsComponent::hide ( ) { #ifndef NDEBUG - if (!XtIsManaged (_base)) - cout << "Re-unmanaging a widget:" << _name << endl; + // if (!XtIsManaged (_base)) + // cout << "Re-unmanaging a widget:" << _name << endl; #endif assert (_base != 0); diff --git a/src/motif/mdi/lib/XsComponent.h b/src/motif/mdi/lib/XsComponent.h index d2d71f061a..e67f07fc37 100644 --- a/src/motif/mdi/lib/XsComponent.h +++ b/src/motif/mdi/lib/XsComponent.h @@ -7,7 +7,7 @@ XsComponent.h History - 03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com) + 03-Mar-96 1.0; Scott W. Sadler (ssadler@cisco.com) Created */ @@ -33,9 +33,6 @@ class XsComponent { virtual void show ( ); // Show the component virtual void hide ( ); // Hide the component -// Added JACS 19/10/98 - inline Widget GetBase() const { return _base; } - // Component name const char *name ( ) const; diff --git a/src/motif/mdi/lib/XsMDICanvas.C b/src/motif/mdi/lib/XsMDICanvas.C index 6d84aabe54..66a4047aa4 100644 --- a/src/motif/mdi/lib/XsMDICanvas.C +++ b/src/motif/mdi/lib/XsMDICanvas.C @@ -7,7 +7,7 @@ XsMDICanvas.C History - 03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com) + 03-Mar-96 1.0; Scott W. Sadler (ssadler@cisco.com) Created */ diff --git a/src/motif/mdi/lib/XsMDICanvas.h b/src/motif/mdi/lib/XsMDICanvas.h index 0e676b71cf..99ca57fad5 100644 --- a/src/motif/mdi/lib/XsMDICanvas.h +++ b/src/motif/mdi/lib/XsMDICanvas.h @@ -7,7 +7,7 @@ XsMDICanvas.h History - 03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com) + 03-Mar-96 1.0; Scott W. Sadler (ssadler@cisco.com) Created */ @@ -38,13 +38,11 @@ class XsMDICanvas : public XsComponent { virtual void add (XsMDIWindow *win); // Add an MDI window virtual void remove (XsMDIWindow *win); // Remove an MDI window void removeAll ( ); // Remove all MDI windows - -// Added JACS 19/10/98 - inline Widget GetDrawingArea() const { return _drawArea; } // Utilities int numWindows ( ) const; // Number of MDI windows + Widget GetDrawingArea() const { return _drawArea; } // Component methods diff --git a/src/motif/mdi/lib/XsMDIWindow.C b/src/motif/mdi/lib/XsMDIWindow.C index 6d112a25f5..cbc61cc5b0 100644 --- a/src/motif/mdi/lib/XsMDIWindow.C +++ b/src/motif/mdi/lib/XsMDIWindow.C @@ -7,7 +7,7 @@ XsMDIWindow.C History - 03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com) + 03-Mar-96 1.0; Scott W. Sadler (ssadler@cisco.com) Created */ diff --git a/src/motif/mdi/lib/XsMDIWindow.h b/src/motif/mdi/lib/XsMDIWindow.h index ef12b3c3be..9bc9c9580d 100644 --- a/src/motif/mdi/lib/XsMDIWindow.h +++ b/src/motif/mdi/lib/XsMDIWindow.h @@ -7,7 +7,7 @@ XsMDIWindow.h History - 03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com) + 03-Mar-96 1.0; Scott W. Sadler (ssadler@cisco.com) Created */ diff --git a/src/motif/mdi/lib/XsMotifWindow.C b/src/motif/mdi/lib/XsMotifWindow.C index f1a2a4d2c3..a3b895fc1a 100644 --- a/src/motif/mdi/lib/XsMotifWindow.C +++ b/src/motif/mdi/lib/XsMotifWindow.C @@ -7,7 +7,7 @@ XsMotifWindow.C History - 03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com) + 03-Mar-96 1.0; Scott W. Sadler (ssadler@cisco.com) Created */ @@ -2880,12 +2880,6 @@ void XsMotifWindow::restore ( ) setPosition (_savedX, _savedY); setSize (_savedWidth, _savedHeight); - - _maximized = False; - -// Redraw the maximize button - - _buttons[_XsMotifButton::Maximize]->redraw ( ); } } @@ -2972,6 +2966,17 @@ void XsMotifWindow::setSize (Dimension w, Dimension h) if (_minimized == False) XtVaSetValues (_base, XmNwidth, w, XmNheight, h, NULL); + +// If window was maximized, change the window state back to normal + + if (_maximized == True) + { + _maximized = False; + +// Redraw the maximize button + + _buttons[_XsMotifButton::Maximize]->redraw ( ); + } } else XsMDIWindow::setSize (w, h); // Cache the points diff --git a/src/motif/mdi/lib/XsMotifWindow.h b/src/motif/mdi/lib/XsMotifWindow.h index 203e13d949..4580cb4438 100644 --- a/src/motif/mdi/lib/XsMotifWindow.h +++ b/src/motif/mdi/lib/XsMotifWindow.h @@ -7,7 +7,7 @@ XsMotifWindow.h History - 03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com) + 03-Mar-96 1.0; Scott W. Sadler (ssadler@cisco.com) Created */ diff --git a/src/motif/mdi/lib/XsMoveOutline.C b/src/motif/mdi/lib/XsMoveOutline.C index f00118f72e..eacd376f40 100644 --- a/src/motif/mdi/lib/XsMoveOutline.C +++ b/src/motif/mdi/lib/XsMoveOutline.C @@ -7,7 +7,7 @@ XsMoveOutline.C History - 03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com) + 03-Mar-96 1.0; Scott W. Sadler (ssadler@cisco.com) Created */ diff --git a/src/motif/mdi/lib/XsMoveOutline.h b/src/motif/mdi/lib/XsMoveOutline.h index 7e830c6ed0..01e24087c4 100644 --- a/src/motif/mdi/lib/XsMoveOutline.h +++ b/src/motif/mdi/lib/XsMoveOutline.h @@ -7,7 +7,7 @@ XsMoveOutline.h History - 03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com) + 03-Mar-96 1.0; Scott W. Sadler (ssadler@cisco.com) Created */ diff --git a/src/motif/mdi/lib/XsOutline.C b/src/motif/mdi/lib/XsOutline.C index 63980462e2..3301065180 100644 --- a/src/motif/mdi/lib/XsOutline.C +++ b/src/motif/mdi/lib/XsOutline.C @@ -7,7 +7,7 @@ XsOutline.C History - 03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com) + 03-Mar-96 1.0; Scott W. Sadler (ssadler@cisco.com) Created */ diff --git a/src/motif/mdi/lib/XsOutline.h b/src/motif/mdi/lib/XsOutline.h index 51ca7494f4..2bfc4b73f9 100644 --- a/src/motif/mdi/lib/XsOutline.h +++ b/src/motif/mdi/lib/XsOutline.h @@ -7,7 +7,7 @@ XsOutline.h History - 03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com) + 03-Mar-96 1.0; Scott W. Sadler (ssadler@cisco.com) Created */ diff --git a/src/motif/mdi/lib/XsResizeOutline.C b/src/motif/mdi/lib/XsResizeOutline.C index 42e662cd1f..6ccbcf9d86 100644 --- a/src/motif/mdi/lib/XsResizeOutline.C +++ b/src/motif/mdi/lib/XsResizeOutline.C @@ -7,7 +7,7 @@ XsResizeOutline.C History - 03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com) + 03-Mar-96 1.0; Scott W. Sadler (ssadler@cisco.com) Created */ diff --git a/src/motif/mdi/lib/XsResizeOutline.h b/src/motif/mdi/lib/XsResizeOutline.h index d32f2050ae..009035a6db 100644 --- a/src/motif/mdi/lib/XsResizeOutline.h +++ b/src/motif/mdi/lib/XsResizeOutline.h @@ -7,7 +7,7 @@ XsResizeOutline.h History - 03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com) + 03-Mar-96 1.0; Scott W. Sadler (ssadler@cisco.com) Created */ diff --git a/src/motif/mdi/lib/xs_motif_icon.xbm b/src/motif/mdi/lib/xs_motif_icon.xbm index 5541657a49..2f7c75ef25 100644 --- a/src/motif/mdi/lib/xs_motif_icon.xbm +++ b/src/motif/mdi/lib/xs_motif_icon.xbm @@ -7,7 +7,7 @@ xs_motif_icon.xbm History - 03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com) + 03-Mar-96 1.0; Scott W. Sadler (ssadler@cisco.com) Created */ diff --git a/src/motif/notebook.cpp b/src/motif/notebook.cpp index 229dc45e59..c93dbba6f9 100644 --- a/src/motif/notebook.cpp +++ b/src/motif/notebook.cpp @@ -365,3 +365,18 @@ void wxNotebook::ChangePage(int nOldSel, int nSel) m_nSelection = nSel; } +void wxNotebook::ChangeFont() +{ + // TODO +} + +void wxNotebook::ChangeBackgroundColour() +{ + // TODO +} + +void wxNotebook::ChangeForegroundColour() +{ + // TODO +} + diff --git a/src/motif/radiobox.cpp b/src/motif/radiobox.cpp index 9720e0ff9e..152e1d3888 100644 --- a/src/motif/radiobox.cpp +++ b/src/motif/radiobox.cpp @@ -57,6 +57,8 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title, m_labelWidget = (WXWidget) 0; m_radioButtons = (WXWidget*) NULL; m_radioButtonLabels = (wxString*) NULL; + m_backgroundColour = parent->GetBackgroundColour(); + m_foregroundColour = parent->GetForegroundColour(); SetName(name); SetValidator(val); @@ -176,7 +178,7 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title, AttachWidget (parent, m_mainWidget, m_formWidget, pos.x, pos.y, size.x, size.y); SetFont(* parent->GetFont()); - ChangeColour(m_mainWidget); + ChangeBackgroundColour(); return TRUE; } @@ -389,6 +391,21 @@ void wxRadioBox::Command (wxCommandEvent & event) ProcessCommand (event); } +void wxRadioBox::ChangeFont() +{ + // TODO +} + +void wxRadioBox::ChangeBackgroundColour() +{ + // TODO +} + +void wxRadioBox::ChangeForegroundColour() +{ + // TODO +} + void wxRadioBoxCallback (Widget w, XtPointer clientData, XmToggleButtonCallbackStruct * cbs) { diff --git a/src/motif/radiobut.cpp b/src/motif/radiobut.cpp index 29223c6d9a..4fe1489f09 100644 --- a/src/motif/radiobut.cpp +++ b/src/motif/radiobut.cpp @@ -47,6 +47,8 @@ bool wxRadioButton::Create(wxWindow *parent, wxWindowID id, { SetName(name); SetValidator(validator); + m_backgroundColour = parent->GetBackgroundColour(); + m_foregroundColour = parent->GetForegroundColour(); if (parent) parent->AddChild(this); @@ -130,7 +132,7 @@ bool wxRadioButton::Create(wxWindow *parent, wxWindowID id, AttachWidget (parent, m_mainWidget, m_formWidget, pos.x, pos.y, size.x, size.y); SetFont(* parent->GetFont()); - ChangeColour(m_mainWidget); + ChangeBackgroundColour(); return TRUE; } @@ -154,6 +156,21 @@ void wxRadioButton::Command (wxCommandEvent & event) ProcessCommand (event); } +void wxRadioButton::ChangeFont() +{ + // TODO +} + +void wxRadioButton::ChangeBackgroundColour() +{ + // TODO +} + +void wxRadioButton::ChangeForegroundColour() +{ + // TODO +} + void wxRadioButtonCallback (Widget w, XtPointer clientData, XmToggleButtonCallbackStruct * cbs) { diff --git a/src/motif/scrolbar.cpp b/src/motif/scrolbar.cpp index 84fa92fe64..3ac6967bf6 100644 --- a/src/motif/scrolbar.cpp +++ b/src/motif/scrolbar.cpp @@ -40,7 +40,9 @@ bool wxScrollBar::Create(wxWindow *parent, wxWindowID id, return FALSE; parent->AddChild(this); SetName(name); - SetValidator(validator); + m_backgroundColour = parent->GetBackgroundColour(); + m_foregroundColour = parent->GetForegroundColour(); + SetValidator(validator); m_windowStyle = style; @@ -91,7 +93,7 @@ bool wxScrollBar::Create(wxWindow *parent, wxWindowID id, SetCanAddEventHandler(TRUE); AttachWidget (parent, m_mainWidget, (WXWidget) NULL, x, y, width, height); - ChangeColour(m_mainWidget); + ChangeBackgroundColour(); return TRUE; } @@ -150,6 +152,21 @@ void wxScrollBar::Command(wxCommandEvent& event) ProcessCommand(event); } +void wxScrollBar::ChangeFont() +{ + // TODO +} + +void wxScrollBar::ChangeBackgroundColour() +{ + // TODO +} + +void wxScrollBar::ChangeForegroundColour() +{ + // TODO +} + void wxScrollBarCallback(Widget widget, XtPointer clientData, XmScaleCallbackStruct *cbs) { diff --git a/src/motif/slider.cpp b/src/motif/slider.cpp index 244843b4d8..20a1b07711 100644 --- a/src/motif/slider.cpp +++ b/src/motif/slider.cpp @@ -54,6 +54,8 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id, { SetName(name); SetValidator(validator); + m_backgroundColour = parent->GetBackgroundColour(); + m_foregroundColour = parent->GetForegroundColour(); if (parent) parent->AddChild(this); @@ -101,7 +103,7 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id, AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y); SetFont(* parent->GetFont()); - ChangeColour(m_mainWidget); + ChangeBackgroundColour(); return TRUE; } @@ -245,6 +247,21 @@ void wxSlider::Command (wxCommandEvent & event) ProcessCommand (event); } +void wxSlider::ChangeFont() +{ + // TODO +} + +void wxSlider::ChangeBackgroundColour() +{ + // TODO +} + +void wxSlider::ChangeForegroundColour() +{ + // TODO +} + void wxSliderCallback (Widget widget, XtPointer clientData, XmScaleCallbackStruct * cbs) { wxSlider *slider = (wxSlider *) clientData; diff --git a/src/motif/spinbutt.cpp b/src/motif/spinbutt.cpp index 5111233fe9..0afe79ada0 100644 --- a/src/motif/spinbutt.cpp +++ b/src/motif/spinbutt.cpp @@ -68,6 +68,21 @@ void wxSpinButton::SetRange(int minVal, int maxVal) // TODO } +void wxSpinButton::ChangeFont() +{ + // TODO +} + +void wxSpinButton::ChangeBackgroundColour() +{ + // TODO +} + +void wxSpinButton::ChangeForegroundColour() +{ + // TODO +} + // Spin event IMPLEMENT_DYNAMIC_CLASS(wxSpinEvent, wxScrollEvent) diff --git a/src/motif/statbmp.cpp b/src/motif/statbmp.cpp index 5dc08a3296..009d175a64 100644 --- a/src/motif/statbmp.cpp +++ b/src/motif/statbmp.cpp @@ -39,6 +39,8 @@ bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id, { m_messageBitmap = bitmap; SetName(name); + m_backgroundColour = parent->GetBackgroundColour(); + m_foregroundColour = parent->GetForegroundColour(); if (parent) parent->AddChild(this); if ( id == -1 ) @@ -69,7 +71,7 @@ bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id, SetFont(* parent->GetFont()); - ChangeColour (m_mainWidget); + ChangeBackgroundColour (); return TRUE; } @@ -117,3 +119,18 @@ void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap) } } +void wxStaticBitmap::ChangeFont() +{ + // TODO +} + +void wxStaticBitmap::ChangeBackgroundColour() +{ + // TODO +} + +void wxStaticBitmap::ChangeForegroundColour() +{ + // TODO +} + diff --git a/src/motif/statbox.cpp b/src/motif/statbox.cpp index b695120c8f..d973f83979 100644 --- a/src/motif/statbox.cpp +++ b/src/motif/statbox.cpp @@ -51,6 +51,8 @@ bool wxStaticBox::Create(wxWindow *parent, wxWindowID id, { m_formWidget = (WXWidget) 0; m_labelWidget = (WXWidget) 0; + m_backgroundColour = parent->GetBackgroundColour(); + m_foregroundColour = parent->GetForegroundColour(); SetName(name); @@ -112,7 +114,7 @@ bool wxStaticBox::Create(wxWindow *parent, wxWindowID id, SetCanAddEventHandler(TRUE); AttachWidget (parent, m_mainWidget, (WXWidget) frameWidget, pos.x, pos.y, size.x, size.y); - ChangeColour(m_mainWidget); + ChangeBackgroundColour(); return TRUE; } @@ -179,3 +181,18 @@ void wxStaticBox::SetSize(int x, int y, int width, int height, int sizeFlags) } } +void wxStaticBox::ChangeFont() +{ + // TODO +} + +void wxStaticBox::ChangeBackgroundColour() +{ + // TODO +} + +void wxStaticBox::ChangeForegroundColour() +{ + // TODO +} + diff --git a/src/motif/stattext.cpp b/src/motif/stattext.cpp index 57da5bfdeb..947d81c39d 100644 --- a/src/motif/stattext.cpp +++ b/src/motif/stattext.cpp @@ -36,8 +36,8 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id, SetName(name); if (parent) parent->AddChild(this); - SetBackgroundColour(parent->GetBackgroundColour()) ; - SetForegroundColour(parent->GetForegroundColour()) ; + m_backgroundColour = parent->GetBackgroundColour(); + m_foregroundColour = parent->GetForegroundColour(); if ( id == -1 ) m_windowId = (int)NewControlId(); @@ -69,8 +69,23 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id, SetFont(* parent->GetFont()); - ChangeColour (m_mainWidget); + ChangeBackgroundColour (); return TRUE; } +void wxStaticText::ChangeFont() +{ + // TODO +} + +void wxStaticText::ChangeBackgroundColour() +{ + // TODO +} + +void wxStaticText::ChangeForegroundColour() +{ + // TODO +} + diff --git a/src/motif/textctrl.cpp b/src/motif/textctrl.cpp index 3424be1234..3016f39932 100644 --- a/src/motif/textctrl.cpp +++ b/src/motif/textctrl.cpp @@ -80,6 +80,8 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, m_modified = FALSE; m_processedDefault = FALSE; m_fileName = ""; + m_backgroundColour = parent->GetBackgroundColour(); + m_foregroundColour = parent->GetForegroundColour(); SetName(name); SetValidator(validator); @@ -145,7 +147,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y); SetFont(* parent->GetFont()); - ChangeColour(m_mainWidget); + ChangeBackgroundColour(); return TRUE; } @@ -617,6 +619,21 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) } } +void wxTextCtrl::ChangeFont() +{ + // TODO +} + +void wxTextCtrl::ChangeBackgroundColour() +{ + // TODO +} + +void wxTextCtrl::ChangeForegroundColour() +{ + // TODO +} + static void wxTextWindowChangedProc (Widget w, XtPointer clientData, XtPointer ptr) { if (!wxGetWindowFromTable(w)) diff --git a/src/motif/timer.cpp b/src/motif/timer.cpp index bca8e00e0c..1bf9297621 100644 --- a/src/motif/timer.cpp +++ b/src/motif/timer.cpp @@ -14,13 +14,39 @@ #endif #include "wx/timer.h" +#include "wx/app.h" +#include "wx/list.h" + +#include + +#include "wx/motif/private.h" #if !USE_SHARED_LIBRARY IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxObject) #endif +static wxList wxTimerList(wxKEY_INTEGER); + +void wxTimerCallback (wxTimer * timer) +{ + // Check to see if it's still on + if (!wxTimerList.Find((long)timer)) + return; + + if (timer->m_id == 0) + return; // Avoid to process spurious timer events + + if (!timer->m_oneShot) + timer->m_id = XtAppAddTimeOut ((XtAppContext) wxTheApp->GetAppContext(), timer->m_milli, + (XtTimerCallbackProc) wxTimerCallback, (XtPointer) timer); + else + timer->m_id = 0; + timer->Notify (); +} + wxTimer::wxTimer() { + m_id = 0; m_milli = 0 ; m_id = 0; m_oneShot = FALSE; @@ -31,21 +57,34 @@ wxTimer::~wxTimer() Stop(); } -bool wxTimer::Start(int milliseconds,bool mode) +bool wxTimer::Start(int milliseconds, bool mode) { - m_oneShot = mode ; + Stop(); + + m_oneShot = mode; + if (milliseconds < 0) + milliseconds = m_lastMilli; + if (milliseconds <= 0) return FALSE; - m_milli = milliseconds; + m_lastMilli = m_milli = milliseconds; + + if (!wxTimerList.Find((long)this)) + wxTimerList.Append((long)this, this); - // TODO: set the timer going. - return FALSE; + m_id = XtAppAddTimeOut ((XtAppContext) wxTheApp->GetAppContext(), milliseconds, + (XtTimerCallbackProc) wxTimerCallback, (XtPointer) this); + return TRUE; } void wxTimer::Stop() { - m_id = 0 ; + if (m_id > 0) + { + XtRemoveTimeOut (m_id); + m_id = 0; + } m_milli = 0 ; } diff --git a/src/motif/toolbar.cpp b/src/motif/toolbar.cpp index 85b09f9138..d0db4cc532 100644 --- a/src/motif/toolbar.cpp +++ b/src/motif/toolbar.cpp @@ -14,7 +14,16 @@ #endif #include "wx/wx.h" -#include "wx/toolbar.h" +#include "wx/motif/toolbar.h" + +#include +#include +#include +#include +#include +#include + +#include "wx/motif/private.h" #if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxToolBar, wxToolBarBase) @@ -23,7 +32,8 @@ BEGIN_EVENT_TABLE(wxToolBar, wxToolBarBase) END_EVENT_TABLE() #endif -wxToolBar::wxToolBar() +wxToolBar::wxToolBar(): + m_widgets(wxKEY_INTEGER) { m_maxWidth = -1; m_maxHeight = -1; @@ -41,16 +51,32 @@ bool wxToolBar::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, cons m_defaultWidth = 24; m_defaultHeight = 22; SetName(name); - + m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE); + m_foregroundColour = parent->GetForegroundColour(); m_windowStyle = style; SetParent(parent); if (parent) parent->AddChild(this); - // TODO create toolbar + Widget parentWidget = (Widget) parent->GetClientWidget(); + + Widget toolbar = XtVaCreateManagedWidget("toolbar", + xmFormWidgetClass, parentWidget, + XmNtraversalOn, False, + XmNhorizontalSpacing, 0, + XmNverticalSpacing, 0, + NULL); + + m_mainWidget = (WXWidget) toolbar; + + SetCanAddEventHandler(TRUE); + AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y); + + SetFont(* parent->GetFont()); + ChangeBackgroundColour(); - return FALSE; + return TRUE; } wxToolBar::~wxToolBar() @@ -63,8 +89,150 @@ bool wxToolBar::CreateTools() if (m_tools.Number() == 0) return FALSE; - // TODO - return FALSE; + m_widgets.Clear(); + Widget prevButton = (Widget) 0; + wxNode* node = m_tools.First(); + while (node) + { + wxToolBarTool *tool = (wxToolBarTool *)node->Data(); + if ((tool->m_toolStyle != wxTOOL_STYLE_SEPARATOR) && tool->m_bitmap1.Ok()) + { + Widget button = (Widget) 0; + + if (tool->m_isToggle) + { + button = XtVaCreateManagedWidget("toggleButton", + xmToggleButtonWidgetClass, (Widget) m_mainWidget, + XmNleftAttachment, (prevButton == (Widget) 0) ? XmATTACH_FORM : XmATTACH_WIDGET, + XmNleftWidget, (prevButton == (Widget) 0) ? NULL : prevButton, + XmNleftOffset, 0, + XmNtopAttachment, XmATTACH_FORM, + // XmNpushButtonEnabled, True, + XmNmultiClick, XmMULTICLICK_KEEP, + XmNlabelType, XmPIXMAP, + NULL); + } + else + { + button = XtVaCreateManagedWidget("button", + xmPushButtonWidgetClass, (Widget) m_mainWidget, + XmNleftAttachment, (prevButton == (Widget) 0) ? XmATTACH_FORM : XmATTACH_WIDGET, + XmNleftWidget, (prevButton == (Widget) 0) ? NULL : prevButton, + XmNleftOffset, 0, + XmNtopAttachment, XmATTACH_FORM, + XmNpushButtonEnabled, True, + XmNmultiClick, XmMULTICLICK_KEEP, + XmNlabelType, XmPIXMAP, + NULL); + } + + // For each button, if there is a mask, we must create + // a new wxBitmap that has the correct background colour + // for the button. Otherwise the background will just be + // e.g. black if a transparent XPM has been loaded. + if (tool->m_bitmap1.GetMask()) + { + wxBitmap newBitmap(tool->m_bitmap1.GetWidth(), + tool->m_bitmap1.GetHeight(), + tool->m_bitmap1.GetDepth()); + int backgroundPixel; + XtVaGetValues(button, XmNbackground, &backgroundPixel, + NULL); + + + wxColour col; + col.SetPixel(backgroundPixel); + + wxMemoryDC destDC; + wxMemoryDC srcDC; + srcDC.SelectObject(tool->m_bitmap1); + destDC.SelectObject(newBitmap); + + wxBrush brush(col, wxSOLID); + destDC.SetOptimization(FALSE); + destDC.SetBackground(brush); + destDC.Clear(); + destDC.Blit(0, 0, tool->m_bitmap1.GetWidth(), tool->m_bitmap1.GetHeight(), & srcDC, 0, 0, wxCOPY, TRUE); + + tool->m_bitmap1 = newBitmap; + } + if (tool->m_bitmap2.Ok() && tool->m_bitmap2.GetMask()) + { + wxBitmap newBitmap(tool->m_bitmap2.GetWidth(), + tool->m_bitmap2.GetHeight(), + tool->m_bitmap2.GetDepth()); + int backgroundPixel; + XtVaGetValues(button, XmNbackground, &backgroundPixel, + NULL); + + + wxColour col; + col.SetPixel(backgroundPixel); + + wxMemoryDC destDC; + wxMemoryDC srcDC; + srcDC.SelectObject(tool->m_bitmap2); + destDC.SelectObject(newBitmap); + + wxBrush brush(col, wxSOLID); + destDC.SetOptimization(FALSE); + destDC.SetBackground(brush); + destDC.Clear(); + destDC.Blit(0, 0, tool->m_bitmap2.GetWidth(), tool->m_bitmap2.GetHeight(), & srcDC, 0, 0, wxCOPY, TRUE); + + tool->m_bitmap2 = newBitmap; + } + Pixmap pixmap = (Pixmap) tool->m_bitmap1.GetPixmap(); + Pixmap insensPixmap = (Pixmap) tool->m_bitmap1.GetInsensPixmap(); + + if (tool->m_isToggle) + { + Pixmap pixmap2 = (Pixmap) 0; + Pixmap insensPixmap2 = (Pixmap) 0; + + // If there's a bitmap for the toggled state, use it, + // otherwise generate one. + if (tool->m_bitmap2.Ok()) + { + pixmap2 = (Pixmap) tool->m_bitmap2.GetPixmap(); + insensPixmap2 = (Pixmap) tool->m_bitmap2.GetInsensPixmap(); + } + else + { + pixmap2 = (Pixmap) tool->m_bitmap1.GetArmPixmap(button); + // This has to be both toggled and insensitive, but + // wxBitmap doesn't yet have a member to store & destroy + // it, so make it the same as pixmap2. Actually it's not + // used! + insensPixmap2 = pixmap2; + } + XtVaSetValues (button, + XmNlabelPixmap, pixmap, + XmNselectPixmap, pixmap, + XmNlabelInsensitivePixmap, insensPixmap, + XmNselectInsensitivePixmap, insensPixmap, + XmNarmPixmap, pixmap2, + XmNlabelType, XmPIXMAP, + NULL); + + } + else + { + XtVaSetValues(button, + XmNlabelPixmap, pixmap, + XmNlabelInsensitivePixmap, insensPixmap, + NULL); + } + + m_widgets.Append(tool->m_index, (wxObject*) button); + + prevButton = button; + + } + node = node->Next(); + } + + return TRUE; } void wxToolBar::SetToolBitmapSize(const wxSize& size) @@ -113,7 +281,15 @@ void wxToolBar::ToggleTool(int toolIndex, bool toggle) void wxToolBar::ClearTools() { - // TODO + wxNode* node = m_widgets.First(); + while (node) + { + Widget button = (Widget) node->Data(); + XtDestroyWidget(button); + node = node->Next(); + } + m_widgets.Clear(); + wxToolBarBase::ClearTools(); } diff --git a/src/motif/window.cpp b/src/motif/window.cpp index cbaa070490..e0d7b1fec2 100644 --- a/src/motif/window.cpp +++ b/src/motif/window.cpp @@ -1280,33 +1280,6 @@ void wxWindow::ScrollWindow(int dx, int dy, const wxRectangle *rect) } } -void wxWindow::SetFont(const wxFont& font) -{ - m_windowFont = font; - - // 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? - /* - Widget w = (Widget) GetLabelWidget(); // Usually the main widget - if (w && m_windowFont.Ok()) - { - int width, height, width1, height1; - GetSize(& width, & height); - - XtVaSetValues (w, - XmNfontList, (XmFontList) m_windowFont.GetFontList(1.0, XtDisplay(w)), - NULL); - - GetSize(& width1, & height1); - if (width != width1 || height != height1) - { - SetSize(-1, -1, width, height); - } - } - */ -} - void wxWindow::OnChar(wxKeyEvent& event) { if ( event.KeyCode() == WXK_TAB ) { @@ -1977,26 +1950,9 @@ wxWindow *wxWindow::FindWindow(const wxString& name) void wxWindow::OnIdle(wxIdleEvent& event) { -/* TODO: you may need to do something like this - * if your GUI doesn't generate enter/leave events - - // Check if we need to send a LEAVE event - if (m_mouseInWindow) - { - POINT pt; - ::GetCursorPos(&pt); - if (::WindowFromPoint(pt) != (HWND) GetHWND()) - { - // Generate a LEAVE event - m_mouseInWindow = FALSE; - MSWOnMouseLeave(pt.x, pt.y, 0); - } - } -*/ - // This calls the UI-update mechanism (querying windows for // menu/toolbar/control state information) - UpdateWindowUI(); + UpdateWindowUI(); } // Raise the window to the top of the Z order @@ -2990,11 +2946,9 @@ bool wxTranslateKeyEvent(wxKeyEvent& wxevent, wxWindow *win, Widget widget, XEve return FALSE; } -// TODO From wxWin 1.68. What does it do exactly? #define YAllocColor XAllocColor - -XColor itemColors[5]; -int wxComputeColors (Display *display, wxColour * back, wxColour * fore) +XColor g_itemColors[5]; +int wxComputeColours (Display *display, wxColour * back, wxColour * fore) { int result; static XmColorProc colorProc; @@ -3003,10 +2957,10 @@ int wxComputeColors (Display *display, wxColour * back, wxColour * fore) if (back) { - itemColors[0].red = (((long) back->Red ()) << 8); - itemColors[0].green = (((long) back->Green ()) << 8); - itemColors[0].blue = (((long) back->Blue ()) << 8); - itemColors[0].flags = DoRed | DoGreen | DoBlue; + g_itemColors[0].red = (((long) back->Red ()) << 8); + g_itemColors[0].green = (((long) back->Green ()) << 8); + g_itemColors[0].blue = (((long) back->Blue ()) << 8); + g_itemColors[0].flags = DoRed | DoGreen | DoBlue; if (colorProc == (XmColorProc) NULL) { // Get a ptr to the actual function @@ -3014,19 +2968,19 @@ int wxComputeColors (Display *display, wxColour * back, wxColour * fore) // And set it back to motif. XmSetColorCalculation (colorProc); } - (*colorProc) (&itemColors[wxBACK_INDEX], - &itemColors[wxFORE_INDEX], - &itemColors[wxSELE_INDEX], - &itemColors[wxTOPS_INDEX], - &itemColors[wxBOTS_INDEX]); + (*colorProc) (&g_itemColors[wxBACK_INDEX], + &g_itemColors[wxFORE_INDEX], + &g_itemColors[wxSELE_INDEX], + &g_itemColors[wxTOPS_INDEX], + &g_itemColors[wxBOTS_INDEX]); result = wxBACK_COLORS; } if (fore) { - itemColors[wxFORE_INDEX].red = (((long) fore->Red ()) << 8); - itemColors[wxFORE_INDEX].green = (((long) fore->Green ()) << 8); - itemColors[wxFORE_INDEX].blue = (((long) fore->Blue ()) << 8); - itemColors[wxFORE_INDEX].flags = DoRed | DoGreen | DoBlue; + g_itemColors[wxFORE_INDEX].red = (((long) fore->Red ()) << 8); + g_itemColors[wxFORE_INDEX].green = (((long) fore->Green ()) << 8); + g_itemColors[wxFORE_INDEX].blue = (((long) fore->Blue ()) << 8); + g_itemColors[wxFORE_INDEX].flags = DoRed | DoGreen | DoBlue; if (result == wxNO_COLORS) result = wxFORE_COLORS; } @@ -3038,13 +2992,13 @@ int wxComputeColors (Display *display, wxColour * back, wxColour * fore) { /* 5 Colours to allocate */ for (int i = 0; i < 5; i++) - if (!YAllocColor (dpy, cmap, &itemColors[i])) + if (!YAllocColor (dpy, cmap, &g_itemColors[i])) result = wxNO_COLORS; } else if (fore) { /* Only 1 colour to allocate */ - if (!YAllocColor (dpy, cmap, &itemColors[wxFORE_INDEX])) + if (!YAllocColor (dpy, cmap, &g_itemColors[wxFORE_INDEX])) result = wxNO_COLORS; } @@ -3052,58 +3006,101 @@ int wxComputeColors (Display *display, wxColour * back, wxColour * fore) } -void wxWindow::ChangeColour(WXWidget widget) +// Changes the foreground and background colours to be derived +// from the current background colour. +// To change the foreground colour, you must call SetForegroundColour +// explicitly. +void wxWindow::ChangeBackgroundColour() { - // TODO -#if 0 - int change; + if (GetMainWidget()) + DoChangeBackgroundColour(GetMainWidget(), m_backgroundColour); +} - // TODO: how to determine whether we can change this item's colours? - // We used to have wxUSER_COLOURS. Now perhaps we assume we always - // can change it. - // if (!(parent->GetWindowStyleFlag() & wxUSER_COLOURS)) - // return; +void wxWindow::ChangeForegroundColour() +{ + if (GetMainWidget()) + DoChangeForegroundColour(GetMainWidget(), m_foregroundColour); +} - change = wxComputeColors (XtDisplay((Widget)widget), panel->GetBackgroundColour(), - panel->GetLabelColour()); - if (change == wxBACK_COLORS) - XtVaSetValues ((Widget) widget, - XmNbackground, itemColors[wxBACK_INDEX].pixel, - XmNtopShadowColor, itemColors[wxTOPS_INDEX].pixel, - XmNbottomShadowColor, itemColors[wxBOTS_INDEX].pixel, - XmNforeground, itemColors[wxFORE_INDEX].pixel, - NULL); - else if (change == wxFORE_COLORS) - XtVaSetValues (formWidget, - XmNforeground, itemColors[wxFORE_INDEX].pixel, - NULL); +// Change a widget's foreground and background colours. + +// TODO: make this 2 functions, ChangeForegroundColour and ChangeBackgroundColour. + +void wxWindow::DoChangeForegroundColour(WXWidget widget, wxColour& foregroundColour) +{ + // When should we specify the foreground, if it's calculated + // by wxComputeColours? + // Solution: say we start with the default (computed) foreground colour. + // If we call SetForegroundColour explicitly for a control or window, + // then the foreground is changed. + // Therefore SetBackgroundColour computes the foreground colour, and + // SetForegroundColour changes the foreground colour. The ordering is + // important. - change = wxComputeColors (XtDisplay((Widget)formWidget), GetBackgroundColour(), GetLabelColour()); - if (change == wxBACK_COLORS) - XtVaSetValues (labelWidget, - XmNbackground, itemColors[wxBACK_INDEX].pixel, - XmNtopShadowColor, itemColors[wxTOPS_INDEX].pixel, - XmNbottomShadowColor, itemColors[wxBOTS_INDEX].pixel, - XmNarmColor, itemColors[wxSELE_INDEX].pixel, - XmNforeground, itemColors[wxFORE_INDEX].pixel, + XtVaSetValues ((Widget) widget, + XmNforeground, foregroundColour.AllocColour(XtDisplay((Widget) widget)), NULL); - else if (change == wxFORE_COLORS) - XtVaSetValues (labelWidget, - XmNforeground, itemColors[wxFORE_INDEX].pixel, +} + +void wxWindow::DoChangeBackgroundColour(WXWidget widget, wxColour& backgroundColour, bool changeArmColour) +{ + wxComputeColours (XtDisplay((Widget) widget), & backgroundColour, + (wxColour*) NULL); + + XtVaSetValues ((Widget) widget, + XmNbackground, g_itemColors[wxBACK_INDEX].pixel, + XmNtopShadowColor, g_itemColors[wxTOPS_INDEX].pixel, + XmNbottomShadowColor, g_itemColors[wxBOTS_INDEX].pixel, + XmNforeground, g_itemColors[wxFORE_INDEX].pixel, NULL); -#endif + + if (changeArmColour) + XtVaSetValues ((Widget) widget, + XmNarmColor, g_itemColors[wxSELE_INDEX].pixel, + NULL); } -void wxWindow::ChangeFont(WXWidget widget) +void wxWindow::SetBackgroundColour(const wxColour& col) { - /* - if (widget && GetFont() && GetFont()->Ok()) - { - XmFontList fontList = (XmFontList) GetFont()->GetFontList(1.0, GetXDisplay()); - if (fontList) - XtVaSetValues ((Widget) widget, - XmNfontList, fontList, + m_backgroundColour = col; + ChangeBackgroundColour(); +} + +void wxWindow::SetForegroundColour(const wxColour& col) +{ + m_foregroundColour = col; + ChangeForegroundColour(); +} + +void wxWindow::ChangeFont() +{ + // 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? + /* + Widget w = (Widget) GetLabelWidget(); // Usually the main widget + if (w && m_windowFont.Ok()) + { + int width, height, width1, height1; + GetSize(& width, & height); + + XtVaSetValues (w, + XmNfontList, (XmFontList) m_windowFont.GetFontList(1.0, XtDisplay(w)), NULL); - } - */ + + GetSize(& width1, & height1); + if (width != width1 || height != height1) + { + SetSize(-1, -1, width, height); + } + } + */ } + +void wxWindow::SetFont(const wxFont& font) +{ + m_windowFont = font; + ChangeFont(); +} + + -- 2.45.2