\membersection{wxActivateEvent::wxActivateEvent}
-\func{}{wxActivateEvent}{\param{WXTYPE }{eventType = 0}, \param{int }{id = 0}}
+\func{}{wxActivateEvent}{\param{WXTYPE }{eventType = 0}, \param{bool}{ active = TRUE}, \param{int }{id = 0}}
Constructor.
not found, {\it d} is not changed.
\constfunc{bool}{Read}{\param{const wxString\& }{ key}, \param{double*}{ d},
-\param{double}{ defaultVal}}
+ \param{double}{ defaultVal}}
Reads a double value, returning TRUE if the value was found. If the value was
not found, {\it defaultVal} is used instead.
- Colour setting in widgets.
-- Implementation of OnEraseBackground.
+- Implementation of OnEraseBackground. How? Call OnEraseBackground
+ just before OnPaint? Will duplicate Xlib's own erase of the background.
+ However, this is usually OK, because the default wxWindow::OnEraseBackground
+ can do nothing (SetBackgroundColour will make the background look OK).
+ And if a custom OnEraseBackground uses the same colour as the window
+ background, no flicker will be seen. If it does something else, such as
+ painting a tiled bitmap, then a slight flicker might be seen unless
+ X can be persuaded not to repaint the window background by default.
- wxBitmapCheckBox, wxBitmapRadioButton
http://www.motifzone.com/tmd/articles/Kurt_Huhner/jun96.html.
This article also explains how to implement tooltips.
-- wxSystemSettings
+- Find out why modal dialogs give a grab warning.
+
+- Find out why UI updates aren't working (probably an OnIdle failure).
-- wxTimer
+- wxSystemSettings
- wxThread (hopefully, similar to wxGTK)
inline WXDisplay* GetPixmap() const { return M_BITMAPDATA->m_pixmap; }
virtual WXPixmap GetLabelPixmap(WXWidget w) ;
virtual WXPixmap GetArmPixmap(WXWidget w) ;
- virtual WXPixmap GetInsensPixmap(WXWidget w) ;
+ virtual WXPixmap GetInsensPixmap(WXWidget w = (WXWidget) 0) ;
protected:
static wxList sm_handlers;
virtual void SetDefault();
virtual void Command(wxCommandEvent& event);
+
+// Implementation
+ virtual void ChangeFont();
+ virtual void ChangeBackgroundColour();
+ virtual void ChangeForegroundColour();
};
#endif
virtual void SetValue(bool);
virtual bool GetValue() const ;
virtual void Command(wxCommandEvent& event);
+
+// Implementation
+ virtual void ChangeFont();
+ virtual void ChangeBackgroundColour();
+ virtual void ChangeForegroundColour();
};
class WXDLLEXPORT wxBitmapCheckBox: public wxCheckBox
void SetFocus();
+// Implementation
+ virtual void ChangeFont();
+ virtual void ChangeBackgroundColour();
+ virtual void ChangeForegroundColour();
WXWidget GetTopWidget() const { return m_formWidget; }
WXWidget GetMainWidget() const { return m_buttonWidget; }
// Colour
class WXDLLEXPORT wxColour : public wxObject
{
+DECLARE_DYNAMIC_CLASS(wxColour)
public:
// ctors
// default
// accessors
bool Ok() const {return m_isInit; }
+ unsigned char Red() const { return m_red; }
+ unsigned char Green() const { return m_green; }
+ unsigned char Blue() const { return m_blue; }
int GetPixel() const { return m_pixel; };
void SetPixel(int pixel) { m_pixel = pixel; m_isInit = TRUE; };
+ inline bool operator == (const wxColour& colour) { return (m_red == colour.m_red && m_green == colour.m_green && m_blue == colour.m_blue); }
+
+ inline bool operator != (const wxColour& colour) { return (!(m_red == colour.m_red && m_green == colour.m_green && m_blue == colour.m_blue)); }
+
// Allocate a colour, or nearest colour, using the given display.
// If realloc is TRUE, ignore the existing pixel, otherwise just return
// the existing one.
int AllocColour(WXDisplay* display, bool realloc = FALSE);
+ void InitFromName(const wxString& col);
+
private:
bool m_isInit;
unsigned char m_red;
}
virtual void SetSelection(long from, long to);
virtual void SetEditable(bool editable);
+
+// Implementation
+ virtual void ChangeFont();
+ virtual void ChangeBackgroundColour();
+ virtual void ChangeForegroundColour();
};
#endif
// Responds to colour changes
void OnSysColourChanged(wxSysColourChangedEvent& event);
- //// Motif-specific
+// Implementation
+ virtual void ChangeFont();
+ virtual void ChangeBackgroundColour();
+ virtual void ChangeForegroundColour();
inline WXWidget GetTopWidget() const { return m_mainWidget; }
inline WXWidget GetClientWidget() const { return m_mainWidget; }
virtual void CaptureMouse();
virtual void ReleaseMouse();
- //// Motif-specific
-
+// Implementation
+ virtual void ChangeFont();
+ virtual void ChangeBackgroundColour();
+ virtual void ChangeForegroundColour();
WXWidget GetMenuBarWidget() const ;
inline WXWidget GetShellWidget() const { return m_frameShell; }
inline WXWidget GetWorkAreaWidget() const { return m_workArea; }
virtual void Command(wxCommandEvent& WXUNUSED(event)) {} ;
+// Implementation
+ virtual void ChangeFont();
+ virtual void ChangeBackgroundColour();
+ virtual void ChangeForegroundColour();
+
protected:
int m_rangeMax;
int m_gaugePos;
void Command(wxCommandEvent& event);
+// Implementation
+ virtual void ChangeFont();
+ virtual void ChangeBackgroundColour();
+ virtual void ChangeForegroundColour();
WXWidget GetTopWidget() const;
protected:
// toolbar(s), don't call SetToolBar.
void GetClientSize(int *width, int *height) const;
- // Get the active MDI child window (Windows only)
+ // Get the active MDI child window
wxMDIChildFrame *GetActiveChild() const ;
// Get the client window
virtual void ActivateNext();
virtual void ActivatePrevious();
+// Implementation
+ inline void SetActiveChild(wxMDIChildFrame* child) { m_activeChild = child; }
+
protected:
- wxMDIClientWindow *m_clientWindow;
+ wxMDIClientWindow* m_clientWindow;
+ wxMDIChildFrame* m_activeChild;
DECLARE_EVENT_TABLE()
};
void BuildClientArea(WXWidget parent);
inline WXWidget GetTopWidget() const { return m_mainWidget; };
inline wxXsMDIWindow *GetMDIWindow() const { return m_mdiWindow; };
+ virtual void OnRaise();
+ virtual void OnLower();
protected:
wxXsMDIWindow* m_mdiWindow ;
virtual void SetConstraintSizes(bool recurse = TRUE);
virtual bool DoPhase(int nPhase);
+// Implementation
+ virtual void ChangeFont();
+ virtual void ChangeBackgroundColour();
+ virtual void ChangeForegroundColour();
+
protected:
// common part of all ctors
void Init();
bool wxTranslateKeyEvent(wxKeyEvent& wxevent, wxWindow *win, Widget widget, XEvent *xevent);
int wxGetBestMatchingPixel(Display *display, XColor *desiredColor, Colormap cmap);
Pixmap XCreateInsensitivePixmap( Display *display, Pixmap pixmap );
+extern XColor g_itemColors[];
+extern int wxComputeColours (Display *display, wxColour * back, wxColour * fore);
#define wxNO_COLORS 0x00
#define wxBACK_COLORS 0x01
inline int GetNumberOfRowsOrCols() const { return m_noRowsOrCols; }
inline void SetNumberOfRowsOrCols(int n) { m_noRowsOrCols = n; }
+// Implementation
+ virtual void ChangeFont();
+ virtual void ChangeBackgroundColour();
+ virtual void ChangeForegroundColour();
WXWidget GetTopWidget() const { return m_formWidget; }
WXWidget GetLabelWidget() const { return m_labelWidget; }
inline WXWidget* GetRadioButtons() const { return m_radioButtons; }
void Command(wxCommandEvent& event);
+// Implementation
+ virtual void ChangeFont();
+ virtual void ChangeBackgroundColour();
+ virtual void ChangeForegroundColour();
WXWidget GetTopWidget() const { return m_formWidget; }
WXWidget GetLabelWidget() const { return m_labelWidget; }
void Command(wxCommandEvent& event);
+// Implementation
+ virtual void ChangeFont();
+ virtual void ChangeBackgroundColour();
+ virtual void ChangeForegroundColour();
+
protected:
int m_pageSize;
int m_viewSize;
void SetTick(int tickPos) ;
void Command(wxCommandEvent& event);
+
+// Implementation
+ virtual void ChangeFont();
+ virtual void ChangeBackgroundColour();
+ virtual void ChangeForegroundColour();
+
protected:
int m_rangeMin;
int m_rangeMax;
void Command(wxCommandEvent& event) { ProcessCommand(event); };
+// Implementation
+ virtual void ChangeFont();
+ virtual void ChangeBackgroundColour();
+ virtual void ChangeForegroundColour();
+
protected:
int m_min;
int m_max;
// overriden base class virtuals
virtual bool AcceptsFocus() const { return FALSE; }
+// Implementation
+ virtual void ChangeFont();
+ virtual void ChangeBackgroundColour();
+ virtual void ChangeForegroundColour();
+
protected:
wxBitmap m_messageBitmap;
void SetLabel(const wxString& label);
wxString GetLabel() const;
- // Motif-specific
+// Implementation
+ virtual void ChangeFont();
+ virtual void ChangeBackgroundColour();
+ virtual void ChangeForegroundColour();
WXWidget GetTopWidget() const { return m_formWidget; }
WXWidget GetLabelWidget() const { return m_labelWidget; }
// operations
virtual void Command(wxCommandEvent& WXUNUSED(event)) {};
virtual void ProcessCommand(wxCommandEvent& WXUNUSED(event)) {};
+
+// Implementation
+ virtual void ChangeFont();
+ virtual void ChangeBackgroundColour();
+ virtual void ChangeForegroundColour();
};
#endif
void OnChar(wxKeyEvent& event);
// void OnEraseBackground(wxEraseEvent& event);
- // Implementation
- // --------------
virtual void Command(wxCommandEvent& event);
- //// Motif-specific
+// Implementation
+ virtual void ChangeFont();
+ virtual void ChangeBackgroundColour();
+ virtual void ChangeForegroundColour();
inline void SetModified(bool mod) { m_modified = mod; }
virtual WXWidget GetTopWidget() const;
{
DECLARE_DYNAMIC_CLASS(wxTimer)
+ friend void wxTimerCallback (wxTimer * timer);
+
public:
wxTimer();
~wxTimer();
inline wxToolBar(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = wxNO_BORDER|wxTB_HORIZONTAL,
- const wxString& name = wxToolBarNameStr)
+ const wxString& name = wxToolBarNameStr):
+ m_widgets(wxKEY_INTEGER)
+
{
Create(parent, id, pos, size, style, name);
}
bool Realize() { return CreateTools(); };
protected:
+ // List of widgets in the toolbar, indexed by tool index
+ wxList m_widgets;
DECLARE_EVENT_TABLE()
};
void SetConstraints(wxLayoutConstraints *c);
// Set/get window background colour
- inline virtual void SetBackgroundColour(const wxColour& col);
+ virtual void SetBackgroundColour(const wxColour& col);
inline virtual wxColour GetBackgroundColour() const;
// Set/get window foreground colour
- inline virtual void SetForegroundColour(const wxColour& col);
+ virtual void SetForegroundColour(const wxColour& col);
inline virtual wxColour GetForegroundColour() const;
// Get the default button, if there is one
virtual WXRegion GetPaintRegion() const { return m_paintRegion; }
// Change properties
- virtual void ChangeColour(WXWidget widget);
- virtual void ChangeFont(WXWidget widget);
+ virtual void ChangeFont(); // Change to the current font (often overridden)
+ virtual void DoChangeForegroundColour(WXWidget widget, wxColour& foregroundColour);
+ virtual void DoChangeBackgroundColour(WXWidget widget, wxColour& backgroundColour, bool changeArmColour = FALSE);
+ // These to be overridden as needed (may change several widgets)
+ virtual void ChangeBackgroundColour(); // Change background and foreground colour using current
+ // background colour setting (Motif generates
+ // foreground based on background)
+ virtual void ChangeForegroundColour(); // Change foreground colour using current
+ // foreground colour setting
// Adds the widget to the hash table and adds event handlers.
bool AttachWidget (wxWindow* parent, WXWidget mainWidget,
inline void wxWindow::SetAutoLayout(bool a) { m_autoLayout = a; }
inline bool wxWindow::GetAutoLayout() const { return m_autoLayout; }
inline wxLayoutConstraints *wxWindow::GetConstraints() const { return m_constraints; }
-inline void wxWindow::SetBackgroundColour(const wxColour& col) { m_backgroundColour = col; };
inline wxColour wxWindow::GetBackgroundColour() const { return m_backgroundColour; };
-inline void wxWindow::SetForegroundColour(const wxColour& col) { m_foregroundColour = col; };
inline wxColour wxWindow::GetForegroundColour() const { return m_foregroundColour; };
inline wxButton *wxWindow::GetDefaultItem() const { return m_defaultItem; }
# define wxToolBar wxToolBarMSW
# define sm_classwxToolBar sm_classwxToolBarMSW
#elif defined(__WXMOTIF__)
-# include "wx/tbarsmpl.h"
-# define wxToolBar wxToolBarSimple
-# define sm_classwxToolBar sm_classwxToolBarSimple
+# include "wx/motif/toolbar.h"
#elif defined(__WXGTK__)
# include "wx/gtk/tbargtk.h"
#elif defined(__WXQT__)
class MyCanvas: public wxScrolledWindow
{
public:
- MyCanvas(wxWindow* parent, int x, int y, int w, int h);
+ MyCanvas(wxWindow* parent, wxWindowID id, int x, int y, int w, int h);
virtual ~MyCanvas();
virtual void OnDraw(wxDC& dc);
#define SPLIT_VERTICAL 3
#define SPLIT_UNSPLIT 4
+// Window ids
+#define SPLITTER_WINDOW 100
+#define SPLITTER_FRAME 101
+#define CANVAS1 102
+#define CANVAS2 103
+
IMPLEMENT_APP(MyApp)
bool MyApp::OnInit(void)
// My frame constructor
MyFrame::MyFrame(wxFrame* frame, const wxString& title, const wxPoint& pos, const wxSize& size):
- wxFrame(frame, -1, title, pos, size)
+ wxFrame(frame, SPLITTER_FRAME, title, pos, size)
{
// set the icon
#ifdef __WXMSW__
SetMenuBar(menuBar);
- splitter = new wxSplitterWindow(this, -1, wxPoint(0, 0), wxSize(400, 400),
+ splitter = new wxSplitterWindow(this, SPLITTER_WINDOW, wxPoint(0, 0), wxSize(400, 400),
// wxSP_BORDER);
wxSP_3D);
// wxSP_NOBORDER);
- leftCanvas = new MyCanvas(splitter, 0, 0, 400, 400);
+ leftCanvas = new MyCanvas(splitter, CANVAS1, 0, 0, 400, 400);
leftCanvas->SetBackgroundColour(*wxRED);
leftCanvas->SetScrollbars(20, 20, 50, 50);
- rightCanvas = new MyCanvas(splitter, 0, 0, 400, 400);
+ rightCanvas = new MyCanvas(splitter, CANVAS2, 0, 0, 400, 400);
rightCanvas->SetBackgroundColour(*wxCYAN);
rightCanvas->SetScrollbars(20, 20, 50, 50);
rightCanvas->Show(FALSE);
wxFrame::OnIdle(event);
}
-MyCanvas::MyCanvas(wxWindow* parent, int x, int y, int w, int h) :
- wxScrolledWindow(parent, -1, wxPoint(x, y), wxSize(w, h))
+MyCanvas::MyCanvas(wxWindow* parent, wxWindowID id, int x, int y, int w, int h) :
+ wxScrolledWindow(parent, id, wxPoint(x, y), wxSize(w, h))
{
}
XtDispatchEvent(&event);
- DeletePendingObjects();
+ ProcessIdle();
}
}
M_BITMAPHANDLERDATA->m_bitmapMask->SetPixmap((WXPixmap) mask);
}
+ unsigned int depthRet;
+ int xRet, yRet;
+ unsigned int widthRet, heightRet, borderWidthRet;
+ Window rootWindowRet;
+ XGetGeometry(dpy, pixmap, &rootWindowRet, &xRet, &yRet,
+ &widthRet, &heightRet, &borderWidthRet, &depthRet);
+
M_BITMAPHANDLERDATA->m_width = xpmAttr.width;
M_BITMAPHANDLERDATA->m_height = xpmAttr.height;
+
+ /*
if ( xpmAttr.npixels > 2 )
{
M_BITMAPHANDLERDATA->m_depth = 8; // TODO: next time not just a guess :-) ...
{
M_BITMAPHANDLERDATA->m_depth = 1; // mono
}
+ */
+
+ M_BITMAPHANDLERDATA->m_depth = depthRet;
M_BITMAPHANDLERDATA->m_numColors = xpmAttr.npixels;
// Set attributes
M_BITMAPHANDLERDATA->m_width = xpmAttr.width;
M_BITMAPHANDLERDATA->m_height = xpmAttr.height;
+
+ unsigned int depthRet;
+ int xRet, yRet;
+ unsigned int widthRet, heightRet, borderWidthRet;
+ Window rootWindowRet;
+ XGetGeometry(dpy, pixmap, &rootWindowRet, &xRet, &yRet,
+ &widthRet, &heightRet, &borderWidthRet, &depthRet);
+
+ /*
if ( xpmAttr.npixels > 2 )
{
M_BITMAPHANDLERDATA->m_depth = 8; // next time not just a guess :-) ...
{
M_BITMAPHANDLERDATA->m_depth = 1; // mono
}
+ */
+
+ M_BITMAPHANDLERDATA->m_depth = depthRet;
+
M_BITMAPHANDLERDATA->m_numColors = xpmAttr.npixels;
XpmFreeAttributes(&xpmAttr);
M_BITMAPHANDLERDATA->m_ok = TRUE;
{
Display *dpy = (Display*) M_BITMAPDATA->m_display;
+ if (M_BITMAPDATA->m_insensPixmap)
+ return M_BITMAPDATA->m_insensPixmap;
+
+ if (!w)
+ {
+ M_BITMAPDATA->m_insensPixmap = (WXPixmap) XCreateInsensitivePixmap(dpy, (Pixmap) M_BITMAPDATA->m_pixmap);
+ if (M_BITMAPDATA->m_insensPixmap)
+ return M_BITMAPDATA->m_insensPixmap;
+ else
+ return M_BITMAPDATA->m_pixmap;
+ }
+
if (M_BITMAPDATA->m_insensImage == (WXPixmap) 0)
return M_BITMAPDATA->m_pixmap;
SetFont(* parent->GetFont());
- ChangeColour (m_mainWidget);
+ ChangeBackgroundColour ();
return TRUE;
SetName(name);
SetValidator(validator);
m_windowStyle = style;
+ m_backgroundColour = parent->GetBackgroundColour();
+ m_foregroundColour = parent->GetForegroundColour();
parent->AddChild((wxButton *)this);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
SetFont(* parent->GetFont());
- ChangeColour(m_mainWidget);
+ ChangeBackgroundColour();
return TRUE;
}
event.SetEventObject(item);
item->ProcessCommand (event);
}
+
+void wxButton::ChangeFont()
+{
+ // TODO
+}
+
+void wxButton::ChangeBackgroundColour()
+{
+ // TODO
+}
+
+void wxButton::ChangeForegroundColour()
+{
+ // TODO
+}
+
SetName(name);
SetValidator(validator);
m_windowStyle = style;
+ m_backgroundColour = parent->GetBackgroundColour();
+ m_foregroundColour = parent->GetForegroundColour();
if (parent) parent->AddChild(this);
SetCanAddEventHandler(TRUE);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
- ChangeColour(m_mainWidget);
+ ChangeBackgroundColour();
SetFont(* parent->GetFont());
return TRUE;
event.SetEventObject(item);
item->ProcessCommand (event);
}
+
+void wxCheckBox::ChangeFont()
+{
+ // TODO
+}
+
+void wxCheckBox::ChangeBackgroundColour()
+{
+ // TODO
+}
+
+void wxCheckBox::ChangeForegroundColour()
+{
+ // TODO
+}
+
else
m_windowId = id;
+ m_backgroundColour = parent->GetBackgroundColour();
+ m_foregroundColour = parent->GetForegroundColour();
+
Widget parentWidget = (Widget) parent->GetClientWidget();
m_formWidget = (WXWidget) XtVaCreateManagedWidget ((char*) (const char*) name,
AttachWidget (parent, m_buttonWidget, m_formWidget, pos.x, pos.y, size.x, size.y);
SetFont(* parent->GetFont());
- ChangeColour(m_mainWidget);
+ ChangeBackgroundColour();
return TRUE;
}
}
}
+void wxChoice::ChangeFont()
+{
+ // TODO
+}
+
+void wxChoice::ChangeBackgroundColour()
+{
+ // TODO
+}
+
+void wxChoice::ChangeForegroundColour()
+{
+ // TODO
+}
+
SetValidator(validator);
m_noStrings = n;
m_windowStyle = style;
+ m_backgroundColour = parent->GetBackgroundColour();
+ m_foregroundColour = parent->GetForegroundColour();
if (parent) parent->AddChild(this);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
SetFont(* parent->GetFont());
- ChangeColour(m_mainWidget);
+ ChangeBackgroundColour();
return TRUE;
}
}
}
+void wxComboBox::ChangeFont()
+{
+ // TODO
+}
+
+void wxComboBox::ChangeBackgroundColour()
+{
+ // TODO
+}
+
+void wxComboBox::ChangeForegroundColour()
+{
+ // TODO
+}
+
#endif
int pixel = m_backgroundBrush.GetColour().AllocColour(m_display);
- XSetWindowBackground ((Display*) m_display, (Pixmap) m_pixmap, pixel);
+ // XSetWindowBackground doesn't work for non-Window pixmaps
+ if (!this->IsKindOf(CLASSINFO(wxMemoryDC)))
+ XSetWindowBackground ((Display*) m_display, (Pixmap) m_pixmap, pixel);
// Necessary for ::DrawIcon, which use fg/bg pixel or the GC.
// And Blit,... (Any fct that use XCopyPlane, in fact.)
wxDialog::wxDialog()
{
m_modalShowing = FALSE;
- SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
+ m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE);
}
bool wxDialog::Create(wxWindow *parent, wxWindowID id,
m_modalShowing = FALSE;
m_dialogTitle = title;
- SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
+ m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE);
+ m_foregroundColour = *wxBLACK;
+
SetName(name);
if (!parent)
wxDialogBoxEventHandler,
(XtPointer)this);
+ ChangeBackgroundColour();
+
return TRUE;
}
client->m_isShown = FALSE;
*/
}
+
+void wxDialog::ChangeFont()
+{
+ // TODO
+}
+
+void wxDialog::ChangeBackgroundColour()
+{
+ // TODO
+}
+
+void wxDialog::ChangeForegroundColour()
+{
+ // TODO
+}
+
m_visibleStatus = TRUE;
m_title = "";
- SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE));
+ m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE);
+ m_foregroundColour = *wxBLACK;
if ( id > -1 )
m_windowId = id;
#endif
#endif
+ ChangeBackgroundColour();
+
PreResize();
wxSizeEvent sizeEvent(wxSize(width, height), GetId());
return m_clientArea;
}
+void wxFrame::ChangeFont()
+{
+ // TODO
+}
+
+void wxFrame::ChangeBackgroundColour()
+{
+ // TODO
+}
+
+void wxFrame::ChangeForegroundColour()
+{
+ // TODO
+}
+
void wxCloseFrameCallback(Widget widget, XtPointer client_data, XmAnyCallbackStruct *cbs)
{
wxFrame *frame = (wxFrame *)client_data;
// May delete the frame (with delayed deletion)
frame->GetEventHandler()->ProcessEvent(closeEvent);
}
+
SetValidator(validator);
m_rangeMax = range;
m_windowStyle = style;
+ m_backgroundColour = parent->GetBackgroundColour();
+ m_foregroundColour = parent->GetForegroundColour();
if (parent) parent->AddChild(this);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, x, y, width, height);
SetFont(* parent->GetFont());
- ChangeColour(m_mainWidget);
+ ChangeBackgroundColour();
return TRUE;
}
// return m_gaugePos;
}
+void wxGauge::ChangeFont()
+{
+ // TODO
+}
+
+void wxGauge::ChangeBackgroundColour()
+{
+ // TODO
+}
+
+void wxGauge::ChangeForegroundColour()
+{
+ // TODO
+}
+
//// PRIVATE DECLARATIONS FOR XMGAUGE
#include <Xm/PrimitiveP.h>
m_windowStyle = style;
m_noItems = n;
m_selected = 0;
+ m_backgroundColour = parent->GetBackgroundColour();
+ m_foregroundColour = parent->GetForegroundColour();
SetName(name);
SetValidator(validator);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, width, height);
- wxSystemSettings settings;
- SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW));
+ m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW);
SetFont(* parent->GetFont());
- ChangeColour(m_mainWidget);
+ ChangeBackgroundColour();
return TRUE;
}
{
return (WXWidget) XtParent( (Widget) m_mainWidget );
}
+
+void wxListBox::ChangeFont()
+{
+ // TODO
+}
+
+void wxListBox::ChangeBackgroundColour()
+{
+ // TODO
+}
+
+void wxListBox::ChangeForegroundColour()
+{
+ // TODO
+}
+
textctrl.cpp \
thread.cpp \
timer.cpp \
+ toolbar.cpp \
utils.cpp \
utilsexc.cpp \
wave.cpp \
# listctrl.cpp \
# imaglist.cpp \
# statusbr.cpp \
-# toolbar.cpp \
LIB_C_SRC=\
\
// Generate wxSizeEvent here, I think. Maybe also restore, maximize
// Probably don't need to generate size event here since work area
- // is used
+ // is used (???)
wxSizeEvent event(wxSize(w, h), m_childFrame->GetId());
event.SetEventObject(m_childFrame);
m_childFrame->ProcessEvent(event);
XsMotifWindow::close();
m_childFrame->Close();
}
+ virtual void raise()
+ {
+ XsMotifWindow::raise();
+ m_childFrame->OnRaise();
+ }
+ virtual void lower()
+ {
+ XsMotifWindow::lower();
+ m_childFrame->OnLower();
+ }
virtual void _buildClientArea(Widget parent)
{
m_childFrame->BuildClientArea((WXWidget) parent);
wxMDIParentFrame::wxMDIParentFrame()
{
- m_clientWindow = NULL;
+ m_clientWindow = (wxMDIClientWindow*) NULL;
+ m_activeChild = (wxMDIChildFrame*) NULL;
}
bool wxMDIParentFrame::Create(wxWindow *parent,
long style,
const wxString& name)
{
- m_clientWindow = NULL;
+ m_clientWindow = (wxMDIClientWindow*) NULL;
+ m_activeChild = (wxMDIChildFrame*) NULL;
bool success = wxFrame::Create(parent, id, title, pos, size, style, name);
if (success)
// Returns the active MDI child window
wxMDIChildFrame *wxMDIParentFrame::GetActiveChild() const
{
- // TODO
- return NULL;
+ return m_activeChild;
}
// Create the client window class (don't Create the window,
int x = pos.x; int y = pos.y;
int width = size.x; int height = size.y;
+ if (width == -1)
+ width = 200; // TODO: give reasonable default
+ if (height == -1)
+ height = 200; // TODO: give reasonable default
wxMDIClientWindow* clientWindow = parent->GetClientWindow();
if (!clientWindow)
return FALSE;
+ // We're deactivating the old child
+ wxMDIChildFrame* oldActiveChild = parent->GetActiveChild();
+ if (oldActiveChild)
+ {
+ wxActivateEvent event(wxEVT_ACTIVATE, FALSE, oldActiveChild->GetId());
+ event.SetEventObject( oldActiveChild );
+ oldActiveChild->GetEventHandler()->ProcessEvent(event);
+ }
+
m_mdiWindow = new wxXsMDIWindow("mdiChildWindow", this);
clientWindow->GetMDICanvas()->add(m_mdiWindow);
+
+ // This is the currently active child
+ parent->SetActiveChild((wxMDIChildFrame*) this);
+
m_mdiWindow->Show();
+
#if 0
m_mainWidget = (WXWidget) (Widget) (*m_mdiWindow);
PreResize();
- wxSizeEvent sizeEvent(wxSize(width, height), GetId());
- sizeEvent.SetEventObject(this);
-
- GetEventHandler()->ProcessEvent(sizeEvent);
+ m_mdiWindow->setSize(width, height);
wxModelessWindows.Append(this);
return TRUE;
wxMDIChildFrame::~wxMDIChildFrame()
{
- wxMDIClientWindow* clientWindow = ((wxMDIParentFrame*)GetParent())->GetClientWindow();
+ wxMDIParentFrame* parentFrame = (wxMDIParentFrame*) GetParent() ;
+ if (parentFrame->GetActiveChild() == this)
+ parentFrame->SetActiveChild((wxMDIChildFrame*) NULL);
+
+ wxMDIClientWindow* clientWindow = parentFrame->GetClientWindow();
clientWindow->GetMDICanvas()->remove(m_mdiWindow);
m_mainWidget = (WXWidget) 0;
}
+// Implementation: intercept and act upon raise and lower commands.
+void wxMDIChildFrame::OnRaise()
+{
+ wxMDIParentFrame* parentFrame = (wxMDIParentFrame*) GetParent() ;
+ wxMDIChildFrame* oldActiveChild = parentFrame->GetActiveChild();
+ parentFrame->SetActiveChild(this);
+
+ if (oldActiveChild)
+ {
+ wxActivateEvent event(wxEVT_ACTIVATE, FALSE, oldActiveChild->GetId());
+ event.SetEventObject( oldActiveChild );
+ oldActiveChild->GetEventHandler()->ProcessEvent(event);
+ }
+
+ wxActivateEvent event(wxEVT_ACTIVATE, TRUE, this->GetId());
+ event.SetEventObject( this );
+ this->GetEventHandler()->ProcessEvent(event);
+}
+
+void wxMDIChildFrame::OnLower()
+{
+ wxMDIParentFrame* parentFrame = (wxMDIParentFrame*) GetParent() ;
+ wxMDIChildFrame* oldActiveChild = parentFrame->GetActiveChild();
+
+ if (oldActiveChild == this)
+ {
+ wxActivateEvent event(wxEVT_ACTIVATE, FALSE, oldActiveChild->GetId());
+ event.SetEventObject( oldActiveChild );
+ oldActiveChild->GetEventHandler()->ProcessEvent(event);
+ }
+ // TODO: unfortunately we don't now know which is the top-most child,
+ // so make the active child NULL.
+ parentFrame->SetActiveChild((wxMDIChildFrame*) NULL);
+}
+
// Set the client size (i.e. leave the calculation of borders etc.
// to wxWindows)
void wxMDIChildFrame::SetClientSize(int width, int height)
-Copyright (c) 1996 Scott W. Sadler
+Copyright (c) 1996, 1998 Scott W. Sadler
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
in this Software without prior written authorization.
Scott W. Sadler
-Software Engineer
-International TechneGroup Incorporated
-5303 DuPont Circle
-Milford, OH 45150
-sws@iti-oh.com
-http://www.iti-oh.com/~sws
+Cisco Systems
+7025 Kit Creek Road
+P.O. Box 14987
+Research Triangle Park NC, 27709
+ssadler@cisco.com
#define FOUND_COMPILER
#endif
+#ifdef i386SVR4Architecture
+CXX = CC
+CC = $(CXX)
+CCOPTIONS=
+#define COMPILER_FOUND
+#endif
+
#ifndef FOUND_COMPILER
CXX = gcc
CC = $(CXX)
<HEAD>
<TITLE>XsMDICanvas Class</TITLE>
-<LINK REV="made" HREF="mailto:sws@iti-oh.com">
+<LINK REV="made" HREF="mailto:ssadler@cisco.com">
</HEAD>
<H2>
<HEAD>
<TITLE>Motif Multi-Document Interface (MDI)</TITLE>
-<LINK REV="made" HREF="mailto:sws@iti-oh.com">
+<LINK REV="made" HREF="mailto:ssadler@cisco.com">
</HEAD>
<CENTER>
<HEAD>
<TITLE>XsMotifWindow Class</TITLE>
-<LINK REV="made" HREF="mailto:sws@iti-oh.com">
+<LINK REV="made" HREF="mailto:ssadler@cisco.com">
</HEAD>
<H2>
XsComponent.C
History
- 03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com)
+ 03-Mar-96 1.0; Scott W. Sadler (ssadler@cisco.com)
Created
*/
{
#ifndef NDEBUG
- if (XtIsManaged (_base))
- cout << "Re-managing a widget:" << _name << endl;
+ // if (XtIsManaged (_base))
+ // cout << "Re-managing a widget:" << _name << endl;
#endif
// Make sure the _destroyHandler was installed
{
#ifndef NDEBUG
- if (!XtIsManaged (_base))
- cout << "Re-unmanaging a widget:" << _name << endl;
+ // if (!XtIsManaged (_base))
+ // cout << "Re-unmanaging a widget:" << _name << endl;
#endif
assert (_base != 0);
XsComponent.h
History
- 03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com)
+ 03-Mar-96 1.0; Scott W. Sadler (ssadler@cisco.com)
Created
*/
virtual void show ( ); // Show the component
virtual void hide ( ); // Hide the component
-// Added JACS 19/10/98
- inline Widget GetBase() const { return _base; }
-
// Component name
const char *name ( ) const;
XsMDICanvas.C
History
- 03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com)
+ 03-Mar-96 1.0; Scott W. Sadler (ssadler@cisco.com)
Created
*/
XsMDICanvas.h
History
- 03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com)
+ 03-Mar-96 1.0; Scott W. Sadler (ssadler@cisco.com)
Created
*/
virtual void add (XsMDIWindow *win); // Add an MDI window
virtual void remove (XsMDIWindow *win); // Remove an MDI window
void removeAll ( ); // Remove all MDI windows
-
-// Added JACS 19/10/98
- inline Widget GetDrawingArea() const { return _drawArea; }
// Utilities
int numWindows ( ) const; // Number of MDI windows
+ Widget GetDrawingArea() const { return _drawArea; }
// Component methods
XsMDIWindow.C
History
- 03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com)
+ 03-Mar-96 1.0; Scott W. Sadler (ssadler@cisco.com)
Created
*/
XsMDIWindow.h
History
- 03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com)
+ 03-Mar-96 1.0; Scott W. Sadler (ssadler@cisco.com)
Created
*/
XsMotifWindow.C
History
- 03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com)
+ 03-Mar-96 1.0; Scott W. Sadler (ssadler@cisco.com)
Created
*/
setPosition (_savedX, _savedY);
setSize (_savedWidth, _savedHeight);
-
- _maximized = False;
-
-// Redraw the maximize button
-
- _buttons[_XsMotifButton::Maximize]->redraw ( );
}
}
if (_minimized == False)
XtVaSetValues (_base, XmNwidth, w, XmNheight, h, NULL);
+
+// If window was maximized, change the window state back to normal
+
+ if (_maximized == True)
+ {
+ _maximized = False;
+
+// Redraw the maximize button
+
+ _buttons[_XsMotifButton::Maximize]->redraw ( );
+ }
}
else
XsMDIWindow::setSize (w, h); // Cache the points
XsMotifWindow.h
History
- 03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com)
+ 03-Mar-96 1.0; Scott W. Sadler (ssadler@cisco.com)
Created
*/
XsMoveOutline.C
History
- 03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com)
+ 03-Mar-96 1.0; Scott W. Sadler (ssadler@cisco.com)
Created
*/
XsMoveOutline.h
History
- 03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com)
+ 03-Mar-96 1.0; Scott W. Sadler (ssadler@cisco.com)
Created
*/
XsOutline.C
History
- 03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com)
+ 03-Mar-96 1.0; Scott W. Sadler (ssadler@cisco.com)
Created
*/
XsOutline.h
History
- 03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com)
+ 03-Mar-96 1.0; Scott W. Sadler (ssadler@cisco.com)
Created
*/
XsResizeOutline.C
History
- 03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com)
+ 03-Mar-96 1.0; Scott W. Sadler (ssadler@cisco.com)
Created
*/
XsResizeOutline.h
History
- 03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com)
+ 03-Mar-96 1.0; Scott W. Sadler (ssadler@cisco.com)
Created
*/
xs_motif_icon.xbm
History
- 03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com)
+ 03-Mar-96 1.0; Scott W. Sadler (ssadler@cisco.com)
Created
*/
m_nSelection = nSel;
}
+void wxNotebook::ChangeFont()
+{
+ // TODO
+}
+
+void wxNotebook::ChangeBackgroundColour()
+{
+ // TODO
+}
+
+void wxNotebook::ChangeForegroundColour()
+{
+ // TODO
+}
+
m_labelWidget = (WXWidget) 0;
m_radioButtons = (WXWidget*) NULL;
m_radioButtonLabels = (wxString*) NULL;
+ m_backgroundColour = parent->GetBackgroundColour();
+ m_foregroundColour = parent->GetForegroundColour();
SetName(name);
SetValidator(val);
AttachWidget (parent, m_mainWidget, m_formWidget, pos.x, pos.y, size.x, size.y);
SetFont(* parent->GetFont());
- ChangeColour(m_mainWidget);
+ ChangeBackgroundColour();
return TRUE;
}
ProcessCommand (event);
}
+void wxRadioBox::ChangeFont()
+{
+ // TODO
+}
+
+void wxRadioBox::ChangeBackgroundColour()
+{
+ // TODO
+}
+
+void wxRadioBox::ChangeForegroundColour()
+{
+ // TODO
+}
+
void wxRadioBoxCallback (Widget w, XtPointer clientData,
XmToggleButtonCallbackStruct * cbs)
{
{
SetName(name);
SetValidator(validator);
+ m_backgroundColour = parent->GetBackgroundColour();
+ m_foregroundColour = parent->GetForegroundColour();
if (parent) parent->AddChild(this);
AttachWidget (parent, m_mainWidget, m_formWidget, pos.x, pos.y, size.x, size.y);
SetFont(* parent->GetFont());
- ChangeColour(m_mainWidget);
+ ChangeBackgroundColour();
return TRUE;
}
ProcessCommand (event);
}
+void wxRadioButton::ChangeFont()
+{
+ // TODO
+}
+
+void wxRadioButton::ChangeBackgroundColour()
+{
+ // TODO
+}
+
+void wxRadioButton::ChangeForegroundColour()
+{
+ // TODO
+}
+
void wxRadioButtonCallback (Widget w, XtPointer clientData,
XmToggleButtonCallbackStruct * cbs)
{
return FALSE;
parent->AddChild(this);
SetName(name);
- SetValidator(validator);
+ m_backgroundColour = parent->GetBackgroundColour();
+ m_foregroundColour = parent->GetForegroundColour();
+ SetValidator(validator);
m_windowStyle = style;
SetCanAddEventHandler(TRUE);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, x, y, width, height);
- ChangeColour(m_mainWidget);
+ ChangeBackgroundColour();
return TRUE;
}
ProcessCommand(event);
}
+void wxScrollBar::ChangeFont()
+{
+ // TODO
+}
+
+void wxScrollBar::ChangeBackgroundColour()
+{
+ // TODO
+}
+
+void wxScrollBar::ChangeForegroundColour()
+{
+ // TODO
+}
+
void wxScrollBarCallback(Widget widget, XtPointer clientData,
XmScaleCallbackStruct *cbs)
{
{
SetName(name);
SetValidator(validator);
+ m_backgroundColour = parent->GetBackgroundColour();
+ m_foregroundColour = parent->GetForegroundColour();
if (parent) parent->AddChild(this);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
SetFont(* parent->GetFont());
- ChangeColour(m_mainWidget);
+ ChangeBackgroundColour();
return TRUE;
}
ProcessCommand (event);
}
+void wxSlider::ChangeFont()
+{
+ // TODO
+}
+
+void wxSlider::ChangeBackgroundColour()
+{
+ // TODO
+}
+
+void wxSlider::ChangeForegroundColour()
+{
+ // TODO
+}
+
void wxSliderCallback (Widget widget, XtPointer clientData, XmScaleCallbackStruct * cbs)
{
wxSlider *slider = (wxSlider *) clientData;
// TODO
}
+void wxSpinButton::ChangeFont()
+{
+ // TODO
+}
+
+void wxSpinButton::ChangeBackgroundColour()
+{
+ // TODO
+}
+
+void wxSpinButton::ChangeForegroundColour()
+{
+ // TODO
+}
+
// Spin event
IMPLEMENT_DYNAMIC_CLASS(wxSpinEvent, wxScrollEvent)
{
m_messageBitmap = bitmap;
SetName(name);
+ m_backgroundColour = parent->GetBackgroundColour();
+ m_foregroundColour = parent->GetForegroundColour();
if (parent) parent->AddChild(this);
if ( id == -1 )
SetFont(* parent->GetFont());
- ChangeColour (m_mainWidget);
+ ChangeBackgroundColour ();
return TRUE;
}
}
}
+void wxStaticBitmap::ChangeFont()
+{
+ // TODO
+}
+
+void wxStaticBitmap::ChangeBackgroundColour()
+{
+ // TODO
+}
+
+void wxStaticBitmap::ChangeForegroundColour()
+{
+ // TODO
+}
+
{
m_formWidget = (WXWidget) 0;
m_labelWidget = (WXWidget) 0;
+ m_backgroundColour = parent->GetBackgroundColour();
+ m_foregroundColour = parent->GetForegroundColour();
SetName(name);
SetCanAddEventHandler(TRUE);
AttachWidget (parent, m_mainWidget, (WXWidget) frameWidget, pos.x, pos.y, size.x, size.y);
- ChangeColour(m_mainWidget);
+ ChangeBackgroundColour();
return TRUE;
}
}
}
+void wxStaticBox::ChangeFont()
+{
+ // TODO
+}
+
+void wxStaticBox::ChangeBackgroundColour()
+{
+ // TODO
+}
+
+void wxStaticBox::ChangeForegroundColour()
+{
+ // TODO
+}
+
SetName(name);
if (parent) parent->AddChild(this);
- SetBackgroundColour(parent->GetBackgroundColour()) ;
- SetForegroundColour(parent->GetForegroundColour()) ;
+ m_backgroundColour = parent->GetBackgroundColour();
+ m_foregroundColour = parent->GetForegroundColour();
if ( id == -1 )
m_windowId = (int)NewControlId();
SetFont(* parent->GetFont());
- ChangeColour (m_mainWidget);
+ ChangeBackgroundColour ();
return TRUE;
}
+void wxStaticText::ChangeFont()
+{
+ // TODO
+}
+
+void wxStaticText::ChangeBackgroundColour()
+{
+ // TODO
+}
+
+void wxStaticText::ChangeForegroundColour()
+{
+ // TODO
+}
+
m_modified = FALSE;
m_processedDefault = FALSE;
m_fileName = "";
+ m_backgroundColour = parent->GetBackgroundColour();
+ m_foregroundColour = parent->GetForegroundColour();
SetName(name);
SetValidator(validator);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
SetFont(* parent->GetFont());
- ChangeColour(m_mainWidget);
+ ChangeBackgroundColour();
return TRUE;
}
}
}
+void wxTextCtrl::ChangeFont()
+{
+ // TODO
+}
+
+void wxTextCtrl::ChangeBackgroundColour()
+{
+ // TODO
+}
+
+void wxTextCtrl::ChangeForegroundColour()
+{
+ // TODO
+}
+
static void wxTextWindowChangedProc (Widget w, XtPointer clientData, XtPointer ptr)
{
if (!wxGetWindowFromTable(w))
#endif
#include "wx/timer.h"
+#include "wx/app.h"
+#include "wx/list.h"
+
+#include <Xm/Xm.h>
+
+#include "wx/motif/private.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxObject)
#endif
+static wxList wxTimerList(wxKEY_INTEGER);
+
+void wxTimerCallback (wxTimer * timer)
+{
+ // Check to see if it's still on
+ if (!wxTimerList.Find((long)timer))
+ return;
+
+ if (timer->m_id == 0)
+ return; // Avoid to process spurious timer events
+
+ if (!timer->m_oneShot)
+ timer->m_id = XtAppAddTimeOut ((XtAppContext) wxTheApp->GetAppContext(), timer->m_milli,
+ (XtTimerCallbackProc) wxTimerCallback, (XtPointer) timer);
+ else
+ timer->m_id = 0;
+ timer->Notify ();
+}
+
wxTimer::wxTimer()
{
+ m_id = 0;
m_milli = 0 ;
m_id = 0;
m_oneShot = FALSE;
Stop();
}
-bool wxTimer::Start(int milliseconds,bool mode)
+bool wxTimer::Start(int milliseconds, bool mode)
{
- m_oneShot = mode ;
+ Stop();
+
+ m_oneShot = mode;
+ if (milliseconds < 0)
+ milliseconds = m_lastMilli;
+
if (milliseconds <= 0)
return FALSE;
- m_milli = milliseconds;
+ m_lastMilli = m_milli = milliseconds;
+
+ if (!wxTimerList.Find((long)this))
+ wxTimerList.Append((long)this, this);
- // TODO: set the timer going.
- return FALSE;
+ m_id = XtAppAddTimeOut ((XtAppContext) wxTheApp->GetAppContext(), milliseconds,
+ (XtTimerCallbackProc) wxTimerCallback, (XtPointer) this);
+ return TRUE;
}
void wxTimer::Stop()
{
- m_id = 0 ;
+ if (m_id > 0)
+ {
+ XtRemoveTimeOut (m_id);
+ m_id = 0;
+ }
m_milli = 0 ;
}
#endif
#include "wx/wx.h"
-#include "wx/toolbar.h"
+#include "wx/motif/toolbar.h"
+
+#include <Xm/Xm.h>
+#include <Xm/PushBG.h>
+#include <Xm/PushB.h>
+#include <Xm/ToggleB.h>
+#include <Xm/ToggleBG.h>
+#include <Xm/Form.h>
+
+#include "wx/motif/private.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxToolBar, wxToolBarBase)
END_EVENT_TABLE()
#endif
-wxToolBar::wxToolBar()
+wxToolBar::wxToolBar():
+ m_widgets(wxKEY_INTEGER)
{
m_maxWidth = -1;
m_maxHeight = -1;
m_defaultWidth = 24;
m_defaultHeight = 22;
SetName(name);
-
+ m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE);
+ m_foregroundColour = parent->GetForegroundColour();
m_windowStyle = style;
SetParent(parent);
if (parent) parent->AddChild(this);
- // TODO create toolbar
+ Widget parentWidget = (Widget) parent->GetClientWidget();
+
+ Widget toolbar = XtVaCreateManagedWidget("toolbar",
+ xmFormWidgetClass, parentWidget,
+ XmNtraversalOn, False,
+ XmNhorizontalSpacing, 0,
+ XmNverticalSpacing, 0,
+ NULL);
+
+ m_mainWidget = (WXWidget) toolbar;
+
+ SetCanAddEventHandler(TRUE);
+ AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
+
+ SetFont(* parent->GetFont());
+ ChangeBackgroundColour();
- return FALSE;
+ return TRUE;
}
wxToolBar::~wxToolBar()
if (m_tools.Number() == 0)
return FALSE;
- // TODO
- return FALSE;
+ m_widgets.Clear();
+ Widget prevButton = (Widget) 0;
+ wxNode* node = m_tools.First();
+ while (node)
+ {
+ wxToolBarTool *tool = (wxToolBarTool *)node->Data();
+ if ((tool->m_toolStyle != wxTOOL_STYLE_SEPARATOR) && tool->m_bitmap1.Ok())
+ {
+ Widget button = (Widget) 0;
+
+ if (tool->m_isToggle)
+ {
+ button = XtVaCreateManagedWidget("toggleButton",
+ xmToggleButtonWidgetClass, (Widget) m_mainWidget,
+ XmNleftAttachment, (prevButton == (Widget) 0) ? XmATTACH_FORM : XmATTACH_WIDGET,
+ XmNleftWidget, (prevButton == (Widget) 0) ? NULL : prevButton,
+ XmNleftOffset, 0,
+ XmNtopAttachment, XmATTACH_FORM,
+ // XmNpushButtonEnabled, True,
+ XmNmultiClick, XmMULTICLICK_KEEP,
+ XmNlabelType, XmPIXMAP,
+ NULL);
+ }
+ else
+ {
+ button = XtVaCreateManagedWidget("button",
+ xmPushButtonWidgetClass, (Widget) m_mainWidget,
+ XmNleftAttachment, (prevButton == (Widget) 0) ? XmATTACH_FORM : XmATTACH_WIDGET,
+ XmNleftWidget, (prevButton == (Widget) 0) ? NULL : prevButton,
+ XmNleftOffset, 0,
+ XmNtopAttachment, XmATTACH_FORM,
+ XmNpushButtonEnabled, True,
+ XmNmultiClick, XmMULTICLICK_KEEP,
+ XmNlabelType, XmPIXMAP,
+ NULL);
+ }
+
+ // For each button, if there is a mask, we must create
+ // a new wxBitmap that has the correct background colour
+ // for the button. Otherwise the background will just be
+ // e.g. black if a transparent XPM has been loaded.
+ if (tool->m_bitmap1.GetMask())
+ {
+ wxBitmap newBitmap(tool->m_bitmap1.GetWidth(),
+ tool->m_bitmap1.GetHeight(),
+ tool->m_bitmap1.GetDepth());
+ int backgroundPixel;
+ XtVaGetValues(button, XmNbackground, &backgroundPixel,
+ NULL);
+
+
+ wxColour col;
+ col.SetPixel(backgroundPixel);
+
+ wxMemoryDC destDC;
+ wxMemoryDC srcDC;
+ srcDC.SelectObject(tool->m_bitmap1);
+ destDC.SelectObject(newBitmap);
+
+ wxBrush brush(col, wxSOLID);
+ destDC.SetOptimization(FALSE);
+ destDC.SetBackground(brush);
+ destDC.Clear();
+ destDC.Blit(0, 0, tool->m_bitmap1.GetWidth(), tool->m_bitmap1.GetHeight(), & srcDC, 0, 0, wxCOPY, TRUE);
+
+ tool->m_bitmap1 = newBitmap;
+ }
+ if (tool->m_bitmap2.Ok() && tool->m_bitmap2.GetMask())
+ {
+ wxBitmap newBitmap(tool->m_bitmap2.GetWidth(),
+ tool->m_bitmap2.GetHeight(),
+ tool->m_bitmap2.GetDepth());
+ int backgroundPixel;
+ XtVaGetValues(button, XmNbackground, &backgroundPixel,
+ NULL);
+
+
+ wxColour col;
+ col.SetPixel(backgroundPixel);
+
+ wxMemoryDC destDC;
+ wxMemoryDC srcDC;
+ srcDC.SelectObject(tool->m_bitmap2);
+ destDC.SelectObject(newBitmap);
+
+ wxBrush brush(col, wxSOLID);
+ destDC.SetOptimization(FALSE);
+ destDC.SetBackground(brush);
+ destDC.Clear();
+ destDC.Blit(0, 0, tool->m_bitmap2.GetWidth(), tool->m_bitmap2.GetHeight(), & srcDC, 0, 0, wxCOPY, TRUE);
+
+ tool->m_bitmap2 = newBitmap;
+ }
+ Pixmap pixmap = (Pixmap) tool->m_bitmap1.GetPixmap();
+ Pixmap insensPixmap = (Pixmap) tool->m_bitmap1.GetInsensPixmap();
+
+ if (tool->m_isToggle)
+ {
+ Pixmap pixmap2 = (Pixmap) 0;
+ Pixmap insensPixmap2 = (Pixmap) 0;
+
+ // If there's a bitmap for the toggled state, use it,
+ // otherwise generate one.
+ if (tool->m_bitmap2.Ok())
+ {
+ pixmap2 = (Pixmap) tool->m_bitmap2.GetPixmap();
+ insensPixmap2 = (Pixmap) tool->m_bitmap2.GetInsensPixmap();
+ }
+ else
+ {
+ pixmap2 = (Pixmap) tool->m_bitmap1.GetArmPixmap(button);
+ // This has to be both toggled and insensitive, but
+ // wxBitmap doesn't yet have a member to store & destroy
+ // it, so make it the same as pixmap2. Actually it's not
+ // used!
+ insensPixmap2 = pixmap2;
+ }
+ XtVaSetValues (button,
+ XmNlabelPixmap, pixmap,
+ XmNselectPixmap, pixmap,
+ XmNlabelInsensitivePixmap, insensPixmap,
+ XmNselectInsensitivePixmap, insensPixmap,
+ XmNarmPixmap, pixmap2,
+ XmNlabelType, XmPIXMAP,
+ NULL);
+
+ }
+ else
+ {
+ XtVaSetValues(button,
+ XmNlabelPixmap, pixmap,
+ XmNlabelInsensitivePixmap, insensPixmap,
+ NULL);
+ }
+
+ m_widgets.Append(tool->m_index, (wxObject*) button);
+
+ prevButton = button;
+
+ }
+ node = node->Next();
+ }
+
+ return TRUE;
}
void wxToolBar::SetToolBitmapSize(const wxSize& size)
void wxToolBar::ClearTools()
{
- // TODO
+ wxNode* node = m_widgets.First();
+ while (node)
+ {
+ Widget button = (Widget) node->Data();
+ XtDestroyWidget(button);
+ node = node->Next();
+ }
+ m_widgets.Clear();
+
wxToolBarBase::ClearTools();
}
}
}
-void wxWindow::SetFont(const wxFont& font)
-{
- m_windowFont = font;
-
- // Note that this causes the widget to be resized back
- // to its original size! We therefore have to set the size
- // back again. TODO: a better way in Motif?
- /*
- Widget w = (Widget) GetLabelWidget(); // Usually the main widget
- if (w && m_windowFont.Ok())
- {
- int width, height, width1, height1;
- GetSize(& width, & height);
-
- XtVaSetValues (w,
- XmNfontList, (XmFontList) m_windowFont.GetFontList(1.0, XtDisplay(w)),
- NULL);
-
- GetSize(& width1, & height1);
- if (width != width1 || height != height1)
- {
- SetSize(-1, -1, width, height);
- }
- }
- */
-}
-
void wxWindow::OnChar(wxKeyEvent& event)
{
if ( event.KeyCode() == WXK_TAB ) {
void wxWindow::OnIdle(wxIdleEvent& event)
{
-/* TODO: you may need to do something like this
- * if your GUI doesn't generate enter/leave events
-
- // Check if we need to send a LEAVE event
- if (m_mouseInWindow)
- {
- POINT pt;
- ::GetCursorPos(&pt);
- if (::WindowFromPoint(pt) != (HWND) GetHWND())
- {
- // Generate a LEAVE event
- m_mouseInWindow = FALSE;
- MSWOnMouseLeave(pt.x, pt.y, 0);
- }
- }
-*/
-
// This calls the UI-update mechanism (querying windows for
// menu/toolbar/control state information)
- UpdateWindowUI();
+ UpdateWindowUI();
}
// Raise the window to the top of the Z order
return FALSE;
}
-// TODO From wxWin 1.68. What does it do exactly?
#define YAllocColor XAllocColor
-
-XColor itemColors[5];
-int wxComputeColors (Display *display, wxColour * back, wxColour * fore)
+XColor g_itemColors[5];
+int wxComputeColours (Display *display, wxColour * back, wxColour * fore)
{
int result;
static XmColorProc colorProc;
if (back)
{
- itemColors[0].red = (((long) back->Red ()) << 8);
- itemColors[0].green = (((long) back->Green ()) << 8);
- itemColors[0].blue = (((long) back->Blue ()) << 8);
- itemColors[0].flags = DoRed | DoGreen | DoBlue;
+ g_itemColors[0].red = (((long) back->Red ()) << 8);
+ g_itemColors[0].green = (((long) back->Green ()) << 8);
+ g_itemColors[0].blue = (((long) back->Blue ()) << 8);
+ g_itemColors[0].flags = DoRed | DoGreen | DoBlue;
if (colorProc == (XmColorProc) NULL)
{
// Get a ptr to the actual function
// And set it back to motif.
XmSetColorCalculation (colorProc);
}
- (*colorProc) (&itemColors[wxBACK_INDEX],
- &itemColors[wxFORE_INDEX],
- &itemColors[wxSELE_INDEX],
- &itemColors[wxTOPS_INDEX],
- &itemColors[wxBOTS_INDEX]);
+ (*colorProc) (&g_itemColors[wxBACK_INDEX],
+ &g_itemColors[wxFORE_INDEX],
+ &g_itemColors[wxSELE_INDEX],
+ &g_itemColors[wxTOPS_INDEX],
+ &g_itemColors[wxBOTS_INDEX]);
result = wxBACK_COLORS;
}
if (fore)
{
- itemColors[wxFORE_INDEX].red = (((long) fore->Red ()) << 8);
- itemColors[wxFORE_INDEX].green = (((long) fore->Green ()) << 8);
- itemColors[wxFORE_INDEX].blue = (((long) fore->Blue ()) << 8);
- itemColors[wxFORE_INDEX].flags = DoRed | DoGreen | DoBlue;
+ g_itemColors[wxFORE_INDEX].red = (((long) fore->Red ()) << 8);
+ g_itemColors[wxFORE_INDEX].green = (((long) fore->Green ()) << 8);
+ g_itemColors[wxFORE_INDEX].blue = (((long) fore->Blue ()) << 8);
+ g_itemColors[wxFORE_INDEX].flags = DoRed | DoGreen | DoBlue;
if (result == wxNO_COLORS)
result = wxFORE_COLORS;
}
{
/* 5 Colours to allocate */
for (int i = 0; i < 5; i++)
- if (!YAllocColor (dpy, cmap, &itemColors[i]))
+ if (!YAllocColor (dpy, cmap, &g_itemColors[i]))
result = wxNO_COLORS;
}
else if (fore)
{
/* Only 1 colour to allocate */
- if (!YAllocColor (dpy, cmap, &itemColors[wxFORE_INDEX]))
+ if (!YAllocColor (dpy, cmap, &g_itemColors[wxFORE_INDEX]))
result = wxNO_COLORS;
}
}
-void wxWindow::ChangeColour(WXWidget widget)
+// Changes the foreground and background colours to be derived
+// from the current background colour.
+// To change the foreground colour, you must call SetForegroundColour
+// explicitly.
+void wxWindow::ChangeBackgroundColour()
{
- // TODO
-#if 0
- int change;
+ if (GetMainWidget())
+ DoChangeBackgroundColour(GetMainWidget(), m_backgroundColour);
+}
- // TODO: how to determine whether we can change this item's colours?
- // We used to have wxUSER_COLOURS. Now perhaps we assume we always
- // can change it.
- // if (!(parent->GetWindowStyleFlag() & wxUSER_COLOURS))
- // return;
+void wxWindow::ChangeForegroundColour()
+{
+ if (GetMainWidget())
+ DoChangeForegroundColour(GetMainWidget(), m_foregroundColour);
+}
- change = wxComputeColors (XtDisplay((Widget)widget), panel->GetBackgroundColour(),
- panel->GetLabelColour());
- if (change == wxBACK_COLORS)
- XtVaSetValues ((Widget) widget,
- XmNbackground, itemColors[wxBACK_INDEX].pixel,
- XmNtopShadowColor, itemColors[wxTOPS_INDEX].pixel,
- XmNbottomShadowColor, itemColors[wxBOTS_INDEX].pixel,
- XmNforeground, itemColors[wxFORE_INDEX].pixel,
- NULL);
- else if (change == wxFORE_COLORS)
- XtVaSetValues (formWidget,
- XmNforeground, itemColors[wxFORE_INDEX].pixel,
- NULL);
+// Change a widget's foreground and background colours.
+
+// TODO: make this 2 functions, ChangeForegroundColour and ChangeBackgroundColour.
+
+void wxWindow::DoChangeForegroundColour(WXWidget widget, wxColour& foregroundColour)
+{
+ // When should we specify the foreground, if it's calculated
+ // by wxComputeColours?
+ // Solution: say we start with the default (computed) foreground colour.
+ // If we call SetForegroundColour explicitly for a control or window,
+ // then the foreground is changed.
+ // Therefore SetBackgroundColour computes the foreground colour, and
+ // SetForegroundColour changes the foreground colour. The ordering is
+ // important.
- change = wxComputeColors (XtDisplay((Widget)formWidget), GetBackgroundColour(), GetLabelColour());
- if (change == wxBACK_COLORS)
- XtVaSetValues (labelWidget,
- XmNbackground, itemColors[wxBACK_INDEX].pixel,
- XmNtopShadowColor, itemColors[wxTOPS_INDEX].pixel,
- XmNbottomShadowColor, itemColors[wxBOTS_INDEX].pixel,
- XmNarmColor, itemColors[wxSELE_INDEX].pixel,
- XmNforeground, itemColors[wxFORE_INDEX].pixel,
+ XtVaSetValues ((Widget) widget,
+ XmNforeground, foregroundColour.AllocColour(XtDisplay((Widget) widget)),
NULL);
- else if (change == wxFORE_COLORS)
- XtVaSetValues (labelWidget,
- XmNforeground, itemColors[wxFORE_INDEX].pixel,
+}
+
+void wxWindow::DoChangeBackgroundColour(WXWidget widget, wxColour& backgroundColour, bool changeArmColour)
+{
+ wxComputeColours (XtDisplay((Widget) widget), & backgroundColour,
+ (wxColour*) NULL);
+
+ XtVaSetValues ((Widget) widget,
+ XmNbackground, g_itemColors[wxBACK_INDEX].pixel,
+ XmNtopShadowColor, g_itemColors[wxTOPS_INDEX].pixel,
+ XmNbottomShadowColor, g_itemColors[wxBOTS_INDEX].pixel,
+ XmNforeground, g_itemColors[wxFORE_INDEX].pixel,
NULL);
-#endif
+
+ if (changeArmColour)
+ XtVaSetValues ((Widget) widget,
+ XmNarmColor, g_itemColors[wxSELE_INDEX].pixel,
+ NULL);
}
-void wxWindow::ChangeFont(WXWidget widget)
+void wxWindow::SetBackgroundColour(const wxColour& col)
{
- /*
- if (widget && GetFont() && GetFont()->Ok())
- {
- XmFontList fontList = (XmFontList) GetFont()->GetFontList(1.0, GetXDisplay());
- if (fontList)
- XtVaSetValues ((Widget) widget,
- XmNfontList, fontList,
+ m_backgroundColour = col;
+ ChangeBackgroundColour();
+}
+
+void wxWindow::SetForegroundColour(const wxColour& col)
+{
+ m_foregroundColour = col;
+ ChangeForegroundColour();
+}
+
+void wxWindow::ChangeFont()
+{
+ // Note that this causes the widget to be resized back
+ // to its original size! We therefore have to set the size
+ // back again. TODO: a better way in Motif?
+ /*
+ Widget w = (Widget) GetLabelWidget(); // Usually the main widget
+ if (w && m_windowFont.Ok())
+ {
+ int width, height, width1, height1;
+ GetSize(& width, & height);
+
+ XtVaSetValues (w,
+ XmNfontList, (XmFontList) m_windowFont.GetFontList(1.0, XtDisplay(w)),
NULL);
- }
- */
+
+ GetSize(& width1, & height1);
+ if (width != width1 || height != height1)
+ {
+ SetSize(-1, -1, width, height);
+ }
+ }
+ */
}
+
+void wxWindow::SetFont(const wxFont& font)
+{
+ m_windowFont = font;
+ ChangeFont();
+}
+
+