From a4294b7832a5aed3c1cccc06aecd227d43da8830 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Sun, 18 Oct 1998 22:31:48 +0000 Subject: [PATCH] Motif additions git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@868 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/motif/bitmap.h | 2 +- include/wx/motif/bmpbuttn.h | 20 +- include/wx/motif/choice.h | 2 - include/wx/motif/control.h | 30 +- include/wx/motif/dcclient.h | 1 + include/wx/motif/icon.h | 2 +- include/wx/motif/listbox.h | 3 - include/wx/motif/private.h | 1 + include/wx/motif/radiobox.h | 23 +- include/wx/motif/radiobut.h | 32 +- include/wx/motif/setup.h | 11 +- include/wx/motif/slider.h | 2 - include/wx/motif/statbmp.h | 1 + include/wx/motif/textctrl.h | 1 - include/wx/motif/window.h | 2 +- samples/config/makefile.unx | 17 + samples/controls/makefile.unx | 17 + samples/dialogs/makefile.unx | 17 + samples/docview/docview.cpp | 2 + samples/dynamic/makefile.unx | 17 + samples/grid/makefile.unx | 17 + samples/internat/makefile.unx | 53 +-- samples/joytest/makefile.unx | 48 +-- samples/layout/makefile.unx | 69 +--- samples/listctrl/makefile.unx | 17 + samples/mdi/makefile.unx | 48 +-- samples/memcheck/makefile.unx | 55 +-- samples/printing/makefile.unx | 17 + samples/printing/printing.cpp | 4 +- samples/resource/makefile.unx | 69 +--- samples/sashtest/makefile.unx | 17 + samples/splitter/makefile.unx | 18 + samples/tab/makefile.unx | 17 + samples/toolbar/makefile.unx | 18 + samples/toolbar/test.cpp | 16 +- samples/treectrl/makefile.unx | 17 + samples/typetest/makefile.unx | 17 + src/common/docview.cpp | 5 +- src/common/event.cpp | 5 + src/common/prntbase.cpp | 13 +- src/generic/treectrl.cpp | 4 +- src/make.env | 6 +- src/motif/bitmap.cpp | 16 +- src/motif/bmpbuttn.cpp | 144 +++++++- src/motif/checkbox.cpp | 11 +- src/motif/choice.cpp | 4 +- src/motif/control.cpp | 45 +-- src/motif/dcclient.cpp | 2 +- src/motif/dcmemory.cpp | 91 ++++- src/motif/dialog.cpp | 10 +- src/motif/frame.cpp | 48 ++- src/motif/icon.cpp | 2 +- src/motif/listbox.cpp | 8 +- src/motif/radiobox.cpp | 304 ++++++++++++--- src/motif/radiobut.cpp | 122 ++++++- src/motif/slider.cpp | 143 ++++++-- src/motif/statbmp.cpp | 68 +++- src/motif/stattext.cpp | 40 +- src/motif/textctrl.cpp | 8 +- src/motif/utils.cpp | 671 +++++++++++++++++++++++++++++++--- src/motif/window.cpp | 79 +++- 61 files changed, 1919 insertions(+), 650 deletions(-) create mode 100644 samples/config/makefile.unx create mode 100644 samples/controls/makefile.unx create mode 100644 samples/dialogs/makefile.unx create mode 100644 samples/dynamic/makefile.unx create mode 100644 samples/grid/makefile.unx create mode 100644 samples/listctrl/makefile.unx create mode 100644 samples/printing/makefile.unx create mode 100644 samples/sashtest/makefile.unx create mode 100644 samples/splitter/makefile.unx create mode 100644 samples/tab/makefile.unx create mode 100644 samples/toolbar/makefile.unx create mode 100644 samples/treectrl/makefile.unx create mode 100644 samples/typetest/makefile.unx diff --git a/include/wx/motif/bitmap.h b/include/wx/motif/bitmap.h index 9c60d94c91..e36fc5ecf6 100644 --- a/include/wx/motif/bitmap.h +++ b/include/wx/motif/bitmap.h @@ -142,7 +142,7 @@ public: wxBitmap(const char bits[], int width, int height, int depth = 1); // Initialize with XPM data - wxBitmap(const char **data, wxControl* control = NULL); + wxBitmap(char **data, wxControl* control = NULL); // Load a file or resource wxBitmap(const wxString& name, long type = wxBITMAP_TYPE_XBM); diff --git a/include/wx/motif/bmpbuttn.h b/include/wx/motif/bmpbuttn.h index 8dcb69598f..bb5ea2f503 100644 --- a/include/wx/motif/bmpbuttn.h +++ b/include/wx/motif/bmpbuttn.h @@ -26,7 +26,8 @@ class WXDLLEXPORT wxBitmapButton: public wxButton { DECLARE_DYNAMIC_CLASS(wxBitmapButton) public: - inline wxBitmapButton() { m_marginX = wxDEFAULT_BUTTON_MARGIN; m_marginY = wxDEFAULT_BUTTON_MARGIN; } + wxBitmapButton(); + ~wxBitmapButton(); inline wxBitmapButton(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxBU_AUTODRAW, @@ -54,29 +55,24 @@ class WXDLLEXPORT wxBitmapButton: public wxButton inline wxBitmap& GetBitmapFocus() const { return (wxBitmap&) m_buttonBitmapFocus; } inline wxBitmap& GetBitmapDisabled() const { return (wxBitmap&) m_buttonBitmapDisabled; } - inline void SetBitmapSelected(const wxBitmap& sel) { m_buttonBitmapSelected = sel; }; - inline void SetBitmapFocus(const wxBitmap& focus) { m_buttonBitmapFocus = focus; }; - inline void SetBitmapDisabled(const wxBitmap& disabled) { m_buttonBitmapDisabled = disabled; }; + void SetBitmapSelected(const wxBitmap& sel); + void SetBitmapFocus(const wxBitmap& focus); + void SetBitmapDisabled(const wxBitmap& disabled); inline void SetMargins(int x, int y) { m_marginX = x; m_marginY = y; } inline int GetMarginX() { return m_marginX; } inline int GetMarginY() { return m_marginY; } -/* - // TODO: Implementation - virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *item); - virtual void DrawFace( WXHDC dc, int left, int top, int right, int bottom, bool sel ); - virtual void DrawButtonFocus( WXHDC dc, int left, int top, int right, int bottom, bool sel ); - virtual void DrawButtonDisable( WXHDC dc, int left, int top, int right, int bottom, bool with_marg ); -*/ - protected: wxBitmap m_buttonBitmap; wxBitmap m_buttonBitmapSelected; wxBitmap m_buttonBitmapFocus; wxBitmap m_buttonBitmapDisabled; + int m_marginX; int m_marginY; + + WXPixmap m_insensPixmap; }; #endif diff --git a/include/wx/motif/choice.h b/include/wx/motif/choice.h index 30423c0e96..321e5cfab3 100644 --- a/include/wx/motif/choice.h +++ b/include/wx/motif/choice.h @@ -77,8 +77,6 @@ protected: WXWidget* m_widgetList ; WXWidget m_formWidget; wxStringList m_stringList; -public: - bool m_inSetValue; }; #endif diff --git a/include/wx/motif/control.h b/include/wx/motif/control.h index 4913175b71..a40687a118 100644 --- a/include/wx/motif/control.h +++ b/include/wx/motif/control.h @@ -23,27 +23,31 @@ // General item class class WXDLLEXPORT wxControl: public wxWindow { - DECLARE_ABSTRACT_CLASS(wxControl) + DECLARE_ABSTRACT_CLASS(wxControl) public: - wxControl(); - ~wxControl(); + wxControl(); + ~wxControl(); - virtual void Command(wxCommandEvent& WXUNUSED(event)) {}; // Simulates an event - virtual void ProcessCommand(wxCommandEvent& event); // Calls the callback and + virtual void Command(wxCommandEvent& WXUNUSED(event)) {}; // Simulates an event + virtual void ProcessCommand(wxCommandEvent& event); // Calls the callback and // appropriate event handlers - virtual void SetLabel(const wxString& label); - virtual wxString GetLabel() const ; + virtual void SetLabel(const wxString& label); + virtual wxString GetLabel() const ; - // Places item in centre of panel - so can't be used BEFORE panel->Fit() - void Centre(int direction = wxHORIZONTAL); - inline void Callback(const wxFunction function) { m_callback = function; }; // Adds callback + // Places item in centre of panel - so can't be used BEFORE panel->Fit() + void Centre(int direction = wxHORIZONTAL); + inline void Callback(const wxFunction function) { m_callback = function; }; // Adds callback - inline wxFunction GetCallback() { return m_callback; } + inline wxFunction GetCallback() { return m_callback; } + inline bool InSetValue() const { return m_inSetValue; } protected: - wxFunction m_callback; // Callback associated with the window + wxFunction m_callback; // Callback associated with the window -DECLARE_EVENT_TABLE() + bool m_inSetValue; // Motif: prevent callbacks being called while + // in SetValue + + DECLARE_EVENT_TABLE() }; #endif diff --git a/include/wx/motif/dcclient.h b/include/wx/motif/dcclient.h index 38c9b2d5ec..6784cda790 100644 --- a/include/wx/motif/dcclient.h +++ b/include/wx/motif/dcclient.h @@ -97,6 +97,7 @@ class WXDLLEXPORT wxWindowDC: public wxDC void SetDCClipping (); // Helper function for setting clipping inline WXGC GetGC() const { return m_gc; } + inline WXDisplay* GetDisplay() const { return m_display; } inline bool GetAutoSetting() const { return m_autoSetting; } inline void SetAutoSetting(bool flag) { m_autoSetting = flag; } diff --git a/include/wx/motif/icon.h b/include/wx/motif/icon.h index 92eb0eccfc..dcec9a6004 100644 --- a/include/wx/motif/icon.h +++ b/include/wx/motif/icon.h @@ -49,7 +49,7 @@ public: wxIcon(const char bits[], int width, int height); // Initialize with XPM data - wxIcon(const char **data); + wxIcon(char **data); wxIcon(const wxString& name, long flags = wxBITMAP_TYPE_ICO_RESOURCE, int desiredWidth = -1, int desiredHeight = -1); diff --git a/include/wx/motif/listbox.h b/include/wx/motif/listbox.h index 8672e99ada..0b938da821 100644 --- a/include/wx/motif/listbox.h +++ b/include/wx/motif/listbox.h @@ -97,9 +97,6 @@ protected: // List mapping positions->client data wxList m_clientDataList; - -public: - bool m_inSetValue; }; #endif diff --git a/include/wx/motif/private.h b/include/wx/motif/private.h index 7e055be692..3a04b6df43 100644 --- a/include/wx/motif/private.h +++ b/include/wx/motif/private.h @@ -34,6 +34,7 @@ extern KeySym wxCharCodeWXToX(int id); bool wxTranslateMouseEvent(wxMouseEvent& wxevent, wxWindow *win, Widget widget, XEvent *xevent); bool wxTranslateKeyEvent(wxKeyEvent& wxevent, wxWindow *win, Widget widget, XEvent *xevent); int wxGetBestMatchingPixel(Display *display, XColor *desiredColor, Colormap cmap); +Pixmap XCreateInsensitivePixmap( Display *display, Pixmap pixmap ); #define wxNO_COLORS 0x00 #define wxBACK_COLORS 0x01 diff --git a/include/wx/motif/radiobox.h b/include/wx/motif/radiobox.h index f46b0a265a..6f3a788f39 100644 --- a/include/wx/motif/radiobox.h +++ b/include/wx/motif/radiobox.h @@ -51,19 +51,14 @@ public: int GetSelection() const; wxString GetString(int N) const; void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO); - void GetSize(int *x, int *y) const; - void GetPosition(int *x, int *y) const; - wxString GetLabel() const; - void SetLabel(const wxString& label); + void SetLabel(const wxString& label) { wxControl::SetLabel(label); }; void SetLabel(int item, const wxString& label) ; wxString GetLabel(int item) const; - bool Show(bool show); - void SetFocus(); + wxString GetLabel() const { return wxControl::GetLabel(); }; void Enable(bool enable); void Enable(int item, bool enable); void Show(int item, bool show) ; - inline void SetLabelFont(const wxFont& WXUNUSED(font)) {}; - inline void SetButtonFont(const wxFont& font) { SetFont(font); } + bool Show(bool show) { return wxControl::Show(show); }; virtual wxString GetStringSelection() const; virtual bool SetStringSelection(const wxString& s); @@ -73,15 +68,21 @@ public: inline int GetNumberOfRowsOrCols() const { return m_noRowsOrCols; } inline void SetNumberOfRowsOrCols(int n) { m_noRowsOrCols = n; } + WXWidget GetTopWidget() const { return m_formWidget; } + WXWidget GetLabelWidget() const { return m_labelWidget; } + inline WXWidget* GetRadioButtons() const { return m_radioButtons; } + inline void SetSel(int i) { m_selectedButton = i; } + protected: -/* TODO: implementation - WXHWND * m_radioButtons; -*/ int m_majorDim ; int m_noItems; int m_noRowsOrCols; int m_selectedButton; + WXWidget m_formWidget; + WXWidget m_labelWidget; + WXWidget* m_radioButtons; + wxString* m_radioButtonLabels; }; #endif diff --git a/include/wx/motif/radiobut.h b/include/wx/motif/radiobut.h index 582eb470f1..a9b58d777e 100644 --- a/include/wx/motif/radiobut.h +++ b/include/wx/motif/radiobut.h @@ -22,32 +22,38 @@ WXDLLEXPORT_DATA(extern const char*) wxRadioButtonNameStr; class WXDLLEXPORT wxRadioButton: public wxControl { - DECLARE_DYNAMIC_CLASS(wxRadioButton) - protected: - public: - inline wxRadioButton() {} - inline wxRadioButton(wxWindow *parent, wxWindowID id, + DECLARE_DYNAMIC_CLASS(wxRadioButton) +protected: +public: + wxRadioButton(); + inline wxRadioButton(wxWindow *parent, wxWindowID id, const wxString& label, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxValidator& validator = wxDefaultValidator, const wxString& name = wxRadioButtonNameStr) - { - Create(parent, id, label, pos, size, style, validator, name); - } + { + Create(parent, id, label, pos, size, style, validator, name); + } - bool Create(wxWindow *parent, wxWindowID id, + bool Create(wxWindow *parent, wxWindowID id, const wxString& label, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxValidator& validator = wxDefaultValidator, const wxString& name = wxRadioButtonNameStr); - virtual void SetLabel(const wxString& label); - virtual void SetValue(bool val); - virtual bool GetValue() const ; + virtual void SetValue(bool val); + virtual bool GetValue() const ; + + void Command(wxCommandEvent& event); + + WXWidget GetTopWidget() const { return m_formWidget; } + WXWidget GetLabelWidget() const { return m_labelWidget; } - void Command(wxCommandEvent& event); +private: + WXWidget m_formWidget; + WXWidget m_labelWidget; }; // Not implemented diff --git a/include/wx/motif/setup.h b/include/wx/motif/setup.h index a53bfbea35..b69937aca0 100644 --- a/include/wx/motif/setup.h +++ b/include/wx/motif/setup.h @@ -51,9 +51,12 @@ // AIAI spline code is slower, but freer of copyright issues. // 0 for no splines -#define wxUSE_TOOLBAR 1 +#define wxUSE_XPM 1 + // Use XPMs + +#define wxUSE_TOOLBAR 1 // Use toolbars -#define wxUSE_COMBOBOX 1 +#define wxUSE_COMBOBOX 1 // Use wxComboBox #define wxUSE_DRAG_AND_DROP 1 // 0 for no drag and drop @@ -110,6 +113,10 @@ // if enabled, compiles built-in OS independent wxConfig // class and it's file (any platform) and registry (Win) // based implementations + +#define wxUSE_GADGETS 0 + // Use gadgets where possible + /* * Finer detail * diff --git a/include/wx/motif/slider.h b/include/wx/motif/slider.h index a11705040c..d54c2772ea 100644 --- a/include/wx/motif/slider.h +++ b/include/wx/motif/slider.h @@ -53,8 +53,6 @@ public: virtual void SetValue(int); void GetSize(int *x, int *y) const ; void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO); - void GetPosition(int *x, int *y) const ; - bool Show(bool show); void SetRange(int minValue, int maxValue); diff --git a/include/wx/motif/statbmp.h b/include/wx/motif/statbmp.h index 8045813fc4..a37e1c4a12 100644 --- a/include/wx/motif/statbmp.h +++ b/include/wx/motif/statbmp.h @@ -25,6 +25,7 @@ class WXDLLEXPORT wxStaticBitmap: public wxControl DECLARE_DYNAMIC_CLASS(wxStaticBitmap) public: inline wxStaticBitmap() { } + ~wxStaticBitmap(); inline wxStaticBitmap(wxWindow *parent, wxWindowID id, const wxBitmap& label, diff --git a/include/wx/motif/textctrl.h b/include/wx/motif/textctrl.h index 4556a46d82..518d8a1edf 100644 --- a/include/wx/motif/textctrl.h +++ b/include/wx/motif/textctrl.h @@ -139,7 +139,6 @@ public: void* m_tempCallbackStruct; bool m_modified; wxString m_value; // Required for password text controls - bool m_inSetValue; bool m_processedDefault; // Did we call wxTextCtrl::OnChar? // If so, generate a command event. DECLARE_EVENT_TABLE() diff --git a/include/wx/motif/window.h b/include/wx/motif/window.h index 80a794fa43..8ba732f698 100644 --- a/include/wx/motif/window.h +++ b/include/wx/motif/window.h @@ -465,7 +465,7 @@ public: // Get main widget for this window, e.g. a text widget virtual WXWidget GetMainWidget() const; - // Get the widget that supports font setting + // Get the widget that corresponds to the label (for font setting, label setting etc.) virtual WXWidget GetLabelWidget() const { return GetMainWidget(); } // Get the client widget for this window (something we can // create other windows on) diff --git a/samples/config/makefile.unx b/samples/config/makefile.unx new file mode 100644 index 0000000000..892ffd1f30 --- /dev/null +++ b/samples/config/makefile.unx @@ -0,0 +1,17 @@ +# +# File: makefile.unx +# Author: Julian Smart +# Created: 1998 +# Updated: +# Copyright: (c) 1998 Julian Smart +# +# "%W% %G%" +# +# Makefile for config example (UNIX). + +PROGRAM=conftest + +OBJECTS=$(PROGRAM).o + +include ../../src/makeprog.env + diff --git a/samples/controls/makefile.unx b/samples/controls/makefile.unx new file mode 100644 index 0000000000..8e5eeb17a1 --- /dev/null +++ b/samples/controls/makefile.unx @@ -0,0 +1,17 @@ +# +# File: makefile.unx +# Author: Julian Smart +# Created: 1998 +# Updated: +# Copyright: (c) 1998 Julian Smart +# +# "%W% %G%" +# +# Makefile for controls example (UNIX). + +PROGRAM=controls + +OBJECTS=$(PROGRAM).o + +include ../../src/makeprog.env + diff --git a/samples/dialogs/makefile.unx b/samples/dialogs/makefile.unx new file mode 100644 index 0000000000..b144f19701 --- /dev/null +++ b/samples/dialogs/makefile.unx @@ -0,0 +1,17 @@ +# +# File: makefile.unx +# Author: Julian Smart +# Created: 1998 +# Updated: +# Copyright: (c) 1998 Julian Smart +# +# "%W% %G%" +# +# Makefile for dialogs example (UNIX). + +PROGRAM=dialogs + +OBJECTS=$(PROGRAM).o + +include ../../src/makeprog.env + diff --git a/samples/docview/docview.cpp b/samples/docview/docview.cpp index 53699369c1..681fa2ebc0 100644 --- a/samples/docview/docview.cpp +++ b/samples/docview/docview.cpp @@ -257,6 +257,8 @@ MyCanvas *MyFrame::CreateCanvas(wxView *view, wxFrame *parent) // Give it scrollbars canvas->SetScrollbars(20, 20, 50, 50); + canvas->SetBackgroundColour(*wxWHITE); + canvas->Clear(); return canvas; } diff --git a/samples/dynamic/makefile.unx b/samples/dynamic/makefile.unx new file mode 100644 index 0000000000..c4c52d7f6e --- /dev/null +++ b/samples/dynamic/makefile.unx @@ -0,0 +1,17 @@ +# +# File: makefile.unx +# Author: Julian Smart +# Created: 1998 +# Updated: +# Copyright: (c) 1998 Julian Smart +# +# "%W% %G%" +# +# Makefile for dynamic example (UNIX). + +PROGRAM=dynamic + +OBJECTS=$(PROGRAM).o + +include ../../src/makeprog.env + diff --git a/samples/grid/makefile.unx b/samples/grid/makefile.unx new file mode 100644 index 0000000000..069b823b1a --- /dev/null +++ b/samples/grid/makefile.unx @@ -0,0 +1,17 @@ +# +# File: makefile.unx +# Author: Julian Smart +# Created: 1998 +# Updated: +# Copyright: (c) 1998 Julian Smart +# +# "%W% %G%" +# +# Makefile for grid example (UNIX). + +PROGRAM=test + +OBJECTS=$(PROGRAM).o + +include ../../src/makeprog.env + diff --git a/samples/internat/makefile.unx b/samples/internat/makefile.unx index 9685d06789..f5db8b1f46 100644 --- a/samples/internat/makefile.unx +++ b/samples/internat/makefile.unx @@ -1,58 +1,17 @@ # # File: makefile.unx # Author: Julian Smart -# Created: 1993 +# Created: 1998 # Updated: -# Copyright: (c) 1993, AIAI, University of Edinburgh +# Copyright: (c) 1998 Julian Smart # # "%W% %G%" # -# Makefile for minimal example (UNIX). +# Makefile for internat example (UNIX). -WXDIR = ../.. +PROGRAM=internat -# All common UNIX compiler flags and options are now in -# this central makefile. -include $(WXDIR)/src/make.env +OBJECTS=$(PROGRAM).o -OBJECTS = $(OBJDIR)/minimal.$(OBJSUFF) +include ../../src/makeprog.env -.SUFFIXES: - -all: $(OBJDIR) minimal$(GUISUFFIX) - -wx: - - -motif: - $(MAKE) -f makefile.unx GUISUFFIX=_motif GUI=-Dwx_motif GUISUFFIX=_motif OPT='$(OPT)' LDLIBS='$(MOTIFLDLIBS)' WXLIB=$(WXDIR)/lib/libwx_motif.a OPTIONS='$(OPTIONS)' DEBUG='$(DEBUG)' WARN='$(WARN)' XLIB='$(XLIB)' XINCLUDE='$(XINCLUDE)' XVIEW_LINK= - -xview: - cd $(WXDIR)/src/x; $(MAKE) -f makefile.unx xview - $(MAKE) -f makefile.unx GUI=-Dwx_xview GUISUFFIX=_ol CC=$(CC) OPTIONS='$(OPTIONS)' DEBUG='$(DEBUG)' WARN='$(WARN)' XLIB='$(XLIB)' XINCLUDE='$(XINCLUDE)' - -hp: - cd $(WXDIR)/src/x; $(MAKE) -f makefile.unx hp - $(MAKE) -f makefile.unx GUI=-Dwx_motif GUISUFFIX=_hp CC=CC DEBUG='$(DEBUG)' WARN='-w' \ - XINCLUDE='$(HPXINCLUDE)' XLIB='$(HPXLIB)' XVIEW_LINK='' LDLIBS='$(HPLDLIBS)' - -$(OBJDIR): - mkdir $(OBJDIR) - -minimal$(GUISUFFIX): $(OBJDIR)/minimal.$(OBJSUFF) $(WXLIB) - $(CC) $(LDFLAGS) -o minimal$(GUISUFFIX) $(OBJDIR)/minimal.$(OBJSUFF) $(XVIEW_LINK) $(LDLIBS) - -$(OBJDIR)/minimal.$(OBJSUFF): minimal.$(SRCSUFF) - $(CC) -c $(CPPFLAGS) -o $@ minimal.$(SRCSUFF) - -clean_motif: - $(MAKE) -f makefile.unx GUISUFFIX=_motif cleanany - -clean_ol: - $(MAKE) -f makefile.unx GUISUFFIX=_ol cleanany - -clean_hp: - $(MAKE) -f makefile.unx GUISUFFIX=_hp cleanany - -cleanany: - rm -f $(OBJECTS) minimal$(GUISUFFIX) core diff --git a/samples/joytest/makefile.unx b/samples/joytest/makefile.unx index c4156423ac..7b60c08bea 100644 --- a/samples/joytest/makefile.unx +++ b/samples/joytest/makefile.unx @@ -1,55 +1,17 @@ # # File: makefile.unx # Author: Julian Smart -# Created: 1993 +# Created: 1998 # Updated: -# Copyright: (c) 1993, AIAI, University of Edinburgh +# Copyright: (c) 1998 Julian Smart # # "%W% %G%" # # Makefile for joytest example (UNIX). -WXDIR = ../.. +PROGRAM=joytest -# All common UNIX compiler flags and options are now in -# this central makefile. -include $(WXDIR)/src/make.env +OBJECTS=$(PROGRAM).o -OBJECTS = $(OBJDIR)/joytest.$(OBJSUFF) +include ../../src/makeprog.env -.SUFFIXES: - -all: $(OBJDIR) joytest$(GUISUFFIX) - -wx: -# cd $(WXDIR)/src/x; $(MAKE) -f makefile.unx -motif: - $(MAKE) -f makefile.unx GUISUFFIX=_motif GUI=-Dwx_motif GUISUFFIX=_motif OPT='$(OPT)' LDLIBS='$(MOTIFLDLIBS)' OPTIONS='$(OPTIONS)' DEBUG='$(DEBUG)' WARN='$(WARN)' XLIB='$(XLIB)' XINCLUDE='$(XINCLUDE)' XVIEW_LINK= - -xview: - $(MAKE) -f makefile.unx GUI=-Dwx_xview GUISUFFIX=_ol CC=$(CC) OPTIONS='$(OPTIONS)' DEBUG='$(DEBUG)' WARN='$(WARN)' XLIB='$(XLIB)' XINCLUDE='$(XINCLUDE)' - -hp: - $(MAKE) -f makefile.unx GUI=-Dwx_motif GUISUFFIX=_hp CC=CC DEBUG='$(DEBUG)' WARN='-w' \ - XINCLUDE='$(HPXINCLUDE)' XLIB='$(HPXLIB)' XVIEW_LINK='' LDLIBS='$(HPLDLIBS)' - -$(OBJDIR): - mkdir $(OBJDIR) - -joytest$(GUISUFFIX): $(OBJDIR)/joytest.$(OBJSUFF) $(WXLIB) - $(CC) $(LDFLAGS) -o joytest$(GUISUFFIX) $(OBJDIR)/joytest.$(OBJSUFF) $(XVIEW_LINK) $(LDLIBS) - -$(OBJDIR)/joytest.$(OBJSUFF): joytest.$(SRCSUFF) joytest.h - $(CC) -c $(CPPFLAGS) -o $@ joytest.$(SRCSUFF) - -clean_motif: - $(MAKE) -f makefile.unx GUISUFFIX=_motif cleanany - -clean_ol: - $(MAKE) -f makefile.unx GUISUFFIX=_ol cleanany - -clean_hp: - $(MAKE) -f makefile.unx GUISUFFIX=_hp cleanany - -cleanany: - rm -f $(OBJECTS) joytest$(GUISUFFIX) core diff --git a/samples/layout/makefile.unx b/samples/layout/makefile.unx index 3f9aad0ac2..ff2edfa6ce 100644 --- a/samples/layout/makefile.unx +++ b/samples/layout/makefile.unx @@ -1,76 +1,17 @@ # # File: makefile.unx # Author: Julian Smart -# Created: 1993 +# Created: 1998 # Updated: -# Copyright: (c) 1993, AIAI, University of Edinburgh +# Copyright: (c) 1998 Julian Smart # # "%W% %G%" # # Makefile for layout example (UNIX). -WXDIR = ../.. +PROGRAM=layout -# All common UNIX compiler flags and options are now in -# this central makefile. -include $(WXDIR)/src/make.env +OBJECTS=$(PROGRAM).o -OBJECTS=$(OBJDIR)/layout.$(OBJSUFF) - -.SUFFIXES: - -all: $(OBJDIR) layout$(GUISUFFIX) - -wxmotif: - cd $(WXDIR)/src/x; $(MAKE) -f makefile.unx motif - -wxxview: - cd $(WXDIR)/src/x; $(MAKE) -f makefile.unx xview - -wxhp: - cd $(WXDIR)/src/x; $(MAKE) -f makefile.unx hp - -# For SGI, include -lPW on your LDLIBS -motif: wxmotif - $(MAKE) -f makefile.unx all GUISUFFIX=_motif GUI=-Dwx_motif GUISUFFIX=_motif OPT='$(OPT)' LDLIBS='$(MOTIFLDLIBS)' WXLIB=$(WXDIR)/lib/libwx_motif.a OPTIONS='$(OPTIONS)' DEBUG='$(DEBUG)' WARN='$(WARN)' XLIB='$(XLIB)' XINCLUDE='$(XINCLUDE)' XVIEW_LINK= - -xview: wxxview - $(MAKE) -f makefile.unx GUI=-Dwx_xview GUISUFFIX=_ol CC=$(CC) OPTIONS='$(OPTIONS)' DEBUG='$(DEBUG)' WARN='$(WARN)' XLIB='$(XLIB)' XINCLUDE='$(XINCLUDE)' LDLIBS='$(XVIEWLDLIBS)' - -hp: wxhp - $(MAKE) -f makefile.unx GUI=-Dwx_motif GUISUFFIX=_hp CC=CC OPT='' DEBUG='$(DEBUG)' WARN='-w' \ - XINCLUDE='$(HPXINCLUDE)' \ - XLIB='$(HPXLIB)' \ - XVIEW_LINK='' \ - LDLIBS='$(HPLDLIBS)' - -$(OBJDIR): - mkdir $(OBJDIR) - -layout$(GUISUFFIX): $(OBJDIR)/layout.$(OBJSUFF) $(WXLIB) - $(CC) $(LDFLAGS) -o layout$(GUISUFFIX) $(OBJDIR)/layout.$(OBJSUFF) $(XVIEW_LINK) $(LDLIBS) - -$(OBJDIR)/layout.$(OBJSUFF): layout.$(SRCSUFF) layout.h - $(CC) -c $(CPPFLAGS) -o $@ layout.$(SRCSUFF) - -clean_motif: - $(MAKE) -f makefile.unx GUISUFFIX=_motif cleanany - -clean_ol: - $(MAKE) -f makefile.unx GUISUFFIX=_ol cleanany - -clean_hp: - $(MAKE) -f makefile.unx GUISUFFIX=_hp cleanany - -cleanany: - rm -f $(OBJECTS) layout$(GUISUFFIX) core - -wxclean_ol: - cd $(WXDIR)/src/x; $(MAKE) -f makefile.unx clean_ol - -wxclean_motif: - cd $(WXDIR)/src/x; $(MAKE) -f makefile.unx clean_motif - -wxclean_hp: - cd $(WXDIR)/src/x; $(MAKE) -f makefile.unx clean_hp +include ../../src/makeprog.env diff --git a/samples/listctrl/makefile.unx b/samples/listctrl/makefile.unx new file mode 100644 index 0000000000..a94e6cb31d --- /dev/null +++ b/samples/listctrl/makefile.unx @@ -0,0 +1,17 @@ +# +# File: makefile.unx +# Author: Julian Smart +# Created: 1998 +# Updated: +# Copyright: (c) 1998 Julian Smart +# +# "%W% %G%" +# +# Makefile for listctrl example (UNIX). + +PROGRAM=listtest + +OBJECTS=$(PROGRAM).o + +include ../../src/makeprog.env + diff --git a/samples/mdi/makefile.unx b/samples/mdi/makefile.unx index 24b30ac061..4c904e4c6f 100644 --- a/samples/mdi/makefile.unx +++ b/samples/mdi/makefile.unx @@ -1,55 +1,17 @@ # # File: makefile.unx # Author: Julian Smart -# Created: 1993 +# Created: 1998 # Updated: -# Copyright: (c) 1993, AIAI, University of Edinburgh +# Copyright: (c) 1998 Julian Smart # # "%W% %G%" # # Makefile for mdi example (UNIX). -WXDIR = ../.. +PROGRAM=mdi -# All common UNIX compiler flags and options are now in -# this central makefile. -include $(WXDIR)/src/make.env +OBJECTS=$(PROGRAM).o -OBJECTS = $(OBJDIR)/mdi.$(OBJSUFF) +include ../../src/makeprog.env -.SUFFIXES: - -all: $(OBJDIR) mdi$(GUISUFFIX) - -wx: -# cd $(WXDIR)/src/x; $(MAKE) -f makefile.unx -motif: - $(MAKE) -f makefile.unx GUISUFFIX=_motif GUI=-Dwx_motif GUISUFFIX=_motif OPT='$(OPT)' LDLIBS='$(MOTIFLDLIBS)' OPTIONS='$(OPTIONS)' DEBUG='$(DEBUG)' WARN='$(WARN)' XLIB='$(XLIB)' XINCLUDE='$(XINCLUDE)' XVIEW_LINK= - -xview: - $(MAKE) -f makefile.unx GUI=-Dwx_xview GUISUFFIX=_ol CC=$(CC) OPTIONS='$(OPTIONS)' DEBUG='$(DEBUG)' WARN='$(WARN)' XLIB='$(XLIB)' XINCLUDE='$(XINCLUDE)' - -hp: - $(MAKE) -f makefile.unx GUI=-Dwx_motif GUISUFFIX=_hp CC=CC DEBUG='$(DEBUG)' WARN='-w' \ - XINCLUDE='$(HPXINCLUDE)' XLIB='$(HPXLIB)' XVIEW_LINK='' LDLIBS='$(HPLDLIBS)' - -$(OBJDIR): - mkdir $(OBJDIR) - -mdi$(GUISUFFIX): $(OBJDIR)/mdi.$(OBJSUFF) $(WXLIB) - $(CC) $(LDFLAGS) -o mdi$(GUISUFFIX) $(OBJDIR)/mdi.$(OBJSUFF) $(XVIEW_LINK) $(LDLIBS) - -$(OBJDIR)/mdi.$(OBJSUFF): mdi.$(SRCSUFF) mdi.h - $(CC) -c $(CPPFLAGS) -o $@ mdi.$(SRCSUFF) - -clean_motif: - $(MAKE) -f makefile.unx GUISUFFIX=_motif cleanany - -clean_ol: - $(MAKE) -f makefile.unx GUISUFFIX=_ol cleanany - -clean_hp: - $(MAKE) -f makefile.unx GUISUFFIX=_hp cleanany - -cleanany: - rm -f $(OBJECTS) mdi$(GUISUFFIX) core diff --git a/samples/memcheck/makefile.unx b/samples/memcheck/makefile.unx index 8dd50b9c44..5be5c0abf6 100644 --- a/samples/memcheck/makefile.unx +++ b/samples/memcheck/makefile.unx @@ -1,62 +1,17 @@ # # File: makefile.unx # Author: Julian Smart -# Created: 1993 +# Created: 1998 # Updated: -# Copyright: (c) 1993, AIAI, University of Edinburgh +# Copyright: (c) 1998 Julian Smart # # "%W% %G%" # # Makefile for memcheck example (UNIX). -WXDIR = ../.. +PROGRAM=memcheck -# All common UNIX compiler flags and options are now in -# this central makefile. -include $(WXDIR)/src/make.env +OBJECTS=$(PROGRAM).o -OBJECTS = $(OBJDIR)/memcheck.$(OBJSUFF) +include ../../src/makeprog.env -.SUFFIXES: - -all: $(OBJDIR) memcheck$(GUISUFFIX) - -wxmotif: - cd $(WXDIR)/src/x; $(MAKE) -f makefile.unx motif GUISUFFIX=_motif GUI=-Dwx_motif GUISUFFIX=_motif OPT='$(OPT)' LDLIBS='$(MOTIFLDLIBS)' WXLIB=$(WXDIR)/lib/libwx_motif.a OPTIONS='$(OPTIONS)'\ - DEBUG='$(DEBUG)' DEBUGFLAGS='$(DEBUGFLAGS)' WARN='$(WARN)' XLIB='$(XLIB)' XINCLUDE='$(XINCLUDE)' XVIEW_LINK= - - -motif: wxmotif - $(MAKE) -f makefile.unx GUISUFFIX=_motif GUI=-Dwx_motif GUISUFFIX=_motif OPT='$(OPT)' LDLIBS='$(MOTIFLDLIBS)' WXLIB=$(WXDIR)/lib/libwx_motif.a OPTIONS='$(OPTIONS)'\ - DEBUG='$(DEBUG)' DEBUGFLAGS='$(DEBUGFLAGS)' WARN='$(WARN)' XLIB='$(XLIB)' XINCLUDE='$(XINCLUDE)' XVIEW_LINK= - -xview: - cd $(WXDIR)/src/x; $(MAKE) -f makefile.unx xview - $(MAKE) -f makefile.unx GUI=-Dwx_xview GUISUFFIX=_ol CC=$(CC) OPTIONS='$(OPTIONS)'\ - DEBUG='$(DEBUG)' DEBUGFLAGS='$(DEBUGFLAGS)' WARN='$(WARN)' XLIB='$(XLIB)' XINCLUDE='$(XINCLUDE)' - -hp: - cd $(WXDIR)/src/x; $(MAKE) -f makefile.unx hp - $(MAKE) -f makefile.unx GUI=-Dwx_motif GUISUFFIX=_hp CC=CC DEBUG='$(DEBUG)' DEBUGFLAGS='' WARN='-w' \ - XINCLUDE='$(HPXINCLUDE)' XLIB='$(HPXLIB)' XVIEW_LINK='' LDLIBS='$(HPLDLIBS)' - -$(OBJDIR): - mkdir $(OBJDIR) - -memcheck$(GUISUFFIX): $(OBJDIR)/memcheck.$(OBJSUFF) $(WXLIB) - $(CC) $(LDFLAGS) -o memcheck$(GUISUFFIX) $(OBJDIR)/memcheck.$(OBJSUFF) $(XVIEW_LINK) $(LDLIBS) - -$(OBJDIR)/memcheck.$(OBJSUFF): memcheck.$(SRCSUFF) - $(CC) -c $(CPPFLAGS) -o $@ memcheck.$(SRCSUFF) - -clean_motif: - $(MAKE) -f makefile.unx GUISUFFIX=_motif cleanany - -clean_ol: - $(MAKE) -f makefile.unx GUISUFFIX=_ol cleanany - -clean_hp: - $(MAKE) -f makefile.unx GUISUFFIX=_hp cleanany - -cleanany: - rm -f $(OBJECTS) memcheck$(GUISUFFIX) core diff --git a/samples/printing/makefile.unx b/samples/printing/makefile.unx new file mode 100644 index 0000000000..319cf1c827 --- /dev/null +++ b/samples/printing/makefile.unx @@ -0,0 +1,17 @@ +# +# File: makefile.unx +# Author: Julian Smart +# Created: 1998 +# Updated: +# Copyright: (c) 1998 Julian Smart +# +# "%W% %G%" +# +# Makefile for printing example (UNIX). + +PROGRAM=printing + +OBJECTS=$(PROGRAM).o + +include ../../src/makeprog.env + diff --git a/samples/printing/printing.cpp b/samples/printing/printing.cpp index ac806d6184..af82cf63d8 100644 --- a/samples/printing/printing.cpp +++ b/samples/printing/printing.cpp @@ -52,7 +52,7 @@ int orientation = wxPORTRAIT; // Main proc IMPLEMENT_APP(MyApp) -#ifdef __WXGTK__ +#if defined(__WXGTK__) || defined(__WXMOTIF__) #include "folder.xpm" #endif @@ -316,7 +316,7 @@ void MyFrame::Draw(wxDC& dc) dc.DrawLine(0, 0, 200, 200); dc.DrawLine(200, 0, 0, 200); -#if defined(__WXGTK__) +#if defined(__WXGTK__) || defined(__WXMOTIF__) wxIcon my_icon( folder_xpm ); #elif defined(__WXMSW__) wxIcon my_icon( "mondrian" ); diff --git a/samples/resource/makefile.unx b/samples/resource/makefile.unx index 1967b5e242..2076a000a7 100644 --- a/samples/resource/makefile.unx +++ b/samples/resource/makefile.unx @@ -1,76 +1,17 @@ # # File: makefile.unx # Author: Julian Smart -# Created: 1993 +# Created: 1998 # Updated: -# Copyright: (c) 1993, AIAI, University of Edinburgh +# Copyright: (c) 1998 Julian Smart # # "%W% %G%" # # Makefile for resource example (UNIX). -WXDIR = ../.. +PROGRAM=resource -# All common UNIX compiler flags and options are now in -# this central makefile. -include $(WXDIR)/src/make.env +OBJECTS=$(PROGRAM).o -OBJECTS=$(OBJDIR)/resource.$(OBJSUFF) - -.SUFFIXES: - -all: $(OBJDIR) resource$(GUISUFFIX) - -wxmotif: - cd $(WXDIR)/src/x; $(MAKE) -f makefile.unx motif - -wxxview: - cd $(WXDIR)/src/x; $(MAKE) -f makefile.unx xview - -wxhp: - cd $(WXDIR)/src/x; $(MAKE) -f makefile.unx hp - -# For SGI, include -lPW on your LDLIBS -motif: wxmotif - $(MAKE) -f makefile.unx all GUISUFFIX=_motif GUI=-Dwx_motif GUISUFFIX=_motif OPT='$(OPT)' LDLIBS='$(MOTIFLDLIBS)' WXLIB=$(WXDIR)/lib/libwx_motif.a OPTIONS='$(OPTIONS)' DEBUG='$(DEBUG)' WARN='$(WARN)' XLIB='$(XLIB)' XINCLUDE='$(XINCLUDE)' XVIEW_LINK= - -xview: wxxview - $(MAKE) -f makefile.unx GUI=-Dwx_xview GUISUFFIX=_ol CC=$(CC) OPTIONS='$(OPTIONS)' DEBUG='$(DEBUG)' WARN='$(WARN)' XLIB='$(XLIB)' XINCLUDE='$(XINCLUDE)' LDLIBS='$(XVIEWLDLIBS)' - -hp: wxhp - $(MAKE) -f makefile.unx GUI=-Dwx_motif GUISUFFIX=_hp CC=CC OPT='' DEBUG='$(DEBUG)' WARN='-w' \ - XINCLUDE='$(HPXINCLUDE)' \ - XLIB='$(HPXLIB)' \ - XVIEW_LINK='' \ - LDLIBS='$(HPLDLIBS)' - -$(OBJDIR): - mkdir $(OBJDIR) - -resource$(GUISUFFIX): $(OBJDIR)/resource.$(OBJSUFF) $(WXLIB) - $(CC) $(LDFLAGS) -o resource$(GUISUFFIX) $(OBJDIR)/resource.$(OBJSUFF) $(XVIEW_LINK) $(LDLIBS) - -$(OBJDIR)/resource.$(OBJSUFF): resource.$(SRCSUFF) resource.h - $(CC) -c $(CPPFLAGS) -o $@ resource.$(SRCSUFF) - -clean_motif: - $(MAKE) -f makefile.unx GUISUFFIX=_motif cleanany - -clean_ol: - $(MAKE) -f makefile.unx GUISUFFIX=_ol cleanany - -clean_hp: - $(MAKE) -f makefile.unx GUISUFFIX=_hp cleanany - -cleanany: - rm -f $(OBJECTS) resource$(GUISUFFIX) core - -wxclean_ol: - cd $(WXDIR)/src/x; $(MAKE) -f makefile.unx clean_ol - -wxclean_motif: - cd $(WXDIR)/src/x; $(MAKE) -f makefile.unx clean_motif - -wxclean_hp: - cd $(WXDIR)/src/x; $(MAKE) -f makefile.unx clean_hp +include ../../src/makeprog.env diff --git a/samples/sashtest/makefile.unx b/samples/sashtest/makefile.unx new file mode 100644 index 0000000000..1b3cff37d5 --- /dev/null +++ b/samples/sashtest/makefile.unx @@ -0,0 +1,17 @@ +# +# File: makefile.unx +# Author: Julian Smart +# Created: 1998 +# Updated: +# Copyright: (c) 1998 Julian Smart +# +# "%W% %G%" +# +# Makefile for sashtest example (UNIX). + +PROGRAM=sashtest + +OBJECTS=$(PROGRAM).o + +include ../../src/makeprog.env + diff --git a/samples/splitter/makefile.unx b/samples/splitter/makefile.unx new file mode 100644 index 0000000000..49afaf4cdd --- /dev/null +++ b/samples/splitter/makefile.unx @@ -0,0 +1,18 @@ +# +# File: makefile.unx +# Author: Julian Smart +# Created: 1998 +# Updated: +# Copyright: (c) 1998 Julian Smart +# +# "%W% %G%" +# +# Makefile for splitter example (UNIX). + +PROGRAM=test + +OBJECTS=$(PROGRAM).o + +include ../../src/makeprog.env + + diff --git a/samples/tab/makefile.unx b/samples/tab/makefile.unx new file mode 100644 index 0000000000..ad1b7690ec --- /dev/null +++ b/samples/tab/makefile.unx @@ -0,0 +1,17 @@ +# +# File: makefile.unx +# Author: Julian Smart +# Created: 1998 +# Updated: +# Copyright: (c) 1998 Julian Smart +# +# "%W% %G%" +# +# Makefile for tab example (UNIX). + +PROGRAM=tab + +OBJECTS=$(PROGRAM).o + +include ../../src/makeprog.env + diff --git a/samples/toolbar/makefile.unx b/samples/toolbar/makefile.unx new file mode 100644 index 0000000000..0b249d4c88 --- /dev/null +++ b/samples/toolbar/makefile.unx @@ -0,0 +1,18 @@ +# +# File: makefile.unx +# Author: Julian Smart +# Created: 1998 +# Updated: +# Copyright: (c) 1998 Julian Smart +# +# "%W% %G%" +# +# Makefile for toolbar example (UNIX). + +PROGRAM=test + +OBJECTS=$(PROGRAM).o + +include ../../src/makeprog.env + + diff --git a/samples/toolbar/test.cpp b/samples/toolbar/test.cpp index 0274aefac2..9b4b9434e2 100644 --- a/samples/toolbar/test.cpp +++ b/samples/toolbar/test.cpp @@ -23,7 +23,7 @@ #include "wx/toolbar.h" #include "test.h" -#ifdef __WXGTK__ +#if defined(__WXGTK__) || defined(__WXMOTIF__) #include "mondrian.xpm" #include "bitmaps/new.xpm" #include "bitmaps/open.xpm" @@ -125,21 +125,21 @@ bool MyApp::InitToolbar(wxToolBar* toolBar) #endif int currentX = 5; - toolBar->AddTool(wxID_NEW, *(toolBarBitmaps[0]), wxNullBitmap, FALSE, (float)currentX, -1, (wxObject *) NULL, "New file"); + toolBar->AddTool(wxID_NEW, *(toolBarBitmaps[0]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "New file"); currentX += width + 5; - toolBar->AddTool(wxID_OPEN, *(toolBarBitmaps[1]), wxNullBitmap, FALSE, (float)currentX, -1, (wxObject *) NULL, "Open file"); + toolBar->AddTool(wxID_OPEN, *(toolBarBitmaps[1]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Open file"); currentX += width + 5; - toolBar->AddTool(wxID_SAVE, *(toolBarBitmaps[2]), wxNullBitmap, FALSE, (float)currentX, -1, (wxObject *) NULL, "Save file"); + toolBar->AddTool(wxID_SAVE, *(toolBarBitmaps[2]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Save file"); currentX += width + 5; toolBar->AddSeparator(); - toolBar->AddTool(wxID_COPY, *(toolBarBitmaps[3]), wxNullBitmap, FALSE, (float)currentX, -1, (wxObject *) NULL, "Copy"); + toolBar->AddTool(wxID_COPY, *(toolBarBitmaps[3]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Copy"); currentX += width + 5; - toolBar->AddTool(wxID_CUT, *(toolBarBitmaps[4]), wxNullBitmap, FALSE, (float)currentX, -1, (wxObject *) NULL, "Cut"); + toolBar->AddTool(wxID_CUT, *(toolBarBitmaps[4]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Cut"); currentX += width + 5; - toolBar->AddTool(wxID_PASTE, *(toolBarBitmaps[5]), wxNullBitmap, FALSE, (float)currentX, -1, (wxObject *) NULL, "Paste"); + toolBar->AddTool(wxID_PASTE, *(toolBarBitmaps[5]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Paste"); currentX += width + 5; toolBar->AddSeparator(); - toolBar->AddTool(wxID_PRINT, *(toolBarBitmaps[6]), wxNullBitmap, FALSE, (float)currentX, -1, (wxObject *) NULL, "Print"); + toolBar->AddTool(wxID_PRINT, *(toolBarBitmaps[6]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Print"); currentX += width + 5; toolBar->AddSeparator(); toolBar->AddTool(wxID_HELP, *(toolBarBitmaps[7]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Help"); diff --git a/samples/treectrl/makefile.unx b/samples/treectrl/makefile.unx new file mode 100644 index 0000000000..aa0c92a4ad --- /dev/null +++ b/samples/treectrl/makefile.unx @@ -0,0 +1,17 @@ +# +# File: makefile.unx +# Author: Julian Smart +# Created: 1998 +# Updated: +# Copyright: (c) 1998 Julian Smart +# +# "%W% %G%" +# +# Makefile for treectrl example (UNIX). + +PROGRAM=treetest + +OBJECTS=$(PROGRAM).o + +include ../../src/makeprog.env + diff --git a/samples/typetest/makefile.unx b/samples/typetest/makefile.unx new file mode 100644 index 0000000000..44f21e1899 --- /dev/null +++ b/samples/typetest/makefile.unx @@ -0,0 +1,17 @@ +# +# File: makefile.unx +# Author: Julian Smart +# Created: 1998 +# Updated: +# Copyright: (c) 1998 Julian Smart +# +# "%W% %G%" +# +# Makefile for typetest example (UNIX). + +PROGRAM=typetest + +OBJECTS=$(PROGRAM).o + +include ../../src/makeprog.env + diff --git a/src/common/docview.cpp b/src/common/docview.cpp index bbfdf9ab3f..d25ac43c1e 100644 --- a/src/common/docview.cpp +++ b/src/common/docview.cpp @@ -1155,6 +1155,9 @@ wxDocTemplate *wxDocManager::SelectDocumentPath(wxDocTemplate **templates, if (len > 0) // Omit final "|" descrBuf[len-1] = 0; +#else + char* descrBuf = copystring("*.*"); +#endif char *pathTmp = wxFileSelector(_("Select a file"), "", "", "", descrBuf, 0, wxTheApp->GetTopWindow()); delete[] descrBuf; @@ -1177,7 +1180,7 @@ wxDocTemplate *wxDocManager::SelectDocumentPath(wxDocTemplate **templates, path = ""; return (wxDocTemplate *) NULL; } -#else +#if 0 // In all other windowing systems, until we have more advanced // file selectors, we must select the document type (template) first, and // _then_ pop up the file selector. diff --git a/src/common/event.cpp b/src/common/event.cpp index 14278f5373..dd13024c23 100644 --- a/src/common/event.cpp +++ b/src/common/event.cpp @@ -134,6 +134,11 @@ wxMouseEvent::wxMouseEvent(wxEventType commandType) m_altDown = FALSE; m_controlDown = FALSE; m_shiftDown = FALSE; + m_leftDown = FALSE; + m_rightDown = FALSE; + m_middleDown = FALSE; + m_x = 0; + m_y = 0; } // True if was a button dclick event (1 = left, 2 = middle, 3 = right) diff --git a/src/common/prntbase.cpp b/src/common/prntbase.cpp index 46bf2547c7..6a19cf7ea5 100644 --- a/src/common/prntbase.cpp +++ b/src/common/prntbase.cpp @@ -22,7 +22,7 @@ #include "wx/defs.h" -#ifdef __WXMSW__ +#ifndef __WXGTK__ #define __GOOD_COMPILER__ #endif @@ -324,7 +324,7 @@ void wxPreviewControlBar::CreateButtons() #endif wxFont buttonFont(fontSize, wxSWISS, wxNORMAL, wxBOLD); - SetButtonFont(buttonFont); + SetFont(buttonFont); int buttonWidth = 65; int buttonHeight = 24; @@ -359,7 +359,8 @@ void wxPreviewControlBar::CreateButtons() x += gap + buttonWidth; } - static wxString choices[] = { "10%", "20%", "25%", "30%", "35%", "40%", "45%", "50%", "55%", "60%", + // Can't be static because gcc bails out + wxString choices[] = { "10%", "20%", "25%", "30%", "35%", "40%", "45%", "50%", "55%", "60%", "65%", "70%", "75%", "80%", "85%", "90%", "95%", "100%", "110%", "120%", "150%", "200%" }; int n = 22; if (m_buttonFlags & wxPREVIEW_ZOOM) @@ -370,7 +371,7 @@ void wxPreviewControlBar::CreateButtons() } m_closeButton->SetDefault(); - + #endif } @@ -730,14 +731,14 @@ bool wxPrintPreviewBase::DrawBlankPage(wxWindow *canvas, wxDC& dc) int shadowOffset = 4; dc.SetPen(*wxBLACK_PEN); dc.SetBrush(*wxBLACK_BRUSH); - dc.DrawRectangle(x-1 + shadowOffset, y-1 + shadowOffset, actualWidth+2, actualHeight+2); + dc.DrawRectangle((int)(x-1 + shadowOffset), (int)(y-1 + shadowOffset), (int)(actualWidth+2), (int)(actualHeight+2)); // Draw blank page allowing for 1-pixel border AROUND the actual page dc.SetPen(*wxBLACK_PEN); dc.SetBrush(*wxWHITE_BRUSH); - dc.DrawRectangle(x-1, y-1, actualWidth+2, actualHeight+2); + dc.DrawRectangle((int)(x-1), (int)(y-1), (int)(actualWidth+2), (int)(actualHeight+2)); #endif diff --git a/src/generic/treectrl.cpp b/src/generic/treectrl.cpp index 2008aa3fba..c7862e8099 100644 --- a/src/generic/treectrl.cpp +++ b/src/generic/treectrl.cpp @@ -447,8 +447,8 @@ long wxTreeCtrl::InsertItem( long parent, const wxString& label, int image, if (!p->HasChildren()) p->m_hasChildren = TRUE; - int ch = 0; - GetClientSize( (int *) NULL, &ch ); + int cw = 0, ch = 0; + GetClientSize( &cw, &ch ); PrepareDC( dc ); diff --git a/src/make.env b/src/make.env index 874f37ec13..55a9efe36d 100644 --- a/src/make.env +++ b/src/make.env @@ -54,7 +54,7 @@ XLIB = -L/usr/local/X11/lib -L/usr/openwin/lib -L/usr/X11/lib -L/usr/X11R ############################ Libraries ################################ COMPLIBS = -lstdc++ -GUILDLIBS = -lwx_stubs $(COMPLIBS) -lXm -lXmu -lXt -lX11 -lm +GUILDLIBS = -lwx_stubs $(COMPLIBS) -lXm -lXmu -lXt -lXpm -lX11 -lm ############################# Suffixes ################################ @@ -97,10 +97,10 @@ stubs: make -f makefile.unx all GUI='-D__WXSTUBS__ -D__LINUX__ -D__UNIX__' GUISUFFIX='_stubs' GUILDLIBS='-lwx_stubs $(COMPLIBS) -lXm -lXmu -lXt -lX11 -lm' motif: - make -f makefile.unx all GUI='-D__WXMOTIF__ -D__LINUX__ -D__UNIX__' GUISUFFIX='_motif' GUILDLIBS='-lwx_motif $(COMPLIBS) -lXm -lXmu -lXt -lX11 -lm' + make -f makefile.unx all GUI='-D__WXMOTIF__ -D__LINUX__ -D__UNIX__' GUISUFFIX='_motif' GUILDLIBS='-lwx_motif $(COMPLIBS) -lXm -lXmu -lXt -lXpm -lX11 -lm' gtk: - make -f makefile.unx all GUI='-D__WXGTK__ -D__LINUX__ -D__UNIX__' GUISUFFIX='_gtk' GUILDLIBS='-lwx_gtk $(COMPLIBS) -lXm -lXmu -lX11 -lm' + make -f makefile.unx all GUI='-D__WXGTK__ -D__LINUX__ -D__UNIX__' GUISUFFIX='_gtk' GUILDLIBS='-lwx_gtk $(COMPLIBS) -lXm -lXmu -lXpm -lX11 -lm' cleanstubs: make -f makefile.unx clean GUI='-D__WXSTUBS__ -D__LINUX__ -D__UNIX__' GUISUFFIX='_stubs' GUILDLIBS='-lwx_stubs $(COMPLIBS) -lXm -lXmu -lXt -lX11 -lm' diff --git a/src/motif/bitmap.cpp b/src/motif/bitmap.cpp index 58b53da7f7..237b73924e 100644 --- a/src/motif/bitmap.cpp +++ b/src/motif/bitmap.cpp @@ -19,13 +19,14 @@ #include "wx/bitmap.h" #include "wx/icon.h" #include "wx/log.h" +#include "wx/control.h" #include #include "wx/motif/private.h" // TODO: correct symbol, path? -#if USE_XPM +#if wxUSE_XPM #include #endif @@ -152,7 +153,7 @@ wxBitmap::wxBitmap(const wxString& filename, long type) // Create from XPM data static wxControl* sg_Control = NULL; -wxBitmap::wxBitmap(const char **data, wxControl* control) +wxBitmap::wxBitmap(char **data, wxControl* control) { // Pass the control to the Create function using a global sg_Control = control; @@ -573,7 +574,7 @@ bool wxXBMDataHandler::Create(wxBitmap *bitmap, void *data, long flags, int widt return TRUE; } -#if USE_XPM +#if wxUSE_XPM class WXDLLEXPORT wxXPMFileHandler: public wxBitmapHandler { DECLARE_DYNAMIC_CLASS(wxXPMFileHandler) @@ -595,7 +596,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxXPMFileHandler, wxBitmapHandler) bool wxXPMFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags, int desiredWidth, int desiredHeight) { - Display *dpy = wxGetDisplay(); + Display *dpy = (Display*) wxGetDisplay(); M_BITMAPHANDLERDATA->m_display = (WXDisplay*) dpy; XpmAttributes xpmAttr; @@ -633,6 +634,7 @@ bool wxXPMFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long fla XpmFreeAttributes(&xpmAttr); M_BITMAPHANDLERDATA->m_ok = TRUE; + return TRUE; } else { // XpmDebugError(errorStatus, name); @@ -663,7 +665,7 @@ class WXDLLEXPORT wxXPMDataHandler: public wxBitmapHandler { DECLARE_DYNAMIC_CLASS(wxXPMDataHandler) public: - inline wxXBMDataHandler() + inline wxXPMDataHandler() { m_name = "XPM data"; m_extension = "xpm"; @@ -681,7 +683,7 @@ bool wxXPMDataHandler::Create(wxBitmap *bitmap, void *data, long flags, int widt M_BITMAPHANDLERDATA->m_depth = 1; M_BITMAPHANDLERDATA->m_freePixmap = TRUE; - Display *dpy = wxGetDisplay(); + Display *dpy = (Display*) wxGetDisplay(); M_BITMAPHANDLERDATA->m_display = (WXDisplay*) dpy; XpmAttributes xpmAttr; @@ -760,7 +762,7 @@ void wxBitmap::InitStandardHandlers() // XPM is considered standard for Moif, although it can be omitted if absolutely // necessary. -#if USE_XPM +#if wxUSE_XPM AddHandler(new wxXPMFileHandler); AddHandler(new wxXPMDataHandler); #endif diff --git a/src/motif/bmpbuttn.cpp b/src/motif/bmpbuttn.cpp index fa758ff084..de4f6201b3 100644 --- a/src/motif/bmpbuttn.cpp +++ b/src/motif/bmpbuttn.cpp @@ -15,10 +15,26 @@ #include "wx/bmpbuttn.h" +#include +#include + +#include "wx/motif/private.h" + +// Implemented in button.cpp +void wxButtonCallback (Widget w, XtPointer clientData, XtPointer ptr); + +Pixmap XCreateInsensitivePixmap( Display *display, Pixmap pixmap ); + #if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton, wxButton) #endif +wxBitmapButton::wxBitmapButton() +{ + m_marginX = wxDEFAULT_BUTTON_MARGIN; m_marginY = wxDEFAULT_BUTTON_MARGIN; + m_insensPixmap = (WXPixmap) 0; +} + bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap, const wxPoint& pos, const wxSize& size, long style, @@ -46,20 +62,134 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit else m_windowId = id; - if ( width == -1 && bitmap.Ok()) - width = bitmap.GetWidth() + 2*m_marginX; + Widget parentWidget = (Widget) parent->GetClientWidget(); + + /* + * Patch Note (important) + * There is no major reason to put a defaultButtonThickness here. + * Not requesting it give the ability to put wxButton with a spacing + * as small as requested. However, if some button become a DefaultButton, + * other buttons are no more aligned -- This is why we set + * defaultButtonThickness of ALL buttons belonging to the same wxPanel, + * in the ::SetDefaultButton method. + */ + Widget buttonWidget = XtVaCreateManagedWidget ("button", + + // Gadget causes problems for default button operation. +#if wxUSE_GADGETS + xmPushButtonGadgetClass, parentWidget, +#else + xmPushButtonWidgetClass, parentWidget, +#endif +// XmNdefaultButtonShadowThickness, 1, // See comment for wxButton::SetDefault + NULL); + + m_mainWidget = (WXWidget) buttonWidget; + + if (bitmap.Ok()) + { + Pixmap p1, p2; + + p1 = (Pixmap) ((wxBitmap&)bitmap).GetLabelPixmap(m_mainWidget); + p2 = (Pixmap) ((wxBitmap&)bitmap).GetInsensPixmap(m_mainWidget); + + if(p1 == p2) // <- the Get...Pixmap()-functions return the same pixmap! + { + p2 = + XCreateInsensitivePixmap(DisplayOfScreen(XtScreen(buttonWidget)), p1); + m_insensPixmap = (WXPixmap) p2; + } + + XtVaSetValues (buttonWidget, + XmNlabelPixmap, p1, + XmNlabelInsensitivePixmap, p2, + XmNarmPixmap, (Pixmap) ((wxBitmap&)bitmap).GetArmPixmap (m_mainWidget), + XmNlabelType, XmPIXMAP, + NULL); + } + + XtAddCallback (buttonWidget, XmNactivateCallback, (XtCallbackProc) wxButtonCallback, + (XtPointer) this); + + SetCanAddEventHandler(TRUE); + AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y); + + SetFont(* parent->GetFont()); - if ( height == -1 && bitmap.Ok()) - height = bitmap.GetHeight() + 2*m_marginY; + ChangeColour (m_mainWidget); - /* TODO: create bitmap button - */ - return FALSE; + return TRUE; +} + +wxBitmapButton::~wxBitmapButton() +{ + SetBitmapLabel(wxNullBitmap); + + if (m_insensPixmap) + XmDestroyPixmap (DefaultScreenOfDisplay ((Display*) GetXDisplay()), (Pixmap) m_insensPixmap); } void wxBitmapButton::SetBitmapLabel(const wxBitmap& bitmap) { m_buttonBitmap = bitmap; + + if (bitmap.Ok()) + { + Pixmap labelPixmap, insensPixmap, armPixmap; + + labelPixmap = (Pixmap) ((wxBitmap&)bitmap).GetLabelPixmap(m_mainWidget); + + if (m_buttonBitmapSelected.Ok()) + armPixmap = (Pixmap) m_buttonBitmapSelected.GetLabelPixmap(m_mainWidget); + else + armPixmap = (Pixmap) ((wxBitmap&)bitmap).GetArmPixmap(m_mainWidget); + + if (m_buttonBitmapDisabled.Ok()) + insensPixmap = (Pixmap) m_buttonBitmapDisabled.GetLabelPixmap(m_mainWidget); + else + insensPixmap = (Pixmap) ((wxBitmap&)bitmap).GetInsensPixmap(m_mainWidget); + + if (!insensPixmap || (insensPixmap == labelPixmap)) // <- the Get...Pixmap()-functions return the same pixmap! + { + insensPixmap = XCreateInsensitivePixmap(DisplayOfScreen(XtScreen((Widget) m_mainWidget)), labelPixmap); + m_insensPixmap = (WXPixmap) insensPixmap; + } + + XtVaSetValues ((Widget) m_mainWidget, + XmNlabelPixmap, labelPixmap, + XmNlabelInsensitivePixmap, insensPixmap, + XmNarmPixmap, armPixmap, + XmNlabelType, XmPIXMAP, + NULL); + } + else + { + // Null bitmap: must not use current pixmap + // since it is no longer valid. + XtVaSetValues ((Widget) m_mainWidget, + XmNlabelType, XmSTRING, + XmNlabelPixmap, NULL, // TODO: Does this work? + XmNlabelInsensitivePixmap, NULL, + XmNarmPixmap, NULL, + NULL); + } } +void wxBitmapButton::SetBitmapSelected(const wxBitmap& sel) +{ + m_buttonBitmapSelected = sel; +}; + +void wxBitmapButton::SetBitmapFocus(const wxBitmap& focus) +{ + m_buttonBitmapFocus = focus; + // Not used in Motif +}; + +void wxBitmapButton::SetBitmapDisabled(const wxBitmap& disabled) +{ + m_buttonBitmapDisabled = disabled; +}; + + diff --git a/src/motif/checkbox.cpp b/src/motif/checkbox.cpp index 4f2330ab32..c71ed1a5ab 100644 --- a/src/motif/checkbox.cpp +++ b/src/motif/checkbox.cpp @@ -75,10 +75,9 @@ bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, void wxCheckBox::SetValue(bool val) { - // TODO: m_inSetValue - // inSetValue = TRUE; + m_inSetValue = TRUE; XmToggleButtonSetState ((Widget) m_mainWidget, (Boolean) val, TRUE); - // inSetValue = FALSE; + m_inSetValue = FALSE; } bool wxCheckBox::GetValue() const @@ -140,9 +139,9 @@ void wxCheckBoxCallback (Widget w, XtPointer clientData, XtPointer ptr) { wxCheckBox *item = (wxCheckBox *) clientData; - // TODO - // if (item->inSetValue) - // return; + + if (item->InSetValue()) + return; wxCommandEvent event (wxEVT_COMMAND_CHECKBOX_CLICKED, item->GetId()); event.SetInt((int) item->GetValue ()); diff --git a/src/motif/choice.cpp b/src/motif/choice.cpp index 7012c75c0f..4c2f903f86 100644 --- a/src/motif/choice.cpp +++ b/src/motif/choice.cpp @@ -38,7 +38,6 @@ wxChoice::wxChoice() m_menuWidget = (WXWidget) 0; m_widgetList = (WXWidget*) 0; m_formWidget = (WXWidget) 0; - m_inSetValue = FALSE; } bool wxChoice::Create(wxWindow *parent, wxWindowID id, @@ -57,7 +56,6 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id, m_menuWidget = (WXWidget) 0; m_widgetList = (WXWidget*) 0; m_formWidget = (WXWidget) 0; - m_inSetValue = FALSE; if (parent) parent->AddChild(this); @@ -402,7 +400,7 @@ void wxChoiceCallback (Widget w, XtPointer clientData, wxChoice *item = (wxChoice *) clientData; if (item) { - if (item->m_inSetValue) + if (item->InSetValue()) return; char *s = NULL; diff --git a/src/motif/control.cpp b/src/motif/control.cpp index 4e708a5c14..64369b26d2 100644 --- a/src/motif/control.cpp +++ b/src/motif/control.cpp @@ -31,6 +31,7 @@ wxControl::wxControl() m_backgroundColour = *wxWHITE; m_foregroundColour = *wxBLACK; m_callback = 0; + m_inSetValue = FALSE; } wxControl::~wxControl() @@ -47,41 +48,43 @@ wxControl::~wxControl() void wxControl::SetLabel(const wxString& label) { - if (!GetMainWidget()) - return; + Widget widget = (Widget) GetLabelWidget() ; + if (!widget) + return; - wxStripMenuCodes((char*) (const char*) label, wxBuffer); + wxStripMenuCodes((char*) (const char*) label, wxBuffer); - XmString text = XmStringCreateSimple (wxBuffer); - XtVaSetValues ((Widget) GetMainWidget(), - XmNlabelString, text, - XmNlabelType, XmSTRING, + XmString text = XmStringCreateSimple (wxBuffer); + XtVaSetValues (widget, + XmNlabelString, text, + XmNlabelType, XmSTRING, NULL); - XmStringFree (text); + XmStringFree (text); } wxString wxControl::GetLabel() const { - if (!GetMainWidget()) - return wxEmptyString; + Widget widget = (Widget) GetLabelWidget() ; + if (!widget) + return wxEmptyString; - XmString text; - char *s; - XtVaGetValues ((Widget) GetMainWidget(), + XmString text; + char *s; + XtVaGetValues (widget, XmNlabelString, &text, NULL); - if (XmStringGetLtoR (text, XmSTRING_DEFAULT_CHARSET, &s)) + if (XmStringGetLtoR (text, XmSTRING_DEFAULT_CHARSET, &s)) { - wxString str(s); - XtFree (s); - XmStringFree(text); - return str; + wxString str(s); + XtFree (s); + XmStringFree(text); + return str; } - else + else { - XmStringFree(text); - return wxEmptyString; + XmStringFree(text); + return wxEmptyString; } } diff --git a/src/motif/dcclient.cpp b/src/motif/dcclient.cpp index 1a9b9abb6a..8054aec456 100644 --- a/src/motif/dcclient.cpp +++ b/src/motif/dcclient.cpp @@ -146,7 +146,7 @@ wxWindowDC::wxWindowDC( wxWindow *window ) wxWindowDC::~wxWindowDC(void) { - if ((m_oldFont != (WXFont) 0) && ((long) m_oldFont != -1)) + if (m_gc && (m_oldFont != (WXFont) 0) && ((long) m_oldFont != -1)) { XSetFont ((Display*) m_display, (GC) m_gc, (Font) m_oldFont); diff --git a/src/motif/dcmemory.cpp b/src/motif/dcmemory.cpp index 6c58af617f..c27c9a22e4 100644 --- a/src/motif/dcmemory.cpp +++ b/src/motif/dcmemory.cpp @@ -14,6 +14,11 @@ #endif #include "wx/dcmemory.h" +#include "wx/utils.h" + +#include + +#include "wx/motif/private.h" //----------------------------------------------------------------------------- // wxMemoryDC @@ -23,12 +28,57 @@ IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC, wxWindowDC) wxMemoryDC::wxMemoryDC(void) { - m_ok = FALSE; + m_ok = TRUE; + m_display = wxGetDisplay(); + + Display* display = (Display*) m_display; + + XGCValues gcvalues; + gcvalues.foreground = BlackPixel (display, DefaultScreen (display)); + gcvalues.background = WhitePixel (display, DefaultScreen (display)); + gcvalues.graphics_exposures = False; + gcvalues.line_width = 1; + m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)), + GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth, + &gcvalues); + + m_backgroundPixel = (int) gcvalues.background; + + // Get the current Font so we can set it back later + XGCValues valReturn; + XGetGCValues((Display*) m_display, (GC) m_gc, GCFont, &valReturn); + m_oldFont = (WXFont) valReturn.font; + SetBrush (wxWHITE_BRUSH); + SetPen (wxBLACK_PEN); }; -wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) ) +wxMemoryDC::wxMemoryDC( wxDC* dc ) { - m_ok = FALSE; + m_ok = TRUE; + if (dc && dc->IsKindOf(CLASSINFO(wxWindowDC))) + m_display = ((wxWindowDC*)dc)->GetDisplay(); + else + m_display = wxGetDisplay(); + + Display* display = (Display*) m_display; + + XGCValues gcvalues; + gcvalues.foreground = BlackPixel (display, DefaultScreen (display)); + gcvalues.background = WhitePixel (display, DefaultScreen (display)); + gcvalues.graphics_exposures = False; + gcvalues.line_width = 1; + m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)), + GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth, + &gcvalues); + + m_backgroundPixel = (int) gcvalues.background; + + // Get the current Font so we can set it back later + XGCValues valReturn; + XGetGCValues((Display*) m_display, (GC) m_gc, GCFont, &valReturn); + m_oldFont = (WXFont) valReturn.font; + SetBrush (wxWHITE_BRUSH); + SetPen (wxBLACK_PEN); }; wxMemoryDC::~wxMemoryDC(void) @@ -38,13 +88,46 @@ wxMemoryDC::~wxMemoryDC(void) void wxMemoryDC::SelectObject( const wxBitmap& bitmap ) { m_bitmap = bitmap; - if (m_bitmap.Ok()) + + if (m_gc) + XFreeGC((Display*) m_display, (GC) m_gc); + m_gc = (WXGC) NULL; + + if (m_bitmap.Ok() && (bitmap.GetDisplay() == m_display)) { m_pixmap = m_bitmap.GetPixmap(); + Display* display = (Display*) m_display; + + XGCValues gcvalues; + gcvalues.foreground = BlackPixel (display, DefaultScreen (display)); + gcvalues.background = WhitePixel (display, DefaultScreen (display)); + gcvalues.graphics_exposures = False; + gcvalues.line_width = 1; + m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)), + GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth, + &gcvalues); + + m_backgroundPixel = (int) gcvalues.background; + + // Get the current Font so we can set it back later + XGCValues valReturn; + XGetGCValues((Display*) m_display, (GC) m_gc, GCFont, &valReturn); + m_oldFont = (WXFont) valReturn.font; + + bool oldOpt = GetOptimization(); + SetOptimization(FALSE); + + SetBrush (wxWHITE_BRUSH); + SetPen (wxBLACK_PEN); + + SetOptimization(oldOpt); + + m_ok = TRUE; } else { m_ok = FALSE; + m_pixmap = (WXPixmap) 0; }; }; diff --git a/src/motif/dialog.cpp b/src/motif/dialog.cpp index 2d0606b265..8154065c11 100644 --- a/src/motif/dialog.cpp +++ b/src/motif/dialog.cpp @@ -280,10 +280,16 @@ wxDialog::~wxDialog() // Now process all events, because otherwise // this might remain on the screen. - XSync(XtDisplay(XtParent((Widget) m_mainWidget)), FALSE); + Display* display; + if (m_mainWidget) + display = XtDisplay((Widget) m_mainWidget); + else + display = (Display*) wxGetDisplay(); + + XSync(display, FALSE); XEvent event; while (XtAppPending((XtAppContext) wxTheApp->GetAppContext())) { - XFlush(XtDisplay((Widget) XtParent((Widget) m_mainWidget))); + XFlush(display); XtAppNextEvent((XtAppContext) wxTheApp->GetAppContext(), &event); XtDispatchEvent(&event); } diff --git a/src/motif/frame.cpp b/src/motif/frame.cpp index c3222764ab..16be1d39c3 100644 --- a/src/motif/frame.cpp +++ b/src/motif/frame.cpp @@ -348,7 +348,16 @@ void wxFrame::GetClientSize(int *x, int *y) const m_frameStatusBar->GetSize(& sbw, & sbh); yy -= sbh; } - + if (m_frameToolBar) + { + int tbw, tbh; + m_frameToolBar->GetSize(& tbw, & tbh); + if (m_frameToolBar->GetWindowStyleFlag() & wxTB_VERTICAL) + xx -= tbw; + else + yy -= tbh; + } +/* if (GetMenuBar() != (wxMenuBar*) NULL) { // it seems that if a frame holds a panel, the menu bar size @@ -368,6 +377,7 @@ void wxFrame::GetClientSize(int *x, int *y) const yy -= ys; } } + */ *x = xx; *y = yy; } @@ -384,14 +394,22 @@ void wxFrame::SetClientSize(int width, int height) if (height > -1) { - /* TODO - if (status_line_exists) + if (m_frameStatusBar) { - Dimension ys; - XtVaGetValues(statusLineWidget, XmNheight, &ys, NULL); - height += ys; + int sbw, sbh; + m_frameStatusBar->GetSize(& sbw, & sbh); + height += sbh; } - */ + if (m_frameToolBar) + { + int tbw, tbh; + m_frameToolBar->GetSize(& tbw, & tbh); + if (m_frameToolBar->GetWindowStyleFlag() & wxTB_VERTICAL) + width += tbw; + else + height += tbh; + } + XtVaSetValues((Widget) m_workArea, XmNheight, height, NULL); } PreResize(); @@ -875,26 +893,15 @@ wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& nam wxToolBar* wxFrame::OnCreateToolBar(long style, wxWindowID id, const wxString& name) { - return new wxToolBar(this, id, wxDefaultPosition, wxDefaultSize, style, name); + return new wxToolBar(this, id, wxPoint(0, 0), wxSize(100, 24), style, name); } void wxFrame::PositionToolBar() { int cw, ch; - // TODO: we actually need to use the low-level client size, before - // the toolbar/status bar were added. - // So DEFINITELY replace the line below with something appropriate. - GetClientSize(& cw, &ch); - if ( GetStatusBar() ) - { - int statusX, statusY; - GetStatusBar()->GetClientSize(&statusX, &statusY); - ch -= statusY; - } - if (GetToolBar()) { int tw, th; @@ -905,7 +912,7 @@ void wxFrame::PositionToolBar() // Use the 'real' position. wxSIZE_NO_ADJUSTMENTS // means, pretend we don't have toolbar/status bar, so we // have the original client size. - GetToolBar()->SetSize(0, 0, tw, ch, wxSIZE_NO_ADJUSTMENTS); + GetToolBar()->SetSize(0, 0, tw, ch + th, wxSIZE_NO_ADJUSTMENTS); } else { @@ -1013,6 +1020,7 @@ static void wxFrameMapProc(Widget frameShell, XtPointer clientData, //// Motif-specific bool wxFrame::PreResize() { + PositionToolBar(); PositionStatusBar(); return TRUE; } diff --git a/src/motif/icon.cpp b/src/motif/icon.cpp index 0f3ff04a64..8a46da1412 100644 --- a/src/motif/icon.cpp +++ b/src/motif/icon.cpp @@ -40,7 +40,7 @@ wxIcon::wxIcon(const char bits[], int width, int height) } // Create from XPM data -wxIcon::wxIcon(const char **data) +wxIcon::wxIcon(char **data) { (void) Create((void*) data, wxBITMAP_TYPE_XPM_DATA, 0, 0, 0); } diff --git a/src/motif/listbox.cpp b/src/motif/listbox.cpp index 7425164595..8bf509bbbe 100644 --- a/src/motif/listbox.cpp +++ b/src/motif/listbox.cpp @@ -40,7 +40,6 @@ wxListBox::wxListBox(): m_clientDataList(wxKEY_INTEGER) { m_noItems = 0; m_selected = 0; - m_inSetValue = FALSE; } bool wxListBox::Create(wxWindow *parent, wxWindowID id, @@ -51,7 +50,6 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, const wxValidator& validator, const wxString& name) { - m_inSetValue = FALSE; m_windowStyle = style; m_noItems = n; m_selected = 0; @@ -86,6 +84,8 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, m_mainWidget = (WXWidget) listWidget; + Set(n, choices); + XtManageChild (listWidget); long width = size.x; @@ -434,6 +434,8 @@ void wxListBox::SetClientData(int N, char *Client_data) wxNode *node = m_clientDataList.Find ((long) N); if (node) node->SetData ((wxObject *)Client_data); + else + node = m_clientDataList.Append((long) N, (wxObject*) Client_data); } // Return number of selections and an array of selected integers @@ -681,7 +683,7 @@ void wxListBoxCallback (Widget w, XtPointer clientData, wxListBox *item = (wxListBox *) clientData; - if (item->m_inSetValue) + if (item->InSetValue()) return; wxCommandEvent event (wxEVT_COMMAND_LISTBOX_SELECTED); diff --git a/src/motif/radiobox.cpp b/src/motif/radiobox.cpp index ee9c66c2dd..9720e0ff9e 100644 --- a/src/motif/radiobox.cpp +++ b/src/motif/radiobox.cpp @@ -14,6 +14,19 @@ #endif #include "wx/radiobox.h" +#include "wx/utils.h" + +#include +#include +#include +#include +#include +#include + +#include + +void wxRadioBoxCallback (Widget w, XtPointer clientData, + XmToggleButtonCallbackStruct * cbs); #if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxRadioBox, wxControl) @@ -26,6 +39,11 @@ wxRadioBox::wxRadioBox() m_noItems = 0; m_noRowsOrCols = 0; m_majorDim = 0 ; + + m_formWidget = (WXWidget) 0; + m_labelWidget = (WXWidget) 0; + m_radioButtons = (WXWidget*) NULL; + m_radioButtonLabels = (wxString*) NULL; } bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title, @@ -36,6 +54,9 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title, { m_selectedButton = -1; m_noItems = n; + m_labelWidget = (WXWidget) 0; + m_radioButtons = (WXWidget*) NULL; + m_radioButtonLabels = (wxString*) NULL; SetName(name); SetValidator(val); @@ -56,31 +77,168 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title, else m_majorDim = majorDim ; + Widget parentWidget = (Widget) parent->GetClientWidget(); + + wxString label1(wxStripMenuCodes(title)); + + XmString text = XmStringCreateSimple ((char*) (const char*) label1); + + Widget formWidget = XtVaCreateManagedWidget ((char*) (const char*) name, + xmFormWidgetClass, parentWidget, + XmNmarginHeight, 0, + XmNmarginWidth, 0, + NULL); + + m_formWidget = (WXWidget) formWidget; + + if (label1 != "") + { + text = XmStringCreateSimple ((char*) (const char*) label1); + Widget labelWidget = XtVaCreateManagedWidget ((char*) (const char*) label1, +#if wxUSE_GADGETS + style & wxCOLOURED ? + xmLabelWidgetClass : xmLabelGadgetClass, + formWidget, +#else + xmLabelWidgetClass, formWidget, +#endif + XmNlabelString, text, + NULL); + +/* TODO: change label font + if (labelFont) + XtVaSetValues (labelWidget, + XmNfontList, labelFont->GetInternalFont (XtDisplay(formWidget)), + NULL); +*/ + + XmStringFree (text); + } + + Arg args[3]; + + majorDim = (n + majorDim - 1) / majorDim; + + XtSetArg (args[0], XmNorientation, ((style & wxHORIZONTAL) == wxHORIZONTAL ? + XmHORIZONTAL : XmVERTICAL)); + XtSetArg (args[1], XmNnumColumns, majorDim); + + Widget radioBoxWidget = XmCreateRadioBox (formWidget, "radioBoxWidget", args, 2); + m_mainWidget = (WXWidget) radioBoxWidget; - // TODO create radiobox - return FALSE; + + if (m_labelWidget) + XtVaSetValues ((Widget) m_labelWidget, + XmNtopAttachment, XmATTACH_FORM, + XmNleftAttachment, XmATTACH_FORM, + XmNalignment, XmALIGNMENT_BEGINNING, + NULL); + + XtVaSetValues (radioBoxWidget, + XmNtopAttachment, m_labelWidget ? XmATTACH_WIDGET : XmATTACH_FORM, + XmNtopWidget, m_labelWidget ? (Widget) m_labelWidget : formWidget, + XmNbottomAttachment, XmATTACH_FORM, + XmNleftAttachment, XmATTACH_FORM, + NULL); + + // if (style & wxFLAT) + // XtVaSetValues (radioBoxWidget, XmNborderWidth, 1, NULL); + + m_radioButtons = new WXWidget[n]; + m_radioButtonLabels = new wxString[n]; + int i; + for (i = 0; i < n; i++) + { + wxString str(wxStripMenuCodes(choices[i])); + m_radioButtonLabels[i] = str; + m_radioButtons[i] = (WXWidget) XtVaCreateManagedWidget ((char*) (const char*) str, +#if wxUSE_GADGETS + xmToggleButtonGadgetClass, radioBoxWidget, +#else + xmToggleButtonWidgetClass, radioBoxWidget, +#endif + NULL); + XtAddCallback ((Widget) m_radioButtons[i], XmNvalueChangedCallback, (XtCallbackProc) wxRadioBoxCallback, + (XtCallbackProc) this); + +/* TODO: set font + if (buttonFont) + XtVaSetValues ((Widget) m_radioButtons[i], + XmNfontList, buttonFont->GetInternalFont (XtDisplay(formWidget)), + NULL); +*/ + } + SetSelection (0); + + XtManageChild (radioBoxWidget); + + SetCanAddEventHandler(TRUE); + AttachWidget (parent, m_mainWidget, m_formWidget, pos.x, pos.y, size.x, size.y); + + SetFont(* parent->GetFont()); + ChangeColour(m_mainWidget); + + return TRUE; } wxRadioBox::~wxRadioBox() { - // TODO + delete[] m_radioButtonLabels; + delete[] m_radioButtons; } wxString wxRadioBox::GetLabel(int item) const { - // TODO - return wxString(""); + if (item < 0 || item >= m_noItems) + return wxEmptyString; + + Widget widget = (Widget) m_radioButtons[item]; + XmString text; + char *s; + XtVaGetValues (widget, + XmNlabelString, &text, + NULL); + + if (XmStringGetLtoR (text, XmSTRING_DEFAULT_CHARSET, &s)) + { + // Should we free 'text'??? + XmStringFree(text); + wxString str(s); + XtFree (s); + return str; + } + else + { + XmStringFree(text); + return wxEmptyString; + } } void wxRadioBox::SetLabel(int item, const wxString& label) { - // TODO + if (item < 0 || item >= m_noItems) + return; + + Widget widget = (Widget) m_radioButtons[item]; + if (label != "") + { + wxString label1(wxStripMenuCodes(label)); + XmString text = XmStringCreateSimple ((char*) (const char*) label1); + XtVaSetValues (widget, + XmNlabelString, text, + XmNlabelType, XmSTRING, + NULL); + XmStringFree (text); + } } int wxRadioBox::FindString(const wxString& s) const { - // TODO + int i; + for (i = 0; i < m_noItems; i++) + if (s == m_radioButtonLabels[i]) + return i; return -1; } @@ -88,9 +246,19 @@ void wxRadioBox::SetSelection(int n) { if ((n < 0) || (n >= m_noItems)) return; - // TODO m_selectedButton = n; + + m_inSetValue = TRUE; + + XmToggleButtonSetState ((Widget) m_radioButtons[n], TRUE, FALSE); + + int i; + for (i = 0; i < m_noItems; i++) + if (i != n) + XmToggleButtonSetState ((Widget) m_radioButtons[i], FALSE, FALSE); + + m_inSetValue = FALSE; } // Get single selection, for single choice list items @@ -102,51 +270,56 @@ int wxRadioBox::GetSelection() const // Find string for position wxString wxRadioBox::GetString(int n) const { - // TODO - return wxString(""); + if ((n < 0) || (n >= m_noItems)) + return wxEmptyString; + return m_radioButtonLabels[n]; } void wxRadioBox::SetSize(int x, int y, int width, int height, int sizeFlags) { - // TODO -} + bool managed = XtIsManaged((Widget) m_formWidget); -void wxRadioBox::GetSize(int *width, int *height) const -{ - // TODO -} + if (managed) + XtUnmanageChild ((Widget) m_formWidget); -void wxRadioBox::GetPosition(int *x, int *y) const -{ - // TODO -} + int xx = x; int yy = y; + AdjustForParentClientOrigin(xx, yy, sizeFlags); -wxString wxRadioBox::GetLabel() const -{ - // TODO - return wxString(""); -} + if (x > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) + XtVaSetValues ((Widget) m_formWidget, XmNleftAttachment, XmATTACH_SELF, + XmNx, xx, NULL); + if (y > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) + XtVaSetValues ((Widget) m_formWidget, XmNtopAttachment, XmATTACH_SELF, + XmNy, yy, NULL); -void wxRadioBox::SetLabel(const wxString& label) -{ - // TODO -} + // Must set the actual RadioBox to be desired size MINUS label size + Dimension labelWidth = 0, labelHeight = 0, actualWidth = 0, actualHeight = 0; -void wxRadioBox::SetFocus() -{ - // TODO -} + if (m_labelWidget) + XtVaGetValues ((Widget) m_labelWidget, XmNwidth, &labelWidth, XmNheight, &labelHeight, NULL); -bool wxRadioBox::Show(bool show) -{ - // TODO - return FALSE; + actualWidth = width; + actualHeight = height - labelHeight; + + if (width > -1) + { + XtVaSetValues ((Widget) m_mainWidget, XmNwidth, actualWidth, NULL); + } + if (height > -1) + { + XtVaSetValues ((Widget) m_mainWidget, XmNheight, actualHeight, NULL); + } + if (managed) + XtManageChild ((Widget) m_formWidget); } // Enable a specific button -void wxRadioBox::Enable(int item, bool enable) +void wxRadioBox::Enable(int n, bool enable) { - // TODO + if ((n < 0) || (n >= m_noItems)) + return; + + XtSetSensitive ((Widget) m_radioButtons[n], (Boolean) enable); } // Enable all controls @@ -154,13 +327,38 @@ void wxRadioBox::Enable(bool enable) { wxControl::Enable(enable); - // TODO + int i; + for (i = 0; i < m_noItems; i++) + XtSetSensitive ((Widget) m_radioButtons[i], (Boolean) enable); } // Show a specific button -void wxRadioBox::Show(int item, bool show) +void wxRadioBox::Show(int n, bool show) { - // TODO + // This method isn't complete, and we try do do our best... + // It's main purpose isn't for allowing Show/Unshow dynamically, + // but rather to provide a way to design wxRadioBox such: + // + // o Val1 o Val2 o Val3 + // o Val4 o Val6 + // o Val7 o Val8 o Val9 + // + // In my case, this is a 'direction' box, and the Show(5,False) is + // coupled with an Enable(5,False) + // + if ((n < 0) || (n >= m_noItems)) + return; + + XtVaSetValues ((Widget) m_radioButtons[n], + XmNindicatorOn, (unsigned char) show, + NULL); + + // Please note that this is all we can do: removing the label + // if switching to unshow state. However, when switching + // to the on state, it's the prog. resp. to call SetLabel(item,...) + // after this call!! + if (!show) + wxRadioBox::SetLabel (n, " "); } // For single selection items only @@ -191,4 +389,26 @@ void wxRadioBox::Command (wxCommandEvent & event) ProcessCommand (event); } +void wxRadioBoxCallback (Widget w, XtPointer clientData, + XmToggleButtonCallbackStruct * cbs) +{ + if (!cbs->set) + return; + + wxRadioBox *item = (wxRadioBox *) clientData; + int sel = -1; + int i; + for (i = 0; i < item->Number(); i++) + if (item->GetRadioButtons() && ((Widget) (item->GetRadioButtons()[i]) == w)) + sel = i; + item->SetSel(sel); + + if (item->InSetValue()) + return; + + wxCommandEvent event (wxEVT_COMMAND_RADIOBOX_SELECTED, item->GetId()); + event.m_commandInt = sel; + event.SetEventObject(item); + item->ProcessCommand (event); +} diff --git a/src/motif/radiobut.cpp b/src/motif/radiobut.cpp index 31c7504715..29223c6d9a 100644 --- a/src/motif/radiobut.cpp +++ b/src/motif/radiobut.cpp @@ -14,11 +14,30 @@ #endif #include "wx/radiobut.h" +#include "wx/utils.h" + +#include +#include +#include +#include +#include +#include + +#include + +void wxRadioButtonCallback (Widget w, XtPointer clientData, + XmToggleButtonCallbackStruct * cbs); #if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxRadioButton, wxControl) #endif +wxRadioButton::wxRadioButton() +{ + m_labelWidget = (WXWidget) 0; + m_formWidget = (WXWidget) 0; +} + bool wxRadioButton::Create(wxWindow *parent, wxWindowID id, const wxString& label, const wxPoint& pos, @@ -38,25 +57,95 @@ bool wxRadioButton::Create(wxWindow *parent, wxWindowID id, m_windowStyle = style ; - // TODO create radiobutton - return FALSE; -} + Widget parentWidget = (Widget) parent->GetClientWidget(); -void wxRadioButton::SetLabel(const wxString& label) -{ - // TODO + wxString label1(wxStripMenuCodes(label)); + + XmString text = XmStringCreateSimple ((char*) (const char*) label1); + + Widget formWidget = XtVaCreateManagedWidget ((char*) (const char*) name, + xmFormWidgetClass, parentWidget, + XmNmarginHeight, 0, + XmNmarginWidth, 0, + NULL); + + m_formWidget = (WXWidget) formWidget; + + Widget labelWidget = XtVaCreateManagedWidget ((char*) (const char*) label1, +#if wxUSE_GADGETS + xmLabelGadgetClass, + formWidget, +#else + xmLabelWidgetClass, formWidget, +#endif + XmNlabelString, text, + NULL); + m_labelWidget = (WXWidget) labelWidget; +/* TODO + if (labelFont) + XtVaSetValues (labelWidget, + XmNfontList, labelFont->GetInternalFont (XtDisplay(formWidget)), + NULL); +*/ + + XmStringFree (text); + + Widget radioButtonWidget = XtVaCreateManagedWidget ("toggle", +#if wxUSE_GADGETS + xmToggleButtonGadgetClass, formWidget, +#else + xmToggleButtonWidgetClass, formWidget, +#endif + NULL); + XtAddCallback (radioButtonWidget, XmNvalueChangedCallback, (XtCallbackProc) wxRadioButtonCallback, + (XtCallbackProc) this); + + m_mainWidget = (WXWidget) radioButtonWidget; + +/* TODO + if (labelFont) + XtVaSetValues (radioButtonWidget, + XmNfontList, labelFont->GetInternalFont (XtDisplay(formWidget)), + NULL); +*/ + + if (labelWidget) + XtVaSetValues (labelWidget, + XmNtopAttachment, XmATTACH_FORM, + XmNleftAttachment, XmATTACH_FORM, + XmNbottomAttachment, XmATTACH_FORM, + XmNalignment, XmALIGNMENT_BEGINNING, + NULL); + XtVaSetValues (radioButtonWidget, + XmNleftOffset, 4, + XmNtopAttachment, XmATTACH_FORM, + XmNbottomAttachment, XmATTACH_FORM, + XmNleftAttachment, (Widget) m_labelWidget ? XmATTACH_WIDGET : XmATTACH_FORM, + XmNleftWidget, (Widget) m_labelWidget ? (Widget) m_labelWidget : formWidget, + NULL); + + XtManageChild (radioButtonWidget); + + SetCanAddEventHandler(TRUE); + AttachWidget (parent, m_mainWidget, m_formWidget, pos.x, pos.y, size.x, size.y); + + SetFont(* parent->GetFont()); + ChangeColour(m_mainWidget); + + return TRUE; } void wxRadioButton::SetValue(bool value) { - // TODO + m_inSetValue = TRUE; + XmToggleButtonSetState ((Widget) m_mainWidget, (Boolean) value, FALSE); + m_inSetValue = FALSE; } // Get single selection, for single choice list items bool wxRadioButton::GetValue() const { - // TODO - return FALSE; + return (XmToggleButtonGetState ((Widget) m_mainWidget) != 0); } void wxRadioButton::Command (wxCommandEvent & event) @@ -65,4 +154,19 @@ void wxRadioButton::Command (wxCommandEvent & event) ProcessCommand (event); } +void wxRadioButtonCallback (Widget w, XtPointer clientData, + XmToggleButtonCallbackStruct * cbs) +{ + if (!cbs->set) + return; + + wxRadioButton *item = (wxRadioButton *) clientData; + if (item->InSetValue()) + return; + + wxCommandEvent event (wxEVT_COMMAND_RADIOBUTTON_SELECTED, item->GetId()); + event.SetEventObject(item); + + item->ProcessCommand (event); +} diff --git a/src/motif/slider.cpp b/src/motif/slider.cpp index a7c3788bf6..244843b4d8 100644 --- a/src/motif/slider.cpp +++ b/src/motif/slider.cpp @@ -14,6 +14,17 @@ #endif #include "wx/slider.h" +#include "wx/utils.h" + +#include +#include +#include +#include +#include + +#include + +void wxSliderCallback (Widget widget, XtPointer clientData, XmScaleCallbackStruct * cbs); #if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxSlider, wxControl) @@ -58,11 +69,41 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id, m_rangeMax = maxValue; m_rangeMin = minValue; + // Not used in Motif, I think m_pageSize = (int)((maxValue-minValue)/10); - // TODO create slider + Widget parentWidget = (Widget) parent->GetClientWidget(); + + Widget sliderWidget = XtVaCreateManagedWidget ("sliderWidget", + xmScaleWidgetClass, parentWidget, + XmNorientation, + (((m_windowStyle & wxSL_VERTICAL) == wxSL_VERTICAL) ? XmVERTICAL : XmHORIZONTAL), + XmNprocessingDirection, + (((m_windowStyle & wxSL_VERTICAL) == wxSL_VERTICAL) ? XmMAX_ON_TOP : XmMAX_ON_RIGHT), + XmNmaximum, maxValue, + XmNminimum, minValue, + XmNvalue, value, + XmNshowValue, True, + NULL); + + m_mainWidget = (WXWidget) sliderWidget; + + if(style & wxSL_NOTIFY_DRAG) + XtAddCallback (sliderWidget, XmNdragCallback, + (XtCallbackProc) wxSliderCallback, (XtPointer) this); + else + XtAddCallback (sliderWidget, XmNvalueChangedCallback, + (XtCallbackProc) wxSliderCallback, (XtPointer) this); + + XtAddCallback (sliderWidget, XmNdragCallback, (XtCallbackProc) wxSliderCallback, (XtPointer) this); + + SetCanAddEventHandler(TRUE); + AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y); - return FALSE; + SetFont(* parent->GetFont()); + ChangeColour(m_mainWidget); + + return TRUE; } wxSlider::~wxSlider() @@ -71,28 +112,50 @@ wxSlider::~wxSlider() int wxSlider::GetValue() const { - // TODO - return 0; + int val; + XtVaGetValues ((Widget) m_mainWidget, XmNvalue, &val, NULL); + return val; } void wxSlider::SetValue(int value) { - // TODO + XtVaSetValues ((Widget) m_mainWidget, XmNvalue, value, NULL); } void wxSlider::GetSize(int *width, int *height) const { - // TODO -} - -void wxSlider::GetPosition(int *x, int *y) const -{ - // TODO + wxControl::GetSize(width, height); } void wxSlider::SetSize(int x, int y, int width, int height, int sizeFlags) { - // TODO + Widget widget = (Widget) m_mainWidget; + + bool managed = XtIsManaged(widget); + + if (managed) + XtUnmanageChild (widget); + + if (((m_windowStyle & wxHORIZONTAL) == wxHORIZONTAL) && (width > -1)) + { + XtVaSetValues (widget, XmNscaleWidth, wxMax (width, 10), NULL); + } + + if (((m_windowStyle & wxVERTICAL) == wxVERTICAL) && (height > -1)) + { + XtVaSetValues (widget, XmNscaleHeight, wxMax (height, 10), NULL); + } + + int xx = x; int yy = y; + AdjustForParentClientOrigin(xx, yy, sizeFlags); + + if (x > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) + XtVaSetValues (widget, XmNx, xx, NULL); + if (y > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) + XtVaSetValues (widget, XmNy, yy, NULL); + + if (managed) + XtManageChild (widget); } void wxSlider::SetRange(int minValue, int maxValue) @@ -100,19 +163,19 @@ void wxSlider::SetRange(int minValue, int maxValue) m_rangeMin = minValue; m_rangeMax = maxValue; - // TODO + XtVaSetValues ((Widget) m_mainWidget, XmNminimum, minValue, XmNmaximum, maxValue, NULL); } // For trackbars only void wxSlider::SetTickFreq(int n, int pos) { - // TODO + // Not implemented in Motif m_tickFreq = n; } void wxSlider::SetPageSize(int pageSize) { - // TODO + // Not implemented in Motif m_pageSize = pageSize; } @@ -123,57 +186,57 @@ int wxSlider::GetPageSize() const void wxSlider::ClearSel() { - // TODO + // Not implemented in Motif } void wxSlider::ClearTicks() { - // TODO + // Not implemented in Motif } void wxSlider::SetLineSize(int lineSize) { + // Not implemented in Motif m_lineSize = lineSize; - // TODO } int wxSlider::GetLineSize() const { - // TODO - return 0; + // Not implemented in Motif + return m_lineSize; } int wxSlider::GetSelEnd() const { - // TODO + // Not implemented in Motif return 0; } int wxSlider::GetSelStart() const { - // TODO + // Not implemented in Motif return 0; } -void wxSlider::SetSelection(int minPos, int maxPos) +void wxSlider::SetSelection(int WXUNUSED(minPos), int WXUNUSED(maxPos)) { - // TODO + // Not implemented in Motif } -void wxSlider::SetThumbLength(int len) +void wxSlider::SetThumbLength(int WXUNUSED(len)) { - // TODO + // Not implemented in Motif (?) } int wxSlider::GetThumbLength() const { - // TODO + // Not implemented in Motif (?) return 0; } -void wxSlider::SetTick(int tickPos) +void wxSlider::SetTick(int WXUNUSED(tickPos)) { - // TODO + // Not implemented in Motif } void wxSlider::Command (wxCommandEvent & event) @@ -182,9 +245,25 @@ void wxSlider::Command (wxCommandEvent & event) ProcessCommand (event); } -bool wxSlider::Show(bool show) +void wxSliderCallback (Widget widget, XtPointer clientData, XmScaleCallbackStruct * cbs) { - // TODO - return TRUE; + wxSlider *slider = (wxSlider *) clientData; + switch (cbs->reason) + { + case XmCR_VALUE_CHANGED: + case XmCR_DRAG: + default: + { + // TODO: the XmCR_VALUE_CHANGED case should be handled + // differently (it's not sent continually as the slider moves). + // In which case we need a similar behaviour for other platforms. + + wxScrollEvent event(wxEVT_SCROLL_THUMBTRACK, slider->GetId()); + XtVaGetValues (widget, XmNvalue, &event.m_commandInt, NULL); + event.SetEventObject(slider); + slider->ProcessCommand(event); + break; + } + } } diff --git a/src/motif/statbmp.cpp b/src/motif/statbmp.cpp index 05acdc7411..5dc08a3296 100644 --- a/src/motif/statbmp.cpp +++ b/src/motif/statbmp.cpp @@ -15,6 +15,13 @@ #include "wx/statbmp.h" +#include +#include +#include +#include + +#include + #if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap, wxControl) #endif @@ -41,19 +48,72 @@ bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id, m_windowStyle = style; - // TODO: create static bitmap control - return FALSE; + Widget parentWidget = (Widget) parent->GetClientWidget(); + + m_mainWidget = (WXWidget) XtVaCreateManagedWidget ("staticBitmap", +#if USE_GADGETS + xmLabelGadgetClass, parentWidget, +#else + xmLabelWidgetClass, parentWidget, +#endif + XmNalignment, XmALIGNMENT_BEGINNING, + NULL); + + XtVaSetValues ((Widget) m_mainWidget, + XmNlabelPixmap, (Pixmap) ((wxBitmap&)bitmap).GetLabelPixmap (m_mainWidget), + XmNlabelType, XmPIXMAP, + NULL); + + SetCanAddEventHandler(TRUE); + AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y); + + SetFont(* parent->GetFont()); + + ChangeColour (m_mainWidget); + + return TRUE; +} + +wxStaticBitmap::~wxStaticBitmap() +{ + SetBitmap(wxNullBitmap); } void wxStaticBitmap::SetSize(int x, int y, int width, int height, int sizeFlags) { - // TODO + wxControl::SetSize(x, y, width, height, sizeFlags); } void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap) { m_messageBitmap = bitmap; - // TODO: redraw bitmap + Widget widget = (Widget) m_mainWidget; + int x, y, w1, h1, w2, h2; + + GetPosition(&x, &y); + + if (bitmap.Ok()) + { + w2 = bitmap.GetWidth(); + h2 = bitmap.GetHeight(); + XtVaSetValues (widget, + XmNlabelPixmap, ((wxBitmap&)bitmap).GetLabelPixmap (widget), + XmNlabelType, XmPIXMAP, + NULL); + GetSize(&w1, &h1); + + if (! (w1 == w2) && (h1 == h2)) + SetSize(x, y, w2, h2); + } + else + { + // Null bitmap: must not use current pixmap + // since it is no longer valid. + XtVaSetValues (widget, + XmNlabelType, XmSTRING, + XmNlabelPixmap, NULL, // TODO: Does this work? + NULL); + } } diff --git a/src/motif/stattext.cpp b/src/motif/stattext.cpp index fbe223dd14..57da5bfdeb 100644 --- a/src/motif/stattext.cpp +++ b/src/motif/stattext.cpp @@ -33,26 +33,26 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id, long style, const wxString& name) { - SetName(name); - if (parent) parent->AddChild(this); + SetName(name); + if (parent) parent->AddChild(this); - SetBackgroundColour(parent->GetBackgroundColour()) ; - SetForegroundColour(parent->GetForegroundColour()) ; + SetBackgroundColour(parent->GetBackgroundColour()) ; + SetForegroundColour(parent->GetForegroundColour()) ; - if ( id == -1 ) - m_windowId = (int)NewControlId(); - else - m_windowId = id; + if ( id == -1 ) + m_windowId = (int)NewControlId(); + else + m_windowId = id; - m_windowStyle = style; + m_windowStyle = style; - char* label1 = (label.IsNull() ? "" : (char*) (const char*) label); + char* label1 = (label.IsNull() ? "" : (char*) (const char*) label); - Widget parentWidget = (Widget) parent->GetClientWidget(); + Widget parentWidget = (Widget) parent->GetClientWidget(); - XmString text = XmStringCreateSimple (label1); + XmString text = XmStringCreateSimple (label1); - m_mainWidget = (WXWidget) XtVaCreateManagedWidget ((char*) (const char*) name, + m_mainWidget = (WXWidget) XtVaCreateManagedWidget ((char*) (const char*) name, xmLabelWidgetClass, parentWidget, XmNlabelString, text, @@ -62,17 +62,15 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id, XmALIGNMENT_BEGINNING)), NULL); - XmStringFree (text); + XmStringFree (text); - SetCanAddEventHandler(TRUE); - AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y); + SetCanAddEventHandler(TRUE); + AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y); - SetFont(* parent->GetFont()); + SetFont(* parent->GetFont()); - ChangeColour (m_mainWidget); - // ChangeFont (m_mainWidget); + ChangeColour (m_mainWidget); - return TRUE; + return TRUE; } - diff --git a/src/motif/textctrl.cpp b/src/motif/textctrl.cpp index d62cac41f6..3424be1234 100644 --- a/src/motif/textctrl.cpp +++ b/src/motif/textctrl.cpp @@ -67,7 +67,6 @@ wxTextCtrl::wxTextCtrl() m_tempCallbackStruct = (void*) NULL; m_modified = FALSE; m_processedDefault = FALSE; - m_inSetValue = FALSE; } bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, @@ -81,7 +80,6 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, m_modified = FALSE; m_processedDefault = FALSE; m_fileName = ""; - m_inSetValue = FALSE; SetName(name); SetValidator(validator); @@ -718,7 +716,7 @@ wxTextWindowModifyProc (Widget w, XtPointer clientData, XmTextVerifyCallbackStru tw->m_tempCallbackStruct = NULL; - if (tw->m_inSetValue) + if (tw->InSetValue()) return; if (tw->m_processedDefault) @@ -757,7 +755,7 @@ wxTextWindowModifyProc (Widget w, XtPointer clientData, XmTextVerifyCallbackStru tw->m_tempCallbackStruct = NULL; - if (tw->m_inSetValue) + if (tw->InSetValue()) return; if (tw->m_processedDefault) @@ -810,7 +808,7 @@ static void wxTextWindowActivateProc(Widget w, XtPointer clientData, } */ - if (tw->m_inSetValue) + if (tw->InSetValue()) return; wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER); diff --git a/src/motif/utils.cpp b/src/motif/utils.cpp index b8d38a5282..5c2797dc17 100644 --- a/src/motif/utils.cpp +++ b/src/motif/utils.cpp @@ -18,43 +18,108 @@ #include "wx/setup.h" #include "wx/utils.h" #include "wx/app.h" +#include "wx/msgdlg.h" +#include "wx/cursor.h" #include - -#include -#include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __SVR4__ +#include +#endif #include #include "wx/motif/private.h" +// Yuck this is really BOTH site and platform dependent +// so we should use some other strategy! +#ifdef sun +# define DEFAULT_XRESOURCE_DIR "/usr/openwin/lib/app-defaults" +#else +# define DEFAULT_XRESOURCE_DIR "/usr/lib/X11/app-defaults" +#endif + +static char *GetIniFile (char *dest, const char *filename); + +extern wxList wxTopLevelWindows; + // Get full hostname (eg. DoDo.BSn-Germany.crg.de) bool wxGetHostName(char *buf, int maxSize) { - // TODO - return FALSE; +#if defined(SVR4) && !defined(__hpux) + return (sysinfo (SI_HOSTNAME, buf, maxSize) != -1); +#else /* BSD Sockets */ + char name[255]; + struct hostent *h; + + // Get hostname + if (gethostname (name, sizeof (name) / sizeof (char) - 1) == -1) + return FALSE; + // Get official full name of host + strncpy (buf + ,(h = gethostbyname (name)) != NULL ? h->h_name : name + ,maxSize - 1); + return TRUE; +#endif } // Get user ID e.g. jacs bool wxGetUserId(char *buf, int maxSize) { - // TODO - return FALSE; +#ifdef VMS + *buf = '\0'; // return empty string + return FALSE; +#else + struct passwd *who; + + if ((who = getpwuid (getuid ())) != NULL) + { + strncpy (buf, who->pw_name, maxSize - 1); + return TRUE; + } + return FALSE; +#endif } // Get user name e.g. Julian Smart bool wxGetUserName(char *buf, int maxSize) { - // TODO - return FALSE; +#ifdef VMS + *buf = '\0'; // return empty string + return FALSE; +#else + struct passwd *who; + + if ((who = getpwuid (getuid ())) != NULL) + { + strncpy (buf, who->pw_gecos, maxSize - 1); + return TRUE; + } + return FALSE; +#endif } int wxKill(long pid, int sig) { - // TODO - return 0; + int unixSignal = 0; + switch (sig) + { + case wxSIGTERM: + default: + unixSignal = SIGTERM; + } + return kill( (int)pid, unixSignal); } // @@ -62,75 +127,194 @@ int wxKill(long pid, int sig) // bool wxShell(const wxString& command) { - // TODO - return FALSE; +#ifdef VMS + return(FALSE); +#else +#if defined(sun) || defined(__ultrix) || defined(__bsdi__) + pid_t pid = vfork (); +#else + pid_t pid = fork (); +#endif + switch( pid ) { + case -1: /* error */ + return(FALSE); + case 0: /* child */ + // Generic X windows terminal window + if (command != "") + execlp("xterm", "-e", (char *) (const char*) command, NULL); + else + execlp("xterm", NULL); + _exit(127); + } + return TRUE; +#endif + // End VMS } // Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX) long wxGetFreeMemory() { - // TODO - return 0; + return -1; } void wxSleep(int nSecs) { - // TODO + sleep(nSecs); } // Consume all events until no more left void wxFlushEvents() { + Display *display = (Display*) wxGetDisplay(); + + XSync (display, FALSE); + XEvent event; + // XtAppPending returns availability of events AND timers/inputs, which + // are processed via callbacks, so XtAppNextEvent will not return if + // there are no events. So added '& XtIMXEvent' - Sergey. + while (XtAppPending ((XtAppContext) wxTheApp->GetAppContext()) & XtIMXEvent) + { + XFlush (XtDisplay ((Widget) wxTheApp->GetTopLevelWidget())); + // Jan Lessner: works better when events are non-X events + XtAppProcessEvent((XtAppContext) wxTheApp->GetAppContext(), XtIMXEvent); + } } // Output a debug message, in a system dependent fashion. void wxDebugMsg(const char *fmt ...) { va_list ap; - static char buffer[512]; + char buffer[BUFSIZ]; if (!wxTheApp->GetWantDebugOutput()) return ; - va_start(ap, fmt); + va_start (ap, fmt); - // wvsprintf(buffer,fmt,ap) ; - // TODO: output buffer + vsprintf (buffer, fmt, ap); + cerr << buffer; - va_end(ap); + va_end (ap); } // Non-fatal error: pop up message box and (possibly) continue void wxError(const wxString& msg, const wxString& title) { - // TODO - wxExit(); + cerr << (const char*) title << ": " << (const char*) msg << "\n"; } // Fatal error: pop up message box and abort void wxFatalError(const wxString& msg, const wxString& title) { - // TODO + cerr << (const char*) title << ": " << (const char*) msg << "\n"; + exit (1); } // Emit a beeeeeep void wxBell() { - // TODO + // Use current setting for the bell + XBell ((Display*) wxGetDisplay(), 0); } int wxGetOsVersion(int *majorVsn, int *minorVsn) { // TODO - return 0; + // This code is WRONG!! Does NOT return the + // Motif version of the libs but the X protocol + // version! @@@@@ Fix ME!!!!!!!!! + Display *display = XtDisplay ((Widget) wxTheApp->GetTopLevelWidget()); + if (majorVsn) + *majorVsn = ProtocolVersion (display); + if (minorVsn) + *minorVsn = ProtocolRevision (display); + return wxMOTIF_X; } // Reading and writing resources (eg WIN.INI, .Xdefaults) #if wxUSE_RESOURCES + +static char *GetResourcePath(char *buf, const char *name, bool create = FALSE) +{ + if (create && wxFileExists (name) ) { + strcpy(buf, name); + return buf; // Exists so ... + } + + if (*name == '/') + strcpy(buf, name); + else { + // Put in standard place for resource files if not absolute + strcpy (buf, DEFAULT_XRESOURCE_DIR); + strcat (buf, "/"); + strcat (buf, (const char*) wxFileNameFromPath (name)); + } + + if (create) { + // Touch the file to create it + FILE *fd = fopen (buf, "w"); + if (fd) fclose (fd); + } + return buf; +} + +/* + * We have a cache for writing different resource files, + * which will only get flushed when we call wxFlushResources(). + * Build up a list of resource databases waiting to be written. + * + */ + +wxList wxResourceCache (wxKEY_STRING); + +void +wxFlushResources (void) +{ + char nameBuffer[512]; + + wxNode *node = wxResourceCache.First (); + while (node) + { + char *file = node->key.string; + // If file doesn't exist, create it first. + (void)GetResourcePath(nameBuffer, file, TRUE); + + XrmDatabase database = (XrmDatabase) node->Data (); + XrmPutFileDatabase (database, nameBuffer); + XrmDestroyDatabase (database); + wxNode *next = node->Next (); + delete node; + node = next; + } +} + +static XrmDatabase wxResourceDatabase = 0; + +void wxXMergeDatabases (wxApp * theApp, Display * display); + bool wxWriteResource(const wxString& section, const wxString& entry, const wxString& value, const wxString& file) { - // TODO - return FALSE; + char buffer[500]; + + (void) GetIniFile (buffer, file); + + XrmDatabase database; + wxNode *node = wxResourceCache.Find (buffer); + if (node) + database = (XrmDatabase) node->Data (); + else + { + database = XrmGetFileDatabase (buffer); + wxResourceCache.Append (buffer, (wxObject *) database); + } + + char resName[300]; + strcpy (resName, (const char*) section); + strcat (resName, "."); + strcat (resName, (const char*) entry); + + XrmPutStringResource (&database, resName, value); + return TRUE; } bool wxWriteResource(const wxString& section, const wxString& entry, float value, const wxString& file) @@ -156,8 +340,60 @@ bool wxWriteResource(const wxString& section, const wxString& entry, int value, bool wxGetResource(const wxString& section, const wxString& entry, char **value, const wxString& file) { - // TODO - return FALSE; + if (!wxResourceDatabase) + { + Display *display = (Display*) wxGetDisplay(); + wxXMergeDatabases (wxTheApp, display); + } + + XrmDatabase database; + + if (file != "") + { + char buffer[500]; + + // Is this right? Trying to get it to look in the user's + // home directory instead of current directory -- JACS + (void) GetIniFile (buffer, file); + + wxNode *node = wxResourceCache.Find (buffer); + if (node) + database = (XrmDatabase) node->Data (); + else + { + database = XrmGetFileDatabase (buffer); + wxResourceCache.Append (buffer, (wxObject *) database); + } + } + else + database = wxResourceDatabase; + + XrmValue xvalue; + char *str_type[20]; + char buf[150]; + strcpy (buf, section); + strcat (buf, "."); + strcat (buf, entry); + + Bool success = XrmGetResource (database, buf, "*", str_type, + &xvalue); + // Try different combinations of upper/lower case, just in case... + if (!success) + { + buf[0] = (isupper (buf[0]) ? tolower (buf[0]) : toupper (buf[0])); + success = XrmGetResource (database, buf, "*", str_type, + &xvalue); + } + if (success) + { + if (*value) + delete[] *value; + + *value = new char[xvalue.size + 1]; + strncpy (*value, xvalue.addr, (int) xvalue.size); + return TRUE; + } + return FALSE; } bool wxGetResource(const wxString& section, const wxString& entry, float *value, const wxString& file) @@ -192,27 +428,167 @@ bool wxGetResource(const wxString& section, const wxString& entry, int *value, c bool succ = wxGetResource(section, entry, (char **)&s, file); if (succ) { - *value = (int)strtol(s, NULL, 10); - delete[] s; - return TRUE; + // Handle True, False here + // True, Yes, Enables, Set or Activated + if (*s == 'T' || *s == 'Y' || *s == 'E' || *s == 'S' || *s == 'A') + *value = TRUE; + // False, No, Disabled, Reset, Cleared, Deactivated + else if (*s == 'F' || *s == 'N' || *s == 'D' || *s == 'R' || *s == 'C') + *value = FALSE; + // Handle as Integer + else + *value = (int) strtol (s, NULL, 10); + delete[] s; + return TRUE; } - else return FALSE; + else + return FALSE; +} + +void wxXMergeDatabases (wxApp * theApp, Display * display) +{ + XrmDatabase homeDB, serverDB, applicationDB; + char filenamebuf[1024]; + + char *filename = &filenamebuf[0]; + char *environment; + wxString classname = theApp->GetClassName(); + char name[256]; + (void) strcpy (name, "/usr/lib/X11/app-defaults/"); + (void) strcat (name, (const char*) classname); + + /* Get application defaults file, if any */ + applicationDB = XrmGetFileDatabase (name); + (void) XrmMergeDatabases (applicationDB, &wxResourceDatabase); + + /* Merge server defaults, created by xrdb, loaded as a property of the root + * window when the server initializes and loaded into the display + * structure on XOpenDisplay; + * if not defined, use .Xdefaults + */ + + if (XResourceManagerString (display) != NULL) + { + serverDB = XrmGetStringDatabase (XResourceManagerString (display)); + } + else + { + (void) GetIniFile (filename, NULL); + serverDB = XrmGetFileDatabase (filename); + } + XrmMergeDatabases (serverDB, &wxResourceDatabase); + + /* Open XENVIRONMENT file, or if not defined, the .Xdefaults, + * and merge into existing database + */ + + if ((environment = getenv ("XENVIRONMENT")) == NULL) + { + size_t len; + environment = GetIniFile (filename, NULL); + len = strlen (environment); +#if defined(SVR4) && !defined(__hpux) + (void) sysinfo (SI_HOSTNAME, environment + len, 1024 - len); +#else + (void) gethostname (environment + len, 1024 - len); +#endif + } + homeDB = XrmGetFileDatabase (environment); + XrmMergeDatabases (homeDB, &wxResourceDatabase); +} + +#if 0 + +/* + * Not yet used but may be useful. + * + */ +void +wxSetDefaultResources (const Widget w, const char **resourceSpec, const char *name) +{ + int i; + Display *dpy = XtDisplay (w); // Retrieve the display pointer + + XrmDatabase rdb = NULL; // A resource data base + + // Create an empty resource database + rdb = XrmGetStringDatabase (""); + + // Add the Component resources, prepending the name of the component + + i = 0; + while (resourceSpec[i] != NULL) + { + char buf[1000]; + + sprintf (buf, "*%s%s", name, resourceSpec[i++]); + XrmPutLineResource (&rdb, buf); + } + + // Merge them into the Xt database, with lowest precendence + + if (rdb) + { +#if (XlibSpecificationRelease>=5) + XrmDatabase db = XtDatabase (dpy); + XrmCombineDatabase (rdb, &db, FALSE); +#else + XrmMergeDatabases (dpy->db, &rdb); + dpy->db = rdb; +#endif + } } +#endif + // 0 + #endif // wxUSE_RESOURCES static int wxBusyCursorCount = 0; +// Helper function +static void +wxXSetBusyCursor (wxWindow * win, wxCursor * cursor) +{ + Display *display = (Display*) win->GetXDisplay(); + + Window xwin = (Window) win->GetXWindow(); + XSetWindowAttributes attrs; + + if (cursor) + { + attrs.cursor = (Cursor) cursor->GetXCursor(display); + } + else + { + // Restore old cursor + if (win->GetCursor()->Ok()) + attrs.cursor = (Cursor) win->GetCursor()->GetXCursor(display); + else + attrs.cursor = None; + } + if (xwin) + XChangeWindowAttributes (display, xwin, CWCursor, &attrs); + + XFlush (display); + + for(wxNode *node = win->GetChildren()->First (); node; node = node->Next()) + { + wxWindow *child = (wxWindow *) node->Data (); + wxXSetBusyCursor (child, cursor); + } +} + // Set the cursor to the busy cursor for all windows void wxBeginBusyCursor(wxCursor *cursor) { - wxBusyCursorCount ++; + wxBusyCursorCount++; if (wxBusyCursorCount == 1) { - // TODO - } - else - { - // TODO + for(wxNode *node = wxTopLevelWindows.First (); node; node = node->Next()) + { + wxWindow *win = (wxWindow *) node->Data (); + wxXSetBusyCursor (win, cursor); + } } } @@ -221,11 +597,15 @@ void wxEndBusyCursor() { if (wxBusyCursorCount == 0) return; - - wxBusyCursorCount --; + + wxBusyCursorCount--; if (wxBusyCursorCount == 0) { - // TODO + for(wxNode *node = wxTopLevelWindows.First (); node; node = node->Next()) + { + wxWindow *win = (wxWindow *) node->Data (); + wxXSetBusyCursor (win, NULL); + } } } @@ -237,21 +617,72 @@ bool wxIsBusy() char *wxGetUserHome (const wxString& user) { - // TODO - return NULL; +#ifdef VMS + return(NULL); +#else + struct passwd *who = NULL; + + if (user == "") { + register char *ptr; + + if ((ptr = getenv("HOME")) != NULL) + return ptr; + if ((ptr = getenv("USER")) != NULL || + (ptr = getenv("LOGNAME")) != NULL) + { + who = getpwnam( ptr ); + } + // We now make sure the the user exists! + if (who == NULL) + who = getpwuid( getuid() ); + } else + who = getpwnam ((const char*) user); + + return who ? who->pw_dir : (char*) NULL; +#endif + // ifdef VMS } // Check whether this window wants to process messages, e.g. Stop button // in long calculations. bool wxCheckForInterrupt(wxWindow *wnd) { - // TODO - return FALSE; + if(wnd){ + Display *dpy=(Display*) wnd->GetXDisplay(); + Window win=(Window) wnd->GetXWindow(); + XEvent event; + XFlush(dpy); + if(wnd->GetMainWidget()){ + XmUpdateDisplay((Widget)(wnd->GetMainWidget())); + } + while(XCheckMaskEvent(dpy, + ButtonPressMask|ButtonReleaseMask|ButtonMotionMask| + PointerMotionMask|KeyPressMask|KeyReleaseMask, + &event)){ + if(event.xany.window==win) + XtDispatchEvent(&event); + // else + // XBell(dpy,50); + } + return TRUE;//*** temporary? + } + else{ + wxMessageBox("wnd==NULL !!!"); + return FALSE;//*** temporary? + } } void wxGetMousePosition( int* x, int* y ) { - // TODO + XMotionEvent xev; + Window root, child; + XQueryPointer((Display*) wxGetDisplay(), + DefaultRootWindow((Display*) wxGetDisplay()), &root, &child, + &(xev.x_root), &(xev.y_root), + &(xev.x), &(xev.y), + &(xev.state)); + *x = xev.x_root; + *y = xev.y_root; }; // Return TRUE if we have a colour display @@ -656,3 +1087,145 @@ KeySym wxCharCodeWXToX(int id) } // switch return keySym; } + +// Read $HOME for what it says is home, if not +// read $USER or $LOGNAME for user name else determine +// the Real User, then determine the Real home dir. +static char * GetIniFile (char *dest, const char *filename) +{ + char *home = NULL; + if (filename && wxIsAbsolutePath(filename)) + { + strcpy(dest, filename); + } + else if ((home = wxGetUserHome("")) != NULL) + { + strcpy(dest, home); + if (dest[strlen(dest) - 1] != '/') + strcat (dest, "/"); + if (filename == NULL) + { + if ((filename = getenv ("XENVIRONMENT")) == NULL) + filename = ".Xdefaults"; + } + else if (*filename != '.') + strcat (dest, "."); + strcat (dest, filename); + } else + { + dest[0] = '\0'; + } + return dest; +} + +/* + * Some colour manipulation routines + */ + +void wxHSVToXColor(wxHSV *hsv,XColor *rgb) + { + int h = hsv->h; + int s = hsv->s; + int v = hsv->v; + int r, g, b; + int i, f; + int p, q, t; + s = (s * wxMAX_RGB) / wxMAX_SV; + v = (v * wxMAX_RGB) / wxMAX_SV; + if (h == 360) h = 0; + if (s == 0) { h = 0; r = g = b = v; } + i = h / 60; + f = h % 60; + p = v * (wxMAX_RGB - s) / wxMAX_RGB; + q = v * (wxMAX_RGB - s * f / 60) / wxMAX_RGB; + t = v * (wxMAX_RGB - s * (60 - f) / 60) / wxMAX_RGB; + switch (i) + { + case 0: r = v, g = t, b = p; break; + case 1: r = q, g = v, b = p; break; + case 2: r = p, g = v, b = t; break; + case 3: r = p, g = q, b = v; break; + case 4: r = t, g = p, b = v; break; + case 5: r = v, g = p, b = q; break; + } + rgb->red = r << 8; + rgb->green = g << 8; + rgb->blue = b << 8; + } + +void wxXColorToHSV(wxHSV *hsv,XColor *rgb) + { + int r = rgb->red >> 8; + int g = rgb->green >> 8; + int b = rgb->blue >> 8; + int maxv = wxMax3(r, g, b); + int minv = wxMin3(r, g, b); + int h, s, v; + v = maxv; + if (maxv) s = (maxv - minv) * wxMAX_RGB / maxv; + else s = 0; + if (s == 0) h = 0; + else + { + int rc, gc, bc, hex; + rc = (maxv - r) * wxMAX_RGB / (maxv - minv); + gc = (maxv - g) * wxMAX_RGB / (maxv - minv); + bc = (maxv - b) * wxMAX_RGB / (maxv - minv); + if (r == maxv) { h = bc - gc, hex = 0; } + else if (g == maxv) { h = rc - bc, hex = 2; } + else if (b == maxv) { h = gc - rc, hex = 4; } + h = hex * 60 + (h * 60 / wxMAX_RGB); + if (h < 0) h += 360; + } + hsv->h = h; + hsv->s = (s * wxMAX_SV) / wxMAX_RGB; + hsv->v = (v * wxMAX_SV) / wxMAX_RGB; + } + +void wxAllocNearestColor(Display *d,Colormap cmp,XColor *xc) + { + int llp; + + int screen = DefaultScreen(d); + int num_colors = DisplayCells(d,screen); + + XColor *color_defs = new XColor[num_colors]; + for(llp = 0;llp < num_colors;llp++) color_defs[llp].pixel = llp; + XQueryColors(d,cmp,color_defs,num_colors); + + wxHSV hsv_defs, hsv; + wxXColorToHSV(&hsv,xc); + + int diff, min_diff, pixel = 0; + + for(llp = 0;llp < num_colors;llp++) + { + wxXColorToHSV(&hsv_defs,&color_defs[llp]); + diff = wxSIGN(wxH_WEIGHT * (hsv.h - hsv_defs.h)) + + wxSIGN(wxS_WEIGHT * (hsv.s - hsv_defs.s)) + + wxSIGN(wxV_WEIGHT * (hsv.v - hsv_defs.v)); + if (llp == 0) min_diff = diff; + if (min_diff > diff) { min_diff = diff; pixel = llp; } + if (min_diff == 0) break; + } + + xc -> red = color_defs[pixel].red; + xc -> green = color_defs[pixel].green; + xc -> blue = color_defs[pixel].blue; + xc -> flags = DoRed | DoGreen | DoBlue; + if (!XAllocColor(d,cmp,xc)) + cout << "wxAllocNearestColor : Warning : Cannot find nearest color !\n"; + + delete[] color_defs; + } + +void wxAllocColor(Display *d,Colormap cmp,XColor *xc) + { + if (!XAllocColor(d,cmp,xc)) + { +// cout << "wxAllocColor : Warning : Can not allocate color, attempt find nearest !\n"; + wxAllocNearestColor(d,cmp,xc); + } + } + + diff --git a/src/motif/window.cpp b/src/motif/window.cpp index b17a7515ba..cbaa070490 100644 --- a/src/motif/window.cpp +++ b/src/motif/window.cpp @@ -475,6 +475,9 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id, if (m_vScrollBar) XtRealizeWidget ((Widget) m_vScrollBar); + // Without this, the cursor may not be restored properly + // (e.g. in splitter sample). + SetCursor(*wxSTANDARD_CURSOR); SetSize(pos.x, pos.y, size.x, size.y); return TRUE; @@ -584,15 +587,26 @@ void wxWindow::GetSize(int *x, int *y) const void wxWindow::GetPosition(int *x, int *y) const { - if (m_drawingArea) - { - CanvasGetPosition(x, y); - return; - } - Widget widget = (Widget) GetTopWidget(); - Position xx, yy; - XtVaGetValues(widget, XmNx, &xx, XmNy, &yy, NULL); - *x = xx; *y = yy; + if (m_drawingArea) + { + CanvasGetPosition(x, y); + return; + } + Widget widget = (Widget) GetTopWidget(); + Position xx, yy; + XtVaGetValues(widget, XmNx, &xx, XmNy, &yy, NULL); + + // We may be faking the client origin. + // So a window that's really at (0, 30) may appear + // (to wxWin apps) to be at (0, 0). + if (GetParent()) + { + wxPoint pt(GetParent()->GetClientAreaOrigin()); + xx -= pt.x; + yy -= pt.y; + } + + *x = xx; *y = yy; } void wxWindow::ScreenToClient(int *x, int *y) const @@ -660,10 +674,13 @@ void wxWindow::SetSize(int x, int y, int width, int height, int sizeFlags) if (managed) XtUnmanageChild(widget); + int xx = x; int yy = y; + AdjustForParentClientOrigin(xx, yy, sizeFlags); + if (x > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) - XtVaSetValues(widget, XmNx, x, NULL); + XtVaSetValues(widget, XmNx, xx, NULL); if (y > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) - XtVaSetValues(widget, XmNy, y, NULL); + XtVaSetValues(widget, XmNy, yy, NULL); if (width > -1) XtVaSetValues(widget, XmNwidth, width, NULL); if (height > -1) @@ -1268,14 +1285,24 @@ void wxWindow::SetFont(const wxFont& font) m_windowFont = font; // Note that this causes the widget to be resized back - // to its original size! How can we stop that? + // 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); + } } */ } @@ -2380,6 +2407,8 @@ void wxCanvasInputEvent (Widget drawingArea, XtPointer data, XmDrawingAreaCallba 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 (eventType == wxEVT_ENTER_WINDOW || @@ -2494,16 +2523,19 @@ void wxWindow::CanvasSetSize (int x, int y, int w, int h, int sizeFlags) XtUnmanageChild (m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow); XtVaSetValues((Widget) m_drawingArea, XmNresizePolicy, XmRESIZE_ANY, NULL); + int xx = x; int yy = y; + AdjustForParentClientOrigin(xx, yy, sizeFlags); + if (x > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) { XtVaSetValues (m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow, - XmNx, x, NULL); + XmNx, xx, NULL); } if (y > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) { XtVaSetValues (m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow, - XmNy, y, NULL); + XmNy, yy, NULL); } if (w > -1) @@ -2641,10 +2673,21 @@ void wxWindow::CanvasGetSize (int *w, int *h) const void wxWindow::CanvasGetPosition (int *x, int *y) const { - Position xx, yy; - XtVaGetValues (m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow, XmNx, &xx, XmNy, &yy, NULL); - *x = xx; - *y = yy; + Position xx, yy; + XtVaGetValues (m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow, XmNx, &xx, XmNy, &yy, NULL); + + // We may be faking the client origin. + // So a window that's really at (0, 30) may appear + // (to wxWin apps) to be at (0, 0). + if (GetParent()) + { + wxPoint pt(GetParent()->GetClientAreaOrigin()); + xx -= pt.x; + yy -= pt.y; + } + + *x = xx; + *y = yy; } // Add to hash table, add event handler -- 2.45.2