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);
{
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,
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
WXWidget* m_widgetList ;
WXWidget m_formWidget;
wxStringList m_stringList;
-public:
- bool m_inSetValue;
};
#endif
// 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
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; }
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);
// List mapping positions->client data
wxList m_clientDataList;
-
-public:
- bool m_inSetValue;
};
#endif
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
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);
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
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
// 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
// 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
*
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);
DECLARE_DYNAMIC_CLASS(wxStaticBitmap)
public:
inline wxStaticBitmap() { }
+ ~wxStaticBitmap();
inline wxStaticBitmap(wxWindow *parent, wxWindowID id,
const wxBitmap& label,
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()
// 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)
--- /dev/null
+#
+# 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
+
--- /dev/null
+#
+# 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
+
--- /dev/null
+#
+# 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
+
// Give it scrollbars
canvas->SetScrollbars(20, 20, 50, 50);
+ canvas->SetBackgroundColour(*wxWHITE);
+ canvas->Clear();
return canvas;
}
--- /dev/null
+#
+# 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
+
--- /dev/null
+#
+# 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
+
#
# 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
#
# 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
#
# 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
--- /dev/null
+#
+# 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
+
#
# 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
#
# 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
--- /dev/null
+#
+# 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
+
// Main proc
IMPLEMENT_APP(MyApp)
-#ifdef __WXGTK__
+#if defined(__WXGTK__) || defined(__WXMOTIF__)
#include "folder.xpm"
#endif
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" );
#
# 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
--- /dev/null
+#
+# 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
+
--- /dev/null
+#
+# 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
+
+
--- /dev/null
+#
+# 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
+
--- /dev/null
+#
+# 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
+
+
#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"
#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");
--- /dev/null
+#
+# 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
+
--- /dev/null
+#
+# 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
+
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;
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.
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)
#include "wx/defs.h"
-#ifdef __WXMSW__
+#ifndef __WXGTK__
#define __GOOD_COMPILER__
#endif
#endif
wxFont buttonFont(fontSize, wxSWISS, wxNORMAL, wxBOLD);
- SetButtonFont(buttonFont);
+ SetFont(buttonFont);
int buttonWidth = 65;
int buttonHeight = 24;
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)
}
m_closeButton->SetDefault();
-
+
#endif
}
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
if (!p->HasChildren()) p->m_hasChildren = TRUE;
- int ch = 0;
- GetClientSize( (int *) NULL, &ch );
+ int cw = 0, ch = 0;
+ GetClientSize( &cw, &ch );
PrepareDC( dc );
############################ Libraries ################################
COMPLIBS = -lstdc++
-GUILDLIBS = -lwx_stubs $(COMPLIBS) -lXm -lXmu -lXt -lX11 -lm
+GUILDLIBS = -lwx_stubs $(COMPLIBS) -lXm -lXmu -lXt -lXpm -lX11 -lm
############################# Suffixes ################################
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'
#include "wx/bitmap.h"
#include "wx/icon.h"
#include "wx/log.h"
+#include "wx/control.h"
#include <Xm/Xm.h>
#include "wx/motif/private.h"
// TODO: correct symbol, path?
-#if USE_XPM
+#if wxUSE_XPM
#include <X11/xpm.h>
#endif
// 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;
return TRUE;
}
-#if USE_XPM
+#if wxUSE_XPM
class WXDLLEXPORT wxXPMFileHandler: public wxBitmapHandler
{
DECLARE_DYNAMIC_CLASS(wxXPMFileHandler)
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;
XpmFreeAttributes(&xpmAttr);
M_BITMAPHANDLERDATA->m_ok = TRUE;
+ return TRUE;
} else
{
// XpmDebugError(errorStatus, name);
{
DECLARE_DYNAMIC_CLASS(wxXPMDataHandler)
public:
- inline wxXBMDataHandler()
+ inline wxXPMDataHandler()
{
m_name = "XPM data";
m_extension = "xpm";
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;
// 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
#include "wx/bmpbuttn.h"
+#include <Xm/PushBG.h>
+#include <Xm/PushB.h>
+
+#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,
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;
+};
+
+
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
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 ());
m_menuWidget = (WXWidget) 0;
m_widgetList = (WXWidget*) 0;
m_formWidget = (WXWidget) 0;
- m_inSetValue = FALSE;
}
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);
wxChoice *item = (wxChoice *) clientData;
if (item)
{
- if (item->m_inSetValue)
+ if (item->InSetValue())
return;
char *s = NULL;
m_backgroundColour = *wxWHITE;
m_foregroundColour = *wxBLACK;
m_callback = 0;
+ m_inSetValue = FALSE;
}
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;
}
}
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);
#endif
#include "wx/dcmemory.h"
+#include "wx/utils.h"
+
+#include <Xm/Xm.h>
+
+#include "wx/motif/private.h"
//-----------------------------------------------------------------------------
// wxMemoryDC
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)
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;
};
};
// 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);
}
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
yy -= ys;
}
}
+ */
*x = xx; *y = yy;
}
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();
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;
// 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
{
//// Motif-specific
bool wxFrame::PreResize()
{
+ PositionToolBar();
PositionStatusBar();
return TRUE;
}
}
// Create from XPM data
-wxIcon::wxIcon(const char **data)
+wxIcon::wxIcon(char **data)
{
(void) Create((void*) data, wxBITMAP_TYPE_XPM_DATA, 0, 0, 0);
}
{
m_noItems = 0;
m_selected = 0;
- m_inSetValue = FALSE;
}
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;
m_mainWidget = (WXWidget) listWidget;
+ Set(n, choices);
+
XtManageChild (listWidget);
long width = size.x;
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
wxListBox *item = (wxListBox *) clientData;
- if (item->m_inSetValue)
+ if (item->InSetValue())
return;
wxCommandEvent event (wxEVT_COMMAND_LISTBOX_SELECTED);
#endif
#include "wx/radiobox.h"
+#include "wx/utils.h"
+
+#include <Xm/Label.h>
+#include <Xm/LabelG.h>
+#include <Xm/ToggleB.h>
+#include <Xm/ToggleBG.h>
+#include <Xm/RowColumn.h>
+#include <Xm/Form.h>
+
+#include <wx/motif/private.h>
+
+void wxRadioBoxCallback (Widget w, XtPointer clientData,
+ XmToggleButtonCallbackStruct * cbs);
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxRadioBox, wxControl)
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,
{
m_selectedButton = -1;
m_noItems = n;
+ m_labelWidget = (WXWidget) 0;
+ m_radioButtons = (WXWidget*) NULL;
+ m_radioButtonLabels = (wxString*) NULL;
SetName(name);
SetValidator(val);
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;
}
{
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
// 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
{
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
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);
+}
#endif
#include "wx/radiobut.h"
+#include "wx/utils.h"
+
+#include <Xm/Label.h>
+#include <Xm/LabelG.h>
+#include <Xm/ToggleB.h>
+#include <Xm/ToggleBG.h>
+#include <Xm/RowColumn.h>
+#include <Xm/Form.h>
+
+#include <wx/motif/private.h>
+
+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,
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)
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);
+}
#endif
#include "wx/slider.h"
+#include "wx/utils.h"
+
+#include <Xm/Xm.h>
+#include <Xm/Label.h>
+#include <Xm/LabelG.h>
+#include <Xm/RowColumn.h>
+#include <Xm/Scale.h>
+
+#include <wx/motif/private.h>
+
+void wxSliderCallback (Widget widget, XtPointer clientData, XmScaleCallbackStruct * cbs);
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxSlider, wxControl)
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()
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)
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;
}
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)
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;
+ }
+ }
}
#include "wx/statbmp.h"
+#include <Xm/Xm.h>
+#include <Xm/Label.h>
+#include <Xm/LabelG.h>
+#include <Xm/RowColumn.h>
+
+#include <wx/motif/private.h>
+
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap, wxControl)
#endif
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);
+ }
}
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,
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;
}
-
m_tempCallbackStruct = (void*) NULL;
m_modified = FALSE;
m_processedDefault = FALSE;
- m_inSetValue = FALSE;
}
bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
m_modified = FALSE;
m_processedDefault = FALSE;
m_fileName = "";
- m_inSetValue = FALSE;
SetName(name);
SetValidator(validator);
tw->m_tempCallbackStruct = NULL;
- if (tw->m_inSetValue)
+ if (tw->InSetValue())
return;
if (tw->m_processedDefault)
tw->m_tempCallbackStruct = NULL;
- if (tw->m_inSetValue)
+ if (tw->InSetValue())
return;
if (tw->m_processedDefault)
}
*/
- if (tw->m_inSetValue)
+ if (tw->InSetValue())
return;
wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER);
#include "wx/setup.h"
#include "wx/utils.h"
#include "wx/app.h"
+#include "wx/msgdlg.h"
+#include "wx/cursor.h"
#include <ctype.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#include <stdarg.h>
+#include <dirent.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <sys/wait.h>
+#include <pwd.h>
+#include <errno.h>
+#include <netdb.h>
+#include <signal.h>
+
+#ifdef __SVR4__
+#include <sys/systeminfo.h>
+#endif
#include <Xm/Xm.h>
#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);
}
//
//
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)
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)
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);
+ }
}
}
{
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);
+ }
}
}
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
} // 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);
+ }
+ }
+
+
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;
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
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)
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);
+ }
}
*/
}
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 ||
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)
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