From 83df96d63a52ebb08b9e32549dc255354b4a18d0 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Tue, 5 Feb 2002 16:34:33 +0000 Subject: [PATCH] Reformatted Motif headers; added __WXX11__ symbol support to common headers; added place-holding src/x11 and include/wx/x11 files. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14015 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/accel.h | 4 +- include/wx/app.h | 2 + include/wx/bitmap.h | 2 + include/wx/brush.h | 2 + include/wx/clipbrd.h | 2 + include/wx/colour.h | 2 + include/wx/cursor.h | 2 + include/wx/dataobj.h | 2 + include/wx/dc.h | 2 + include/wx/dcclient.h | 2 + include/wx/dcmemory.h | 2 + include/wx/dcscreen.h | 2 + include/wx/defs.h | 8 +- include/wx/dirdlg.h | 2 + include/wx/dnd.h | 2 + include/wx/dragimag.h | 5 + include/wx/filedlg.h | 2 + include/wx/font.h | 2 + include/wx/gdicmn.h | 8 +- include/wx/gdiobj.h | 2 + include/wx/glcanvas.h | 2 + include/wx/icon.h | 2 + include/wx/joystick.h | 2 + include/wx/mdi.h | 2 + include/wx/minifram.h | 2 + include/wx/motif/accel.h | 65 +- include/wx/motif/app.h | 52 +- include/wx/motif/bitmap.h | 308 ++-- include/wx/motif/bmpbuttn.h | 128 +- include/wx/motif/brush.h | 66 +- include/wx/motif/button.h | 32 +- include/wx/motif/checkbox.h | 86 +- include/wx/motif/checklst.h | 26 +- include/wx/motif/choice.h | 55 +- include/wx/motif/clipbrd.h | 30 +- include/wx/motif/colordlg.h | 14 +- include/wx/motif/colour.h | 114 +- include/wx/motif/combobox.h | 50 +- include/wx/motif/control.h | 46 +- include/wx/motif/cursor.h | 72 +- include/wx/motif/dataform.h | 28 +- include/wx/motif/dataobj.h | 4 +- include/wx/motif/dc.h | 48 +- include/wx/motif/dcclient.h | 94 +- include/wx/motif/dcmemory.h | 18 +- include/wx/motif/dcprint.h | 16 +- include/wx/motif/dcscreen.h | 42 +- include/wx/motif/dialog.h | 82 +- include/wx/motif/dirdlg.h | 12 +- include/wx/motif/dnd.h | 86 +- include/wx/motif/filedlg.h | 32 +- include/wx/motif/font.h | 64 +- include/wx/motif/fontdlg.h | 16 +- include/wx/motif/frame.h | 84 +- include/wx/motif/gauge.h | 42 +- include/wx/motif/gdiobj.h | 30 +- include/wx/motif/glcanvas.h | 136 +- include/wx/motif/helpxxxx.h | 46 +- include/wx/motif/icon.h | 66 +- include/wx/motif/joystick.h | 134 +- include/wx/motif/listbox.h | 72 +- include/wx/motif/mdi.h | 260 +-- include/wx/motif/menu.h | 82 +- include/wx/motif/menuitem.h | 36 +- include/wx/motif/metafile.h | 108 +- include/wx/motif/minifram.h | 36 +- include/wx/motif/msgdlg.h | 20 +- include/wx/motif/palette.h | 56 +- include/wx/motif/pen.h | 114 +- include/wx/motif/print.h | 50 +- include/wx/motif/printdlg.h | 70 +- include/wx/motif/private.h | 10 +- include/wx/motif/radiobox.h | 48 +- include/wx/motif/radiobut.h | 82 +- include/wx/motif/region.h | 192 +-- include/wx/motif/scrolbar.h | 78 +- include/wx/motif/slider.h | 60 +- include/wx/motif/spinbutt.h | 39 +- include/wx/motif/statbmp.h | 46 +- include/wx/motif/statbox.h | 44 +- include/wx/motif/stattext.h | 34 +- include/wx/motif/tabctrl.h | 92 +- include/wx/motif/taskbar.h | 22 +- include/wx/motif/textctrl.h | 78 +- include/wx/motif/timer.h | 20 +- include/wx/motif/toolbar.h | 62 +- include/wx/motif/wave.h | 28 +- include/wx/motif/window.h | 202 +-- include/wx/palette.h | 2 + include/wx/pen.h | 2 + include/wx/popupwin.h | 2 + include/wx/printdlg.h | 2 + include/wx/region.h | 2 + include/wx/timer.h | 2 + include/wx/toolbar.h | 2 + include/wx/toplevel.h | 3 + include/wx/window.h | 8 + include/wx/x11/accel.h | 51 + include/wx/x11/app.h | 131 ++ include/wx/x11/bitmap.h | 230 +++ include/wx/x11/brush.h | 79 + include/wx/x11/clipbrd.h | 84 + include/wx/x11/colour.h | 92 ++ include/wx/x11/cursor.h | 84 + include/wx/x11/dataform.h | 66 + include/wx/x11/dataobj.h | 30 + include/wx/x11/dc.h | 168 ++ include/wx/x11/dcclient.h | 177 ++ include/wx/x11/dcmemory.h | 43 + include/wx/x11/dcprint.h | 34 + include/wx/x11/dcscreen.h | 48 + include/wx/x11/dnd.h | 178 +++ include/wx/x11/font.h | 117 ++ include/wx/x11/gdiobj.h | 48 + include/wx/x11/glcanvas.h | 161 ++ include/wx/x11/icon.h | 57 + include/wx/x11/joystick.h | 93 ++ include/wx/x11/mdi.h | 250 +++ include/wx/x11/minifram.h | 46 + include/wx/x11/palette.h | 81 + include/wx/x11/pen.h | 102 ++ include/wx/x11/popupwin.h | 50 + include/wx/x11/print.h | 56 + include/wx/x11/private.h | 120 ++ include/wx/x11/region.h | 155 ++ include/wx/x11/timer.h | 44 + include/wx/x11/toolbar.h | 82 + include/wx/x11/toplevel.h | 134 ++ include/wx/x11/window.h | 358 +++++ src/x11/accel.cpp | 116 ++ src/x11/app.cpp | 796 +++++++++ src/x11/bitmap.cpp | 1558 ++++++++++++++++++ src/x11/brush.cpp | 123 ++ src/x11/clipbrd.cpp | 525 ++++++ src/x11/colour.cpp | 214 +++ src/x11/cursor.cpp | 440 +++++ src/x11/data.cpp | 138 ++ src/x11/dataobj.cpp | 200 +++ src/x11/dc.cpp | 232 +++ src/x11/dcclient.cpp | 2408 ++++++++++++++++++++++++++++ src/x11/dcmemory.cpp | 159 ++ src/x11/dcscreen.cpp | 134 ++ src/x11/dnd.cpp | 238 +++ src/x11/font.cpp | 551 +++++++ src/x11/gdiobj.cpp | 18 + src/x11/glcanvas.cpp | 395 +++++ src/x11/gsockx11.c | 126 ++ src/x11/icon.cpp | 82 + src/x11/joystick.cpp | 284 ++++ src/x11/main.cpp | 18 + src/x11/makefile.unx | 356 +++++ src/x11/menu.cpp | 767 +++++++++ src/x11/minifram.cpp | 20 + src/x11/palette.cpp | 356 +++++ src/x11/pen.cpp | 182 +++ src/x11/region.cpp | 536 +++++++ src/x11/settings.cpp | 246 +++ src/x11/timer.cpp | 92 ++ src/x11/toolbar.cpp | 666 ++++++++ src/x11/toplevel.cpp | 930 +++++++++++ src/x11/utils.cpp | 1233 ++++++++++++++ src/x11/window.cpp | 3024 +++++++++++++++++++++++++++++++++++ 162 files changed, 22793 insertions(+), 2176 deletions(-) create mode 100644 include/wx/x11/accel.h create mode 100644 include/wx/x11/app.h create mode 100644 include/wx/x11/bitmap.h create mode 100644 include/wx/x11/brush.h create mode 100644 include/wx/x11/clipbrd.h create mode 100644 include/wx/x11/colour.h create mode 100644 include/wx/x11/cursor.h create mode 100644 include/wx/x11/dataform.h create mode 100644 include/wx/x11/dataobj.h create mode 100644 include/wx/x11/dc.h create mode 100644 include/wx/x11/dcclient.h create mode 100644 include/wx/x11/dcmemory.h create mode 100644 include/wx/x11/dcprint.h create mode 100644 include/wx/x11/dcscreen.h create mode 100644 include/wx/x11/dnd.h create mode 100644 include/wx/x11/font.h create mode 100644 include/wx/x11/gdiobj.h create mode 100644 include/wx/x11/glcanvas.h create mode 100644 include/wx/x11/icon.h create mode 100644 include/wx/x11/joystick.h create mode 100644 include/wx/x11/mdi.h create mode 100644 include/wx/x11/minifram.h create mode 100644 include/wx/x11/palette.h create mode 100644 include/wx/x11/pen.h create mode 100644 include/wx/x11/popupwin.h create mode 100644 include/wx/x11/print.h create mode 100644 include/wx/x11/private.h create mode 100644 include/wx/x11/region.h create mode 100644 include/wx/x11/timer.h create mode 100644 include/wx/x11/toolbar.h create mode 100644 include/wx/x11/toplevel.h create mode 100644 include/wx/x11/window.h create mode 100644 src/x11/accel.cpp create mode 100644 src/x11/app.cpp create mode 100644 src/x11/bitmap.cpp create mode 100644 src/x11/brush.cpp create mode 100644 src/x11/clipbrd.cpp create mode 100644 src/x11/colour.cpp create mode 100644 src/x11/cursor.cpp create mode 100644 src/x11/data.cpp create mode 100644 src/x11/dataobj.cpp create mode 100644 src/x11/dc.cpp create mode 100644 src/x11/dcclient.cpp create mode 100644 src/x11/dcmemory.cpp create mode 100644 src/x11/dcscreen.cpp create mode 100644 src/x11/dnd.cpp create mode 100644 src/x11/font.cpp create mode 100644 src/x11/gdiobj.cpp create mode 100644 src/x11/glcanvas.cpp create mode 100644 src/x11/gsockx11.c create mode 100644 src/x11/icon.cpp create mode 100644 src/x11/joystick.cpp create mode 100644 src/x11/main.cpp create mode 100644 src/x11/makefile.unx create mode 100644 src/x11/menu.cpp create mode 100644 src/x11/minifram.cpp create mode 100644 src/x11/palette.cpp create mode 100644 src/x11/pen.cpp create mode 100644 src/x11/region.cpp create mode 100644 src/x11/settings.cpp create mode 100644 src/x11/timer.cpp create mode 100644 src/x11/toolbar.cpp create mode 100644 src/x11/toplevel.cpp create mode 100644 src/x11/utils.cpp create mode 100644 src/x11/window.cpp diff --git a/include/wx/accel.h b/include/wx/accel.h index 40676ee7f0..78595ea427 100644 --- a/include/wx/accel.h +++ b/include/wx/accel.h @@ -75,7 +75,7 @@ public: bool operator!=(const wxAcceleratorEntry& entry) const { return !(*this == entry); } -#ifdef __WXMOTIF__ +#if defined(__WXMOTIF__) || defined(__WXX11__) // Implementation use only bool MatchesEvent(const wxKeyEvent& event) const ; #endif @@ -105,6 +105,8 @@ private: #include "wx/motif/accel.h" #elif defined(__WXGTK__) #include "wx/gtk/accel.h" +#elif defined(__WXX11__) + #include "wx/x11/accel.h" #elif defined(__WXMAC__) #include "wx/mac/accel.h" #elif defined(__WXPM__) diff --git a/include/wx/app.h b/include/wx/app.h index 9c76ed5d7e..88258c10fe 100644 --- a/include/wx/app.h +++ b/include/wx/app.h @@ -375,6 +375,8 @@ protected: #include "wx/mgl/app.h" #elif defined(__WXGTK__) #include "wx/gtk/app.h" + #elif defined(__WXX11__) + #include "wx/x11/app.h" #elif defined(__WXMAC__) #include "wx/mac/app.h" #elif defined(__WXPM__) diff --git a/include/wx/bitmap.h b/include/wx/bitmap.h index aa86bc86b9..478697ae6b 100644 --- a/include/wx/bitmap.h +++ b/include/wx/bitmap.h @@ -159,6 +159,8 @@ protected: #include "wx/motif/bitmap.h" #elif defined(__WXGTK__) #include "wx/gtk/bitmap.h" +#elif defined(__WXX11__) +#include "wx/x11/bitmap.h" #elif defined(__WXMGL__) #include "wx/mgl/bitmap.h" #elif defined(__WXMAC__) diff --git a/include/wx/brush.h b/include/wx/brush.h index b8ddfd0181..9b8bdfe4c4 100644 --- a/include/wx/brush.h +++ b/include/wx/brush.h @@ -7,6 +7,8 @@ #include "wx/motif/brush.h" #elif defined(__WXGTK__) #include "wx/gtk/brush.h" +#elif defined(__WXX11__) +#include "wx/x11/brush.h" #elif defined(__WXMGL__) #include "wx/mgl/brush.h" #elif defined(__WXMAC__) diff --git a/include/wx/clipbrd.h b/include/wx/clipbrd.h index 25c9b7f806..69c06bdce4 100644 --- a/include/wx/clipbrd.h +++ b/include/wx/clipbrd.h @@ -88,6 +88,8 @@ public: #include "wx/motif/clipbrd.h" #elif defined(__WXGTK__) #include "wx/gtk/clipbrd.h" +#elif defined(__WXX11__) + #include "wx/x11/clipbrd.h" #elif defined(__WXMGL__) #include "wx/mgl/clipbrd.h" #elif defined(__WXMAC__) diff --git a/include/wx/colour.h b/include/wx/colour.h index 9f43002689..4dc427d4e0 100644 --- a/include/wx/colour.h +++ b/include/wx/colour.h @@ -9,6 +9,8 @@ #include "wx/gtk/colour.h" #elif defined(__WXMGL__) #include "wx/mgl/colour.h" +#elif defined(__WXX11__) +#include "wx/x11/colour.h" #elif defined(__WXMAC__) #include "wx/mac/colour.h" #elif defined(__WXPM__) diff --git a/include/wx/cursor.h b/include/wx/cursor.h index cc89879e13..fbb4ab7b2e 100644 --- a/include/wx/cursor.h +++ b/include/wx/cursor.h @@ -7,6 +7,8 @@ #include "wx/motif/cursor.h" #elif defined(__WXGTK__) #include "wx/gtk/cursor.h" +#elif defined(__WXX11__) +#include "wx/x11/cursor.h" #elif defined(__WXMGL__) #include "wx/mgl/cursor.h" #elif defined(__WXMAC__) diff --git a/include/wx/dataobj.h b/include/wx/dataobj.h index 923f297094..1e6ecad470 100644 --- a/include/wx/dataobj.h +++ b/include/wx/dataobj.h @@ -79,6 +79,8 @@ public: #include "wx/motif/dataform.h" #elif defined(__WXGTK__) #include "wx/gtk/dataform.h" +#elif defined(__WXX11__) + #include "wx/x11/dataform.h" #elif defined(__WXMAC__) #include "wx/mac/dataform.h" #elif defined(__WXPM__) diff --git a/include/wx/dc.h b/include/wx/dc.h index ccf87a1784..9eb23674a1 100644 --- a/include/wx/dc.h +++ b/include/wx/dc.h @@ -758,6 +758,8 @@ private: #include "wx/motif/dc.h" #elif defined(__WXGTK__) #include "wx/gtk/dc.h" +#elif defined(__WXX11__) + #include "wx/x11/dc.h" #elif defined(__WXMGL__) #include "wx/mgl/dc.h" #elif defined(__WXMAC__) diff --git a/include/wx/dcclient.h b/include/wx/dcclient.h index 63acb36e88..1a8f9c6301 100644 --- a/include/wx/dcclient.h +++ b/include/wx/dcclient.h @@ -7,6 +7,8 @@ #include "wx/motif/dcclient.h" #elif defined(__WXGTK__) #include "wx/gtk/dcclient.h" +#elif defined(__WXX11__) +#include "wx/x11/dcclient.h" #elif defined(__WXMGL__) #include "wx/mgl/dcclient.h" #elif defined(__WXMAC__) diff --git a/include/wx/dcmemory.h b/include/wx/dcmemory.h index 0716eab54a..50a21b73c1 100644 --- a/include/wx/dcmemory.h +++ b/include/wx/dcmemory.h @@ -7,6 +7,8 @@ #include "wx/motif/dcmemory.h" #elif defined(__WXGTK__) #include "wx/gtk/dcmemory.h" +#elif defined(__WXX11__) +#include "wx/x11/dcmemory.h" #elif defined(__WXMGL__) #include "wx/mgl/dcmemory.h" #elif defined(__WXMAC__) diff --git a/include/wx/dcscreen.h b/include/wx/dcscreen.h index d0b8f133ad..e4ba503442 100644 --- a/include/wx/dcscreen.h +++ b/include/wx/dcscreen.h @@ -7,6 +7,8 @@ #include "wx/motif/dcscreen.h" #elif defined(__WXGTK__) #include "wx/gtk/dcscreen.h" +#elif defined(__WXX11__) +#include "wx/x11/dcscreen.h" #elif defined(__WXMGL__) #include "wx/mgl/dcscreen.h" #elif defined(__WXMAC__) diff --git a/include/wx/defs.h b/include/wx/defs.h index 786572f161..1182724f77 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -27,7 +27,7 @@ #error "Target can't be both X and Windows" #elif !defined(__WXMOTIF__) && !defined(__WXMSW__) && !defined(__WXGTK__) && \ !defined(__WXPM__) && !defined(__WXMAC__) && !defined(__X__) && \ - !defined(__WXMGL__) && wxUSE_GUI + !defined(__WXMGL__) && !defined(__WXX11__) && wxUSE_GUI #ifdef __UNIX__ #error "No Target! You should use wx-config program for compilation flags!" #else // !Unix @@ -424,6 +424,7 @@ enum wxGEOS, // GEOS wxOS2_PM, // OS/2 Workplace wxWINDOWS, // Windows or WfW + wxMICROWINDOWS, // MicroWindows wxPENWINDOWS, // Windows for Pen Computing wxWINDOWS_NT, // Windows NT wxWIN32S, // Windows 32S API @@ -435,7 +436,8 @@ enum wxMGL_OS2, // MGL on OS/2 wxMGL_DOS, // MGL on MS-DOS wxWINDOWS_OS2, // Native OS/2 PM - wxUNIX // wxBase under Unix + wxUNIX, // wxBase under Unix + wxX11 // Plain X11 and Universal widgets }; // ---------------------------------------------------------------------------- @@ -1852,7 +1854,7 @@ typedef WXRESULT (_System *WXFARPROC)(WXHWND, WXMSGID, WXWPARAM, WXLPARAM); #endif //__WXPM__ -#ifdef __WXMOTIF__ +#if defined(__WXMOTIF__) || defined(__WXX11__) /* Stand-ins for X/Xt/Motif types */ typedef void* WXWindow; typedef void* WXWidget; diff --git a/include/wx/dirdlg.h b/include/wx/dirdlg.h index cedb296539..423b40e080 100644 --- a/include/wx/dirdlg.h +++ b/include/wx/dirdlg.h @@ -21,6 +21,8 @@ WXDLLEXPORT_DATA(extern const wxChar*) wxEmptyString; #include "wx/generic/dirdlgg.h" #elif defined(__WXGTK__) #include "wx/generic/dirdlgg.h" +#elif defined(__WXX11__) + #include "wx/generic/dirdlgg.h" #elif defined(__WXMGL__) #include "wx/generic/dirdlgg.h" #elif defined(__WXMAC__) diff --git a/include/wx/dnd.h b/include/wx/dnd.h index b0c68b3b54..61f7625876 100644 --- a/include/wx/dnd.h +++ b/include/wx/dnd.h @@ -187,6 +187,8 @@ protected: #include "wx/msw/ole/droptgt.h" #elif defined(__WXMOTIF__) #include "wx/motif/dnd.h" +#elif defined(__WXX11__) + #include "wx/x11/dnd.h" #elif defined(__WXGTK__) #include "wx/gtk/dnd.h" #elif defined(__WXMAC__) diff --git a/include/wx/dragimag.h b/include/wx/dragimag.h index 63ab20c64d..0cee7e64cc 100644 --- a/include/wx/dragimag.h +++ b/include/wx/dragimag.h @@ -22,6 +22,11 @@ #define wxDragImage wxGenericDragImage #define sm_classwxDragImage sm_classwxGenericDragImage +#elif defined(__WXX11__) +#include "wx/generic/dragimgg.h" +#define wxDragImage wxGenericDragImage +#define sm_classwxDragImage sm_classwxGenericDragImage + #elif defined(__WXMAC__) #include "wx/generic/dragimgg.h" #define wxDragImage wxGenericDragImage diff --git a/include/wx/filedlg.h b/include/wx/filedlg.h index 29b0b58290..c8dc4ed5d9 100644 --- a/include/wx/filedlg.h +++ b/include/wx/filedlg.h @@ -20,6 +20,8 @@ enum #include "wx/motif/filedlg.h" #elif defined(__WXGTK__) #include "wx/generic/filedlgg.h" +#elif defined(__WXX11__) +#include "wx/generic/filedlg.h" #elif defined(__WXMGL__) #include "wx/generic/filedlgg.h" #elif defined(__WXMAC__) diff --git a/include/wx/font.h b/include/wx/font.h index 26e0b6ff92..7ca50d5dbb 100644 --- a/include/wx/font.h +++ b/include/wx/font.h @@ -166,6 +166,8 @@ private: #include "wx/motif/font.h" #elif defined(__WXGTK__) #include "wx/gtk/font.h" +#elif defined(__WXX11__) + #include "wx/x11/font.h" #elif defined(__WXMGL__) #include "wx/mgl/font.h" #elif defined(__WXMAC__) diff --git a/include/wx/gdicmn.h b/include/wx/gdicmn.h index 199f6aa679..55c7105a0b 100644 --- a/include/wx/gdicmn.h +++ b/include/wx/gdicmn.h @@ -166,6 +166,9 @@ enum wxStockCursor #elif defined(__WXMOTIF__) // Initialize from an included XPM #define wxICON(X) wxIcon( X##_xpm ) +#elif defined(__WXX11__) + // Initialize from an included XPM + #define wxICON(X) wxIcon( X##_xpm ) #else // This will usually mean something on any platform #define wxICON(X) wxIcon("" #X "") @@ -177,7 +180,7 @@ enum wxStockCursor #if defined(__WXMSW__) || defined(__WXPM__) #define wxBITMAP(name) wxBitmap(#name, wxBITMAP_TYPE_RESOURCE) -#elif defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__) || defined(__WXMGL__) +#elif defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXX11__) || defined(__WXMAC__) || defined(__WXMGL__) // Initialize from an included XPM #define wxBITMAP(name) wxBitmap( (const char**) name##_xpm ) #else // other platforms @@ -213,8 +216,7 @@ public: wxSize operator+(const wxSize& sz) { return wxSize(x + sz.x, y + sz.y); } wxSize operator-(const wxSize& sz) { return wxSize(x - sz.x, y - sz.y); } - // accessors - void Set(int xx, int yy) { x = xx; y = yy; } + // accessors void Set(int xx, int yy) { x = xx; y = yy; } void SetWidth(int w) { x = w; } void SetHeight(int h) { y = h; } diff --git a/include/wx/gdiobj.h b/include/wx/gdiobj.h index a5bf86c00c..46f310dc88 100644 --- a/include/wx/gdiobj.h +++ b/include/wx/gdiobj.h @@ -7,6 +7,8 @@ #include "wx/motif/gdiobj.h" #elif defined(__WXGTK__) #include "wx/gtk/gdiobj.h" +#elif defined(__WXX11__) +#include "wx/x11/gdiobj.h" #elif defined(__WXMGL__) #include "wx/mgl/gdiobj.h" #elif defined(__WXMAC__) diff --git a/include/wx/glcanvas.h b/include/wx/glcanvas.h index dac83974e5..45962a519d 100644 --- a/include/wx/glcanvas.h +++ b/include/wx/glcanvas.h @@ -11,6 +11,8 @@ #include "wx/motif/glcanvas.h" #elif defined(__WXGTK__) #include "wx/gtk/glcanvas.h" +#elif defined(__WXX11__) +#include "wx/x11/glcanvas.h" #elif defined(__WXMAC__) #include "wx/mac/glcanvas.h" #elif defined(__WXPM__) diff --git a/include/wx/icon.h b/include/wx/icon.h index 1632b1a03f..bd8703d178 100644 --- a/include/wx/icon.h +++ b/include/wx/icon.h @@ -13,6 +13,8 @@ #include "wx/motif/icon.h" #elif defined(__WXGTK__) #include "wx/gtk/icon.h" +#elif defined(__WXX11__) + #include "wx/x11/icon.h" #elif defined(__WXMGL__) #include "wx/mgl/icon.h" #elif defined(__WXMAC__) diff --git a/include/wx/joystick.h b/include/wx/joystick.h index 7203acb5bb..86134d92a3 100644 --- a/include/wx/joystick.h +++ b/include/wx/joystick.h @@ -9,6 +9,8 @@ #include "wx/motif/joystick.h" #elif defined(__WXGTK__) #include "wx/gtk/joystick.h" +#elif defined(__WXX11__) +#include "wx/x11/joystick.h" #elif defined(__WXMAC__) #include "wx/mac/joystick.h" #elif defined(__WXPM__) diff --git a/include/wx/mdi.h b/include/wx/mdi.h index 2eae537791..b712c1dd84 100644 --- a/include/wx/mdi.h +++ b/include/wx/mdi.h @@ -7,6 +7,8 @@ #include "wx/motif/mdi.h" #elif defined(__WXGTK__) #include "wx/gtk/mdi.h" +#elif defined(__WXX11__) +#include "wx/x11/mdi.h" #elif defined(__WXMAC__) #include "wx/mac/mdi.h" #elif defined(__WXPM__) diff --git a/include/wx/minifram.h b/include/wx/minifram.h index c8bd992496..3d3f853f87 100644 --- a/include/wx/minifram.h +++ b/include/wx/minifram.h @@ -7,6 +7,8 @@ #include "wx/motif/minifram.h" #elif defined(__WXGTK__) #include "wx/gtk/minifram.h" +#elif defined(__WXX11__) +#include "wx/x11/minifram.h" #elif defined(__WXMAC__) #include "wx/mac/minifram.h" #elif defined(__WXPM__) diff --git a/include/wx/motif/accel.h b/include/wx/motif/accel.h index 156290f84a..6b61e38b12 100644 --- a/include/wx/motif/accel.h +++ b/include/wx/motif/accel.h @@ -20,76 +20,27 @@ #include "wx/string.h" #include "wx/event.h" -class WXDLLEXPORT wxAcceleratorTable; - -#if 0 -// Hold Ctrl key down -#define wxACCEL_ALT 0x01 - -// Hold Ctrl key down -#define wxACCEL_CTRL 0x02 - - // Hold Shift key down -#define wxACCEL_SHIFT 0x04 - - // Hold no key down -#define wxACCEL_NORMAL 0x00 - -class WXDLLEXPORT wxAcceleratorEntry -{ -public: - wxAcceleratorEntry(const wxAcceleratorEntry& entry) - { - m_flags = entry.m_flags; m_keyCode = entry.m_keyCode; m_command = entry.m_command; - } - wxAcceleratorEntry(int flags = 0, int keyCode = 0, int cmd = 0) - { - m_flags = flags; m_keyCode = keyCode; m_command = cmd; - } - - void Set(int flags, int keyCode, int cmd) - { m_flags = flags; m_keyCode = keyCode; m_command = cmd; } - - int GetFlags() const { return m_flags; } - int GetKeyCode() const { return m_keyCode; } - int GetCommand() const { return m_command; } - - void operator = (const wxAcceleratorEntry& entry) - { - m_flags = entry.m_flags; m_keyCode = entry.m_keyCode; m_command = entry.m_command; - } - - // Implementation use only - bool MatchesEvent(const wxKeyEvent& event) const; - -public: - int m_flags; - int m_keyCode; // ASCII or virtual keycode - int m_command; // Command id to generate -}; -#endif - class WXDLLEXPORT wxAcceleratorTable: public wxObject { -DECLARE_DYNAMIC_CLASS(wxAcceleratorTable) + DECLARE_DYNAMIC_CLASS(wxAcceleratorTable) public: wxAcceleratorTable(); wxAcceleratorTable(const wxString& resource); // Load from .rc resource wxAcceleratorTable(int n, wxAcceleratorEntry entries[]); // Load from array - + // Copy constructors wxAcceleratorTable(const wxAcceleratorTable& accel) { Ref(accel); } wxAcceleratorTable(const wxAcceleratorTable* accel) { if (accel) Ref(*accel); } - + ~wxAcceleratorTable(); - + wxAcceleratorTable& operator = (const wxAcceleratorTable& accel) { if (*this == accel) return (*this); Ref(accel); return *this; } bool operator == (const wxAcceleratorTable& accel) { return m_refData == accel.m_refData; } bool operator != (const wxAcceleratorTable& accel) { return m_refData != accel.m_refData; } - + bool Ok() const; - -// Implementation only + + // Implementation only int GetCount() const; wxAcceleratorEntry* GetEntries() const; }; @@ -97,4 +48,4 @@ public: WXDLLEXPORT_DATA(extern wxAcceleratorTable) wxNullAcceleratorTable; #endif - // _WX_ACCEL_H_ +// _WX_ACCEL_H_ diff --git a/include/wx/motif/app.h b/include/wx/motif/app.h index 092e6515a7..d3bc19d40b 100644 --- a/include/wx/motif/app.h +++ b/include/wx/motif/app.h @@ -13,7 +13,7 @@ #define _WX_APP_H_ #ifdef __GNUG__ - #pragma interface "app.h" +#pragma interface "app.h" #endif // ---------------------------------------------------------------------------- @@ -39,93 +39,93 @@ class WXDLLEXPORT wxLog; class WXDLLEXPORT wxApp : public wxAppBase { -DECLARE_DYNAMIC_CLASS(wxApp) - + DECLARE_DYNAMIC_CLASS(wxApp) + public: wxApp(); ~wxApp() {} - + // override base class (pure) virtuals // ----------------------------------- - + virtual int MainLoop(); virtual void ExitMainLoop(); virtual bool Initialized(); virtual bool Pending(); virtual void Dispatch(); virtual bool Yield(bool onlyIfNeeded = FALSE); - + virtual bool OnInitGui(); - + virtual wxIcon GetStdIcon(int which) const; - + // implementation from now on // -------------------------- - + void OnIdle(wxIdleEvent& event); - + // Send idle event to all top-level windows. // Returns TRUE if more idle time is requested. bool SendIdleEvents(); - + // Send idle event to window and all subwindows // Returns TRUE if more idle time is requested. bool SendIdleEvents(wxWindow* win); - + // Motif implementation. - + // Processes an X event. virtual void ProcessXEvent(WXEvent* event); - + // Returns TRUE if an accelerator has been processed virtual bool CheckForAccelerator(WXEvent* event); - + // Returns TRUE if a key down event has been processed virtual bool CheckForKeyDown(WXEvent* event); - + // Returns TRUE if a key up event has been processed virtual bool CheckForKeyUp(WXEvent* event); - + protected: bool m_showOnInit; - + public: // Implementation static bool Initialize(); static void CleanUp(); - + void DeletePendingObjects(); bool ProcessIdle(); - + // Motif-specific WXAppContext GetAppContext() const { return m_appContext; } WXWidget GetTopLevelWidget() const { return m_topLevelWidget; } WXColormap GetMainColormap(WXDisplay* display); WXDisplay* GetInitialDisplay() const { return m_initialDisplay; } long GetMaxRequestSize() const { return m_maxRequestSize; } - + // This handler is called when a property change event occurs virtual void HandlePropertyChange(WXEvent *event); - + public: static long sm_lastMessageTime; int m_nCmdShow; - + protected: bool m_keepGoing; - + // Motif-specific WXAppContext m_appContext; WXWidget m_topLevelWidget; WXColormap m_mainColormap; WXDisplay* m_initialDisplay; long m_maxRequestSize; - + DECLARE_EVENT_TABLE() }; int WXDLLEXPORT wxEntry( int argc, char *argv[] ); #endif - // _WX_APP_H_ +// _WX_APP_H_ diff --git a/include/wx/motif/bitmap.h b/include/wx/motif/bitmap.h index d44ba42386..23f8bcd9be 100644 --- a/include/wx/motif/bitmap.h +++ b/include/wx/motif/bitmap.h @@ -33,33 +33,33 @@ class WXDLLEXPORT wxImage; // transparently. class WXDLLEXPORT wxMask: public wxObject { - DECLARE_DYNAMIC_CLASS(wxMask) - + DECLARE_DYNAMIC_CLASS(wxMask) + public: - wxMask(); - - // Construct a mask from a bitmap and a colour indicating - // the transparent area - wxMask(const wxBitmap& bitmap, const wxColour& colour); - - // Construct a mask from a bitmap and a palette index indicating - // the transparent area - wxMask(const wxBitmap& bitmap, int paletteIndex); - - // Construct a mask from a mono bitmap (copies the bitmap). - wxMask(const wxBitmap& bitmap); - - ~wxMask(); - - bool Create(const wxBitmap& bitmap, const wxColour& colour); - bool Create(const wxBitmap& bitmap, int paletteIndex); - bool Create(const wxBitmap& bitmap); - - WXPixmap GetPixmap() const { return m_pixmap; } - void SetPixmap(WXPixmap pixmap) { m_pixmap = pixmap; } - + wxMask(); + + // Construct a mask from a bitmap and a colour indicating + // the transparent area + wxMask(const wxBitmap& bitmap, const wxColour& colour); + + // Construct a mask from a bitmap and a palette index indicating + // the transparent area + wxMask(const wxBitmap& bitmap, int paletteIndex); + + // Construct a mask from a mono bitmap (copies the bitmap). + wxMask(const wxBitmap& bitmap); + + ~wxMask(); + + bool Create(const wxBitmap& bitmap, const wxColour& colour); + bool Create(const wxBitmap& bitmap, int paletteIndex); + bool Create(const wxBitmap& bitmap); + + WXPixmap GetPixmap() const { return m_pixmap; } + void SetPixmap(WXPixmap pixmap) { m_pixmap = pixmap; } + protected: - WXPixmap m_pixmap; + WXPixmap m_pixmap; }; class WXDLLEXPORT wxBitmapRefData: public wxGDIRefData @@ -70,153 +70,153 @@ class WXDLLEXPORT wxBitmapRefData: public wxGDIRefData public: wxBitmapRefData(); ~wxBitmapRefData(); - + public: - int m_width; - int m_height; - int m_depth; - bool m_ok; - int m_numColors; - wxPalette m_bitmapPalette; - int m_quality; - - wxMask * m_bitmapMask; // Optional mask - - // Motif implementation + int m_width; + int m_height; + int m_depth; + bool m_ok; + int m_numColors; + wxPalette m_bitmapPalette; + int m_quality; + + wxMask * m_bitmapMask; // Optional mask + + // Motif implementation public: - WXPixmap m_pixmap; - WXDisplay* m_display; - bool m_freePixmap; - unsigned long* m_freeColors; - long m_freeColorsCount; - - // These 5 variables are for wxControl - WXPixmap m_insensPixmap ; - WXPixmap m_labelPixmap ; - WXPixmap m_armPixmap ; - WXImage* m_image ; - WXImage* m_insensImage ; + WXPixmap m_pixmap; + WXDisplay* m_display; + bool m_freePixmap; + unsigned long* m_freeColors; + long m_freeColorsCount; + + // These 5 variables are for wxControl + WXPixmap m_insensPixmap ; + WXPixmap m_labelPixmap ; + WXPixmap m_armPixmap ; + WXImage* m_image ; + WXImage* m_insensImage ; }; #define M_BITMAPDATA ((wxBitmapRefData *)m_refData) class WXDLLEXPORT wxBitmapHandler: public wxObject { - DECLARE_DYNAMIC_CLASS(wxBitmapHandler) + DECLARE_DYNAMIC_CLASS(wxBitmapHandler) public: - wxBitmapHandler() { m_name = ""; m_extension = ""; m_type = 0; }; - - virtual bool Create(wxBitmap *bitmap, void *data, long flags, int width, int height, int depth = 1); - virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags, - int desiredWidth, int desiredHeight); - virtual bool SaveFile(wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette = NULL); - - void SetName(const wxString& name) { m_name = name; } - void SetExtension(const wxString& ext) { m_extension = ext; } - void SetType(long type) { m_type = type; } - wxString GetName() const { return m_name; } - wxString GetExtension() const { return m_extension; } - long GetType() const { return m_type; } + wxBitmapHandler() { m_name = ""; m_extension = ""; m_type = 0; }; + + virtual bool Create(wxBitmap *bitmap, void *data, long flags, int width, int height, int depth = 1); + virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags, + int desiredWidth, int desiredHeight); + virtual bool SaveFile(wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette = NULL); + + void SetName(const wxString& name) { m_name = name; } + void SetExtension(const wxString& ext) { m_extension = ext; } + void SetType(long type) { m_type = type; } + wxString GetName() const { return m_name; } + wxString GetExtension() const { return m_extension; } + long GetType() const { return m_type; } protected: - wxString m_name; - wxString m_extension; - long m_type; + wxString m_name; + wxString m_extension; + long m_type; }; #define M_BITMAPHANDLERDATA ((wxBitmapRefData *)bitmap->GetRefData()) class WXDLLEXPORT wxBitmap: public wxGDIObject { - DECLARE_DYNAMIC_CLASS(wxBitmap) - - friend class WXDLLEXPORT wxBitmapHandler; - + DECLARE_DYNAMIC_CLASS(wxBitmap) + + friend class WXDLLEXPORT wxBitmapHandler; + public: - wxBitmap(); // Platform-specific - - // Copy constructors - wxBitmap(const wxBitmap& bitmap) - { Ref(bitmap); } - - // Initialize with raw XBM data - wxBitmap(const char bits[], int width, int height, int depth = 1); - - // from XPM - wxBitmap(const char **data) { (void)CreateFromXpm(data); } - wxBitmap(char **data) { (void)CreateFromXpm((const char **)data); } - - // Initialize with XPM data -- deprecated - wxBitmap(char **data, wxControl* control); - - // Load a file or resource - wxBitmap(const wxString& name, long type = wxBITMAP_TYPE_XPM); - - // Constructor for generalised creation from data - wxBitmap(void *data, long type, int width, int height, int depth = 1); - - // If depth is omitted, will create a bitmap compatible with the display - wxBitmap(int width, int height, int depth = -1); - - // Convert from wxImage: - wxBitmap(const wxImage& image, int depth = -1) { (void)CreateFromImage(image, depth); } - - ~wxBitmap(); - - virtual bool Create(int width, int height, int depth = -1); - virtual bool Create(void *data, long type, int width, int height, int depth = 1); - - wxBitmap GetSubBitmap( const wxRect& rect ) const; - - virtual bool LoadFile(const wxString& name, long type = wxBITMAP_TYPE_XPM); - virtual bool SaveFile(const wxString& name, int type, const wxPalette *cmap = NULL); - - wxImage ConvertToImage() const; - - bool Ok() const { return (M_BITMAPDATA && M_BITMAPDATA->m_ok); } - int GetWidth() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_width : 0); } - int GetHeight() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_height : 0); } - int GetDepth() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_depth : 0); } - int GetQuality() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_quality : 0); } - void SetWidth(int w); - void SetHeight(int h); - void SetDepth(int d); - void SetQuality(int q); - void SetOk(bool isOk); - - wxPalette* GetPalette() const { return (M_BITMAPDATA ? (& M_BITMAPDATA->m_bitmapPalette) : (wxPalette*) NULL); } - void SetPalette(const wxPalette& palette); - - wxMask *GetMask() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_bitmapMask : (wxMask*) NULL); } - void SetMask(wxMask *mask) ; - - wxBitmap& operator = (const wxBitmap& bitmap) { if (*this == bitmap) return (*this); Ref(bitmap); return *this; } - bool operator == (const wxBitmap& bitmap) const { return m_refData == bitmap.m_refData; } - bool operator != (const wxBitmap& bitmap) const { return m_refData != bitmap.m_refData; } - - // Format handling - static wxList& GetHandlers() { return sm_handlers; } - static void AddHandler(wxBitmapHandler *handler); - static void InsertHandler(wxBitmapHandler *handler); - static bool RemoveHandler(const wxString& name); - static wxBitmapHandler *FindHandler(const wxString& name); - static wxBitmapHandler *FindHandler(const wxString& extension, long bitmapType); - static wxBitmapHandler *FindHandler(long bitmapType); - - static void InitStandardHandlers(); - static void CleanUpHandlers(); - - // Motif implementation + wxBitmap(); // Platform-specific + + // Copy constructors + wxBitmap(const wxBitmap& bitmap) + { Ref(bitmap); } + + // Initialize with raw XBM data + wxBitmap(const char bits[], int width, int height, int depth = 1); + + // from XPM + wxBitmap(const char **data) { (void)CreateFromXpm(data); } + wxBitmap(char **data) { (void)CreateFromXpm((const char **)data); } + + // Initialize with XPM data -- deprecated + wxBitmap(char **data, wxControl* control); + + // Load a file or resource + wxBitmap(const wxString& name, long type = wxBITMAP_TYPE_XPM); + + // Constructor for generalised creation from data + wxBitmap(void *data, long type, int width, int height, int depth = 1); + + // If depth is omitted, will create a bitmap compatible with the display + wxBitmap(int width, int height, int depth = -1); + + // Convert from wxImage: + wxBitmap(const wxImage& image, int depth = -1) { (void)CreateFromImage(image, depth); } + + ~wxBitmap(); + + virtual bool Create(int width, int height, int depth = -1); + virtual bool Create(void *data, long type, int width, int height, int depth = 1); + + wxBitmap GetSubBitmap( const wxRect& rect ) const; + + virtual bool LoadFile(const wxString& name, long type = wxBITMAP_TYPE_XPM); + virtual bool SaveFile(const wxString& name, int type, const wxPalette *cmap = NULL); + + wxImage ConvertToImage() const; + + bool Ok() const { return (M_BITMAPDATA && M_BITMAPDATA->m_ok); } + int GetWidth() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_width : 0); } + int GetHeight() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_height : 0); } + int GetDepth() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_depth : 0); } + int GetQuality() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_quality : 0); } + void SetWidth(int w); + void SetHeight(int h); + void SetDepth(int d); + void SetQuality(int q); + void SetOk(bool isOk); + + wxPalette* GetPalette() const { return (M_BITMAPDATA ? (& M_BITMAPDATA->m_bitmapPalette) : (wxPalette*) NULL); } + void SetPalette(const wxPalette& palette); + + wxMask *GetMask() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_bitmapMask : (wxMask*) NULL); } + void SetMask(wxMask *mask) ; + + wxBitmap& operator = (const wxBitmap& bitmap) { if (*this == bitmap) return (*this); Ref(bitmap); return *this; } + bool operator == (const wxBitmap& bitmap) const { return m_refData == bitmap.m_refData; } + bool operator != (const wxBitmap& bitmap) const { return m_refData != bitmap.m_refData; } + + // Format handling + static wxList& GetHandlers() { return sm_handlers; } + static void AddHandler(wxBitmapHandler *handler); + static void InsertHandler(wxBitmapHandler *handler); + static bool RemoveHandler(const wxString& name); + static wxBitmapHandler *FindHandler(const wxString& name); + static wxBitmapHandler *FindHandler(const wxString& extension, long bitmapType); + static wxBitmapHandler *FindHandler(long bitmapType); + + static void InitStandardHandlers(); + static void CleanUpHandlers(); + + // Motif implementation public: - WXDisplay* GetDisplay() const { return M_BITMAPDATA->m_display; } - WXPixmap GetPixmap() const { return (WXPixmap) M_BITMAPDATA->m_pixmap; } - virtual WXPixmap GetLabelPixmap(WXWidget w) ; - virtual WXPixmap GetArmPixmap(WXWidget w) ; - virtual WXPixmap GetInsensPixmap(WXWidget w = (WXWidget) 0) ; - void SetPixmapNull() { M_BITMAPDATA->m_pixmap = 0; } - + WXDisplay* GetDisplay() const { return M_BITMAPDATA->m_display; } + WXPixmap GetPixmap() const { return (WXPixmap) M_BITMAPDATA->m_pixmap; } + virtual WXPixmap GetLabelPixmap(WXWidget w) ; + virtual WXPixmap GetArmPixmap(WXWidget w) ; + virtual WXPixmap GetInsensPixmap(WXWidget w = (WXWidget) 0) ; + void SetPixmapNull() { M_BITMAPDATA->m_pixmap = 0; } + protected: - static wxList sm_handlers; - + static wxList sm_handlers; + protected: bool CreateFromXpm(const char **bits); bool CreateFromImage(const wxImage& image, int depth); @@ -227,4 +227,4 @@ protected: wxBitmap wxCreateMaskedBitmap(const wxBitmap& bitmap, wxColour& colour); #endif - // _WX_BITMAP_H_ +// _WX_BITMAP_H_ diff --git a/include/wx/motif/bmpbuttn.h b/include/wx/motif/bmpbuttn.h index 47fe63c018..68a92fb886 100644 --- a/include/wx/motif/bmpbuttn.h +++ b/include/wx/motif/bmpbuttn.h @@ -24,70 +24,70 @@ WXDLLEXPORT_DATA(extern const char*) wxButtonNameStr; class WXDLLEXPORT wxBitmapButton: public wxButton { - DECLARE_DYNAMIC_CLASS(wxBitmapButton) - public: - wxBitmapButton(); - ~wxBitmapButton(); - inline wxBitmapButton(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = wxBU_AUTODRAW, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxButtonNameStr) - { - Create(parent, id, bitmap, pos, size, style, validator, name); - } - - bool Create(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = wxBU_AUTODRAW, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxButtonNameStr); - - virtual void SetLabel(const wxBitmap& bitmap) - { - SetBitmapLabel(bitmap); - } - virtual void SetLabel(const wxString& label) - { - wxControl::SetLabel(label); - } - - virtual void SetBitmapLabel(const wxBitmap& bitmap); - - inline wxBitmap& GetBitmapLabel() const { return (wxBitmap&) m_buttonBitmap; } - inline wxBitmap& GetBitmapSelected() const { return (wxBitmap&) m_buttonBitmapSelected; } - inline wxBitmap& GetBitmapFocus() const { return (wxBitmap&) m_buttonBitmapFocus; } - inline wxBitmap& GetBitmapDisabled() const { return (wxBitmap&) m_buttonBitmapDisabled; } - - 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; } - -// Implementation - void DoSetBitmap(); - virtual void ChangeBackgroundColour(); - - protected: - wxBitmap m_buttonBitmapFocus; - wxBitmap m_buttonBitmap; - wxBitmap m_buttonBitmapOriginal; // May be different from m_buttonBitmap - // if m_buttonBitmap has been changed - // to reflect button background colour - wxBitmap m_buttonBitmapSelected; - wxBitmap m_buttonBitmapSelectedOriginal; - - wxBitmap m_buttonBitmapDisabled; - wxBitmap m_buttonBitmapDisabledOriginal; - - int m_marginX; - int m_marginY; - - WXPixmap m_insensPixmap; + DECLARE_DYNAMIC_CLASS(wxBitmapButton) +public: + wxBitmapButton(); + ~wxBitmapButton(); + inline wxBitmapButton(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, long style = wxBU_AUTODRAW, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxButtonNameStr) + { + Create(parent, id, bitmap, pos, size, style, validator, name); + } + + bool Create(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, long style = wxBU_AUTODRAW, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxButtonNameStr); + + virtual void SetLabel(const wxBitmap& bitmap) + { + SetBitmapLabel(bitmap); + } + virtual void SetLabel(const wxString& label) + { + wxControl::SetLabel(label); + } + + virtual void SetBitmapLabel(const wxBitmap& bitmap); + + inline wxBitmap& GetBitmapLabel() const { return (wxBitmap&) m_buttonBitmap; } + inline wxBitmap& GetBitmapSelected() const { return (wxBitmap&) m_buttonBitmapSelected; } + inline wxBitmap& GetBitmapFocus() const { return (wxBitmap&) m_buttonBitmapFocus; } + inline wxBitmap& GetBitmapDisabled() const { return (wxBitmap&) m_buttonBitmapDisabled; } + + 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; } + + // Implementation + void DoSetBitmap(); + virtual void ChangeBackgroundColour(); + +protected: + wxBitmap m_buttonBitmapFocus; + wxBitmap m_buttonBitmap; + wxBitmap m_buttonBitmapOriginal; // May be different from m_buttonBitmap + // if m_buttonBitmap has been changed + // to reflect button background colour + wxBitmap m_buttonBitmapSelected; + wxBitmap m_buttonBitmapSelectedOriginal; + + wxBitmap m_buttonBitmapDisabled; + wxBitmap m_buttonBitmapDisabledOriginal; + + int m_marginX; + int m_marginY; + + WXPixmap m_insensPixmap; }; #endif - // _WX_BMPBUTTN_H_ +// _WX_BMPBUTTN_H_ diff --git a/include/wx/motif/brush.h b/include/wx/motif/brush.h index 03c23ce98a..513d7fc9c3 100644 --- a/include/wx/motif/brush.h +++ b/include/wx/motif/brush.h @@ -29,7 +29,7 @@ public: wxBrushRefData(); wxBrushRefData(const wxBrushRefData& data); ~wxBrushRefData(); - + protected: int m_style; wxBitmap m_stipple ; @@ -41,39 +41,39 @@ protected: // Brush class WXDLLEXPORT wxBrush: public wxGDIObject { - DECLARE_DYNAMIC_CLASS(wxBrush) - + DECLARE_DYNAMIC_CLASS(wxBrush) + public: - wxBrush(); - wxBrush(const wxColour& col, int style); - wxBrush(const wxBitmap& stipple); - inline wxBrush(const wxBrush& brush) { Ref(brush); } - ~wxBrush(); - - virtual void SetColour(const wxColour& col) ; - virtual void SetColour(unsigned char r, unsigned char g, unsigned char b) ; - virtual void SetStyle(int style) ; - virtual void SetStipple(const wxBitmap& stipple) ; - - inline wxBrush& operator = (const wxBrush& brush) { if (*this == brush) return (*this); Ref(brush); return *this; } - inline bool operator == (const wxBrush& brush) const { return m_refData == brush.m_refData; } - inline bool operator != (const wxBrush& brush) const { return m_refData != brush.m_refData; } - - inline wxColour& GetColour() const { return (M_BRUSHDATA ? M_BRUSHDATA->m_colour : wxNullColour); }; - inline int GetStyle() const { return (M_BRUSHDATA ? M_BRUSHDATA->m_style : 0); }; - inline wxBitmap *GetStipple() const { return (M_BRUSHDATA ? & M_BRUSHDATA->m_stipple : 0); }; - - virtual bool Ok() const { return (m_refData != NULL) ; } - -// Implementation - - // Useful helper: create the brush resource - bool RealizeResource(); - - // When setting properties, we must make sure we're not changing - // another object - void Unshare(); + wxBrush(); + wxBrush(const wxColour& col, int style); + wxBrush(const wxBitmap& stipple); + inline wxBrush(const wxBrush& brush) { Ref(brush); } + ~wxBrush(); + + virtual void SetColour(const wxColour& col) ; + virtual void SetColour(unsigned char r, unsigned char g, unsigned char b) ; + virtual void SetStyle(int style) ; + virtual void SetStipple(const wxBitmap& stipple) ; + + inline wxBrush& operator = (const wxBrush& brush) { if (*this == brush) return (*this); Ref(brush); return *this; } + inline bool operator == (const wxBrush& brush) const { return m_refData == brush.m_refData; } + inline bool operator != (const wxBrush& brush) const { return m_refData != brush.m_refData; } + + inline wxColour& GetColour() const { return (M_BRUSHDATA ? M_BRUSHDATA->m_colour : wxNullColour); }; + inline int GetStyle() const { return (M_BRUSHDATA ? M_BRUSHDATA->m_style : 0); }; + inline wxBitmap *GetStipple() const { return (M_BRUSHDATA ? & M_BRUSHDATA->m_stipple : 0); }; + + virtual bool Ok() const { return (m_refData != NULL) ; } + + // Implementation + + // Useful helper: create the brush resource + bool RealizeResource(); + + // When setting properties, we must make sure we're not changing + // another object + void Unshare(); }; #endif - // _WX_BRUSH_H_ +// _WX_BRUSH_H_ diff --git a/include/wx/motif/button.h b/include/wx/motif/button.h index c872066bb9..dc69dceae7 100644 --- a/include/wx/motif/button.h +++ b/include/wx/motif/button.h @@ -13,7 +13,7 @@ #define _WX_BUTTON_H_ #ifdef __GNUG__ - #pragma interface "button.h" +#pragma interface "button.h" #endif #include "wx/control.h" @@ -25,29 +25,29 @@ WXDLLEXPORT_DATA(extern const char*) wxButtonNameStr; class WXDLLEXPORT wxButton: public wxControl { DECLARE_DYNAMIC_CLASS(wxButton) - + public: wxButton() { } wxButton(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 = wxButtonNameStr) + wxWindowID id, + const wxString& label, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, long style = 0, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxButtonNameStr) { Create(parent, id, label, pos, size, style, validator, name); } - + 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 = wxButtonNameStr); - + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, long style = 0, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxButtonNameStr); + virtual void SetDefault(); virtual void Command(wxCommandEvent& event); - + static wxSize GetDefaultSize(); // Implementation @@ -57,4 +57,4 @@ public: }; #endif - // _WX_BUTTON_H_ +// _WX_BUTTON_H_ diff --git a/include/wx/motif/checkbox.h b/include/wx/motif/checkbox.h index e6ca1a43ae..eba4bea34f 100644 --- a/include/wx/motif/checkbox.h +++ b/include/wx/motif/checkbox.h @@ -24,68 +24,68 @@ WXDLLEXPORT_DATA(extern const char*) wxCheckBoxNameStr; class WXDLLEXPORT wxBitmap; class WXDLLEXPORT wxCheckBox: public wxControl { - DECLARE_DYNAMIC_CLASS(wxCheckBox) - - public: - inline wxCheckBox() { } - inline wxCheckBox(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 = wxCheckBoxNameStr) - { - Create(parent, id, label, pos, size, style, validator, name); - } - - 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 = wxCheckBoxNameStr); - virtual void SetValue(bool); - virtual bool GetValue() const ; - virtual void Command(wxCommandEvent& event); - -// Implementation - virtual void ChangeFont(bool keepOriginalSize = TRUE); - virtual void ChangeBackgroundColour(); - virtual void ChangeForegroundColour(); + DECLARE_DYNAMIC_CLASS(wxCheckBox) + +public: + inline wxCheckBox() { } + inline wxCheckBox(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 = wxCheckBoxNameStr) + { + Create(parent, id, label, pos, size, style, validator, name); + } + + 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 = wxCheckBoxNameStr); + virtual void SetValue(bool); + virtual bool GetValue() const ; + virtual void Command(wxCommandEvent& event); + + // Implementation + virtual void ChangeFont(bool keepOriginalSize = TRUE); + virtual void ChangeBackgroundColour(); + virtual void ChangeForegroundColour(); }; class WXDLLEXPORT wxBitmapCheckBox: public wxCheckBox { DECLARE_DYNAMIC_CLASS(wxBitmapCheckBox) - + public: int checkWidth; int checkHeight; - + inline wxBitmapCheckBox() { checkWidth = -1; checkHeight = -1; } inline wxBitmapCheckBox(wxWindow *parent, wxWindowID id, const wxBitmap *label, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxCheckBoxNameStr) + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, long style = 0, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxCheckBoxNameStr) { Create(parent, id, label, pos, size, style, validator, name); } - + bool Create(wxWindow *parent, wxWindowID id, const wxBitmap *bitmap, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxCheckBoxNameStr); - + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, long style = 0, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxCheckBoxNameStr); + virtual void SetValue(bool value); virtual bool GetValue() const; - + virtual void SetLabel(const wxBitmap& bitmap); virtual void SetLabel(const wxString& label) { wxControl::SetLabel(label); }; - + protected: virtual void DoSetSize(int x, int y, - int width, int height, - int sizeFlags = wxSIZE_AUTO); + int width, int height, + int sizeFlags = wxSIZE_AUTO); }; #endif - // _WX_CHECKBOX_H_ +// _WX_CHECKBOX_H_ diff --git a/include/wx/motif/checklst.h b/include/wx/motif/checklst.h index 554ee2e6e5..3a0444f892 100644 --- a/include/wx/motif/checklst.h +++ b/include/wx/motif/checklst.h @@ -14,34 +14,34 @@ #define _WX_CHECKLST_H_ #ifdef __GNUG__ - #pragma interface "checklst.h" +#pragma interface "checklst.h" #endif #include "wx/listbox.h" class wxCheckListBox : public wxListBox { -DECLARE_DYNAMIC_CLASS(wxCheckListBox) - + DECLARE_DYNAMIC_CLASS(wxCheckListBox) + public: // ctors wxCheckListBox(); wxCheckListBox(wxWindow *parent, wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - int nStrings = 0, - const wxString choices[] = NULL, - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxListBoxNameStr); - + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + int nStrings = 0, + const wxString choices[] = NULL, + long style = 0, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxListBoxNameStr); + // items may be checked bool IsChecked(size_t uiIndex) const; void Check(size_t uiIndex, bool bCheck = TRUE); - + private: DECLARE_EVENT_TABLE() }; #endif - // _WX_CHECKLST_H_ +// _WX_CHECKLST_H_ diff --git a/include/wx/motif/choice.h b/include/wx/motif/choice.h index df445f9e9b..821f16096a 100644 --- a/include/wx/motif/choice.h +++ b/include/wx/motif/choice.h @@ -24,30 +24,30 @@ WXDLLEXPORT_DATA(extern const char*) wxChoiceNameStr; class WXDLLEXPORT wxChoice: public wxControlWithItems { DECLARE_DYNAMIC_CLASS(wxChoice) - + public: wxChoice(); ~wxChoice(); - + wxChoice(wxWindow *parent, wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - int n = 0, const wxString choices[] = NULL, - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxChoiceNameStr) + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + int n = 0, const wxString choices[] = NULL, + long style = 0, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxChoiceNameStr) { Create(parent, id, pos, size, n, choices, style, validator, name); } - + bool Create(wxWindow *parent, wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - int n = 0, const wxString choices[] = NULL, - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxChoiceNameStr); - + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + int n = 0, const wxString choices[] = NULL, + long style = 0, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxChoiceNameStr); + // Virtual functions required by wxControlWithItems. // They are not all implemented yet :-( virtual int GetCount() const; @@ -61,7 +61,7 @@ public: virtual wxClientData* DoGetItemClientObject(int n) const; virtual void Select(int n); virtual void SetString(int n, const wxString& s); - + // Original API virtual void Append(const wxString& item); virtual void Delete(int n); @@ -70,25 +70,25 @@ public: virtual void SetSelection(int n); virtual int FindString(const wxString& s) const; virtual wxString GetString(int n) const ; - + virtual wxString GetStringSelection() const ; virtual bool SetStringSelection(const wxString& sel); - + virtual int Number() const { return m_noStrings; } virtual void Command(wxCommandEvent& event); - + virtual void SetColumns(int n = 1 ); virtual int GetColumns() const ; - + void SetFocus(); - + // Implementation virtual void ChangeFont(bool keepOriginalSize = TRUE); virtual void ChangeBackgroundColour(); virtual void ChangeForegroundColour(); WXWidget GetTopWidget() const { return m_formWidget; } WXWidget GetMainWidget() const { return m_buttonWidget; } - + protected: int m_noStrings; WXWidget m_menuWidget; @@ -97,12 +97,11 @@ protected: WXWidget m_formWidget; wxStringList m_stringList; wxList m_clientList; // contains the client data for the items - - + virtual void DoSetSize(int x, int y, - int width, int height, - int sizeFlags = wxSIZE_AUTO); + int width, int height, + int sizeFlags = wxSIZE_AUTO); }; #endif - // _WX_CHOICE_H_ +// _WX_CHOICE_H_ diff --git a/include/wx/motif/clipbrd.h b/include/wx/motif/clipbrd.h index e0baf4a4ac..848bfe6565 100644 --- a/include/wx/motif/clipbrd.h +++ b/include/wx/motif/clipbrd.h @@ -13,7 +13,7 @@ #define _WX_CLIPBRD_H_ #ifdef __GNUG__ - #pragma interface "clipbrd.h" +#pragma interface "clipbrd.h" #endif #if wxUSE_CLIPBOARD @@ -40,40 +40,40 @@ class wxClipboard : public wxClipboardBase public: wxClipboard(); ~wxClipboard(); - + // open the clipboard before SetData() and GetData() virtual bool Open(); - + // close the clipboard after SetData() and GetData() virtual void Close(); - + // opened? virtual bool IsOpened() const { return m_open; } - + // replaces the data on the clipboard with data virtual bool SetData( wxDataObject *data ); - + // adds data to the clipboard virtual bool AddData( wxDataObject *data ); - + // format available on the clipboard ? virtual bool IsSupported( const wxDataFormat& format ); - + // fill data with data on the clipboard (if available) virtual bool GetData( wxDataObject& data ); - + // clears wxTheClipboard and the system's clipboard if possible virtual void Clear(); - + virtual void UsePrimarySelection(bool primary = TRUE) - { m_usePrimary = primary; } - + { m_usePrimary = primary; } + // implementation from now on - + bool m_open; wxList m_data; bool m_usePrimary; - + private: DECLARE_DYNAMIC_CLASS(wxClipboard) }; @@ -81,4 +81,4 @@ private: #endif // wxUSE_CLIPBOARD #endif - // _WX_CLIPBRD_H_ +// _WX_CLIPBRD_H_ diff --git a/include/wx/motif/colordlg.h b/include/wx/motif/colordlg.h index 58cbb11e0a..911e766596 100644 --- a/include/wx/motif/colordlg.h +++ b/include/wx/motif/colordlg.h @@ -22,25 +22,25 @@ #include "wx/cmndata.h" /* - * Platform-specific colour dialog implementation - */ +* Platform-specific colour dialog implementation +*/ class WXDLLEXPORT wxColourDialog: public wxDialog { -DECLARE_DYNAMIC_CLASS(wxColourDialog) + DECLARE_DYNAMIC_CLASS(wxColourDialog) public: wxColourDialog(); wxColourDialog(wxWindow *parent, wxColourData *data = NULL); - + bool Create(wxWindow *parent, wxColourData *data = NULL); - + int ShowModal(); wxColourData& GetColourData() { return m_colourData; } - + protected: wxColourData m_colourData; wxWindow* m_dialogParent; }; #endif - // _WX_COLORDLG_H_ +// _WX_COLORDLG_H_ diff --git a/include/wx/motif/colour.h b/include/wx/motif/colour.h index 238d46cfe1..0a3409aa7b 100644 --- a/include/wx/motif/colour.h +++ b/include/wx/motif/colour.h @@ -22,71 +22,71 @@ // Colour class WXDLLEXPORT wxColour : public wxObject { -DECLARE_DYNAMIC_CLASS(wxColour) + DECLARE_DYNAMIC_CLASS(wxColour) public: - // ctors + // ctors // default - wxColour(); + wxColour(); // from RGB - wxColour( unsigned char red, unsigned char green, unsigned char blue ); - wxColour( unsigned long colRGB ) { Set(colRGB); } - + wxColour( unsigned char red, unsigned char green, unsigned char blue ); + wxColour( unsigned long colRGB ) { Set(colRGB); } + // implicit conversion from the colour name - wxColour( const wxString &colourName ) { InitFromName(colourName); } - wxColour( const char *colourName ) { InitFromName(colourName); } - + wxColour( const wxString &colourName ) { InitFromName(colourName); } + wxColour( const char *colourName ) { InitFromName(colourName); } + // copy ctors and assignment operators - wxColour( const wxColour& col ); - wxColour& operator = ( const wxColour& col ); - + wxColour( const wxColour& col ); + wxColour& operator = ( const wxColour& col ); + // dtor - ~wxColour(); - - // Set() functions - void Set( unsigned char red, unsigned char green, unsigned char blue ); - void Set( unsigned long colRGB ) - { - // we don't need to know sizeof(long) here because we assume that the three - // least significant bytes contain the R, G and B values - Set((unsigned char)colRGB, - (unsigned char)(colRGB >> 8), - (unsigned char)(colRGB >> 16)); - } - - // 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) const { return (m_red == colour.m_red && m_green == colour.m_green && m_blue == colour.m_blue); } - - inline bool operator != (const wxColour& colour) const { 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. - // Returns the allocated pixel. - - // TODO: can this handle mono displays? If not, we should have an extra - // flag to specify whether this should be black or white by default. - - int AllocColour(WXDisplay* display, bool realloc = FALSE); - - void InitFromName(const wxString& col); - + ~wxColour(); + + // Set() functions + void Set( unsigned char red, unsigned char green, unsigned char blue ); + void Set( unsigned long colRGB ) + { + // we don't need to know sizeof(long) here because we assume that the three + // least significant bytes contain the R, G and B values + Set((unsigned char)colRGB, + (unsigned char)(colRGB >> 8), + (unsigned char)(colRGB >> 16)); + } + + // 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) const { return (m_red == colour.m_red && m_green == colour.m_green && m_blue == colour.m_blue); } + + inline bool operator != (const wxColour& colour) const { 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. + // Returns the allocated pixel. + + // TODO: can this handle mono displays? If not, we should have an extra + // flag to specify whether this should be black or white by default. + + int AllocColour(WXDisplay* display, bool realloc = FALSE); + + void InitFromName(const wxString& col); + private: - bool m_isInit; - unsigned char m_red; - unsigned char m_blue; - unsigned char m_green; - + bool m_isInit; + unsigned char m_red; + unsigned char m_blue; + unsigned char m_green; + public: - int m_pixel; + int m_pixel; }; #endif - // _WX_COLOUR_H_ +// _WX_COLOUR_H_ diff --git a/include/wx/motif/combobox.h b/include/wx/motif/combobox.h index 4df7da5137..68980bf6b1 100644 --- a/include/wx/motif/combobox.h +++ b/include/wx/motif/combobox.h @@ -25,32 +25,32 @@ WXDLLEXPORT_DATA(extern const char*) wxEmptyString; class WXDLLEXPORT wxComboBox: public wxChoice { DECLARE_DYNAMIC_CLASS(wxComboBox) - + public: inline wxComboBox() {} ~wxComboBox(); - + inline wxComboBox(wxWindow *parent, wxWindowID id, - const wxString& value = wxEmptyString, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - int n = 0, const wxString choices[] = NULL, - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxComboBoxNameStr) + const wxString& value = wxEmptyString, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + int n = 0, const wxString choices[] = NULL, + long style = 0, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxComboBoxNameStr) { Create(parent, id, value, pos, size, n, choices, style, validator, name); } - + bool Create(wxWindow *parent, wxWindowID id, - const wxString& value = wxEmptyString, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - int n = 0, const wxString choices[] = NULL, - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxComboBoxNameStr); - + const wxString& value = wxEmptyString, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + int n = 0, const wxString choices[] = NULL, + long style = 0, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxComboBoxNameStr); + // List functions virtual void Append(const wxString& item); virtual void Delete(int n); @@ -62,11 +62,11 @@ public: virtual wxString GetStringSelection() const ; virtual bool SetStringSelection(const wxString& sel); virtual inline int Number() const { return m_noStrings; } - + // Text field functions virtual wxString GetValue() const ; virtual void SetValue(const wxString& value); - + // Clipboard operations virtual void Copy(); virtual void Cut(); @@ -79,19 +79,19 @@ public: virtual void Remove(long from, long to); virtual void SetSelection(long from, long to); virtual void SetEditable(bool editable); - + // Implementation virtual void ChangeFont(bool keepOriginalSize = TRUE); virtual void ChangeBackgroundColour(); virtual void ChangeForegroundColour(); WXWidget GetTopWidget() const { return m_mainWidget; } WXWidget GetMainWidget() const { return m_mainWidget; } - + protected: virtual void DoSetSize(int x, int y, - int width, int height, - int sizeFlags = wxSIZE_AUTO); + int width, int height, + int sizeFlags = wxSIZE_AUTO); }; #endif - // _WX_COMBOBOX_H_ +// _WX_COMBOBOX_H_ diff --git a/include/wx/motif/control.h b/include/wx/motif/control.h index d164e52485..b029556632 100644 --- a/include/wx/motif/control.h +++ b/include/wx/motif/control.h @@ -26,54 +26,54 @@ class WXDLLEXPORT wxControl: public wxControlBase { DECLARE_ABSTRACT_CLASS(wxControl) - + public: wxControl(); wxControl( wxWindow *parent, - wxWindowID id, - const wxPoint &pos = wxDefaultPosition, - const wxSize &size = wxDefaultSize, - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString &name = wxControlNameStr ) + wxWindowID id, + const wxPoint &pos = wxDefaultPosition, + const wxSize &size = wxDefaultSize, + long style = 0, + const wxValidator& validator = wxDefaultValidator, + const wxString &name = wxControlNameStr ) { Create(parent, id, pos, size, style, validator, name); } - + bool Create(wxWindow *parent, wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxControlNameStr); - + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, long style = 0, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxControlNameStr); + // simulates the event, returns TRUE if the event was processed virtual void Command(wxCommandEvent& WXUNUSED(event)) { } - + // calls the callback and appropriate event handlers, returns TRUE if // event was processed virtual bool ProcessCommand(wxCommandEvent& event); - + virtual void SetLabel(const wxString& label); virtual wxString GetLabel() const ; - + #if WXWIN_COMPATIBILITY void Callback(const wxFunction function) { m_callback = function; }; // Adds callback - + wxFunction GetCallback() { return m_callback; } #endif // WXWIN_COMPATIBILITY - + bool InSetValue() const { return m_inSetValue; } - + protected: #if WXWIN_COMPATIBILITY wxFunction m_callback; // Callback associated with the window #endif // WXWIN_COMPATIBILITY - + bool m_inSetValue; // Motif: prevent callbacks being called while - // in SetValue - + // in SetValue + DECLARE_EVENT_TABLE() }; #endif - // _WX_CONTROL_H_ +// _WX_CONTROL_H_ diff --git a/include/wx/motif/cursor.h b/include/wx/motif/cursor.h index a6344c8148..c1d3bce5c3 100644 --- a/include/wx/motif/cursor.h +++ b/include/wx/motif/cursor.h @@ -19,15 +19,15 @@ #include "wx/bitmap.h" /* Cursor for one display, so we can choose the correct one for - * the current display. - */ +* the current display. +*/ class wxXCursor : public wxObject { - DECLARE_DYNAMIC_CLASS(wxXCursor) - - public: - WXDisplay* m_display; - WXCursor m_cursor; + DECLARE_DYNAMIC_CLASS(wxXCursor) + +public: + WXDisplay* m_display; + WXCursor m_cursor; }; class WXDLLEXPORT wxCursorRefData: public wxBitmapRefData @@ -37,7 +37,7 @@ class WXDLLEXPORT wxCursorRefData: public wxBitmapRefData public: wxCursorRefData(); ~wxCursorRefData(); - + wxList m_cursors; // wxXCursor objects, one per display wxStockCursor m_cursorId; // wxWindows standard cursor id }; @@ -48,37 +48,37 @@ public: // Cursor class WXDLLEXPORT wxCursor: public wxBitmap { - DECLARE_DYNAMIC_CLASS(wxCursor) - + DECLARE_DYNAMIC_CLASS(wxCursor) + public: - wxCursor(); - - // Copy constructors - wxCursor(const wxCursor& cursor) { Ref(cursor); } - - wxCursor(const char bits[], int width, int height, int hotSpotX = -1, int hotSpotY = -1, - const char maskBits[] = NULL); - - wxCursor(const wxString& name, long flags = wxBITMAP_TYPE_XBM, - int hotSpotX = 0, int hotSpotY = 0); - - wxCursor(wxStockCursor id); - ~wxCursor(); - - virtual bool Ok() const { return ((m_refData != NULL) && M_CURSORDATA->m_ok); } - - wxCursor& operator = (const wxCursor& cursor) { if (*this == cursor) return (*this); Ref(cursor); return *this; } - bool operator == (const wxCursor& cursor) const { return m_refData == cursor.m_refData; } - bool operator != (const wxCursor& cursor) const { return m_refData != cursor.m_refData; } - - // Motif-specific. - // Create/get a cursor for the current display - WXCursor GetXCursor(WXDisplay* display) ; - // Make a cursor from standard id - WXCursor MakeCursor(WXDisplay* display, wxStockCursor id); + wxCursor(); + + // Copy constructors + wxCursor(const wxCursor& cursor) { Ref(cursor); } + + wxCursor(const char bits[], int width, int height, int hotSpotX = -1, int hotSpotY = -1, + const char maskBits[] = NULL); + + wxCursor(const wxString& name, long flags = wxBITMAP_TYPE_XBM, + int hotSpotX = 0, int hotSpotY = 0); + + wxCursor(wxStockCursor id); + ~wxCursor(); + + virtual bool Ok() const { return ((m_refData != NULL) && M_CURSORDATA->m_ok); } + + wxCursor& operator = (const wxCursor& cursor) { if (*this == cursor) return (*this); Ref(cursor); return *this; } + bool operator == (const wxCursor& cursor) const { return m_refData == cursor.m_refData; } + bool operator != (const wxCursor& cursor) const { return m_refData != cursor.m_refData; } + + // Motif-specific. + // Create/get a cursor for the current display + WXCursor GetXCursor(WXDisplay* display) ; + // Make a cursor from standard id + WXCursor MakeCursor(WXDisplay* display, wxStockCursor id); }; extern WXDLLEXPORT void wxSetCursor(const wxCursor& cursor); #endif - // _WX_CURSOR_H_ +// _WX_CURSOR_H_ diff --git a/include/wx/motif/dataform.h b/include/wx/motif/dataform.h index e6dbcb0a91..eebf507e23 100644 --- a/include/wx/motif/dataform.h +++ b/include/wx/motif/dataform.h @@ -17,46 +17,46 @@ class wxDataFormat public: // the clipboard formats under Xt are Atoms typedef Atom NativeFormat; - + wxDataFormat(); wxDataFormat( wxDataFormatId type ); wxDataFormat( const wxString &id ); wxDataFormat( const wxChar *id ); wxDataFormat( NativeFormat format ); - + wxDataFormat& operator=(NativeFormat format) - { SetId(format); return *this; } - + { SetId(format); return *this; } + // comparison (must have both versions) bool operator==(NativeFormat format) const - { return m_format == (NativeFormat)format; } + { return m_format == (NativeFormat)format; } bool operator!=(NativeFormat format) const - { return m_format != (NativeFormat)format; } + { return m_format != (NativeFormat)format; } bool operator==(wxDataFormatId format) const - { return m_type == (wxDataFormatId)format; } + { return m_type == (wxDataFormatId)format; } bool operator!=(wxDataFormatId format) const - { return m_type != (wxDataFormatId)format; } - + { return m_type != (wxDataFormatId)format; } + // explicit and implicit conversions to NativeFormat which is one of // standard data types (implicit conversion is useful for preserving the // compatibility with old code) NativeFormat GetFormatId() const { return m_format; } operator NativeFormat() const { return m_format; } - + void SetId( NativeFormat format ); - + // string ids are used for custom types - this SetId() must be used for // application-specific formats wxString GetId() const; void SetId( const wxChar *id ); - + // implementation wxDataFormatId GetType() const; - + private: wxDataFormatId m_type; NativeFormat m_format; - + void PrepareFormats(); void SetType( wxDataFormatId type ); }; diff --git a/include/wx/motif/dataobj.h b/include/wx/motif/dataobj.h index 878d9b0c39..77064e648d 100644 --- a/include/wx/motif/dataobj.h +++ b/include/wx/motif/dataobj.h @@ -11,7 +11,7 @@ #define _WX_MOTIF_DATAOBJ_H_ #ifdef __GNUG__ - #pragma interface "dataobj.h" +#pragma interface "dataobj.h" #endif // ---------------------------------------------------------------------------- @@ -20,7 +20,7 @@ class wxDataObject : public wxDataObjectBase { - public: +public: #ifdef __DARWIN__ ~wxDataObject() { } #endif diff --git a/include/wx/motif/dc.h b/include/wx/motif/dc.h index 5368b113b0..f456f8d57f 100644 --- a/include/wx/motif/dc.h +++ b/include/wx/motif/dc.h @@ -13,7 +13,7 @@ #define _WX_DC_H_ #ifdef __GNUG__ - #pragma interface "dc.h" +#pragma interface "dc.h" #endif #include "wx/pen.h" @@ -27,14 +27,14 @@ //----------------------------------------------------------------------------- #ifndef MM_TEXT - #define MM_TEXT 0 - #define MM_ISOTROPIC 1 - #define MM_ANISOTROPIC 2 - #define MM_LOMETRIC 3 - #define MM_HIMETRIC 4 - #define MM_TWIPS 5 - #define MM_POINTS 6 - #define MM_METRIC 7 +#define MM_TEXT 0 +#define MM_ISOTROPIC 1 +#define MM_ANISOTROPIC 2 +#define MM_LOMETRIC 3 +#define MM_HIMETRIC 4 +#define MM_TWIPS 5 +#define MM_POINTS 6 +#define MM_METRIC 7 #endif //----------------------------------------------------------------------------- @@ -44,38 +44,38 @@ class WXDLLEXPORT wxDC : public wxDCBase { DECLARE_DYNAMIC_CLASS(wxDC) - + public: wxDC(); ~wxDC() { } - + // implement base class pure virtuals // ---------------------------------- - + virtual void DestroyClippingRegion(); - + virtual wxSize GetPPI() const; - + virtual void SetMapMode(int mode); virtual void SetUserScale(double x, double y); virtual void SetLogicalScale(double x, double y); virtual void SetLogicalOrigin(wxCoord x, wxCoord y); virtual void SetDeviceOrigin(wxCoord x, wxCoord y); virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp); - + protected: virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y); virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, - bool useMask = FALSE); - + bool useMask = FALSE); + virtual void DoSetClippingRegion(wxCoord x, wxCoord y, - wxCoord width, wxCoord height); + wxCoord width, wxCoord height); virtual void DoGetSize(int *width, int *height) const; virtual void DoGetSizeMM(int* width, int* height) const; - + public: void ComputeScaleAndOrigin(); - + wxCoord XDEV2LOG(wxCoord x) const { wxCoord new_x = x - m_deviceOriginX; @@ -154,15 +154,15 @@ public: else return (wxCoord)((double)(y) * m_scaleY - 0.5); } - + public: // not sure what for, but what is a mm on a screen you don't know the size of? double m_mm_to_pix_x,m_mm_to_pix_y; - + // recompute scale? bool m_needComputeScaleX, m_needComputeScaleY; - + }; #endif - // _WX_DC_H_ +// _WX_DC_H_ diff --git a/include/wx/motif/dcclient.h b/include/wx/motif/dcclient.h index 4ead5fd1c1..ec974c1bb3 100644 --- a/include/wx/motif/dcclient.h +++ b/include/wx/motif/dcclient.h @@ -13,7 +13,7 @@ #define _WX_DCCLIENT_H_ #ifdef __GNUG__ - #pragma interface "dcclient.h" +#pragma interface "dcclient.h" #endif #include "wx/dc.h" @@ -35,21 +35,21 @@ class WXDLLEXPORT wxWindow; class WXDLLEXPORT wxWindowDC : public wxDC { DECLARE_DYNAMIC_CLASS(wxWindowDC) - + public: wxWindowDC(); wxWindowDC( wxWindow *win ); - + ~wxWindowDC(); - + // TODO this function is Motif-only for now - should it go into base class? void Clear(const wxRect& rect); - + // implement base class pure virtuals // ---------------------------------- - + virtual void Clear(); - + virtual void SetFont(const wxFont& font); virtual void SetPen(const wxPen& pen); virtual void SetBrush(const wxBrush& brush); @@ -57,78 +57,78 @@ public: virtual void SetBackgroundMode(int mode); virtual void SetPalette(const wxPalette& palette); virtual void SetLogicalFunction( int function ); - + virtual void SetTextForeground(const wxColour& colour); virtual void SetTextBackground(const wxColour& colour); - + virtual wxCoord GetCharHeight() const; virtual wxCoord GetCharWidth() const; virtual void DoGetTextExtent(const wxString& string, - wxCoord *x, wxCoord *y, - wxCoord *descent = NULL, - wxCoord *externalLeading = NULL, - wxFont *theFont = NULL) const; - + wxCoord *x, wxCoord *y, + wxCoord *descent = NULL, + wxCoord *externalLeading = NULL, + wxFont *theFont = NULL) const; + virtual bool CanDrawBitmap() const; virtual bool CanGetTextExtent() const; - + virtual int GetDepth() const; virtual wxSize GetPPI() const; - + virtual void DestroyClippingRegion(); - + // Helper function for setting clipping void SetDCClipping(); - + // implementation from now on // -------------------------- - + WXGC GetGC() const { return m_gc; } WXGC GetBackingGC() const { return m_gcBacking; } WXDisplay* GetDisplay() const { return m_display; } bool GetAutoSetting() const { return m_autoSetting; } void SetAutoSetting(bool flag) { m_autoSetting = flag; } - + protected: virtual void DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, - int style = wxFLOOD_SURFACE); - + int style = wxFLOOD_SURFACE); + virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const; - + virtual void DoDrawPoint(wxCoord x, wxCoord y); virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2); - + virtual void DoDrawArc(wxCoord x1, wxCoord y1, - wxCoord x2, wxCoord y2, - wxCoord xc, wxCoord yc); + wxCoord x2, wxCoord y2, + wxCoord xc, wxCoord yc); virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h, - double sa, double ea); - + double sa, double ea); + virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height); virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y, - wxCoord width, wxCoord height, - double radius); + wxCoord width, wxCoord height, + double radius); virtual void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height); - + virtual void DoCrossHair(wxCoord x, wxCoord y); - + virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y); virtual void DoDrawRotatedText(const wxString &text, wxCoord x, wxCoord y, double angle); - + virtual bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, - wxDC *source, wxCoord xsrc, wxCoord ysrc, - int rop = wxCOPY, bool useMask = FALSE, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1); - + wxDC *source, wxCoord xsrc, wxCoord ysrc, + int rop = wxCOPY, bool useMask = FALSE, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1); + virtual void DoSetClippingRegionAsRegion(const wxRegion& region); virtual void DoSetClippingRegion(wxCoord x, wxCoord y, - wxCoord width, wxCoord height); - + wxCoord width, wxCoord height); + virtual void DoDrawLines(int n, wxPoint points[], - wxCoord xoffset, wxCoord yoffset); + wxCoord xoffset, wxCoord yoffset); virtual void DoDrawPolygon(int n, wxPoint points[], - wxCoord xoffset, wxCoord yoffset, - int fillStyle = wxODDEVEN_RULE); - + wxCoord xoffset, wxCoord yoffset, + int fillStyle = wxODDEVEN_RULE); + WXGC m_gc; WXGC m_gcBacking; WXDisplay* m_display; @@ -136,7 +136,7 @@ protected: WXRegion m_currentRegion; // Current clipping region (incl. paint clip region) WXRegion m_userRegion; // User-defined clipping region WXPixmap m_pixmap; // Pixmap for drawing on - + // Not sure if we'll need all of these int m_backgroundPixel; wxColour m_currentColour; @@ -156,22 +156,22 @@ protected: class WXDLLEXPORT wxPaintDC: public wxWindowDC { DECLARE_DYNAMIC_CLASS(wxPaintDC) - + public: wxPaintDC() { } wxPaintDC(wxWindow* win); - + ~wxPaintDC(); }; class WXDLLEXPORT wxClientDC: public wxWindowDC { DECLARE_DYNAMIC_CLASS(wxClientDC) - + public: wxClientDC() { } wxClientDC(wxWindow* win) : wxWindowDC(win) { } }; #endif - // _WX_DCCLIENT_H_ +// _WX_DCCLIENT_H_ diff --git a/include/wx/motif/dcmemory.h b/include/wx/motif/dcmemory.h index bde81607ca..5d85ded03e 100644 --- a/include/wx/motif/dcmemory.h +++ b/include/wx/motif/dcmemory.h @@ -13,31 +13,31 @@ #define _WX_DCMEMORY_H_ #ifdef __GNUG__ - #pragma interface "dcmemory.h" +#pragma interface "dcmemory.h" #endif #include "wx/dcclient.h" class wxMemoryDC : public wxWindowDC { -DECLARE_DYNAMIC_CLASS(wxMemoryDC) - + DECLARE_DYNAMIC_CLASS(wxMemoryDC) + public: wxMemoryDC(); wxMemoryDC( wxDC *dc ); // Create compatible DC ~wxMemoryDC(); - + virtual void SelectObject( const wxBitmap& bitmap ); - + void DoGetSize( int *width, int *height ) const; - + wxBitmap& GetBitmap() const { return (wxBitmap&) m_bitmap; } - + private: friend class wxPaintDC; - + wxBitmap m_bitmap; }; #endif - // _WX_DCMEMORY_H_ +// _WX_DCMEMORY_H_ diff --git a/include/wx/motif/dcprint.h b/include/wx/motif/dcprint.h index d46260ffce..2454826e8e 100644 --- a/include/wx/motif/dcprint.h +++ b/include/wx/motif/dcprint.h @@ -20,15 +20,15 @@ class WXDLLEXPORT wxPrinterDC: public wxDC { - public: - DECLARE_CLASS(wxPrinterDC) - - // Create a printer DC - wxPrinterDC(const wxString& driver, const wxString& device, const wxString& output, bool interactive = TRUE, int orientation = wxPORTRAIT); - - ~wxPrinterDC(); +public: + DECLARE_CLASS(wxPrinterDC) + + // Create a printer DC + wxPrinterDC(const wxString& driver, const wxString& device, const wxString& output, bool interactive = TRUE, int orientation = wxPORTRAIT); + + ~wxPrinterDC(); }; #endif - // _WX_DCPRINT_H_ +// _WX_DCPRINT_H_ diff --git a/include/wx/motif/dcscreen.h b/include/wx/motif/dcscreen.h index e4d4c16979..27cf673db2 100644 --- a/include/wx/motif/dcscreen.h +++ b/include/wx/motif/dcscreen.h @@ -20,29 +20,29 @@ class WXDLLEXPORT wxScreenDC: public wxWindowDC { - DECLARE_DYNAMIC_CLASS(wxScreenDC) - - public: - // Create a DC representing the whole screen - wxScreenDC(); - ~wxScreenDC(); - - // Compatibility with X's requirements for - // drawing on top of all windows - static bool StartDrawingOnTop(wxWindow* window); - static bool StartDrawingOnTop(wxRect* rect = NULL); - static bool EndDrawingOnTop(); - + DECLARE_DYNAMIC_CLASS(wxScreenDC) + +public: + // Create a DC representing the whole screen + wxScreenDC(); + ~wxScreenDC(); + + // Compatibility with X's requirements for + // drawing on top of all windows + static bool StartDrawingOnTop(wxWindow* window); + static bool StartDrawingOnTop(wxRect* rect = NULL); + static bool EndDrawingOnTop(); + private: - static WXWindow sm_overlayWindow; - - // If we have started transparent drawing at a non-(0,0) point - // then we will have to adjust the device origin in the - // constructor. - static int sm_overlayWindowX; - static int sm_overlayWindowY; + static WXWindow sm_overlayWindow; + + // If we have started transparent drawing at a non-(0,0) point + // then we will have to adjust the device origin in the + // constructor. + static int sm_overlayWindowX; + static int sm_overlayWindowY; }; #endif - // _WX_DCSCREEN_H_ +// _WX_DCSCREEN_H_ diff --git a/include/wx/motif/dialog.h b/include/wx/motif/dialog.h index df9688ddee..bdfd0a056d 100644 --- a/include/wx/motif/dialog.h +++ b/include/wx/motif/dialog.h @@ -13,7 +13,7 @@ #define _WX_DIALOG_H_ #ifdef __GNUG__ - #pragma interface "dialog.h" +#pragma interface "dialog.h" #endif WXDLLEXPORT_DATA(extern const char*) wxDialogNameStr; @@ -21,85 +21,85 @@ WXDLLEXPORT_DATA(extern const char*) wxDialogNameStr; // Dialog boxes class WXDLLEXPORT wxDialog : public wxDialogBase { -DECLARE_DYNAMIC_CLASS(wxDialog) - + DECLARE_DYNAMIC_CLASS(wxDialog) + public: wxDialog(); - + // Constructor with a modal flag, but no window id - the old convention wxDialog(wxWindow *parent, - const wxString& title, bool modal, - int x = -1, int y= -1, int width = 500, int height = 500, - long style = wxDEFAULT_DIALOG_STYLE, - const wxString& name = wxDialogNameStr) + const wxString& title, bool modal, + int x = -1, int y= -1, int width = 500, int height = 500, + long style = wxDEFAULT_DIALOG_STYLE, + const wxString& name = wxDialogNameStr) { long modalStyle = modal ? wxDIALOG_MODAL : wxDIALOG_MODELESS ; Create(parent, -1, title, wxPoint(x, y), wxSize(width, height), style|modalStyle, name); } - + // Constructor with no modal flag - the new convention. wxDialog(wxWindow *parent, wxWindowID id, - const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_DIALOG_STYLE, - const wxString& name = wxDialogNameStr) + const wxString& title, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_DIALOG_STYLE, + const wxString& name = wxDialogNameStr) { Create(parent, id, title, pos, size, style, name); } - + bool Create(wxWindow *parent, wxWindowID id, - const wxString& title, // bool modal = FALSE, // TODO make this a window style? - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_DIALOG_STYLE, - const wxString& name = wxDialogNameStr); - + const wxString& title, // bool modal = FALSE, // TODO make this a window style? + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_DIALOG_STYLE, + const wxString& name = wxDialogNameStr); + ~wxDialog(); - + virtual bool Destroy(); - + bool Show(bool show); void Iconize(bool iconize); void Raise(); void Lower(); - + virtual bool IsIconized() const; - + virtual bool IsTopLevel() const { return TRUE; } void SetTitle(const wxString& title); wxString GetTitle() const ; - + void SetModal(bool flag); - + virtual bool IsModal() const - { return ((GetWindowStyleFlag() & wxDIALOG_MODAL) == wxDIALOG_MODAL); } - + { return ((GetWindowStyleFlag() & wxDIALOG_MODAL) == wxDIALOG_MODAL); } + virtual int ShowModal(); virtual void EndModal(int retCode); - + // Implementation virtual void ChangeFont(bool keepOriginalSize = TRUE); virtual void ChangeBackgroundColour(); virtual void ChangeForegroundColour(); inline WXWidget GetTopWidget() const { return m_mainWidget; } inline WXWidget GetClientWidget() const { return m_mainWidget; } - + // Standard buttons void OnOK(wxCommandEvent& event); void OnApply(wxCommandEvent& event); void OnCancel(wxCommandEvent& event); - + void OnPaint(wxPaintEvent &event); - + // Responds to colour changes void OnSysColourChanged(wxSysColourChangedEvent& event); - + // bool OnClose(); void OnCharHook(wxKeyEvent& event); void OnCloseWindow(wxCloseEvent& event); - + // Responds to size changes void OnSize(wxSizeEvent& event); @@ -107,17 +107,17 @@ public: //// Motif-specific bool m_modalShowing; wxString m_dialogTitle; - + protected: virtual void DoSetSize(int x, int y, - int width, int height, - int sizeFlags = wxSIZE_AUTO); - + int width, int height, + int sizeFlags = wxSIZE_AUTO); + virtual void DoSetClientSize(int width, int height); - + private: DECLARE_EVENT_TABLE() }; #endif - // _WX_DIALOG_H_ +// _WX_DIALOG_H_ diff --git a/include/wx/motif/dirdlg.h b/include/wx/motif/dirdlg.h index b27cb74466..6a9275c1ba 100644 --- a/include/wx/motif/dirdlg.h +++ b/include/wx/motif/dirdlg.h @@ -22,22 +22,22 @@ WXDLLEXPORT_DATA(extern const char*) wxFileSelectorPromptStr; class WXDLLEXPORT wxDirDialog: public wxDialog { -DECLARE_DYNAMIC_CLASS(wxDirDialog) + DECLARE_DYNAMIC_CLASS(wxDirDialog) public: wxDirDialog(wxWindow *parent, const wxString& message = wxFileSelectorPromptStr, const wxString& defaultPath = "", long style = 0, const wxPoint& pos = wxDefaultPosition); - + inline void SetMessage(const wxString& message) { m_message = message; } inline void SetPath(const wxString& path) { m_path = path; } inline void SetStyle(long style) { m_dialogStyle = style; } - + inline wxString GetMessage() const { return m_message; } inline wxString GetPath() const { return m_path; } inline long GetStyle() const { return m_dialogStyle; } - + int ShowModal(); - + protected: wxString m_message; long m_dialogStyle; @@ -46,4 +46,4 @@ protected: }; #endif - // _WX_DIRDLG_H_ +// _WX_DIRDLG_H_ diff --git a/include/wx/motif/dnd.h b/include/wx/motif/dnd.h index fab08d7476..b3944af30c 100644 --- a/include/wx/motif/dnd.h +++ b/include/wx/motif/dnd.h @@ -43,21 +43,21 @@ class WXDLLEXPORT wxDropSource; class WXDLLEXPORT wxDropTarget: public wxObject { - public: - +public: + wxDropTarget(); ~wxDropTarget(); virtual void OnEnter() { } virtual void OnLeave() { } virtual bool OnDrop( long x, long y, const void *data, size_t size ) = 0; - + // Override these to indicate what kind of data you support: - + virtual size_t GetFormatCount() const = 0; virtual wxDataFormat GetFormat(size_t n) const = 0; - - // implementation + + // implementation }; //------------------------------------------------------------------------- @@ -66,14 +66,14 @@ class WXDLLEXPORT wxDropTarget: public wxObject class WXDLLEXPORT wxTextDropTarget: public wxDropTarget { - public: - +public: + wxTextDropTarget() {}; virtual bool OnDrop( long x, long y, const void *data, size_t size ); virtual bool OnDropText( long x, long y, const char *psz ); - protected: - +protected: + virtual size_t GetFormatCount() const; virtual wxDataFormat GetFormat(size_t n) const; }; @@ -85,27 +85,27 @@ class WXDLLEXPORT wxTextDropTarget: public wxDropTarget class WXDLLEXPORT wxPrivateDropTarget: public wxDropTarget { public: - - wxPrivateDropTarget(); - - // you have to override OnDrop to get at the data - // the string ID identifies the format of clipboard or DnD data. a word - // processor would e.g. add a wxTextDataObject and a wxPrivateDataObject - // to the clipboard - the latter with the Id "WXWORD_FORMAT". + wxPrivateDropTarget(); - void SetId( const wxString& id ) - { m_id = id; } + // you have to override OnDrop to get at the data + + // the string ID identifies the format of clipboard or DnD data. a word + // processor would e.g. add a wxTextDataObject and a wxPrivateDataObject + // to the clipboard - the latter with the Id "WXWORD_FORMAT". + + void SetId( const wxString& id ) + { m_id = id; } + + wxString GetId() + { return m_id; } - wxString GetId() - { return m_id; } - private: - - virtual size_t GetFormatCount() const; - virtual wxDataFormat GetFormat(size_t n) const; - wxString m_id; + virtual size_t GetFormatCount() const; + virtual wxDataFormat GetFormat(size_t n) const; + + wxString m_id; }; // ---------------------------------------------------------------------------- @@ -114,16 +114,16 @@ private: class WXDLLEXPORT wxFileDropTarget: public wxDropTarget { - public: +public: wxFileDropTarget() {}; virtual bool OnDrop( long x, long y, const void *data, size_t size ); virtual bool OnDropFiles( long x, long y, - size_t nFiles, const char * const aszFiles[] ); - - protected: - + size_t nFiles, const char * const aszFiles[] ); + +protected: + virtual size_t GetFormatCount() const; virtual wxDataFormat GetFormat(size_t n) const; }; @@ -134,17 +134,17 @@ class WXDLLEXPORT wxFileDropTarget: public wxDropTarget enum wxDragResult { - wxDragError, // error prevented the d&d operation from completing - wxDragNone, // drag target didn't accept the data - wxDragCopy, // the data was successfully copied - wxDragMove, // the data was successfully moved - wxDragCancel // the operation was cancelled by user (not an error) + wxDragError, // error prevented the d&d operation from completing + wxDragNone, // drag target didn't accept the data + wxDragCopy, // the data was successfully copied + wxDragMove, // the data was successfully moved + wxDragCancel // the operation was cancelled by user (not an error) }; class WXDLLEXPORT wxDropSource: public wxObject { - public: - +public: + wxDropSource( wxWindow *win ); wxDropSource( wxDataObject &data, wxWindow *win ); @@ -154,12 +154,12 @@ class WXDLLEXPORT wxDropSource: public wxObject wxDragResult DoDragDrop( bool bAllowMove = FALSE ); virtual bool GiveFeedback( wxDragResult WXUNUSED(effect), bool WXUNUSED(bScrolling) ) { return TRUE; }; - - // implementation + + // implementation #if 0 void RegisterWindow(void); void UnregisterWindow(void); - + wxWindow *m_window; wxDragResult m_retValue; wxDataObject *m_data; @@ -171,8 +171,8 @@ class WXDLLEXPORT wxDropSource: public wxObject #endif - // wxUSE_DRAG_AND_DROP +// wxUSE_DRAG_AND_DROP #endif - //_WX_DND_H_ +//_WX_DND_H_ diff --git a/include/wx/motif/filedlg.h b/include/wx/motif/filedlg.h index 510b4392fa..10fae98744 100644 --- a/include/wx/motif/filedlg.h +++ b/include/wx/motif/filedlg.h @@ -19,15 +19,15 @@ #include "wx/dialog.h" /* - * File selector - */ +* File selector +*/ WXDLLEXPORT_DATA(extern const char*) wxFileSelectorPromptStr; WXDLLEXPORT_DATA(extern const char*) wxFileSelectorDefaultWildcardStr; class WXDLLEXPORT wxFileDialog: public wxDialog { -DECLARE_DYNAMIC_CLASS(wxFileDialog) + DECLARE_DYNAMIC_CLASS(wxFileDialog) public: wxString m_message; long m_dialogStyle; @@ -37,17 +37,17 @@ public: wxString m_fileName; wxString m_wildCard; int m_filterIndex; - + // For Motif wxPoint m_pos; static wxString m_fileSelectorAnswer; static bool m_fileSelectorReturned; - + public: wxFileDialog(wxWindow *parent, const wxString& message = wxFileSelectorPromptStr, const wxString& defaultDir = "", const wxString& defaultFile = "", const wxString& wildCard = wxFileSelectorDefaultWildcardStr, long style = 0, const wxPoint& pos = wxDefaultPosition); - + inline void SetMessage(const wxString& message) { m_message = message; } inline void SetPath(const wxString& path) { m_path = path; } inline void SetDirectory(const wxString& dir) { m_dir = dir; } @@ -55,18 +55,18 @@ public: inline void SetWildcard(const wxString& wildCard) { m_wildCard = wildCard; } inline void SetStyle(long style) { m_dialogStyle = style; } inline void SetFilterIndex(int filterIndex) { m_filterIndex = filterIndex; } - + inline wxString GetMessage() const { return m_message; } inline wxString GetPath() const { return m_path; } inline void GetPaths(wxArrayString& a) { a.Empty(); a.Add(m_path); } inline wxString GetDirectory() const { return m_dir; } inline wxString GetFilename() const { return m_fileName; } inline void GetFilenames(wxArrayString& a) { a.Empty(); - a.Add( m_fileName); } + a.Add( m_fileName); } inline wxString GetWildcard() const { return m_wildCard; } inline long GetStyle() const { return m_dialogStyle; } inline int GetFilterIndex() const { return m_filterIndex ; } - + int ShowModal(); }; @@ -78,15 +78,15 @@ public: // File selector - backward compatibility WXDLLEXPORT wxString wxFileSelector(const char *message = wxFileSelectorPromptStr, const char *default_path = NULL, - const char *default_filename = NULL, const char *default_extension = NULL, - const char *wildcard = wxFileSelectorDefaultWildcardStr, int flags = 0, - wxWindow *parent = NULL, int x = -1, int y = -1); + const char *default_filename = NULL, const char *default_extension = NULL, + const char *wildcard = wxFileSelectorDefaultWildcardStr, int flags = 0, + wxWindow *parent = NULL, int x = -1, int y = -1); // An extended version of wxFileSelector WXDLLEXPORT wxString wxFileSelectorEx(const char *message = wxFileSelectorPromptStr, const char *default_path = NULL, - const char *default_filename = NULL, int *indexDefaultExtension = NULL, - const char *wildcard = wxFileSelectorDefaultWildcardStr, int flags = 0, - wxWindow *parent = NULL, int x = -1, int y = -1); + const char *default_filename = NULL, int *indexDefaultExtension = NULL, + const char *wildcard = wxFileSelectorDefaultWildcardStr, int flags = 0, + wxWindow *parent = NULL, int x = -1, int y = -1); // Generic file load dialog WXDLLEXPORT wxString wxLoadFileSelector(const char *what, const char *extension, const char *default_name = NULL, wxWindow *parent = NULL); @@ -95,4 +95,4 @@ WXDLLEXPORT wxString wxLoadFileSelector(const char *what, const char *extension, WXDLLEXPORT wxString wxSaveFileSelector(const char *what, const char *extension, const char *default_name = NULL, wxWindow *parent = NULL); #endif - // _WX_FILEDLG_H_ +// _WX_FILEDLG_H_ diff --git a/include/wx/motif/font.h b/include/wx/motif/font.h index 99d6600abb..f75bf6c423 100644 --- a/include/wx/motif/font.h +++ b/include/wx/motif/font.h @@ -13,7 +13,7 @@ #define _WX_FONT_H_ #ifdef __GNUG__ - #pragma interface "font.h" +#pragma interface "font.h" #endif class wxXFont; @@ -25,40 +25,40 @@ public: // ctors and such wxFont() { Init(); } wxFont(const wxFont& font) { Init(); Ref(font); } - + wxFont(int size, - int family, - int style, - int weight, - bool underlined = FALSE, - const wxString& face = wxEmptyString, - wxFontEncoding encoding = wxFONTENCODING_DEFAULT) + int family, + int style, + int weight, + bool underlined = FALSE, + const wxString& face = wxEmptyString, + wxFontEncoding encoding = wxFONTENCODING_DEFAULT) { Init(); - + (void)Create(size, family, style, weight, underlined, face, encoding); } - + wxFont(const wxNativeFontInfo& info); - + bool Create(int size, - int family, - int style, - int weight, - bool underlined = FALSE, - const wxString& face = wxEmptyString, - wxFontEncoding encoding = wxFONTENCODING_DEFAULT); - + int family, + int style, + int weight, + bool underlined = FALSE, + const wxString& face = wxEmptyString, + wxFontEncoding encoding = wxFONTENCODING_DEFAULT); + // wxMOTIF-specific bool Create(const wxString& fontname, - wxFontEncoding fontenc = wxFONTENCODING_DEFAULT); + wxFontEncoding fontenc = wxFONTENCODING_DEFAULT); bool Create(const wxNativeFontInfo& fontinfo); virtual ~wxFont(); - + // assignment wxFont& operator=(const wxFont& font); - + // implement base class pure virtuals virtual int GetPointSize() const; virtual int GetFamily() const; @@ -79,39 +79,39 @@ public: virtual void SetNativeFontInfo( const wxNativeFontInfo& info ); // Implementation - + // Find an existing, or create a new, XFontStruct // based on this wxFont and the given scale. Append the // font to list in the private data for future reference. - + // TODO This is a fairly basic implementation, that doesn't // allow for different facenames, and also doesn't do a mapping // between 'standard' facenames (e.g. Arial, Helvetica, Times Roman etc.) // and the fonts that are available on a particular system. // Maybe we need to scan the user's machine to build up a profile // of the fonts and a mapping file. - + // Return font struct, and optionally the Motif font list wxXFont *GetInternalFont(double scale = 1.0, - WXDisplay* display = NULL) const; - + WXDisplay* display = NULL) const; + // These two are helper functions for convenient access of the above. WXFontStructPtr GetFontStruct(double scale = 1.0, - WXDisplay* display = NULL) const; + WXDisplay* display = NULL) const; WXFontList GetFontList(double scale = 1.0, - WXDisplay* display = NULL) const; - + WXDisplay* display = NULL) const; + protected: // common part of all ctors void Init(); - + // VZ: IMHO, we don't need it at all... bool RealizeResource() { return TRUE; } void Unshare(); - + private: DECLARE_DYNAMIC_CLASS(wxFont) }; #endif - // _WX_FONT_H_ +// _WX_FONT_H_ diff --git a/include/wx/motif/fontdlg.h b/include/wx/motif/fontdlg.h index ca799d759a..530719ff34 100644 --- a/include/wx/motif/fontdlg.h +++ b/include/wx/motif/fontdlg.h @@ -21,26 +21,26 @@ #include "wx/cmndata.h" /* - * Font dialog - */ - +* Font dialog +*/ + class WXDLLEXPORT wxFontDialog: public wxDialog { -DECLARE_DYNAMIC_CLASS(wxFontDialog) + DECLARE_DYNAMIC_CLASS(wxFontDialog) public: wxFontDialog(); wxFontDialog(wxWindow *parent, wxFontData *data = NULL); - + bool Create(wxWindow *parent, wxFontData *data = NULL); - + int ShowModal(); wxFontData& GetFontData() { return m_fontData; } - + protected: wxWindow* m_dialogParent; wxFontData m_fontData; }; #endif - // _WX_FONTDLG_H_ +// _WX_FONTDLG_H_ diff --git a/include/wx/motif/frame.h b/include/wx/motif/frame.h index e3e1e553ea..f0493408da 100644 --- a/include/wx/motif/frame.h +++ b/include/wx/motif/frame.h @@ -13,7 +13,7 @@ #define _WX_MOTIF_FRAME_H_ #ifdef __GNUG__ - #pragma interface "frame.h" +#pragma interface "frame.h" #endif class WXDLLEXPORT wxFrame : public wxFrameBase @@ -21,72 +21,72 @@ class WXDLLEXPORT wxFrame : public wxFrameBase public: wxFrame() { Init(); } wxFrame(wxWindow *parent, - wxWindowID id, - const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE, - const wxString& name = wxFrameNameStr) + wxWindowID id, + const wxString& title, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_FRAME_STYLE, + const wxString& name = wxFrameNameStr) { Init(); - + Create(parent, id, title, pos, size, style, name); } - + bool Create(wxWindow *parent, - wxWindowID id, - const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE, - const wxString& name = wxFrameNameStr); - + wxWindowID id, + const wxString& title, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_FRAME_STYLE, + const wxString& name = wxFrameNameStr); + virtual ~wxFrame(); - + virtual bool Show(bool show = TRUE); - + // Set menu bar void SetMenuBar(wxMenuBar *menu_bar); - + // Set title void SetTitle(const wxString& title); wxString GetTitle() const { return m_title; } - + // Set icon virtual void SetIcon(const wxIcon& icon); - + #if wxUSE_STATUSBAR virtual void PositionStatusBar(); #endif // wxUSE_STATUSBAR - + // Create toolbar #if wxUSE_TOOLBAR virtual wxToolBar* CreateToolBar(long style = wxNO_BORDER|wxTB_HORIZONTAL, wxWindowID id = -1, const wxString& name = wxToolBarNameStr); virtual void PositionToolBar(); #endif // wxUSE_TOOLBAR - + // Iconize virtual void Iconize(bool iconize); - + virtual bool IsIconized() const; - + // Is the frame maximized? Returns FALSE under Motif (but TRUE for // wxMDIChildFrame due to the tabbed implementation). virtual bool IsMaximized() const; - + virtual void Maximize(bool maximize); - + virtual void Raise(); virtual void Lower(); - + virtual void Restore(); - + // Implementation only from now on // ------------------------------- - + void OnSysColourChanged(wxSysColourChangedEvent& event); void OnActivate(wxActivateEvent& event); - + virtual void ChangeFont(bool keepOriginalSize = TRUE); virtual void ChangeBackgroundColour(); virtual void ChangeForegroundColour(); @@ -95,19 +95,19 @@ public: WXWidget GetWorkAreaWidget() const { return m_workArea; } WXWidget GetClientAreaWidget() const { return m_clientArea; } WXWidget GetTopWidget() const { return m_frameShell; } - + virtual WXWidget GetMainWidget() const { return m_frameWidget; } - + // The widget that can have children on it WXWidget GetClientWidget() const; bool GetVisibleStatus() const { return m_visibleStatus; } - + bool PreResize(); - + protected: // common part of all ctors void Init(); - + //// Motif-specific WXWidget m_frameShell; WXWidget m_frameWidget; @@ -116,19 +116,19 @@ protected: wxString m_title; bool m_visibleStatus; bool m_iconized; - + virtual void DoGetClientSize(int *width, int *height) const; virtual void DoGetSize(int *width, int *height) const; virtual void DoGetPosition(int *x, int *y) const; virtual void DoSetSize(int x, int y, - int width, int height, - int sizeFlags = wxSIZE_AUTO); + int width, int height, + int sizeFlags = wxSIZE_AUTO); virtual void DoSetClientSize(int width, int height); - + private: DECLARE_EVENT_TABLE() - DECLARE_DYNAMIC_CLASS(wxFrame) + DECLARE_DYNAMIC_CLASS(wxFrame) }; #endif - // _WX_MOTIF_FRAME_H_ +// _WX_MOTIF_FRAME_H_ diff --git a/include/wx/motif/gauge.h b/include/wx/motif/gauge.h index 201b6e5488..d8c6e2edb3 100644 --- a/include/wx/motif/gauge.h +++ b/include/wx/motif/gauge.h @@ -24,50 +24,50 @@ WXDLLEXPORT_DATA(extern const char*) wxGaugeNameStr; class WXDLLEXPORT wxGauge : public wxControl { DECLARE_DYNAMIC_CLASS(wxGauge) - + public: inline wxGauge() { m_rangeMax = 0; m_gaugePos = 0; } - + inline wxGauge(wxWindow *parent, wxWindowID id, - int range, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxGA_HORIZONTAL, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxGaugeNameStr) + int range, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxGA_HORIZONTAL, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxGaugeNameStr) { Create(parent, id, range, pos, size, style, validator, name); } - + bool Create(wxWindow *parent, wxWindowID id, - int range, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxGA_HORIZONTAL, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxGaugeNameStr); - + int range, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxGA_HORIZONTAL, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxGaugeNameStr); + void SetShadowWidth(int w); void SetBezelFace(int w); void SetRange(int r); void SetValue(int pos); - + int GetShadowWidth() const ; int GetBezelFace() const ; int GetRange() const ; int GetValue() const ; - + virtual void Command(wxCommandEvent& WXUNUSED(event)) {} ; - + // Implementation virtual void ChangeFont(bool keepOriginalSize = TRUE); virtual void ChangeBackgroundColour(); virtual void ChangeForegroundColour(); - + protected: int m_rangeMax; int m_gaugePos; }; #endif - // _WX_GAUGE_H_ +// _WX_GAUGE_H_ diff --git a/include/wx/motif/gdiobj.h b/include/wx/motif/gdiobj.h index c25575dffc..f55c95cec7 100644 --- a/include/wx/motif/gdiobj.h +++ b/include/wx/motif/gdiobj.h @@ -21,28 +21,28 @@ class WXDLLEXPORT wxGDIRefData: public wxObjectRefData { public: inline wxGDIRefData() - { - } + { + } }; #define M_GDIDATA ((wxGDIRefData *)m_refData) class WXDLLEXPORT wxGDIObject: public wxObject { -DECLARE_DYNAMIC_CLASS(wxGDIObject) - public: - inline wxGDIObject() { m_visible = FALSE; }; - inline ~wxGDIObject() {}; - - inline bool IsNull() const { return (m_refData == 0); } - - virtual bool GetVisible() { return m_visible; } - virtual void SetVisible(bool v) { m_visible = v; } - + DECLARE_DYNAMIC_CLASS(wxGDIObject) +public: + inline wxGDIObject() { m_visible = FALSE; }; + inline ~wxGDIObject() {}; + + inline bool IsNull() const { return (m_refData == 0); } + + virtual bool GetVisible() { return m_visible; } + virtual void SetVisible(bool v) { m_visible = v; } + protected: - bool m_visible; // Can a pointer to this object be safely taken? - // - only if created within FindOrCreate... + bool m_visible; // Can a pointer to this object be safely taken? + // - only if created within FindOrCreate... }; #endif - // _WX_GDIOBJ_H_ +// _WX_GDIOBJ_H_ diff --git a/include/wx/motif/glcanvas.h b/include/wx/motif/glcanvas.h index 3ebad5ebb8..1932fef522 100644 --- a/include/wx/motif/glcanvas.h +++ b/include/wx/motif/glcanvas.h @@ -29,22 +29,22 @@ enum { - WX_GL_RGBA=1, /* use true color palette */ - WX_GL_BUFFER_SIZE, /* bits for buffer if not WX_GL_RGBA */ - WX_GL_LEVEL, /* 0 for main buffer, >0 for overlay, <0 for underlay */ - WX_GL_DOUBLEBUFFER, /* use doublebuffer */ - WX_GL_STEREO, /* use stereoscopic display */ - WX_GL_AUX_BUFFERS, /* number of auxiliary buffers */ - WX_GL_MIN_RED, /* use red buffer with most bits (> MIN_RED bits) */ - WX_GL_MIN_GREEN, /* use green buffer with most bits (> MIN_GREEN bits) */ - WX_GL_MIN_BLUE, /* use blue buffer with most bits (> MIN_BLUE bits) */ - WX_GL_MIN_ALPHA, /* use blue buffer with most bits (> MIN_ALPHA bits) */ - WX_GL_DEPTH_SIZE, /* bits for Z-buffer (0,16,32) */ - WX_GL_STENCIL_SIZE, /* bits for stencil buffer */ - WX_GL_MIN_ACCUM_RED, /* use red accum buffer with most bits (> MIN_ACCUM_RED bits) */ - WX_GL_MIN_ACCUM_GREEN, /* use green buffer with most bits (> MIN_ACCUM_GREEN bits) */ - WX_GL_MIN_ACCUM_BLUE, /* use blue buffer with most bits (> MIN_ACCUM_BLUE bits) */ - WX_GL_MIN_ACCUM_ALPHA /* use blue buffer with most bits (> MIN_ACCUM_ALPHA bits) */ + WX_GL_RGBA=1, /* use true color palette */ + WX_GL_BUFFER_SIZE, /* bits for buffer if not WX_GL_RGBA */ + WX_GL_LEVEL, /* 0 for main buffer, >0 for overlay, <0 for underlay */ + WX_GL_DOUBLEBUFFER, /* use doublebuffer */ + WX_GL_STEREO, /* use stereoscopic display */ + WX_GL_AUX_BUFFERS, /* number of auxiliary buffers */ + WX_GL_MIN_RED, /* use red buffer with most bits (> MIN_RED bits) */ + WX_GL_MIN_GREEN, /* use green buffer with most bits (> MIN_GREEN bits) */ + WX_GL_MIN_BLUE, /* use blue buffer with most bits (> MIN_BLUE bits) */ + WX_GL_MIN_ALPHA, /* use blue buffer with most bits (> MIN_ALPHA bits) */ + WX_GL_DEPTH_SIZE, /* bits for Z-buffer (0,16,32) */ + WX_GL_STENCIL_SIZE, /* bits for stencil buffer */ + WX_GL_MIN_ACCUM_RED, /* use red accum buffer with most bits (> MIN_ACCUM_RED bits) */ + WX_GL_MIN_ACCUM_GREEN, /* use green buffer with most bits (> MIN_ACCUM_GREEN bits) */ + WX_GL_MIN_ACCUM_BLUE, /* use blue buffer with most bits (> MIN_ACCUM_BLUE bits) */ + WX_GL_MIN_ACCUM_ALPHA /* use blue buffer with most bits (> MIN_ACCUM_ALPHA bits) */ }; //--------------------------------------------------------------------------- @@ -56,33 +56,33 @@ class WXDLLEXPORT wxGLContext: public wxObject { public: wxGLContext( bool isRGB, wxWindow *win, - const wxPalette& palette = wxNullPalette ); + const wxPalette& palette = wxNullPalette ); wxGLContext( bool WXUNUSED(isRGB), wxWindow *win, - const wxPalette& WXUNUSED(palette), - const wxGLContext *other /* for sharing display lists */ - ); + const wxPalette& WXUNUSED(palette), + const wxGLContext *other /* for sharing display lists */ + ); ~wxGLContext(); - + void SetCurrent(); void SetColour(const char *colour); void SwapBuffers(); - + void SetupPixelFormat(); void SetupPalette(const wxPalette& palette); wxPalette CreateDefaultPalette(); - + inline wxPalette* GetPalette() const { return (wxPalette*) & m_palette; } inline wxWindow* GetWindow() const { return m_window; } // inline GtkWidget* GetWidget() const { return m_widget; } inline GLXContext GetContext() const { return m_glContext; } - + public: - GLXContext m_glContext; - - // GtkWidget *m_widget; - wxPalette m_palette; - wxWindow* m_window; - + GLXContext m_glContext; + + // GtkWidget *m_widget; + wxPalette m_palette; + wxWindow* m_window; + DECLARE_CLASS(wxGLContext) }; @@ -90,72 +90,72 @@ public: class WXDLLEXPORT wxGLCanvas: public wxScrolledWindow { public: - inline wxGLCanvas() { - m_glContext = (wxGLContext*) NULL; - m_sharedContext = (wxGLContext*) NULL; - // m_glWidget = (GtkWidget*) NULL; - m_vi = (void*) NULL; - // m_exposed = FALSE; - } - wxGLCanvas( wxWindow *parent, wxWindowID id = -1, + inline wxGLCanvas() { + m_glContext = (wxGLContext*) NULL; + m_sharedContext = (wxGLContext*) NULL; + // m_glWidget = (GtkWidget*) NULL; + m_vi = (void*) NULL; + // m_exposed = FALSE; + } + wxGLCanvas( wxWindow *parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = "GLCanvas", int *attribList = (int*) NULL, const wxPalette& palette = wxNullPalette ); - wxGLCanvas( wxWindow *parent, const wxGLContext *shared = (wxGLContext *)NULL, + wxGLCanvas( wxWindow *parent, const wxGLContext *shared = (wxGLContext *)NULL, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = "GLCanvas", int *attribList = (int*) NULL, const wxPalette& palette = wxNullPalette ); - wxGLCanvas( wxWindow *parent, const wxGLCanvas *shared = (wxGLCanvas *)NULL, + wxGLCanvas( wxWindow *parent, const wxGLCanvas *shared = (wxGLCanvas *)NULL, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = "GLCanvas", int *attribList = (int*) NULL, const wxPalette& palette = wxNullPalette ); - - bool Create( wxWindow *parent, - const wxGLContext *shared = (wxGLContext*)NULL, - const wxGLCanvas *shared_context_of = (wxGLCanvas*)NULL, + + bool Create( wxWindow *parent, + const wxGLContext *shared = (wxGLContext*)NULL, + const wxGLCanvas *shared_context_of = (wxGLCanvas*)NULL, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - long style = 0, const wxString& name = "GLCanvas", - int *attribList = (int*) NULL, - const wxPalette& palette = wxNullPalette ); - - ~wxGLCanvas(); - - void SetCurrent(); - void SetColour(const char *colour); - void SwapBuffers(); - - // void OnSize(wxSizeEvent& event); - - // void OnInternalIdle(); - - inline wxGLContext* GetContext() const { return m_glContext; } - - // implementation - + long style = 0, const wxString& name = "GLCanvas", + int *attribList = (int*) NULL, + const wxPalette& palette = wxNullPalette ); + + ~wxGLCanvas(); + + void SetCurrent(); + void SetColour(const char *colour); + void SwapBuffers(); + + // void OnSize(wxSizeEvent& event); + + // void OnInternalIdle(); + + inline wxGLContext* GetContext() const { return m_glContext; } + + // implementation + wxGLContext *m_glContext, - *m_sharedContext; + *m_sharedContext; wxGLCanvas *m_sharedContextOf; void *m_vi; // GtkWidget *m_glWidget; // bool m_exposed; - + DECLARE_EVENT_TABLE() - DECLARE_CLASS(wxGLCanvas) - + DECLARE_CLASS(wxGLCanvas) + }; #endif - // wxUSE_GLCANVAS +// wxUSE_GLCANVAS #endif - // _WX_GLCANVAS_H_ +// _WX_GLCANVAS_H_ diff --git a/include/wx/motif/helpxxxx.h b/include/wx/motif/helpxxxx.h index fc991a93b3..1863184953 100644 --- a/include/wx/motif/helpxxxx.h +++ b/include/wx/motif/helpxxxx.h @@ -23,30 +23,30 @@ class WXDLLEXPORT wxXXXXHelpController: public wxHelpControllerBase { - DECLARE_CLASS(wxXXXXHelpController) - - public: - wxXXXXHelpController(); - ~wxXXXXHelpController(); - - // Must call this to set the filename and server name - virtual bool Initialize(const wxString& file); - - // If file is "", reloads file given in Initialize - virtual bool LoadFile(const wxString& file = ""); - virtual bool DisplayContents(); - virtual bool DisplaySection(int sectionNo); - virtual bool DisplayBlock(long blockNo); - virtual bool KeywordSearch(const wxString& k); - - virtual bool Quit(); - virtual void OnQuit(); - - inline wxString GetHelpFile() const { return m_helpFile; } - + DECLARE_CLASS(wxXXXXHelpController) + +public: + wxXXXXHelpController(); + ~wxXXXXHelpController(); + + // Must call this to set the filename and server name + virtual bool Initialize(const wxString& file); + + // If file is "", reloads file given in Initialize + virtual bool LoadFile(const wxString& file = ""); + virtual bool DisplayContents(); + virtual bool DisplaySection(int sectionNo); + virtual bool DisplayBlock(long blockNo); + virtual bool KeywordSearch(const wxString& k); + + virtual bool Quit(); + virtual void OnQuit(); + + inline wxString GetHelpFile() const { return m_helpFile; } + protected: - wxString m_helpFile; + wxString m_helpFile; }; #endif - // _WX_HELPXXXX_H_ +// _WX_HELPXXXX_H_ diff --git a/include/wx/motif/icon.h b/include/wx/motif/icon.h index 8042fb8f06..4ddc46c336 100644 --- a/include/wx/motif/icon.h +++ b/include/wx/motif/icon.h @@ -18,52 +18,40 @@ #include "wx/bitmap.h" -/* -// Same as for wxBitmap -class WXDLLEXPORT wxIconRefData: public wxBitmapRefData -{ - friend class WXDLLEXPORT wxBitmap; - friend class WXDLLEXPORT wxIcon; -public: - wxIconRefData(); - ~wxIconRefData(); -}; -*/ - #define M_ICONDATA ((wxBitmapRefData *)m_refData) #define M_ICONHANDLERDATA ((wxBitmapRefData *)bitmap->GetRefData()) // Icon class WXDLLEXPORT wxIcon: public wxBitmap { - DECLARE_DYNAMIC_CLASS(wxIcon) - + DECLARE_DYNAMIC_CLASS(wxIcon) + public: - wxIcon(); - - // Copy constructors - inline wxIcon(const wxIcon& icon) { Ref(icon); } - - // Initialize with XBM data - 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_XPM, - int desiredWidth = -1, int desiredHeight = -1); - ~wxIcon(); - - bool LoadFile(const wxString& name, long flags = wxBITMAP_TYPE_XPM, - int desiredWidth = -1, int desiredHeight = -1); - - inline wxIcon& operator = (const wxIcon& icon) { if (*this == icon) return (*this); Ref(icon); return *this; } - inline bool operator == (const wxIcon& icon) const { return m_refData == icon.m_refData; } - inline bool operator != (const wxIcon& icon) const { return m_refData != icon.m_refData; } - - virtual bool Ok() const { return ((m_refData != NULL) && (M_ICONDATA->m_ok)); } + wxIcon(); + + // Copy constructors + inline wxIcon(const wxIcon& icon) { Ref(icon); } + + // Initialize with XBM data + 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_XPM, + int desiredWidth = -1, int desiredHeight = -1); + ~wxIcon(); + + bool LoadFile(const wxString& name, long flags = wxBITMAP_TYPE_XPM, + int desiredWidth = -1, int desiredHeight = -1); + + inline wxIcon& operator = (const wxIcon& icon) { if (*this == icon) return (*this); Ref(icon); return *this; } + inline bool operator == (const wxIcon& icon) const { return m_refData == icon.m_refData; } + inline bool operator != (const wxIcon& icon) const { return m_refData != icon.m_refData; } + + virtual bool Ok() const { return ((m_refData != NULL) && (M_ICONDATA->m_ok)); } }; #endif - // _WX_ICON_H_ +// _WX_ICON_H_ diff --git a/include/wx/motif/joystick.h b/include/wx/motif/joystick.h index cc544c4d93..7148fcd4c9 100644 --- a/include/wx/motif/joystick.h +++ b/include/wx/motif/joystick.h @@ -20,74 +20,74 @@ class WXDLLEXPORT wxJoystick: public wxObject { - DECLARE_DYNAMIC_CLASS(wxJoystick) - public: - /* - * Public interface - */ - - wxJoystick(int joystick = wxJOYSTICK1) { m_joystick = joystick; }; - - // Attributes - //////////////////////////////////////////////////////////////////////////// - - wxPoint GetPosition() const; - int GetZPosition() const; - int GetButtonState() const; - int GetPOVPosition() const; - int GetPOVCTSPosition() const; - int GetRudderPosition() const; - int GetUPosition() const; - int GetVPosition() const; - int GetMovementThreshold() const; - void SetMovementThreshold(int threshold) ; - - // Capabilities - //////////////////////////////////////////////////////////////////////////// - - bool IsOk() const; // Checks that the joystick is functioning - int GetNumberJoysticks() const ; - int GetManufacturerId() const ; - int GetProductId() const ; - wxString GetProductName() const ; - int GetXMin() const; - int GetYMin() const; - int GetZMin() const; - int GetXMax() const; - int GetYMax() const; - int GetZMax() const; - int GetNumberButtons() const; - int GetNumberAxes() const; - int GetMaxButtons() const; - int GetMaxAxes() const; - int GetPollingMin() const; - int GetPollingMax() const; - int GetRudderMin() const; - int GetRudderMax() const; - int GetUMin() const; - int GetUMax() const; - int GetVMin() const; - int GetVMax() const; - - bool HasRudder() const; - bool HasZ() const; - bool HasU() const; - bool HasV() const; - bool HasPOV() const; - bool HasPOV4Dir() const; - bool HasPOVCTS() const; - - // Operations - //////////////////////////////////////////////////////////////////////////// - - // pollingFreq = 0 means that movement events are sent when above the threshold. - // If pollingFreq > 0, events are received every this many milliseconds. - bool SetCapture(wxWindow* win, int pollingFreq = 0); - bool ReleaseCapture(); - + DECLARE_DYNAMIC_CLASS(wxJoystick) +public: +/* +* Public interface + */ + + wxJoystick(int joystick = wxJOYSTICK1) { m_joystick = joystick; }; + + // Attributes + //////////////////////////////////////////////////////////////////////////// + + wxPoint GetPosition() const; + int GetZPosition() const; + int GetButtonState() const; + int GetPOVPosition() const; + int GetPOVCTSPosition() const; + int GetRudderPosition() const; + int GetUPosition() const; + int GetVPosition() const; + int GetMovementThreshold() const; + void SetMovementThreshold(int threshold) ; + + // Capabilities + //////////////////////////////////////////////////////////////////////////// + + bool IsOk() const; // Checks that the joystick is functioning + int GetNumberJoysticks() const ; + int GetManufacturerId() const ; + int GetProductId() const ; + wxString GetProductName() const ; + int GetXMin() const; + int GetYMin() const; + int GetZMin() const; + int GetXMax() const; + int GetYMax() const; + int GetZMax() const; + int GetNumberButtons() const; + int GetNumberAxes() const; + int GetMaxButtons() const; + int GetMaxAxes() const; + int GetPollingMin() const; + int GetPollingMax() const; + int GetRudderMin() const; + int GetRudderMax() const; + int GetUMin() const; + int GetUMax() const; + int GetVMin() const; + int GetVMax() const; + + bool HasRudder() const; + bool HasZ() const; + bool HasU() const; + bool HasV() const; + bool HasPOV() const; + bool HasPOV4Dir() const; + bool HasPOVCTS() const; + + // Operations + //////////////////////////////////////////////////////////////////////////// + + // pollingFreq = 0 means that movement events are sent when above the threshold. + // If pollingFreq > 0, events are received every this many milliseconds. + bool SetCapture(wxWindow* win, int pollingFreq = 0); + bool ReleaseCapture(); + protected: - int m_joystick; + int m_joystick; }; #endif - // _WX_JOYSTICK_H_ +// _WX_JOYSTICK_H_ diff --git a/include/wx/motif/listbox.h b/include/wx/motif/listbox.h index 70715fd948..883a42b420 100644 --- a/include/wx/motif/listbox.h +++ b/include/wx/motif/listbox.h @@ -28,32 +28,32 @@ WXDLLEXPORT_DATA(extern const char*) wxEmptyString; // List box item class WXDLLEXPORT wxListBox: public wxListBoxBase { -DECLARE_DYNAMIC_CLASS(wxListBox) - + DECLARE_DYNAMIC_CLASS(wxListBox) + public: wxListBox(); wxListBox(wxWindow *parent, wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - int n = 0, const wxString choices[] = NULL, - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxListBoxNameStr): - m_clientDataList(wxKEY_INTEGER) - { - Create(parent, id, pos, size, n, choices, style, validator, name); - } - + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + int n = 0, const wxString choices[] = NULL, + long style = 0, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxListBoxNameStr): + m_clientDataList(wxKEY_INTEGER) + { + Create(parent, id, pos, size, n, choices, style, validator, name); + } + bool Create(wxWindow *parent, wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - int n = 0, const wxString choices[] = NULL, - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxListBoxNameStr); - + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + int n = 0, const wxString choices[] = NULL, + long style = 0, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxListBoxNameStr); + ~wxListBox(); - + // Virtual functions required by wxControlWithItems. // They are not all implemented yet :-( virtual int GetCount() const; @@ -66,16 +66,16 @@ public: virtual void DoSetItemClientObject(int n, wxClientData* clientData); virtual wxClientData* DoGetItemClientObject(int n) const; virtual void Select(int n); - + virtual void Append(const wxString& item); virtual void Append(const wxString& item, void *clientData); virtual void Set(int n, const wxString* choices, void **clientData = NULL); virtual int FindString(const wxString& s) const ; virtual void Clear(); virtual void SetSelection(int n, bool select = TRUE); - + virtual void Deselect(int n); - + // For single choice list item only virtual int GetSelection() const ; virtual void Delete(int n); @@ -84,42 +84,42 @@ public: virtual void SetClientData(int n, void *clientData); virtual void SetClientData( void *data ) { wxWindow::SetClientData(data); } virtual void SetString(int n, const wxString& s); - + // For single or multiple choice list item virtual int GetSelections(wxArrayInt& aSelections) const; virtual bool IsSelected(int n) const ; virtual wxString GetString(int n) const ; - + // Set the specified item at the first visible item // or scroll to max range. virtual void SetFirstItem(int n) ; virtual void SetFirstItem(const wxString& s) ; - + virtual void InsertItems(int nItems, const wxString items[], int pos); - + virtual wxString GetStringSelection() const ; virtual bool SetStringSelection(const wxString& s, bool flag = TRUE); virtual int Number() const ; - + void Command(wxCommandEvent& event); - + // Implementation virtual void ChangeFont(bool keepOriginalSize = TRUE); virtual void ChangeBackgroundColour(); virtual void ChangeForegroundColour(); WXWidget GetTopWidget() const; - + protected: int m_noItems; int m_selected; - + // List mapping positions->client data wxList m_clientDataList; - + virtual void DoSetSize(int x, int y, - int width, int height, - int sizeFlags = wxSIZE_AUTO); + int width, int height, + int sizeFlags = wxSIZE_AUTO); }; #endif - // _WX_LISTBOX_H_ +// _WX_LISTBOX_H_ diff --git a/include/wx/motif/mdi.h b/include/wx/motif/mdi.h index 62d6efb7d7..50bcf4f5d1 100644 --- a/include/wx/motif/mdi.h +++ b/include/wx/motif/mdi.h @@ -35,131 +35,131 @@ class WXDLLEXPORT wxMDIChildFrame; class WXDLLEXPORT wxMDIParentFrame: public wxFrame { -DECLARE_DYNAMIC_CLASS(wxMDIParentFrame) - - friend class WXDLLEXPORT wxMDIChildFrame; + DECLARE_DYNAMIC_CLASS(wxMDIParentFrame) + + friend class WXDLLEXPORT wxMDIChildFrame; public: - - wxMDIParentFrame(); - inline wxMDIParentFrame(wxWindow *parent, - wxWindowID id, - const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL, // Scrolling refers to client window - const wxString& name = wxFrameNameStr) - { - Create(parent, id, title, pos, size, style, name); - } - - ~wxMDIParentFrame(); - - bool Create(wxWindow *parent, - wxWindowID id, - const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL, - const wxString& name = wxFrameNameStr); - - void OnSize(wxSizeEvent& event); - void OnActivate(wxActivateEvent& event); - void OnSysColourChanged(wxSysColourChangedEvent& event); - void OnMenuHighlight(wxMenuEvent& event); - - void SetMenuBar(wxMenuBar *menu_bar); - - // Get the active MDI child window - wxMDIChildFrame *GetActiveChild() const ; - - // Get the client window - wxMDIClientWindow *GetClientWindow() const { return m_clientWindow; }; - - // Create the client window class (don't Create the window, - // just return a new class) - virtual wxMDIClientWindow *OnCreateClient() ; - - // MDI operations - virtual void Cascade(); - virtual void Tile(); - virtual void ArrangeIcons(); - virtual void ActivateNext(); - virtual void ActivatePrevious(); - -// Implementation - - // Set the active child - inline void SetActiveChild(wxMDIChildFrame* child) { m_activeChild = child; } - - // Set the child's menubar into the parent frame - void SetChildMenuBar(wxMDIChildFrame* frame); - - inline wxMenuBar* GetActiveMenuBar() const { return m_activeMenuBar; } - - // Redirect events to active child first - virtual bool ProcessEvent(wxEvent& event); - + + wxMDIParentFrame(); + inline wxMDIParentFrame(wxWindow *parent, + wxWindowID id, + const wxString& title, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL, // Scrolling refers to client window + const wxString& name = wxFrameNameStr) + { + Create(parent, id, title, pos, size, style, name); + } + + ~wxMDIParentFrame(); + + bool Create(wxWindow *parent, + wxWindowID id, + const wxString& title, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL, + const wxString& name = wxFrameNameStr); + + void OnSize(wxSizeEvent& event); + void OnActivate(wxActivateEvent& event); + void OnSysColourChanged(wxSysColourChangedEvent& event); + void OnMenuHighlight(wxMenuEvent& event); + + void SetMenuBar(wxMenuBar *menu_bar); + + // Get the active MDI child window + wxMDIChildFrame *GetActiveChild() const ; + + // Get the client window + wxMDIClientWindow *GetClientWindow() const { return m_clientWindow; }; + + // Create the client window class (don't Create the window, + // just return a new class) + virtual wxMDIClientWindow *OnCreateClient() ; + + // MDI operations + virtual void Cascade(); + virtual void Tile(); + virtual void ArrangeIcons(); + virtual void ActivateNext(); + virtual void ActivatePrevious(); + + // Implementation + + // Set the active child + inline void SetActiveChild(wxMDIChildFrame* child) { m_activeChild = child; } + + // Set the child's menubar into the parent frame + void SetChildMenuBar(wxMDIChildFrame* frame); + + inline wxMenuBar* GetActiveMenuBar() const { return m_activeMenuBar; } + + // Redirect events to active child first + virtual bool ProcessEvent(wxEvent& event); + protected: - virtual void DoSetSize(int x, int y, - int width, int height, - int sizeFlags = wxSIZE_AUTO); - virtual void DoSetClientSize(int width, int height); - - // Gets the size available for subwindows after menu size, toolbar size - // and status bar size have been subtracted. If you want to manage your own - // toolbar(s), don't call SetToolBar. - void DoGetClientSize(int *width, int *height) const; - + virtual void DoSetSize(int x, int y, + int width, int height, + int sizeFlags = wxSIZE_AUTO); + virtual void DoSetClientSize(int width, int height); + + // Gets the size available for subwindows after menu size, toolbar size + // and status bar size have been subtracted. If you want to manage your own + // toolbar(s), don't call SetToolBar. + void DoGetClientSize(int *width, int *height) const; + protected: - - wxMDIClientWindow* m_clientWindow; - wxMDIChildFrame* m_activeChild; - wxMenuBar* m_activeMenuBar; - -DECLARE_EVENT_TABLE() + + wxMDIClientWindow* m_clientWindow; + wxMDIChildFrame* m_activeChild; + wxMenuBar* m_activeMenuBar; + + DECLARE_EVENT_TABLE() }; class WXDLLEXPORT wxMDIChildFrame: public wxFrame { -DECLARE_DYNAMIC_CLASS(wxMDIChildFrame) - + DECLARE_DYNAMIC_CLASS(wxMDIChildFrame) + public: wxMDIChildFrame(); wxMDIChildFrame(wxMDIParentFrame *parent, - wxWindowID id, - const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE, - const wxString& name = wxFrameNameStr) + wxWindowID id, + const wxString& title, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_FRAME_STYLE, + const wxString& name = wxFrameNameStr) { Create(parent, id, title, pos, size, style, name); } - + ~wxMDIChildFrame(); - + bool Create(wxMDIParentFrame *parent, - wxWindowID id, - const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE, - const wxString& name = wxFrameNameStr); - + wxWindowID id, + const wxString& title, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_FRAME_STYLE, + const wxString& name = wxFrameNameStr); + // Set menu bar void SetMenuBar(wxMenuBar *menu_bar); void SetTitle(const wxString& title); - + // Set icon virtual void SetIcon(const wxIcon& icon); - + // Override wxFrame operations void CaptureMouse(); void ReleaseMouse(); void Raise(); void Lower(void); void SetSizeHints(int minW = -1, int minH = -1, int maxW = -1, int maxH = -1, int incW = -1, int incH = -1); - + // MDI operations virtual void Maximize(); virtual void Maximize(bool WXUNUSED(maximize)) { }; @@ -168,83 +168,83 @@ public: virtual void Restore(); virtual void Activate(); virtual bool IsIconized() const ; - + virtual bool IsTopLevel() const { return FALSE; } // Is the frame maximized? Returns TRUE for // wxMDIChildFrame due to the tabbed implementation. virtual bool IsMaximized(void) const ; - + bool Show(bool show); - + WXWidget GetMainWidget() const { return m_mainWidget; }; WXWidget GetTopWidget() const { return m_mainWidget; }; WXWidget GetClientWidget() const { return m_mainWidget; }; - + /* - virtual void OnRaise(); - virtual void OnLower(); - */ - + virtual void OnRaise(); + virtual void OnLower(); + */ + void SetMDIParentFrame(wxMDIParentFrame* parentFrame) { m_mdiParentFrame = parentFrame; } wxMDIParentFrame* GetMDIParentFrame() const { return m_mdiParentFrame; } - + protected: wxMDIParentFrame* m_mdiParentFrame; - + virtual void DoSetSize(int x, int y, - int width, int height, - int sizeFlags = wxSIZE_AUTO); + int width, int height, + int sizeFlags = wxSIZE_AUTO); virtual void DoSetClientSize(int width, int height); - + void DoGetClientSize(int *width, int *height) const; void DoGetSize(int *width, int *height) const; void DoGetPosition(int *x, int *y) const ; }; /* The client window is a child of the parent MDI frame, and itself - * contains the child MDI frames. - * However, you create the MDI children as children of the MDI parent: - * only in the implementation does the client window become the parent - * of the children. Phew! So the children are sort of 'adopted'... - */ +* contains the child MDI frames. +* However, you create the MDI children as children of the MDI parent: +* only in the implementation does the client window become the parent +* of the children. Phew! So the children are sort of 'adopted'... +*/ class WXDLLEXPORT wxMDIClientWindow: public wxNotebook { -DECLARE_DYNAMIC_CLASS(wxMDIClientWindow) - + DECLARE_DYNAMIC_CLASS(wxMDIClientWindow) + public: wxMDIClientWindow() ; wxMDIClientWindow(wxMDIParentFrame *parent, long style = 0) { CreateClient(parent, style); } - + ~wxMDIClientWindow(); - + // Note: this is virtual, to allow overridden behaviour. virtual bool CreateClient(wxMDIParentFrame *parent, long style = wxVSCROLL | wxHSCROLL); - + // Explicitly call default scroll behaviour void OnScroll(wxScrollEvent& event); - + // Implementation void OnPageChanged(wxNotebookEvent& event); - + protected: virtual void DoSetSize(int x, int y, - int width, int height, - int sizeFlags = wxSIZE_AUTO); + int width, int height, + int sizeFlags = wxSIZE_AUTO); virtual void DoSetClientSize(int width, int height); - + void DoGetClientSize(int *width, int *height) const; void DoGetSize(int *width, int *height) const ; void DoGetPosition(int *x, int *y) const ; - - + + private: DECLARE_EVENT_TABLE() }; #endif - // _WX_MDI_H_ +// _WX_MDI_H_ diff --git a/include/wx/motif/menu.h b/include/wx/motif/menu.h index c50ae78653..50af6f3781 100644 --- a/include/wx/motif/menu.h +++ b/include/wx/motif/menu.h @@ -13,7 +13,7 @@ #define _WX_MOTIF_MENU_H_ #ifdef __GNUG__ - #pragma interface "menu.h" +#pragma interface "menu.h" #endif #include "wx/colour.h" @@ -31,69 +31,69 @@ public: // ctors & dtor wxMenu(const wxString& title, long style = 0) : wxMenuBase(title, style) { Init(); } - + wxMenu(long style = 0) : wxMenuBase(style) { Init(); } - + virtual ~wxMenu(); - + // implement base class virtuals virtual bool DoAppend(wxMenuItem *item); virtual bool DoInsert(size_t pos, wxMenuItem *item); virtual wxMenuItem *DoRemove(wxMenuItem *item); - + virtual void Break(); - + virtual void SetTitle(const wxString& title); - + bool ProcessCommand(wxCommandEvent& event); - + wxMenu(const wxString& title, const wxFunction func) : wxMenuBase(title) { Init(); - + Callback(func); } - + //// Motif-specific WXWidget GetButtonWidget() const { return m_buttonWidget; } void SetButtonWidget(WXWidget buttonWidget) { m_buttonWidget = buttonWidget; } - + WXWidget GetMainWidget() const { return m_menuWidget; } - + int GetId() const { return m_menuId; } void SetId(int id) { m_menuId = id; } - + void SetMenuBar(wxMenuBar* menuBar) { m_menuBar = menuBar; } wxMenuBar* GetMenuBar() const { return m_menuBar; } - + void CreatePopup(WXWidget logicalParent, int x, int y); void DestroyPopup(); void ShowPopup(int x, int y); void HidePopup(); - + WXWidget CreateMenu(wxMenuBar *menuBar, WXWidget parent, wxMenu *topMenu, - const wxString& title = wxEmptyString, - bool isPulldown = FALSE); - + const wxString& title = wxEmptyString, + bool isPulldown = FALSE); + // For popups, need to destroy, then recreate menu for a different (or // possibly same) window, since the parent may change. void DestroyMenu(bool full); WXWidget FindMenuItem(int id, wxMenuItem **it = NULL) const; - + const wxColour& GetBackgroundColour() const { return m_backgroundColour; } const wxColour& GetForegroundColour() const { return m_foregroundColour; } const wxFont& GetFont() const { return m_font; } - + void SetBackgroundColour(const wxColour& colour); void SetForegroundColour(const wxColour& colour); void SetFont(const wxFont& colour); void ChangeFont(bool keepOriginalSize = FALSE); - + WXWidget GetHandle() const { return m_menuWidget; } - + bool IsTearOff() const { return (m_style & wxMENU_TEAROFF) != 0; } - + public: // Motif-specific data int m_numColumns; @@ -106,11 +106,11 @@ public: wxColour m_foregroundColour; wxColour m_backgroundColour; wxFont m_font; - + private: // common code for both constructors: void Init(); - + DECLARE_DYNAMIC_CLASS(wxMenu) }; @@ -125,59 +125,59 @@ public: wxMenuBar(long WXUNUSED(style)) { Init(); } wxMenuBar(int n, wxMenu *menus[], const wxString titles[]); virtual ~wxMenuBar(); - + // implement base class (pure) virtuals // ------------------------------------ - + virtual bool Append( wxMenu *menu, const wxString &title ); virtual bool Insert(size_t pos, wxMenu *menu, const wxString& title); virtual wxMenu *Replace(size_t pos, wxMenu *menu, const wxString& title); virtual wxMenu *Remove(size_t pos); - + virtual int FindMenuItem(const wxString& menuString, - const wxString& itemString) const; + const wxString& itemString) const; virtual wxMenuItem* FindItem( int id, wxMenu **menu = NULL ) const; - + virtual void EnableTop( size_t pos, bool flag ); virtual void SetLabelTop( size_t pos, const wxString& label ); virtual wxString GetLabelTop( size_t pos ) const; - + // implementation only from now on // ------------------------------- - + wxFrame* GetMenuBarFrame() const { return m_menuBarFrame; } void SetMenuBarFrame(wxFrame* frame) { m_menuBarFrame = frame; } WXWidget GetMainWidget() const { return m_mainWidget; } void SetMainWidget(WXWidget widget) { m_mainWidget = widget; } - + // Create menubar bool CreateMenuBar(wxFrame* frame); - + // Destroy menubar, but keep data structures intact so we can recreate it. bool DestroyMenuBar(); - + const wxColour& GetBackgroundColour() const { return m_backgroundColour; } const wxColour& GetForegroundColour() const { return m_foregroundColour; } const wxFont& GetFont() const { return m_font; } - + virtual bool SetBackgroundColour(const wxColour& colour); virtual bool SetForegroundColour(const wxColour& colour); virtual bool SetFont(const wxFont& colour); void ChangeFont(bool keepOriginalSize = FALSE); - + public: // common part of all ctors void Init(); - + wxArrayString m_titles; wxFrame *m_menuBarFrame; - + WXWidget m_mainWidget; - + wxColour m_foregroundColour; wxColour m_backgroundColour; wxFont m_font; - + DECLARE_DYNAMIC_CLASS(wxMenuBar) }; diff --git a/include/wx/motif/menuitem.h b/include/wx/motif/menuitem.h index dc69814736..f6580cdad0 100644 --- a/include/wx/motif/menuitem.h +++ b/include/wx/motif/menuitem.h @@ -13,7 +13,7 @@ #define _WX_MOTIF_MENUITEM_H #ifdef __GNUG__ - #pragma interface "menuitem.h" +#pragma interface "menuitem.h" #endif #include "wx/bitmap.h" @@ -29,44 +29,44 @@ class wxMenuItem : public wxMenuItemBase public: // ctor & dtor wxMenuItem(wxMenu *parentMenu = (wxMenu *)NULL, - int id = wxID_SEPARATOR, - const wxString& text = wxEmptyString, - const wxString& help = wxEmptyString, - bool isCheckable = FALSE, - wxMenu *subMenu = (wxMenu *)NULL); + int id = wxID_SEPARATOR, + const wxString& text = wxEmptyString, + const wxString& help = wxEmptyString, + bool isCheckable = FALSE, + wxMenu *subMenu = (wxMenu *)NULL); ~wxMenuItem(); - + // accessors (some more are inherited from wxOwnerDrawn or are below) virtual void SetText(const wxString& label); virtual void Enable(bool enable = TRUE); virtual void Check(bool check = TRUE); - // included SetBitmap and GetBitmap as copied from the GTK include file - // I'm not sure if this works but it silences the linker in the - // menu sample. - // JJ + // included SetBitmap and GetBitmap as copied from the GTK include file + // I'm not sure if this works but it silences the linker in the + // menu sample. + // JJ virtual void SetBitmap(const wxBitmap& bitmap) { m_bitmap = bitmap; } virtual const wxBitmap& GetBitmap() const { return m_bitmap; } - + void DeleteSubMenu(); - + // implementation from now on void CreateItem (WXWidget menu, wxMenuBar * menuBar, wxMenu * topMenu); void DestroyItem(bool full); - + WXWidget GetButtonWidget() const { return m_buttonWidget; } - + wxMenuBar* GetMenuBar() const { return m_menuBar; } void SetMenuBar(wxMenuBar* menuBar) { m_menuBar = menuBar; } - + wxMenu* GetTopMenu() const { return m_topMenu; } void SetTopMenu(wxMenu* menu) { m_topMenu = menu; } - + private: WXWidget m_buttonWidget; wxMenuBar* m_menuBar; wxMenu* m_topMenu; // Top-level menu e.g. popup-menu wxBitmap m_bitmap; // Bitmap for menuitem, if any - + DECLARE_DYNAMIC_CLASS(wxMenuItem) }; diff --git a/include/wx/motif/metafile.h b/include/wx/motif/metafile.h index b6f823b860..058d34d2ad 100644 --- a/include/wx/motif/metafile.h +++ b/include/wx/motif/metafile.h @@ -11,7 +11,6 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// - #ifndef _WX_METAFIILE_H_ #define _WX_METAFIILE_H_ @@ -22,74 +21,67 @@ #include "wx/setup.h" /* - * Metafile and metafile device context classes - work in Windows 3.1 only - * - */ +* Metafile and metafile device context classes - work in Windows 3.1 only +* +*/ class WXDLLEXPORT wxDC; class WXDLLEXPORT wxMetaFile: public wxObject { - DECLARE_DYNAMIC_CLASS(wxMetaFile) - public: - wxMetaFile(const wxString& file = ""); - ~wxMetaFile(); - - // After this is called, the metafile cannot be used for anything - // since it is now owned by the clipboard. - virtual bool SetClipboard(int width = 0, int height = 0); - - virtual bool Play(wxDC *dc); - // TODO - inline bool Ok() { return FALSE; }; - -/* TODO: Implementation - inline WXHANDLE GetHMETAFILE() { return m_metaFile; } - inline void SetHMETAFILE(WXHANDLE mf) { m_metaFile = mf; } - -protected: - WXHANDLE m_metaFile; -*/ + DECLARE_DYNAMIC_CLASS(wxMetaFile) +public: + wxMetaFile(const wxString& file = ""); + ~wxMetaFile(); + + // After this is called, the metafile cannot be used for anything + // since it is now owned by the clipboard. + virtual bool SetClipboard(int width = 0, int height = 0); + + virtual bool Play(wxDC *dc); + // TODO + inline bool Ok() { return FALSE; }; + }; class WXDLLEXPORT wxMetaFileDC: public wxDC { - DECLARE_DYNAMIC_CLASS(wxMetaFileDC) - - public: - // Don't supply origin and extent - // Supply them to wxMakeMetaFilePlaceable instead. - wxMetaFileDC(const wxString& file = ""); - - // Supply origin and extent (recommended). - // Then don't need to supply them to wxMakeMetaFilePlaceable. - wxMetaFileDC(const wxString& file, int xext, int yext, int xorg, int yorg); - - ~wxMetaFileDC(); - - // Should be called at end of drawing - virtual wxMetaFile *Close(); - virtual void SetMapMode(int mode); - virtual void GetTextExtent(const wxString& string, float *x, float *y, - float *descent = NULL, float *externalLeading = NULL, - wxFont *theFont = NULL, bool use16bit = FALSE); - - // Implementation - inline wxMetaFile *GetMetaFile() { return m_metaFile; } - inline void SetMetaFile(wxMetaFile *mf) { m_metaFile = mf; } - inline int GetWindowsMappingMode() { return m_windowsMappingMode; } - inline void SetWindowsMappingMode(int mm) { m_windowsMappingMode = mm; } - + DECLARE_DYNAMIC_CLASS(wxMetaFileDC) + +public: + // Don't supply origin and extent + // Supply them to wxMakeMetaFilePlaceable instead. + wxMetaFileDC(const wxString& file = ""); + + // Supply origin and extent (recommended). + // Then don't need to supply them to wxMakeMetaFilePlaceable. + wxMetaFileDC(const wxString& file, int xext, int yext, int xorg, int yorg); + + ~wxMetaFileDC(); + + // Should be called at end of drawing + virtual wxMetaFile *Close(); + virtual void SetMapMode(int mode); + virtual void GetTextExtent(const wxString& string, float *x, float *y, + float *descent = NULL, float *externalLeading = NULL, + wxFont *theFont = NULL, bool use16bit = FALSE); + + // Implementation + inline wxMetaFile *GetMetaFile() { return m_metaFile; } + inline void SetMetaFile(wxMetaFile *mf) { m_metaFile = mf; } + inline int GetWindowsMappingMode() { return m_windowsMappingMode; } + inline void SetWindowsMappingMode(int mm) { m_windowsMappingMode = mm; } + protected: - int m_windowsMappingMode; - wxMetaFile *m_metaFile; + int m_windowsMappingMode; + wxMetaFile *m_metaFile; }; /* - * Pass filename of existing non-placeable metafile, and bounding box. - * Adds a placeable metafile header, sets the mapping mode to anisotropic, - * and sets the window origin and extent to mimic the wxMM_TEXT mapping mode. - * - */ +* Pass filename of existing non-placeable metafile, and bounding box. +* Adds a placeable metafile header, sets the mapping mode to anisotropic, +* and sets the window origin and extent to mimic the wxMM_TEXT mapping mode. +* +*/ // No origin or extent bool WXDLLEXPORT wxMakeMetaFilePlaceable(const wxString& filename, float scale = 1.0); @@ -98,4 +90,4 @@ bool WXDLLEXPORT wxMakeMetaFilePlaceable(const wxString& filename, float scale = bool WXDLLEXPORT wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, int y2, float scale = 1.0, bool useOriginAndExtent = TRUE); #endif - // _WX_METAFIILE_H_ +// _WX_METAFIILE_H_ diff --git a/include/wx/motif/minifram.h b/include/wx/motif/minifram.h index 07d9fff441..cbe4f63269 100644 --- a/include/wx/motif/minifram.h +++ b/include/wx/motif/minifram.h @@ -21,26 +21,26 @@ #include "wx/frame.h" class WXDLLEXPORT wxMiniFrame: public wxFrame { - - DECLARE_DYNAMIC_CLASS(wxMiniFrame) - + + DECLARE_DYNAMIC_CLASS(wxMiniFrame) + public: - inline wxMiniFrame() {} - inline wxMiniFrame(wxWindow *parent, - wxWindowID id, - const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE|wxTINY_CAPTION_HORIZ, - const wxString& name = wxFrameNameStr) - { - // Use wxFrame constructor in absence of more specific code. - Create(parent, id, title, pos, size, style, name); - } - - ~wxMiniFrame() {} + inline wxMiniFrame() {} + inline wxMiniFrame(wxWindow *parent, + wxWindowID id, + const wxString& title, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_FRAME_STYLE|wxTINY_CAPTION_HORIZ, + const wxString& name = wxFrameNameStr) + { + // Use wxFrame constructor in absence of more specific code. + Create(parent, id, title, pos, size, style, name); + } + + ~wxMiniFrame() {} protected: }; #endif - // _WX_MINIFRAM_H_ +// _WX_MINIFRAM_H_ diff --git a/include/wx/motif/msgdlg.h b/include/wx/motif/msgdlg.h index dfb16cbf2f..cc4d9e9a3f 100644 --- a/include/wx/motif/msgdlg.h +++ b/include/wx/motif/msgdlg.h @@ -29,20 +29,20 @@ WXDLLEXPORT_DATA(extern const char*) wxMessageBoxCaptionStr; class WXDLLEXPORT wxMessageDialog: public wxDialog { DECLARE_DYNAMIC_CLASS(wxMessageDialog) - + public: wxMessageDialog(wxWindow *parent, - const wxString& message, - const wxString& caption = wxMessageBoxCaptionStr, - long style = wxOK | wxCENTRE, - const wxPoint& pos = wxDefaultPosition); - + const wxString& message, + const wxString& caption = wxMessageBoxCaptionStr, + long style = wxOK | wxCENTRE, + const wxPoint& pos = wxDefaultPosition); + int ShowModal(); - + // implementation only from now on - // called by the Motif callback + // called by the Motif callback void SetResult(long result) { m_result = result; } - + protected: wxString m_caption; wxString m_message; @@ -52,4 +52,4 @@ protected: }; #endif - // _WX_MSGBOXDLG_H_ +// _WX_MSGBOXDLG_H_ diff --git a/include/wx/motif/palette.h b/include/wx/motif/palette.h index b40831a894..c34767f8ce 100644 --- a/include/wx/motif/palette.h +++ b/include/wx/motif/palette.h @@ -24,11 +24,11 @@ class WXDLLEXPORT wxPalette; // Palette for one display class wxXPalette : public wxObject { -DECLARE_DYNAMIC_CLASS(wxXPalette) - + DECLARE_DYNAMIC_CLASS(wxXPalette) + public: wxXPalette(); - + WXDisplay* m_display; int m_pix_array_n; unsigned long* m_pix_array; @@ -42,7 +42,7 @@ class WXDLLEXPORT wxPaletteRefData: public wxGDIRefData public: wxPaletteRefData(); ~wxPaletteRefData(); - + protected: wxList m_palettes; }; @@ -51,31 +51,31 @@ protected: class WXDLLEXPORT wxPalette: public wxGDIObject { - DECLARE_DYNAMIC_CLASS(wxPalette) - + DECLARE_DYNAMIC_CLASS(wxPalette) + public: - wxPalette(); - wxPalette(const wxPalette& palette) { Ref(palette); } - - wxPalette(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue); - ~wxPalette(); - bool Create(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue); - int GetPixel(const unsigned char red, const unsigned char green, const unsigned char blue) const; - bool GetRGB(int pixel, unsigned char *red, unsigned char *green, unsigned char *blue) const; - - virtual bool Ok() const { return (m_refData != NULL) ; } - - wxPalette& operator = (const wxPalette& palette) { if (*this == palette) return (*this); Ref(palette); return *this; } - bool operator == (const wxPalette& palette) const { return m_refData == palette.m_refData; } - bool operator != (const wxPalette& palette) const { return m_refData != palette.m_refData; } - - // Motif-specific - WXColormap GetXColormap(WXDisplay* display = NULL) const; - bool TransferBitmap(void *data, int depth, int size); - bool TransferBitmap8(unsigned char *data, unsigned long size, void *dest, unsigned int bpp); - unsigned long *GetXPixArray(WXDisplay* display, int *pix_array_n); - void PutXColormap(WXDisplay* display, WXColormap cmap, bool destroyable); + wxPalette(); + wxPalette(const wxPalette& palette) { Ref(palette); } + + wxPalette(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue); + ~wxPalette(); + bool Create(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue); + int GetPixel(const unsigned char red, const unsigned char green, const unsigned char blue) const; + bool GetRGB(int pixel, unsigned char *red, unsigned char *green, unsigned char *blue) const; + + virtual bool Ok() const { return (m_refData != NULL) ; } + + wxPalette& operator = (const wxPalette& palette) { if (*this == palette) return (*this); Ref(palette); return *this; } + bool operator == (const wxPalette& palette) const { return m_refData == palette.m_refData; } + bool operator != (const wxPalette& palette) const { return m_refData != palette.m_refData; } + + // Motif-specific + WXColormap GetXColormap(WXDisplay* display = NULL) const; + bool TransferBitmap(void *data, int depth, int size); + bool TransferBitmap8(unsigned char *data, unsigned long size, void *dest, unsigned int bpp); + unsigned long *GetXPixArray(WXDisplay* display, int *pix_array_n); + void PutXColormap(WXDisplay* display, WXColormap cmap, bool destroyable); }; #endif - // _WX_PALETTE_H_ +// _WX_PALETTE_H_ diff --git a/include/wx/motif/pen.h b/include/wx/motif/pen.h index b0a30769e1..35247eb99c 100644 --- a/include/wx/motif/pen.h +++ b/include/wx/motif/pen.h @@ -31,16 +31,16 @@ public: wxPenRefData(); wxPenRefData(const wxPenRefData& data); ~wxPenRefData(); - + protected: - int m_width; - int m_style; - int m_join ; - int m_cap ; - wxBitmap m_stipple ; - int m_nbDash ; - wxMOTIFDash *m_dash ; - wxColour m_colour; + int m_width; + int m_style; + int m_join ; + int m_cap ; + wxBitmap m_stipple ; + int m_nbDash ; + wxMOTIFDash *m_dash ; + wxColour m_colour; }; #define M_PENDATA ((wxPenRefData *)m_refData) @@ -48,55 +48,55 @@ protected: // Pen class WXDLLEXPORT wxPen: public wxGDIObject { - DECLARE_DYNAMIC_CLASS(wxPen) + DECLARE_DYNAMIC_CLASS(wxPen) public: - wxPen(); - wxPen(const wxColour& col, int width, int style); - wxPen(const wxBitmap& stipple, int width); - inline wxPen(const wxPen& pen) { Ref(pen); } - ~wxPen(); - - inline wxPen& operator = (const wxPen& pen) { if (*this == pen) return (*this); Ref(pen); return *this; } - inline bool operator == (const wxPen& pen) const { return m_refData == pen.m_refData; } - inline bool operator != (const wxPen& pen) const { return m_refData != pen.m_refData; } - - virtual bool Ok() const { return (m_refData != NULL) ; } - - // Override in order to recreate the pen - void SetColour(const wxColour& col) ; - void SetColour(unsigned char r, unsigned char g, unsigned char b) ; - - void SetWidth(int width) ; - void SetStyle(int style) ; - void SetStipple(const wxBitmap& stipple) ; - void SetDashes(int nb_dashes, const wxDash *dash) ; - void SetJoin(int join) ; - void SetCap(int cap) ; - - inline wxColour& GetColour() const { return (M_PENDATA ? M_PENDATA->m_colour : wxNullColour); }; - inline int GetWidth() const { return (M_PENDATA ? M_PENDATA->m_width : 0); }; - inline int GetStyle() const { return (M_PENDATA ? M_PENDATA->m_style : 0); }; - inline int GetJoin() const { return (M_PENDATA ? M_PENDATA->m_join : 0); }; - inline int GetCap() const { return (M_PENDATA ? M_PENDATA->m_cap : 0); }; - inline int GetDashes(wxDash **ptr) const - { - *ptr = (M_PENDATA ? (wxDash*)M_PENDATA->m_dash : (wxDash*) NULL); - return (M_PENDATA ? M_PENDATA->m_nbDash : 0); - } - inline int GetDashCount() const { return (M_PENDATA->m_nbDash); } - inline wxDash* GetDash() const { return (wxDash*)M_PENDATA->m_dash; } - - inline wxBitmap *GetStipple() const { return (M_PENDATA ? (& M_PENDATA->m_stipple) : (wxBitmap*) NULL); }; - -// Implementation - - // Useful helper: create the brush resource - bool RealizeResource(); - - // When setting properties, we must make sure we're not changing - // another object - void Unshare(); + wxPen(); + wxPen(const wxColour& col, int width, int style); + wxPen(const wxBitmap& stipple, int width); + inline wxPen(const wxPen& pen) { Ref(pen); } + ~wxPen(); + + inline wxPen& operator = (const wxPen& pen) { if (*this == pen) return (*this); Ref(pen); return *this; } + inline bool operator == (const wxPen& pen) const { return m_refData == pen.m_refData; } + inline bool operator != (const wxPen& pen) const { return m_refData != pen.m_refData; } + + virtual bool Ok() const { return (m_refData != NULL) ; } + + // Override in order to recreate the pen + void SetColour(const wxColour& col) ; + void SetColour(unsigned char r, unsigned char g, unsigned char b) ; + + void SetWidth(int width) ; + void SetStyle(int style) ; + void SetStipple(const wxBitmap& stipple) ; + void SetDashes(int nb_dashes, const wxDash *dash) ; + void SetJoin(int join) ; + void SetCap(int cap) ; + + inline wxColour& GetColour() const { return (M_PENDATA ? M_PENDATA->m_colour : wxNullColour); }; + inline int GetWidth() const { return (M_PENDATA ? M_PENDATA->m_width : 0); }; + inline int GetStyle() const { return (M_PENDATA ? M_PENDATA->m_style : 0); }; + inline int GetJoin() const { return (M_PENDATA ? M_PENDATA->m_join : 0); }; + inline int GetCap() const { return (M_PENDATA ? M_PENDATA->m_cap : 0); }; + inline int GetDashes(wxDash **ptr) const + { + *ptr = (M_PENDATA ? (wxDash*)M_PENDATA->m_dash : (wxDash*) NULL); + return (M_PENDATA ? M_PENDATA->m_nbDash : 0); + } + inline int GetDashCount() const { return (M_PENDATA->m_nbDash); } + inline wxDash* GetDash() const { return (wxDash*)M_PENDATA->m_dash; } + + inline wxBitmap *GetStipple() const { return (M_PENDATA ? (& M_PENDATA->m_stipple) : (wxBitmap*) NULL); }; + + // Implementation + + // Useful helper: create the brush resource + bool RealizeResource(); + + // When setting properties, we must make sure we're not changing + // another object + void Unshare(); }; #endif - // _WX_PEN_H_ +// _WX_PEN_H_ diff --git a/include/wx/motif/print.h b/include/wx/motif/print.h index 3f4b4a6b7d..0576e30923 100644 --- a/include/wx/motif/print.h +++ b/include/wx/motif/print.h @@ -19,38 +19,38 @@ #include "wx/prntbase.h" /* - * Represents the printer: manages printing a wxPrintout object - */ - +* Represents the printer: manages printing a wxPrintout object +*/ + class WXDLLEXPORT wxPrinter: public wxPrinterBase { - DECLARE_DYNAMIC_CLASS(wxPrinter) - - public: - wxPrinter(wxPrintData *data = NULL); - ~wxPrinter(); - - virtual bool Print(wxWindow *parent, wxPrintout *printout, bool prompt = TRUE); - virtual bool PrintDialog(wxWindow *parent); - virtual bool Setup(wxWindow *parent); + DECLARE_DYNAMIC_CLASS(wxPrinter) + +public: + wxPrinter(wxPrintData *data = NULL); + ~wxPrinter(); + + virtual bool Print(wxWindow *parent, wxPrintout *printout, bool prompt = TRUE); + virtual bool PrintDialog(wxWindow *parent); + virtual bool Setup(wxWindow *parent); }; /* - * wxPrintPreview - * Programmer creates an object of this class to preview a wxPrintout. - */ - +* wxPrintPreview +* Programmer creates an object of this class to preview a wxPrintout. +*/ + class WXDLLEXPORT wxPrintPreview: public wxPrintPreviewBase { - DECLARE_CLASS(wxPrintPreview) - - public: - wxPrintPreview(wxPrintout *printout, wxPrintout *printoutForPrinting = NULL, wxPrintData *data = NULL); - ~wxPrintPreview(); - - virtual bool Print(bool interactive); - virtual void DetermineScaling(); + DECLARE_CLASS(wxPrintPreview) + +public: + wxPrintPreview(wxPrintout *printout, wxPrintout *printoutForPrinting = NULL, wxPrintData *data = NULL); + ~wxPrintPreview(); + + virtual bool Print(bool interactive); + virtual void DetermineScaling(); }; #endif - // _WX_PRINT_H_ +// _WX_PRINT_H_ diff --git a/include/wx/motif/printdlg.h b/include/wx/motif/printdlg.h index 81d630d5b2..3a97021ce7 100644 --- a/include/wx/motif/printdlg.h +++ b/include/wx/motif/printdlg.h @@ -22,49 +22,49 @@ #include "wx/cmndata.h" /* - * wxPrinterDialog - * The common dialog for printing. - */ +* wxPrinterDialog +* The common dialog for printing. +*/ class WXDLLEXPORT wxDC; class WXDLLEXPORT wxPrintDialog: public wxDialog { - DECLARE_DYNAMIC_CLASS(wxPrintDialog) - - public: - wxPrintDialog(); - wxPrintDialog(wxWindow *parent, wxPrintData* data = NULL); - ~wxPrintDialog(); - - bool Create(wxWindow *parent, wxPrintData* data = NULL); - virtual int ShowModal(); - - inline wxPrintData& GetPrintData() { return m_printData; } - virtual wxDC *GetPrintDC(); - - private: - wxPrintData m_printData; - wxDC* m_printerDC; - wxWindow* m_dialogParent; + DECLARE_DYNAMIC_CLASS(wxPrintDialog) + +public: + wxPrintDialog(); + wxPrintDialog(wxWindow *parent, wxPrintData* data = NULL); + ~wxPrintDialog(); + + bool Create(wxWindow *parent, wxPrintData* data = NULL); + virtual int ShowModal(); + + inline wxPrintData& GetPrintData() { return m_printData; } + virtual wxDC *GetPrintDC(); + +private: + wxPrintData m_printData; + wxDC* m_printerDC; + wxWindow* m_dialogParent; }; class WXDLLEXPORT wxPageSetupDialog: public wxDialog { - DECLARE_DYNAMIC_CLASS(wxPageSetupDialog) - - private: - wxPageSetupData m_pageSetupData; - wxWindow* m_dialogParent; - public: - wxPageSetupDialog(); - wxPageSetupDialog(wxWindow *parent, wxPageSetupData *data = NULL); - ~wxPageSetupDialog(); - - bool Create(wxWindow *parent, wxPageSetupData *data = NULL); - virtual int ShowModal(); - - inline wxPageSetupData& GetPageSetupData() { return m_pageSetupData; } + DECLARE_DYNAMIC_CLASS(wxPageSetupDialog) + +private: + wxPageSetupData m_pageSetupData; + wxWindow* m_dialogParent; +public: + wxPageSetupDialog(); + wxPageSetupDialog(wxWindow *parent, wxPageSetupData *data = NULL); + ~wxPageSetupDialog(); + + bool Create(wxWindow *parent, wxPageSetupData *data = NULL); + virtual int ShowModal(); + + inline wxPageSetupData& GetPageSetupData() { return m_pageSetupData; } }; #endif - // _WX_PRINTDLG_H_ +// _WX_PRINTDLG_H_ diff --git a/include/wx/motif/private.h b/include/wx/motif/private.h index 23737aecba..0a9bfe6823 100644 --- a/include/wx/motif/private.h +++ b/include/wx/motif/private.h @@ -90,15 +90,15 @@ public: wxXmString(const wxString& str) { m_string = XmStringCreateLtoR((char *)str.c_str(), - XmSTRING_DEFAULT_CHARSET); + XmSTRING_DEFAULT_CHARSET); } - + ~wxXmString() { XmStringFree(m_string); } - + // semi-implicit conversion to XmString (shouldn't rely on implicit // conversion because many of Motif functions are macros) XmString operator()() const { return m_string; } - + private: XmString m_string; }; @@ -117,4 +117,4 @@ private: extern "C" XtAppContext wxGetAppContext(); #endif - // _WX_PRIVATE_H_ +// _WX_PRIVATE_H_ diff --git a/include/wx/motif/radiobox.h b/include/wx/motif/radiobox.h index 4b4ace5eb0..09ad45314c 100644 --- a/include/wx/motif/radiobox.h +++ b/include/wx/motif/radiobox.h @@ -25,33 +25,33 @@ class WXDLLEXPORT wxBitmap ; class WXDLLEXPORT wxRadioBox : public wxControl { -DECLARE_DYNAMIC_CLASS(wxRadioBox) - + DECLARE_DYNAMIC_CLASS(wxRadioBox) + public: wxRadioBox(); - + wxRadioBox(wxWindow *parent, wxWindowID id, const wxString& title, - const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - int n = 0, const wxString choices[] = NULL, - int majorDim = 0, long style = wxRA_HORIZONTAL, - const wxValidator& val = wxDefaultValidator, const wxString& name = wxRadioBoxNameStr) + const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, + int n = 0, const wxString choices[] = NULL, + int majorDim = 0, long style = wxRA_HORIZONTAL, + const wxValidator& val = wxDefaultValidator, const wxString& name = wxRadioBoxNameStr) { Create(parent, id, title, pos, size, n, choices, majorDim, style, val, name); } - + ~wxRadioBox(); - + bool Create(wxWindow *parent, wxWindowID id, const wxString& title, - const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - int n = 0, const wxString choices[] = NULL, - int majorDim = 0, long style = wxRA_HORIZONTAL, - const wxValidator& val = wxDefaultValidator, const wxString& name = wxRadioBoxNameStr); - + const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, + int n = 0, const wxString choices[] = NULL, + int majorDim = 0, long style = wxRA_HORIZONTAL, + const wxValidator& val = wxDefaultValidator, const wxString& name = wxRadioBoxNameStr); + int FindString(const wxString& s) const; void SetSelection(int N); int GetSelection() const; wxString GetString(int N) const; - + void SetLabel(const wxString& label) { wxControl::SetLabel(label); }; void SetLabel(int item, const wxString& label) ; wxString GetLabel(int item) const; @@ -60,15 +60,15 @@ public: void Enable(int item, bool enable); void Show(int item, bool show) ; bool Show(bool show) ; - + virtual wxString GetStringSelection() const; virtual bool SetStringSelection(const wxString& s); virtual int GetCount() const { return m_noItems; } ; void Command(wxCommandEvent& event); - + int GetNumberOfRowsOrCols() const { return m_noRowsOrCols; } void SetNumberOfRowsOrCols(int n) { m_noRowsOrCols = n; } - + // Implementation virtual void ChangeFont(bool keepOriginalSize = TRUE); virtual void ChangeBackgroundColour(); @@ -78,23 +78,23 @@ public: WXWidget GetFrameWidget() const { return m_frameWidget; } inline WXWidget* GetRadioButtons() const { return m_radioButtons; } inline void SetSel(int i) { m_selectedButton = i; } - + protected: int m_majorDim ; int m_noItems; int m_noRowsOrCols; int m_selectedButton; - + WXWidget m_formWidget; WXWidget m_labelWidget; WXWidget m_frameWidget; WXWidget* m_radioButtons; wxString* m_radioButtonLabels; - + virtual void DoSetSize(int x, int y, - int width, int height, - int sizeFlags = wxSIZE_AUTO); + int width, int height, + int sizeFlags = wxSIZE_AUTO); }; #endif - // _WX_RADIOBOX_H_ +// _WX_RADIOBOX_H_ diff --git a/include/wx/motif/radiobut.h b/include/wx/motif/radiobut.h index 1292321fad..514a731c90 100644 --- a/include/wx/motif/radiobut.h +++ b/include/wx/motif/radiobut.h @@ -27,28 +27,28 @@ 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) + 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); } - + 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); - + const wxString& label, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, long style = 0, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxRadioButtonNameStr); + virtual void SetValue(bool val); virtual bool GetValue() const ; - + void Command(wxCommandEvent& event); - -// Implementation + + // Implementation virtual void ChangeFont(bool keepOriginalSize = TRUE); virtual void ChangeBackgroundColour(); virtual void ChangeForegroundColour(); @@ -62,33 +62,33 @@ WXDLLEXPORT_DATA(extern const char*) wxBitmapRadioButtonNameStr; class WXDLLEXPORT wxBitmapRadioButton: public wxRadioButton { - DECLARE_DYNAMIC_CLASS(wxBitmapRadioButton) - protected: - wxBitmap *theButtonBitmap; - public: - inline wxBitmapRadioButton() { theButtonBitmap = NULL; } - inline wxBitmapRadioButton(wxWindow *parent, wxWindowID id, - const wxBitmap *label, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxBitmapRadioButtonNameStr) - { - Create(parent, id, label, pos, size, style, validator, name); - } - - bool Create(wxWindow *parent, wxWindowID id, - const wxBitmap *label, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxBitmapRadioButtonNameStr); - - virtual void SetLabel(const wxBitmap *label); - virtual void SetValue(bool val) ; - virtual bool GetValue() const ; + DECLARE_DYNAMIC_CLASS(wxBitmapRadioButton) +protected: + wxBitmap *theButtonBitmap; +public: + inline wxBitmapRadioButton() { theButtonBitmap = NULL; } + inline wxBitmapRadioButton(wxWindow *parent, wxWindowID id, + const wxBitmap *label, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, long style = 0, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxBitmapRadioButtonNameStr) + { + Create(parent, id, label, pos, size, style, validator, name); + } + + bool Create(wxWindow *parent, wxWindowID id, + const wxBitmap *label, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, long style = 0, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxBitmapRadioButtonNameStr); + + virtual void SetLabel(const wxBitmap *label); + virtual void SetValue(bool val) ; + virtual bool GetValue() const ; }; #endif #endif - // _WX_RADIOBUT_H_ +// _WX_RADIOBUT_H_ diff --git a/include/wx/motif/region.h b/include/wx/motif/region.h index 8e5157eb05..052eb872f7 100644 --- a/include/wx/motif/region.h +++ b/include/wx/motif/region.h @@ -28,91 +28,91 @@ WX_DECLARE_LIST(wxRect, wxRectList); enum wxRegionContain { - wxOutRegion = 0, wxPartRegion = 1, wxInRegion = 2 + wxOutRegion = 0, wxPartRegion = 1, wxInRegion = 2 }; // So far, for internal use only enum wxRegionOp { -wxRGN_AND, // Creates the intersection of the two combined regions. -wxRGN_COPY, // Creates a copy of the region identified by hrgnSrc1. -wxRGN_DIFF, // Combines the parts of hrgnSrc1 that are not part of hrgnSrc2. -wxRGN_OR, // Creates the union of two combined regions. -wxRGN_XOR // Creates the union of two combined regions except for any overlapping areas. + wxRGN_AND, // Creates the intersection of the two combined regions. + wxRGN_COPY, // Creates a copy of the region identified by hrgnSrc1. + wxRGN_DIFF, // Combines the parts of hrgnSrc1 that are not part of hrgnSrc2. + wxRGN_OR, // Creates the union of two combined regions. + wxRGN_XOR // Creates the union of two combined regions except for any overlapping areas. }; class WXDLLEXPORT wxRegion : public wxGDIObject { DECLARE_DYNAMIC_CLASS(wxRegion) - friend class WXDLLEXPORT wxRegionIterator; + friend class WXDLLEXPORT wxRegionIterator; public: wxRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h); wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight); wxRegion(const wxRect& rect); - wxRegion(); - ~wxRegion(); - - //# Copying - inline wxRegion(const wxRegion& r) - { Ref(r); } - inline wxRegion& operator = (const wxRegion& r) - { Ref(r); return (*this); } - - //# Modify region - // Clear current region - void Clear(); - - // Union rectangle or region with this. - inline bool Union(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { return Combine(x, y, width, height, wxRGN_OR); } - inline bool Union(const wxRect& rect) { return Combine(rect, wxRGN_OR); } - inline bool Union(const wxRegion& region) { return Combine(region, wxRGN_OR); } - - // Intersect rectangle or region with this. - inline bool Intersect(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { return Combine(x, y, width, height, wxRGN_AND); } - inline bool Intersect(const wxRect& rect) { return Combine(rect, wxRGN_AND); } - inline bool Intersect(const wxRegion& region) { return Combine(region, wxRGN_AND); } - - // Subtract rectangle or region from this: + wxRegion(); + ~wxRegion(); + + //# Copying + inline wxRegion(const wxRegion& r) + { Ref(r); } + inline wxRegion& operator = (const wxRegion& r) + { Ref(r); return (*this); } + + //# Modify region + // Clear current region + void Clear(); + + // Union rectangle or region with this. + inline bool Union(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { return Combine(x, y, width, height, wxRGN_OR); } + inline bool Union(const wxRect& rect) { return Combine(rect, wxRGN_OR); } + inline bool Union(const wxRegion& region) { return Combine(region, wxRGN_OR); } + + // Intersect rectangle or region with this. + inline bool Intersect(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { return Combine(x, y, width, height, wxRGN_AND); } + inline bool Intersect(const wxRect& rect) { return Combine(rect, wxRGN_AND); } + inline bool Intersect(const wxRegion& region) { return Combine(region, wxRGN_AND); } + + // Subtract rectangle or region from this: // Combines the parts of 'this' that are not part of the second region. - inline bool Subtract(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { return Combine(x, y, width, height, wxRGN_DIFF); } - inline bool Subtract(const wxRect& rect) { return Combine(rect, wxRGN_DIFF); } - inline bool Subtract(const wxRegion& region) { return Combine(region, wxRGN_DIFF); } - - // XOR: the union of two combined regions except for any overlapping areas. - inline bool Xor(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { return Combine(x, y, width, height, wxRGN_XOR); } - inline bool Xor(const wxRect& rect) { return Combine(rect, wxRGN_XOR); } - inline bool Xor(const wxRegion& region) { return Combine(region, wxRGN_XOR); } - - //# Information on region - // Outer bounds of region - void GetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const; - wxRect GetBox() const ; - - // Is region empty? - bool Empty() const; - inline bool IsEmpty() const { return Empty(); } - bool Ok() const { return (m_refData != NULL) ; } - - //# Tests - // Does the region contain the point (x,y)? - wxRegionContain Contains(wxCoord x, wxCoord y) const; - // Does the region contain the point pt? - wxRegionContain Contains(const wxPoint& pt) const; - // Does the region contain the rectangle (x, y, w, h)? - wxRegionContain Contains(wxCoord x, wxCoord y, wxCoord w, wxCoord h) const; - // Does the region contain the rectangle rect? - wxRegionContain Contains(const wxRect& rect) const; - -// Internal - bool Combine(wxCoord x, wxCoord y, wxCoord width, wxCoord height, wxRegionOp op); - bool Combine(const wxRegion& region, wxRegionOp op); - bool Combine(const wxRect& rect, wxRegionOp op); - + inline bool Subtract(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { return Combine(x, y, width, height, wxRGN_DIFF); } + inline bool Subtract(const wxRect& rect) { return Combine(rect, wxRGN_DIFF); } + inline bool Subtract(const wxRegion& region) { return Combine(region, wxRGN_DIFF); } + + // XOR: the union of two combined regions except for any overlapping areas. + inline bool Xor(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { return Combine(x, y, width, height, wxRGN_XOR); } + inline bool Xor(const wxRect& rect) { return Combine(rect, wxRGN_XOR); } + inline bool Xor(const wxRegion& region) { return Combine(region, wxRGN_XOR); } + + //# Information on region + // Outer bounds of region + void GetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const; + wxRect GetBox() const ; + + // Is region empty? + bool Empty() const; + inline bool IsEmpty() const { return Empty(); } + bool Ok() const { return (m_refData != NULL) ; } + + //# Tests + // Does the region contain the point (x,y)? + wxRegionContain Contains(wxCoord x, wxCoord y) const; + // Does the region contain the point pt? + wxRegionContain Contains(const wxPoint& pt) const; + // Does the region contain the rectangle (x, y, w, h)? + wxRegionContain Contains(wxCoord x, wxCoord y, wxCoord w, wxCoord h) const; + // Does the region contain the rectangle rect? + wxRegionContain Contains(const wxRect& rect) const; + + // Internal + bool Combine(wxCoord x, wxCoord y, wxCoord width, wxCoord height, wxRegionOp op); + bool Combine(const wxRegion& region, wxRegionOp op); + bool Combine(const wxRect& rect, wxRegionOp op); + // Get the internal Region handle WXRegion GetXRegion() const; - -// 'Naughty' functions that allow wxWindows to use a list of rects -// instead of the region, in certain circumstances (e.g. when -// making a region out of the update rectangles). -// These are used by wxPaintDC::wxPaintDC and wxRegionIterator::Reset. + + // 'Naughty' functions that allow wxWindows to use a list of rects + // instead of the region, in certain circumstances (e.g. when + // making a region out of the update rectangles). + // These are used by wxPaintDC::wxPaintDC and wxRegionIterator::Reset. bool UsingRects() const; wxRect* GetRects(); int GetRectCount() const; @@ -123,33 +123,33 @@ public: class WXDLLEXPORT wxRegionIterator : public wxObject { DECLARE_DYNAMIC_CLASS(wxRegionIterator) public: - wxRegionIterator(); - wxRegionIterator(const wxRegion& region); - ~wxRegionIterator(); - - void Reset() { m_current = 0; } - void Reset(const wxRegion& region); - - operator bool () const { return m_current < m_numRects; } - bool HaveRects() const { return m_current < m_numRects; } - - void operator ++ (); - void operator ++ (int); - - wxCoord GetX() const; - wxCoord GetY() const; - wxCoord GetW() const; - wxCoord GetWidth() const { return GetW(); } - wxCoord GetH() const; - wxCoord GetHeight() const { return GetH(); } - wxRect GetRect() const { return wxRect(GetX(), GetY(), GetWidth(), GetHeight()); } - + wxRegionIterator(); + wxRegionIterator(const wxRegion& region); + ~wxRegionIterator(); + + void Reset() { m_current = 0; } + void Reset(const wxRegion& region); + + operator bool () const { return m_current < m_numRects; } + bool HaveRects() const { return m_current < m_numRects; } + + void operator ++ (); + void operator ++ (int); + + wxCoord GetX() const; + wxCoord GetY() const; + wxCoord GetW() const; + wxCoord GetWidth() const { return GetW(); } + wxCoord GetH() const; + wxCoord GetHeight() const { return GetH(); } + wxRect GetRect() const { return wxRect(GetX(), GetY(), GetWidth(), GetHeight()); } + private: - size_t m_current; - size_t m_numRects; - wxRegion m_region; - wxRect* m_rects; + size_t m_current; + size_t m_numRects; + wxRegion m_region; + wxRect* m_rects; }; #endif - // _WX_REGION_H_ +// _WX_REGION_H_ diff --git a/include/wx/motif/scrolbar.h b/include/wx/motif/scrolbar.h index 2cda645071..14b124335c 100644 --- a/include/wx/motif/scrolbar.h +++ b/include/wx/motif/scrolbar.h @@ -23,51 +23,49 @@ WXDLLEXPORT_DATA(extern const char*) wxScrollBarNameStr; // Scrollbar item class WXDLLEXPORT wxScrollBar: public wxControl { - DECLARE_DYNAMIC_CLASS(wxScrollBar) - + DECLARE_DYNAMIC_CLASS(wxScrollBar) + public: - inline wxScrollBar() { m_pageSize = 0; m_viewSize = 0; m_objectSize = 0; } - ~wxScrollBar(); - - inline wxScrollBar(wxWindow *parent, wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxSB_HORIZONTAL, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxScrollBarNameStr) - { - Create(parent, id, pos, size, style, validator, name); - } - bool Create(wxWindow *parent, wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxSB_HORIZONTAL, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxScrollBarNameStr); - - int GetThumbPosition() const ; - inline int GetThumbSize() const { return m_pageSize; } - inline int GetPageSize() const { return m_viewSize; } - inline int GetRange() const { return m_objectSize; } - - virtual void SetThumbPosition(int viewStart); - virtual void SetScrollbar(int position, int thumbSize, int range, int pageSize, - bool refresh = TRUE); - - void Command(wxCommandEvent& event); - -// Implementation - virtual void ChangeFont(bool keepOriginalSize = TRUE); - virtual void ChangeBackgroundColour(); - virtual void ChangeForegroundColour(); - + inline wxScrollBar() { m_pageSize = 0; m_viewSize = 0; m_objectSize = 0; } + ~wxScrollBar(); + + inline wxScrollBar(wxWindow *parent, wxWindowID id, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxSB_HORIZONTAL, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxScrollBarNameStr) + { + Create(parent, id, pos, size, style, validator, name); + } + bool Create(wxWindow *parent, wxWindowID id, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxSB_HORIZONTAL, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxScrollBarNameStr); + + int GetThumbPosition() const ; + inline int GetThumbSize() const { return m_pageSize; } + inline int GetPageSize() const { return m_viewSize; } + inline int GetRange() const { return m_objectSize; } + + virtual void SetThumbPosition(int viewStart); + virtual void SetScrollbar(int position, int thumbSize, int range, int pageSize, + bool refresh = TRUE); + + void Command(wxCommandEvent& event); + + // Implementation + virtual void ChangeFont(bool keepOriginalSize = TRUE); + virtual void ChangeBackgroundColour(); + virtual void ChangeForegroundColour(); + protected: int m_pageSize; int m_viewSize; int m_objectSize; - -// DECLARE_EVENT_TABLE() }; #endif - // _WX_SCROLBAR_H_ +// _WX_SCROLBAR_H_ diff --git a/include/wx/motif/slider.h b/include/wx/motif/slider.h index fd9e5b3c28..935ddbd88f 100644 --- a/include/wx/motif/slider.h +++ b/include/wx/motif/slider.h @@ -23,42 +23,42 @@ WXDLLEXPORT_DATA(extern const char*) wxSliderNameStr; // Slider class WXDLLEXPORT wxSlider: public wxControl { -DECLARE_DYNAMIC_CLASS(wxSlider) - + DECLARE_DYNAMIC_CLASS(wxSlider) + public: wxSlider(); - + wxSlider(wxWindow *parent, wxWindowID id, - int value, int minValue, int maxValue, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxSL_HORIZONTAL, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxSliderNameStr) + int value, int minValue, int maxValue, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxSL_HORIZONTAL, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxSliderNameStr) { Create(parent, id, value, minValue, maxValue, pos, size, style, validator, name); } - + ~wxSlider(); - + bool Create(wxWindow *parent, wxWindowID id, - int value, int minValue, int maxValue, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxSL_HORIZONTAL, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxSliderNameStr); - + int value, int minValue, int maxValue, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxSL_HORIZONTAL, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxSliderNameStr); + virtual int GetValue() const ; virtual void SetValue(int); - + void GetSize(int *x, int *y) const ; - + void SetRange(int minValue, int maxValue); - + inline int GetMin() const { return m_rangeMin; } inline int GetMax() const { return m_rangeMax; } - + // For trackbars only void SetTickFreq(int n, int pos); inline int GetTickFreq() const { return m_tickFreq; } @@ -74,28 +74,28 @@ public: void SetThumbLength(int len) ; int GetThumbLength() const ; void SetTick(int tickPos) ; - + void Command(wxCommandEvent& event); - + // Implementation virtual void ChangeFont(bool keepOriginalSize = TRUE); virtual void ChangeBackgroundColour(); virtual void ChangeForegroundColour(); - + protected: int m_rangeMin; int m_rangeMax; int m_pageSize; int m_lineSize; int m_tickFreq; - + virtual void DoSetSize(int x, int y, - int width, int height, - int sizeFlags = wxSIZE_AUTO); - + int width, int height, + int sizeFlags = wxSIZE_AUTO); + private: DECLARE_EVENT_TABLE() }; #endif - // _WX_SLIDER_H_ +// _WX_SLIDER_H_ diff --git a/include/wx/motif/spinbutt.h b/include/wx/motif/spinbutt.h index 1731d356ed..77aa1ec12d 100644 --- a/include/wx/motif/spinbutt.h +++ b/include/wx/motif/spinbutt.h @@ -13,54 +13,53 @@ #define _WX_SPINBUTT_H_ #ifdef __GNUG__ - #pragma interface "spinbutt.h" +#pragma interface "spinbutt.h" #endif class WXDLLEXPORT wxSpinButton : public wxSpinButtonBase { DECLARE_DYNAMIC_CLASS(wxSpinButton) - + public: wxSpinButton() { } - + wxSpinButton(wxWindow *parent, - wxWindowID id = -1, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxSP_VERTICAL, - const wxString& name = "wxSpinButton") + wxWindowID id = -1, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxSP_VERTICAL, + const wxString& name = "wxSpinButton") { Create(parent, id, pos, size, style, name); } ~wxSpinButton(); - + bool Create(wxWindow *parent, - wxWindowID id = -1, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxSP_VERTICAL, - const wxString& name = "wxSpinButton"); - - + wxWindowID id = -1, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxSP_VERTICAL, + const wxString& name = "wxSpinButton"); + // accessors int GetValue() const; int GetMin() const { return m_min; } int GetMax() const { return m_max; } - + // operations void SetValue(int val); void SetRange(int minVal, int maxVal); - + // Implementation virtual void Command(wxCommandEvent& event) { (void)ProcessCommand(event); }; virtual void ChangeFont(bool keepOriginalSize = TRUE); virtual void ChangeBackgroundColour(); virtual void ChangeForegroundColour(); - + protected: int m_min; int m_max; }; #endif - // _WX_SPINBUTT_H_ +// _WX_SPINBUTT_H_ diff --git a/include/wx/motif/statbmp.h b/include/wx/motif/statbmp.h index b6674c046b..94b063659e 100644 --- a/include/wx/motif/statbmp.h +++ b/include/wx/motif/statbmp.h @@ -23,62 +23,62 @@ WXDLLEXPORT_DATA(extern const char*) wxStaticBitmapNameStr; class WXDLLEXPORT wxStaticBitmap : public wxControl { -DECLARE_DYNAMIC_CLASS(wxStaticBitmap) - + DECLARE_DYNAMIC_CLASS(wxStaticBitmap) + public: wxStaticBitmap() { } ~wxStaticBitmap(); - + wxStaticBitmap(wxWindow *parent, wxWindowID id, - const wxBitmap& label, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxStaticBitmapNameStr) + const wxBitmap& label, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = 0, + const wxString& name = wxStaticBitmapNameStr) { Create(parent, id, label, pos, size, style, name); } - + bool Create(wxWindow *parent, wxWindowID id, - const wxBitmap& label, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxStaticBitmapNameStr); - + const wxBitmap& label, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = 0, + const wxString& name = wxStaticBitmapNameStr); + virtual void SetBitmap(const wxBitmap& bitmap); - + virtual bool ProcessCommand(wxCommandEvent& WXUNUSED(event)) { return FALSE; } - + wxBitmap& GetBitmap() const { return (wxBitmap&) m_messageBitmap; } - + // for compatibility with wxMSW const wxIcon& GetIcon() const { // don't use wxDynamicCast, icons and bitmaps are really the same thing return (const wxIcon &)m_messageBitmap; } - + // for compatibility with wxMSW void SetIcon(const wxIcon& icon) { SetBitmap( icon ); } - + // overriden base class virtuals virtual bool AcceptsFocus() const { return FALSE; } - + // Implementation virtual void ChangeFont(bool keepOriginalSize = TRUE); virtual void ChangeBackgroundColour(); virtual void ChangeForegroundColour(); - + protected: wxBitmap m_messageBitmap; }; #endif - // _WX_STATBMP_H_ +// _WX_STATBMP_H_ diff --git a/include/wx/motif/statbox.h b/include/wx/motif/statbox.h index 99a9b29445..a2a31bdcb7 100644 --- a/include/wx/motif/statbox.h +++ b/include/wx/motif/statbox.h @@ -23,55 +23,55 @@ WXDLLEXPORT_DATA(extern const char*) wxStaticBoxNameStr; // Group box class WXDLLEXPORT wxStaticBox: public wxControl { -DECLARE_DYNAMIC_CLASS(wxStaticBox) - + DECLARE_DYNAMIC_CLASS(wxStaticBox) + public: wxStaticBox(); wxStaticBox(wxWindow *parent, wxWindowID id, - const wxString& label, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxStaticBoxNameStr) + const wxString& label, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = 0, + const wxString& name = wxStaticBoxNameStr) { Create(parent, id, label, pos, size, style, name); } ~wxStaticBox(); - + bool Create(wxWindow *parent, wxWindowID id, - const wxString& label, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxStaticBoxNameStr); - + const wxString& label, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = 0, + const wxString& name = wxStaticBoxNameStr); + virtual bool ProcessCommand(wxCommandEvent& WXUNUSED(event)) { return FALSE; } - + void SetLabel(const wxString& label); wxString GetLabel() const; - + // Implementation virtual void ChangeFont(bool keepOriginalSize = TRUE); virtual void ChangeBackgroundColour(); virtual void ChangeForegroundColour(); WXWidget GetTopWidget() const { return m_formWidget; } WXWidget GetLabelWidget() const { return m_labelWidget; } - + protected: // Motif-specific WXWidget m_formWidget; WXWidget m_labelWidget; - + virtual void DoSetSize(int x, int y, - int width, int height, - int sizeFlags = wxSIZE_AUTO); - + int width, int height, + int sizeFlags = wxSIZE_AUTO); + private: DECLARE_EVENT_TABLE() }; #endif - // _WX_STATBOX_H_ +// _WX_STATBOX_H_ diff --git a/include/wx/motif/stattext.h b/include/wx/motif/stattext.h index e9f3ca8225..c58bcaa7cc 100644 --- a/include/wx/motif/stattext.h +++ b/include/wx/motif/stattext.h @@ -23,40 +23,40 @@ WXDLLEXPORT_DATA(extern const char*) wxStaticTextNameStr; class WXDLLEXPORT wxStaticText: public wxControl { DECLARE_DYNAMIC_CLASS(wxStaticText) - + public: wxStaticText() { } - + wxStaticText(wxWindow *parent, wxWindowID id, - const wxString& label, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxStaticTextNameStr) + const wxString& label, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = 0, + const wxString& name = wxStaticTextNameStr) { Create(parent, id, label, pos, size, style, name); } - + bool Create(wxWindow *parent, wxWindowID id, - const wxString& label, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxStaticTextNameStr); - + const wxString& label, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = 0, + const wxString& name = wxStaticTextNameStr); + // implementation // -------------- - + // operations virtual bool ProcessCommand(wxCommandEvent& WXUNUSED(event)) { return FALSE; } - + virtual void ChangeFont(bool keepOriginalSize = TRUE); virtual void ChangeBackgroundColour(); virtual void ChangeForegroundColour(); }; #endif - // _WX_STATTEXT_H_ +// _WX_STATTEXT_H_ diff --git a/include/wx/motif/tabctrl.h b/include/wx/motif/tabctrl.h index b17804c615..41d5620ce1 100644 --- a/include/wx/motif/tabctrl.h +++ b/include/wx/motif/tabctrl.h @@ -19,8 +19,8 @@ class wxImageList; /* - * Flags returned by HitTest - */ +* Flags returned by HitTest +*/ #define wxTAB_HITTEST_NOWHERE 1 #define wxTAB_HITTEST_ONICON 2 @@ -29,110 +29,110 @@ class wxImageList; class WXDLLEXPORT wxTabCtrl: public wxControl { - DECLARE_DYNAMIC_CLASS(wxTabCtrl) - public: - /* - * Public interface + DECLARE_DYNAMIC_CLASS(wxTabCtrl) +public: +/* +* Public interface */ - + wxTabCtrl(); - + inline wxTabCtrl(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - long style = 0, const wxString& name = "tabCtrl") + long style = 0, const wxString& name = "tabCtrl") { Create(parent, id, pos, size, style, name); } ~wxTabCtrl(); - -// Accessors - + + // Accessors + // Get the selection int GetSelection() const; - + // Get the tab with the current keyboard focus int GetCurFocus() const; - + // Get the associated image list wxImageList* GetImageList() const; - + // Get the number of items int GetItemCount() const; - + // Get the rect corresponding to the tab bool GetItemRect(int item, wxRect& rect) const; - + // Get the number of rows int GetRowCount() const; - + // Get the item text wxString GetItemText(int item) const ; - + // Get the item image int GetItemImage(int item) const; - + // Get the item data void* GetItemData(int item) const; - + // Set the selection int SetSelection(int item); - + // Set the image list void SetImageList(wxImageList* imageList); - + // Set the text for an item bool SetItemText(int item, const wxString& text); - + // Set the image for an item bool SetItemImage(int item, int image); - + // Set the data for an item bool SetItemData(int item, void* data); - + // Set the size for a fixed-width tab control void SetItemSize(const wxSize& size); - + // Set the padding between tabs void SetPadding(const wxSize& padding); - -// Operations - + + // Operations + bool Create(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - long style = 0, const wxString& name = "tabCtrl"); - + long style = 0, const wxString& name = "tabCtrl"); + // Delete all items bool DeleteAllItems(); - + // Delete an item bool DeleteItem(int item); - + // Hit test int HitTest(const wxPoint& pt, long& flags); - + // Insert an item bool InsertItem(int item, const wxString& text, int imageId = -1, void* data = NULL); - + void Command(wxCommandEvent& event); - + protected: wxImageList* m_imageList; - -DECLARE_EVENT_TABLE() + + DECLARE_EVENT_TABLE() }; class WXDLLEXPORT wxTabEvent: public wxCommandEvent { - DECLARE_DYNAMIC_CLASS(wxTabEvent) - - public: - wxTabEvent(wxEventType commandType = wxEVT_NULL, int id = 0); + DECLARE_DYNAMIC_CLASS(wxTabEvent) + +public: + wxTabEvent(wxEventType commandType = wxEVT_NULL, int id = 0); }; typedef void (wxEvtHandler::*wxTabEventFunction)(wxTabEvent&); #define EVT_TAB_SEL_CHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_COMMAND_TAB_SEL_CHANGED, \ - id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTabEventFunction) & fn, NULL ), +id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTabEventFunction) & fn, NULL ), #define EVT_TAB_SEL_CHANGING(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_COMMAND_TAB_SEL_CHANGING, \ - id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTabEventFunction) & fn, NULL ), +id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTabEventFunction) & fn, NULL ), #endif - // _WX_TABCTRL_H_ +// _WX_TABCTRL_H_ diff --git a/include/wx/motif/taskbar.h b/include/wx/motif/taskbar.h index 75574655e3..8227232367 100644 --- a/include/wx/motif/taskbar.h +++ b/include/wx/motif/taskbar.h @@ -23,16 +23,16 @@ class wxTaskBarIcon: public wxObject { public: - wxTaskBarIcon(); - virtual ~wxTaskBarIcon(); - -// Accessors - -// Operations + wxTaskBarIcon(); + virtual ~wxTaskBarIcon(); + + // Accessors + + // Operations bool SetIcon(const wxIcon& icon, const wxString& tooltip = ""); bool RemoveIcon(); - -// Overridables + + // Overridables virtual void OnMouseMove(); virtual void OnLButtonDown(); virtual void OnLButtonUp(); @@ -40,10 +40,10 @@ public: virtual void OnRButtonUp(); virtual void OnLButtonDClick(); virtual void OnRButtonDClick(); - -// Data members + + // Data members protected: }; #endif - // _WX_TASKBAR_H_ +// _WX_TASKBAR_H_ diff --git a/include/wx/motif/textctrl.h b/include/wx/motif/textctrl.h index 6d0bb105de..7355c85555 100644 --- a/include/wx/motif/textctrl.h +++ b/include/wx/motif/textctrl.h @@ -13,7 +13,7 @@ #define _WX_TEXTCTRL_H_ #ifdef __GNUG__ - #pragma interface "textctrl.h" +#pragma interface "textctrl.h" #endif WXDLLEXPORT_DATA(extern const char*) wxTextCtrlNameStr; @@ -23,42 +23,42 @@ WXDLLEXPORT_DATA(extern const char*) wxEmptyString; class WXDLLEXPORT wxTextCtrl : public wxTextCtrlBase { DECLARE_DYNAMIC_CLASS(wxTextCtrl) - + public: // creation // -------- wxTextCtrl(); wxTextCtrl(wxWindow *parent, - wxWindowID id, - const wxString& value = wxEmptyString, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxTextCtrlNameStr) - { - Create(parent, id, value, pos, size, style, validator, name); - } - + wxWindowID id, + const wxString& value = wxEmptyString, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = 0, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxTextCtrlNameStr) + { + Create(parent, id, value, pos, size, style, validator, name); + } + bool Create(wxWindow *parent, wxWindowID id, - const wxString& value = wxEmptyString, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxTextCtrlNameStr); - + const wxString& value = wxEmptyString, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, long style = 0, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxTextCtrlNameStr); + // accessors // --------- virtual wxString GetValue() const; virtual void SetValue(const wxString& value); - + virtual int GetLineLength(long lineNo) const; virtual wxString GetLineText(long lineNo) const; virtual int GetNumberOfLines() const; - + // operations // ---------- - + // Clipboard operations virtual void Copy(); virtual void Cut(); @@ -66,14 +66,14 @@ public: virtual bool CanCopy() const; virtual bool CanCut() const; virtual bool CanPaste() const; - + // Undo/redo virtual void Undo(); virtual void Redo(); - + virtual bool CanUndo() const; virtual bool CanRedo() const; - + virtual void SetInsertionPoint(long pos); virtual void SetInsertionPointEnd(); virtual long GetInsertionPoint() const; @@ -86,39 +86,39 @@ public: // selection. virtual void GetSelection(long* from, long* to) const; virtual bool IsEditable() const ; - + virtual bool LoadFile(const wxString& file); virtual bool SaveFile(const wxString& file); virtual void WriteText(const wxString& text); virtual void AppendText(const wxString& text); virtual void DiscardEdits(); virtual bool IsModified() const; - + virtual long XYToPosition(long x, long y) const; virtual bool PositionToXY(long pos, long *x, long *y) const; virtual void ShowPosition(long pos); virtual void Clear(); - + // callbacks // --------- void OnDropFiles(wxDropFilesEvent& event); void OnChar(wxKeyEvent& event); // void OnEraseBackground(wxEraseEvent& event); - + void OnCut(wxCommandEvent& event); void OnCopy(wxCommandEvent& event); void OnPaste(wxCommandEvent& event); void OnUndo(wxCommandEvent& event); void OnRedo(wxCommandEvent& event); - + void OnUpdateCut(wxUpdateUIEvent& event); void OnUpdateCopy(wxUpdateUIEvent& event); void OnUpdatePaste(wxUpdateUIEvent& event); void OnUpdateUndo(wxUpdateUIEvent& event); void OnUpdateRedo(wxUpdateUIEvent& event); - + virtual void Command(wxCommandEvent& event); - + // implementation from here to the end // ----------------------------------- virtual void ChangeFont(bool keepOriginalSize = TRUE); @@ -126,26 +126,26 @@ public: virtual void ChangeForegroundColour(); void SetModified(bool mod) { m_modified = mod; } virtual WXWidget GetTopWidget() const; - + // send the CHAR and TEXT_UPDATED events void DoSendEvents(void /* XmTextVerifyCallbackStruct */ *cbs, - long keycode); - + long keycode); + protected: wxString m_fileName; - + public: // Motif-specific void* m_tempCallbackStruct; bool m_modified; wxString m_value; // Required for password text controls - + // Did we call wxTextCtrl::OnChar? If so, generate a command event. bool m_processedDefault; - + private: DECLARE_EVENT_TABLE() }; #endif - // _WX_TEXTCTRL_H_ +// _WX_TEXTCTRL_H_ diff --git a/include/wx/motif/timer.h b/include/wx/motif/timer.h index 28c0d776b4..2476a768e2 100644 --- a/include/wx/motif/timer.h +++ b/include/wx/motif/timer.h @@ -13,32 +13,32 @@ #define _WX_TIMER_H_ #ifdef __GNUG__ - #pragma interface "timer.h" +#pragma interface "timer.h" #endif class WXDLLEXPORT wxTimer : public wxTimerBase { -friend void wxTimerCallback(wxTimer * timer); - + friend void wxTimerCallback(wxTimer * timer); + public: wxTimer() { Init(); } wxTimer(wxEvtHandler *owner, int id = -1) : wxTimerBase(owner, id) - { Init(); } + { Init(); } ~wxTimer(); - + virtual bool Start(int milliseconds = -1, bool oneShot = FALSE); virtual void Stop(); - + virtual bool IsRunning() const { return m_id != 0; } - + protected: void Init(); - + long m_id; - + private: DECLARE_DYNAMIC_CLASS(wxTimer) }; #endif - // _WX_TIMER_H_ +// _WX_TIMER_H_ diff --git a/include/wx/motif/toolbar.h b/include/wx/motif/toolbar.h index bbf08831cc..f7864c43af 100644 --- a/include/wx/motif/toolbar.h +++ b/include/wx/motif/toolbar.h @@ -13,7 +13,7 @@ #define _WX_TOOLBAR_H_ #ifdef __GNUG__ - #pragma interface "toolbar.h" +#pragma interface "toolbar.h" #endif class WXDLLEXPORT wxToolBar : public wxToolBarBase @@ -21,62 +21,62 @@ class WXDLLEXPORT wxToolBar : public wxToolBarBase public: // ctors and dtor wxToolBar() { Init(); } - + wxToolBar(wxWindow *parent, - wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxNO_BORDER | wxTB_HORIZONTAL, - const wxString& name = wxToolBarNameStr) + wxWindowID id, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxNO_BORDER | wxTB_HORIZONTAL, + const wxString& name = wxToolBarNameStr) { Init(); - + Create(parent, id, pos, size, style, name); } - + bool Create(wxWindow *parent, - wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxNO_BORDER | wxTB_HORIZONTAL, - const wxString& name = wxToolBarNameStr); - + wxWindowID id, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxNO_BORDER | wxTB_HORIZONTAL, + const wxString& name = wxToolBarNameStr); + virtual ~wxToolBar(); - + // override/implement base class virtuals virtual wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y) const; - + virtual bool Realize(); - + // implementation from now on - + // find tool by widget wxToolBarToolBase *FindToolByWidget(WXWidget w) const; - + protected: // common part of all ctors void Init(); - + // implement base class pure virtuals virtual bool DoInsertTool(size_t pos, wxToolBarToolBase *tool); virtual bool DoDeleteTool(size_t pos, wxToolBarToolBase *tool); - + virtual void DoEnableTool(wxToolBarToolBase *tool, bool enable); virtual void DoToggleTool(wxToolBarToolBase *tool, bool toggle); virtual void DoSetToggle(wxToolBarToolBase *tool, bool toggle); - + virtual wxToolBarToolBase *CreateTool(int id, - const wxBitmap& bitmap1, - const wxBitmap& bitmap2, - bool toggle, - wxObject *clientData, - const wxString& shortHelpString, - const wxString& longHelpString); + const wxBitmap& bitmap1, + const wxBitmap& bitmap2, + bool toggle, + wxObject *clientData, + const wxString& shortHelpString, + const wxString& longHelpString); virtual wxToolBarToolBase *CreateTool(wxControl *control); - + private: DECLARE_DYNAMIC_CLASS(wxToolBar) }; #endif - // _WX_TOOLBAR_H_ +// _WX_TOOLBAR_H_ diff --git a/include/wx/motif/wave.h b/include/wx/motif/wave.h index 272b152aa3..1b337bb7cd 100644 --- a/include/wx/motif/wave.h +++ b/include/wx/motif/wave.h @@ -22,23 +22,23 @@ class wxWave : public wxObject { public: - wxWave(); - wxWave(const wxString& fileName, bool isResource = FALSE); - ~wxWave(); - + wxWave(); + wxWave(const wxString& fileName, bool isResource = FALSE); + ~wxWave(); + public: - bool Create(const wxString& fileName, bool isResource = FALSE); - bool IsOk() const { return (m_waveData ? TRUE : FALSE); }; - bool Play(bool async = TRUE, bool looped = FALSE) const; - + bool Create(const wxString& fileName, bool isResource = FALSE); + bool IsOk() const { return (m_waveData ? TRUE : FALSE); }; + bool Play(bool async = TRUE, bool looped = FALSE) const; + protected: - bool Free(); - + bool Free(); + private: - char* m_waveData; - int m_waveLength; - bool m_isResource; + char* m_waveData; + int m_waveLength; + bool m_isResource; }; #endif - // _WX_WAVE_H_ +// _WX_WAVE_H_ diff --git a/include/wx/motif/window.h b/include/wx/motif/window.h index 0e3d3c0af8..d4cabf0cbc 100644 --- a/include/wx/motif/window.h +++ b/include/wx/motif/window.h @@ -13,7 +13,7 @@ #define _WX_WINDOW_H_ #ifdef __GNUG__ - #pragma interface "window.h" +#pragma interface "window.h" #endif #include "wx/region.h" @@ -24,93 +24,93 @@ class wxWindow : public wxWindowBase { -friend class WXDLLEXPORT wxDC; -friend class WXDLLEXPORT wxWindowDC; - + friend class WXDLLEXPORT wxDC; + friend class WXDLLEXPORT wxWindowDC; + public: wxWindow() { Init(); } - + wxWindow(wxWindow *parent, - wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxPanelNameStr) + wxWindowID id, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = 0, + const wxString& name = wxPanelNameStr) { Init(); Create(parent, id, pos, size, style, name); } - + virtual ~wxWindow(); - + bool Create(wxWindow *parent, - wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxPanelNameStr); - + wxWindowID id, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = 0, + const wxString& name = wxPanelNameStr); + // implement base class pure virtuals virtual void SetTitle( const wxString& title); virtual wxString GetTitle() const; - + virtual void Raise(); virtual void Lower(); - + virtual bool Show( bool show = TRUE ); virtual bool Enable( bool enable = TRUE ); - + virtual void SetFocus(); - + virtual void WarpPointer(int x, int y); - + virtual void Refresh( bool eraseBackground = TRUE, - const wxRect *rect = (const wxRect *) NULL ); + const wxRect *rect = (const wxRect *) NULL ); virtual void Clear(); - + virtual bool SetBackgroundColour( const wxColour &colour ); virtual bool SetForegroundColour( const wxColour &colour ); - + virtual bool SetCursor( const wxCursor &cursor ); virtual bool SetFont( const wxFont &font ); - + virtual int GetCharHeight() const; virtual int GetCharWidth() const; virtual void GetTextExtent(const wxString& string, - int *x, int *y, - int *descent = (int *) NULL, - int *externalLeading = (int *) NULL, - const wxFont *theFont = (const wxFont *) NULL) - const; - + int *x, int *y, + int *descent = (int *) NULL, + int *externalLeading = (int *) NULL, + const wxFont *theFont = (const wxFont *) NULL) + const; + virtual void SetScrollbar( int orient, int pos, int thumbVisible, - int range, bool refresh = TRUE ); + int range, bool refresh = TRUE ); virtual void SetScrollPos( int orient, int pos, bool refresh = TRUE ); virtual int GetScrollPos( int orient ) const; virtual int GetScrollThumb( int orient ) const; virtual int GetScrollRange( int orient ) const; virtual void ScrollWindow( int dx, int dy, - const wxRect* rect = (wxRect *) NULL ); - + const wxRect* rect = (wxRect *) NULL ); + virtual void SetSizeHints(int minW, int minH, - int maxW = -1, int maxH = -1, - int incW = -1, int incH = -1); + int maxW = -1, int maxH = -1, + int incW = -1, int incH = -1); #if wxUSE_DRAG_AND_DROP virtual void SetDropTarget( wxDropTarget *dropTarget ); #endif // wxUSE_DRAG_AND_DROP - + // Accept files for dragging virtual void DragAcceptFiles(bool accept); - + // Get the unique identifier of a window virtual WXWidget GetHandle() const { return GetMainWidget(); } - + // implementation from now on // -------------------------- - + // accessors // --------- - + // Get main widget for this window, e.g. a text widget virtual WXWidget GetMainWidget() const; // Get the widget that corresponds to the label (for font setting, label setting etc.) @@ -122,83 +122,83 @@ public: // multi-line text widget. Top means, top in the window hierarchy that // implements this window. virtual WXWidget GetTopWidget() const; - + // Get the underlying X window and display WXWindow GetXWindow() const; WXDisplay *GetXDisplay() const; - + // called from Motif callbacks - and should only be called from there - + void SetButton1(bool pressed) { m_button1Pressed = pressed; } void SetButton2(bool pressed) { m_button2Pressed = pressed; } void SetButton3(bool pressed) { m_button3Pressed = pressed; } - + void SetLastClick(int button, long timestamp) - { m_lastButton = button; m_lastTS = timestamp; } - + { m_lastButton = button; m_lastTS = timestamp; } + int GetLastClickedButton() const { return m_lastButton; } long GetLastClickTime() const { return m_lastTS; } - + // Gives window a chance to do something in response to a size message, e.g. // arrange status bar, toolbar etc. virtual bool PreResize(); - + // Generates a paint event virtual void DoPaint(); - + // update rectangle/region manipulation // (for wxWindowDC and Motif callbacks only) // ----------------------------------------- - + // read/write access to the update rect list const wxRectList& GetUpdateRects() const { return m_updateRects; } - + // Adds a recangle to the updates list void AddUpdateRect(int x, int y, int w, int h) - { m_updateRects.Append(new wxRect(x, y, w, h)); } - + { m_updateRects.Append(new wxRect(x, y, w, h)); } + // Empties the m_updateRects list void ClearUpdateRects(); - + void ClearUpdateRegion() { m_updateRegion.Clear(); } void SetUpdateRegion(const wxRegion& region) { m_updateRegion = region; } - + // sets the fore/background colour for the given widget static void DoChangeForegroundColour(WXWidget widget, wxColour& foregroundColour); static void DoChangeBackgroundColour(WXWidget widget, wxColour& backgroundColour, bool changeArmColour = FALSE); - + // For implementation purposes - sometimes decorations make the client area // smaller virtual wxPoint GetClientAreaOrigin() const; - + protected: // event handlers (not virtual by design) void OnIdle(wxIdleEvent& event); - + // Makes an adjustment to the window position (for example, a frame that has // a toolbar that it manages itself). virtual void AdjustForParentClientOrigin(int& x, int& y, int sizeFlags); - + wxWindow *GetChild(int number) const - { return GetChildren().Item(number)->GetData(); } - + { return GetChildren().Item(number)->GetData(); } + // Responds to colour changes: passes event on to children. void OnSysColourChanged(wxSysColourChangedEvent& event); - + // Motif-specific - - // CanvasXXXSiize functions + + // CanvasXXXSiize functions void CanvasGetSize(int* width, int* height) const; // If have drawing area void CanvasGetClientSize(int *width, int *height) const; void CanvasGetPosition(int *x, int *y) const; // If have drawing area void CanvasSetClientSize(int width, int size); void CanvasSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO); - + void SetMainWidget(WXWidget w) { m_mainWidget = w; } - + bool CanAddEventHandler() const { return m_canAddEventHandler; } void SetCanAddEventHandler(bool flag) { m_canAddEventHandler = flag; } - + public: WXPixmap GetBackingPixmap() const { return m_backingPixmap; } void SetBackingPixmap(WXPixmap pixmap) { m_backingPixmap = pixmap; } @@ -206,22 +206,22 @@ public: int GetPixmapHeight() const { return m_pixmapHeight; } void SetPixmapWidth(int w) { m_pixmapWidth = w; } void SetPixmapHeight(int h) { m_pixmapHeight = h; } - + // Change properties virtual void ChangeFont(bool keepOriginalSize = TRUE); // Change to the current font (often overridden) - + // Change background and foreground colour using current background colour // setting (Motif generates foreground based on background) virtual void ChangeBackgroundColour(); // Change foreground colour using current foreground colour setting virtual void ChangeForegroundColour(); - + protected: // Adds the widget to the hash table and adds event handlers. bool AttachWidget(wxWindow* parent, WXWidget mainWidget, - WXWidget formWidget, int x, int y, int width, int height); + WXWidget formWidget, int x, int y, int width, int height); bool DetachWidget(WXWidget widget); - + // How to implement accelerators. If we find a key event, translate to // wxWindows wxKeyEvent form. Find a widget for the window. Now find a // wxWindow for the widget. If there isn't one, go up the widget hierarchy @@ -240,22 +240,22 @@ public: protected: // unmanage and destroy an X widget f it's !NULL (passing NULL is ok) void UnmanageAndDestroy(WXWidget widget); - + // map or unmap an X widget (passing NULL is ok), returns TRUE if widget was // mapped/unmapped bool MapOrUnmap(WXWidget widget, bool map); - + // scrolling stuff // --------------- - + // create/destroy window scrollbars void CreateScrollbar(wxOrientation orientation); void DestroyScrollbar(wxOrientation orientation); - + // get either hor or vert scrollbar widget WXWidget GetScrollbar(wxOrientation orient) const - { return orient == wxHORIZONTAL ? m_hScrollBar : m_vScrollBar; } - + { return orient == wxHORIZONTAL ? m_hScrollBar : m_vScrollBar; } + // set the scroll pos void SetInternalScrollPos(wxOrientation orient, int pos) { @@ -264,23 +264,23 @@ protected: else m_scrollPosY = pos; } - + // Motif-specific flags // -------------------- - + bool m_needsRefresh:1; // repaint backing store? bool m_canAddEventHandler:1; // ??? bool m_button1Pressed:1; bool m_button2Pressed:1; bool m_button3Pressed:1; - + // For double-click detection long m_lastTS; // last timestamp int m_lastButton; // last pressed button - + // List of wxRects representing damaged region wxRectList m_updateRects; - + protected: WXWidget m_mainWidget; WXWidget m_hScrollBar; @@ -296,12 +296,12 @@ protected: int m_pixmapHeight; int m_pixmapOffsetX; int m_pixmapOffsetY; - + // Store the last scroll pos, since in wxWin the pos isn't set automatically // by system int m_scrollPosX; int m_scrollPosY; - + // implement the base class pure virtuals virtual void DoClientToScreen( int *x, int *y ) const; virtual void DoScreenToClient( int *x, int *y ) const; @@ -309,23 +309,23 @@ protected: virtual void DoGetSize( int *width, int *height ) const; virtual void DoGetClientSize( int *width, int *height ) const; virtual void DoSetSize(int x, int y, - int width, int height, - int sizeFlags = wxSIZE_AUTO); + int width, int height, + int sizeFlags = wxSIZE_AUTO); virtual void DoSetClientSize(int width, int height); virtual void DoMoveWindow(int x, int y, int width, int height); virtual bool DoPopupMenu(wxMenu *menu, int x, int y); - + virtual void DoCaptureMouse(); virtual void DoReleaseMouse(); - + #if wxUSE_TOOLTIPS virtual void DoSetToolTip( wxToolTip *tip ); #endif // wxUSE_TOOLTIPS - + private: // common part of all ctors void Init(); - + DECLARE_DYNAMIC_CLASS(wxWindow) DECLARE_NO_COPY_CLASS(wxWindow) DECLARE_EVENT_TABLE() @@ -345,14 +345,14 @@ private: class WXDLLEXPORT wxNoOptimize { public: - wxNoOptimize() { ms_count++; } - ~wxNoOptimize() { ms_count--; } - - static bool CanOptimize() { return ms_count == 0; } - + wxNoOptimize() { ms_count++; } + ~wxNoOptimize() { ms_count--; } + + static bool CanOptimize() { return ms_count == 0; } + protected: - static int ms_count; + static int ms_count; }; #endif - // _WX_WINDOW_H_ +// _WX_WINDOW_H_ diff --git a/include/wx/palette.h b/include/wx/palette.h index dc29333be0..39f86eb11d 100644 --- a/include/wx/palette.h +++ b/include/wx/palette.h @@ -12,6 +12,8 @@ #include "wx/motif/palette.h" #elif defined(__WXGTK__) #include "wx/generic/paletteg.h" +#elif defined(__WXX11__) + #include "wx/x11/palette.h" #elif defined(__WXMGL__) #include "wx/mgl/palette.h" #elif defined(__WXMAC__) diff --git a/include/wx/pen.h b/include/wx/pen.h index 5cef9c390e..499dc5d9ce 100644 --- a/include/wx/pen.h +++ b/include/wx/pen.h @@ -7,6 +7,8 @@ #include "wx/motif/pen.h" #elif defined(__WXGTK__) #include "wx/gtk/pen.h" +#elif defined(__WXX11__) +#include "wx/x11/pen.h" #elif defined(__WXMGL__) #include "wx/mgl/pen.h" #elif defined(__WXMAC__) diff --git a/include/wx/popupwin.h b/include/wx/popupwin.h index ec8bc16b04..27779f3484 100644 --- a/include/wx/popupwin.h +++ b/include/wx/popupwin.h @@ -55,6 +55,8 @@ public: #include "wx/os2/popupwin.h" #elif __WXGTK__ #include "wx/gtk/popupwin.h" +#ifdef __WXX11__ + #include "wx/x11/popupwin.h" #elif __WXMGL__ #include "wx/mgl/popupwin.h" #else diff --git a/include/wx/printdlg.h b/include/wx/printdlg.h index 7260859147..e92e2f52f4 100644 --- a/include/wx/printdlg.h +++ b/include/wx/printdlg.h @@ -7,6 +7,8 @@ #include "wx/generic/prntdlgg.h" #elif defined(__WXGTK__) #include "wx/generic/prntdlgg.h" +#elif defined(__WXX11__) +#include "wx/generic/prntdlgg.h" #elif defined(__WXMAC__) #include "wx/mac/printdlg.h" #elif defined(__WXPM__) diff --git a/include/wx/region.h b/include/wx/region.h index fc75ad05eb..3815353f1e 100644 --- a/include/wx/region.h +++ b/include/wx/region.h @@ -7,6 +7,8 @@ #include "wx/motif/region.h" #elif defined(__WXGTK__) #include "wx/gtk/region.h" +#elif defined(__WXX11__) +#include "wx/x11/region.h" #elif defined(__WXMGL__) #include "wx/mgl/region.h" #elif defined(__WXMAC__) diff --git a/include/wx/timer.h b/include/wx/timer.h index b5ce8d830c..b5b5cfab04 100644 --- a/include/wx/timer.h +++ b/include/wx/timer.h @@ -107,6 +107,8 @@ protected: #include "wx/motif/timer.h" #elif defined(__WXGTK__) #include "wx/gtk/timer.h" +#elif defined(__WXX11__) + #include "wx/x11/timer.h" #elif defined(__WXMGL__) #include "wx/mgl/timer.h" #elif defined(__WXMAC__) diff --git a/include/wx/toolbar.h b/include/wx/toolbar.h index e7872223aa..25f71277cb 100644 --- a/include/wx/toolbar.h +++ b/include/wx/toolbar.h @@ -43,6 +43,8 @@ #include "wx/motif/toolbar.h" #elif defined(__WXGTK__) #include "wx/gtk/tbargtk.h" + #elif defined(__WXX11__) + #include "wx/x11/toolbar.h" #elif defined(__WXMAC__) #include "wx/mac/toolbar.h" #elif defined(__WXPM__) diff --git a/include/wx/toplevel.h b/include/wx/toplevel.h index 44d3a45f8a..51caf5929d 100644 --- a/include/wx/toplevel.h +++ b/include/wx/toplevel.h @@ -158,6 +158,9 @@ protected: #elif defined(__WXGTK__) #include "wx/gtk/toplevel.h" #define wxTopLevelWindowNative wxTopLevelWindowGTK +#elif defined(__WXX11__) + #include "wx/x11/toplevel.h" + #define wxTopLevelWindowNative wxTopLevelWindowX11 #elif defined(__WXMGL__) #include "wx/mgl/toplevel.h" #define wxTopLevelWindowNative wxTopLevelWindowMGL diff --git a/include/wx/window.h b/include/wx/window.h index 80ced6d6ab..0fd38143f0 100644 --- a/include/wx/window.h +++ b/include/wx/window.h @@ -977,6 +977,14 @@ private: #define sm_classwxWindowGTK sm_classwxWindow #endif // wxUniv #include "wx/gtk/window.h" +#elif defined(__WXX11__) + #ifdef __WXUNIVERSAL__ + #define wxWindowNative wxWindowX11 + #else // !wxUniv + #define wxWindowX11 wxWindow + #define sm_classwxWindowX11 sm_classwxWindow + #endif // wxUniv + #include "wx/x11/window.h" #elif defined(__WXMGL__) #ifdef __WXUNIVERSAL__ #define wxWindowNative wxWindowMGL diff --git a/include/wx/x11/accel.h b/include/wx/x11/accel.h new file mode 100644 index 0000000000..6b61e38b12 --- /dev/null +++ b/include/wx/x11/accel.h @@ -0,0 +1,51 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: accel.h +// Purpose: wxAcceleratorTable class +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_ACCEL_H_ +#define _WX_ACCEL_H_ + +#ifdef __GNUG__ +#pragma interface "accel.h" +#endif + +#include "wx/object.h" +#include "wx/string.h" +#include "wx/event.h" + +class WXDLLEXPORT wxAcceleratorTable: public wxObject +{ + DECLARE_DYNAMIC_CLASS(wxAcceleratorTable) +public: + wxAcceleratorTable(); + wxAcceleratorTable(const wxString& resource); // Load from .rc resource + wxAcceleratorTable(int n, wxAcceleratorEntry entries[]); // Load from array + + // Copy constructors + wxAcceleratorTable(const wxAcceleratorTable& accel) { Ref(accel); } + wxAcceleratorTable(const wxAcceleratorTable* accel) { if (accel) Ref(*accel); } + + ~wxAcceleratorTable(); + + wxAcceleratorTable& operator = (const wxAcceleratorTable& accel) { if (*this == accel) return (*this); Ref(accel); return *this; } + bool operator == (const wxAcceleratorTable& accel) { return m_refData == accel.m_refData; } + bool operator != (const wxAcceleratorTable& accel) { return m_refData != accel.m_refData; } + + bool Ok() const; + + // Implementation only + int GetCount() const; + wxAcceleratorEntry* GetEntries() const; +}; + +WXDLLEXPORT_DATA(extern wxAcceleratorTable) wxNullAcceleratorTable; + +#endif +// _WX_ACCEL_H_ diff --git a/include/wx/x11/app.h b/include/wx/x11/app.h new file mode 100644 index 0000000000..d3bc19d40b --- /dev/null +++ b/include/wx/x11/app.h @@ -0,0 +1,131 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: app.h +// Purpose: wxApp class +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_APP_H_ +#define _WX_APP_H_ + +#ifdef __GNUG__ +#pragma interface "app.h" +#endif + +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- + +#include "wx/gdicmn.h" +#include "wx/event.h" + +// ---------------------------------------------------------------------------- +// forward declarations +// ---------------------------------------------------------------------------- + +class WXDLLEXPORT wxFrame; +class WXDLLEXPORT wxWindow; +class WXDLLEXPORT wxApp; +class WXDLLEXPORT wxKeyEvent; +class WXDLLEXPORT wxLog; + +// ---------------------------------------------------------------------------- +// the wxApp class for Motif - see wxAppBase for more details +// ---------------------------------------------------------------------------- + +class WXDLLEXPORT wxApp : public wxAppBase +{ + DECLARE_DYNAMIC_CLASS(wxApp) + +public: + wxApp(); + ~wxApp() {} + + // override base class (pure) virtuals + // ----------------------------------- + + virtual int MainLoop(); + virtual void ExitMainLoop(); + virtual bool Initialized(); + virtual bool Pending(); + virtual void Dispatch(); + virtual bool Yield(bool onlyIfNeeded = FALSE); + + virtual bool OnInitGui(); + + virtual wxIcon GetStdIcon(int which) const; + + // implementation from now on + // -------------------------- + + void OnIdle(wxIdleEvent& event); + + // Send idle event to all top-level windows. + // Returns TRUE if more idle time is requested. + bool SendIdleEvents(); + + // Send idle event to window and all subwindows + // Returns TRUE if more idle time is requested. + bool SendIdleEvents(wxWindow* win); + + // Motif implementation. + + // Processes an X event. + virtual void ProcessXEvent(WXEvent* event); + + // Returns TRUE if an accelerator has been processed + virtual bool CheckForAccelerator(WXEvent* event); + + // Returns TRUE if a key down event has been processed + virtual bool CheckForKeyDown(WXEvent* event); + + // Returns TRUE if a key up event has been processed + virtual bool CheckForKeyUp(WXEvent* event); + +protected: + bool m_showOnInit; + +public: + // Implementation + static bool Initialize(); + static void CleanUp(); + + void DeletePendingObjects(); + bool ProcessIdle(); + + // Motif-specific + WXAppContext GetAppContext() const { return m_appContext; } + WXWidget GetTopLevelWidget() const { return m_topLevelWidget; } + WXColormap GetMainColormap(WXDisplay* display); + WXDisplay* GetInitialDisplay() const { return m_initialDisplay; } + long GetMaxRequestSize() const { return m_maxRequestSize; } + + // This handler is called when a property change event occurs + virtual void HandlePropertyChange(WXEvent *event); + +public: + static long sm_lastMessageTime; + int m_nCmdShow; + +protected: + bool m_keepGoing; + + // Motif-specific + WXAppContext m_appContext; + WXWidget m_topLevelWidget; + WXColormap m_mainColormap; + WXDisplay* m_initialDisplay; + long m_maxRequestSize; + + DECLARE_EVENT_TABLE() +}; + +int WXDLLEXPORT wxEntry( int argc, char *argv[] ); + +#endif +// _WX_APP_H_ + diff --git a/include/wx/x11/bitmap.h b/include/wx/x11/bitmap.h new file mode 100644 index 0000000000..23f8bcd9be --- /dev/null +++ b/include/wx/x11/bitmap.h @@ -0,0 +1,230 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: bitmap.h +// Purpose: wxBitmap class +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_BITMAP_H_ +#define _WX_BITMAP_H_ + +#ifdef __GNUG__ +#pragma interface "bitmap.h" +#endif + +#include "wx/gdiobj.h" +#include "wx/gdicmn.h" +#include "wx/palette.h" + +// Bitmap +class WXDLLEXPORT wxDC; +class WXDLLEXPORT wxControl; +class WXDLLEXPORT wxBitmap; +class WXDLLEXPORT wxBitmapHandler; +class WXDLLEXPORT wxIcon; +class WXDLLEXPORT wxCursor; +class WXDLLEXPORT wxImage; + +// A mask is a mono bitmap used for drawing bitmaps +// transparently. +class WXDLLEXPORT wxMask: public wxObject +{ + DECLARE_DYNAMIC_CLASS(wxMask) + +public: + wxMask(); + + // Construct a mask from a bitmap and a colour indicating + // the transparent area + wxMask(const wxBitmap& bitmap, const wxColour& colour); + + // Construct a mask from a bitmap and a palette index indicating + // the transparent area + wxMask(const wxBitmap& bitmap, int paletteIndex); + + // Construct a mask from a mono bitmap (copies the bitmap). + wxMask(const wxBitmap& bitmap); + + ~wxMask(); + + bool Create(const wxBitmap& bitmap, const wxColour& colour); + bool Create(const wxBitmap& bitmap, int paletteIndex); + bool Create(const wxBitmap& bitmap); + + WXPixmap GetPixmap() const { return m_pixmap; } + void SetPixmap(WXPixmap pixmap) { m_pixmap = pixmap; } + +protected: + WXPixmap m_pixmap; +}; + +class WXDLLEXPORT wxBitmapRefData: public wxGDIRefData +{ + friend class WXDLLEXPORT wxBitmap; + friend class WXDLLEXPORT wxIcon; + friend class WXDLLEXPORT wxCursor; +public: + wxBitmapRefData(); + ~wxBitmapRefData(); + +public: + int m_width; + int m_height; + int m_depth; + bool m_ok; + int m_numColors; + wxPalette m_bitmapPalette; + int m_quality; + + wxMask * m_bitmapMask; // Optional mask + + // Motif implementation +public: + WXPixmap m_pixmap; + WXDisplay* m_display; + bool m_freePixmap; + unsigned long* m_freeColors; + long m_freeColorsCount; + + // These 5 variables are for wxControl + WXPixmap m_insensPixmap ; + WXPixmap m_labelPixmap ; + WXPixmap m_armPixmap ; + WXImage* m_image ; + WXImage* m_insensImage ; +}; + +#define M_BITMAPDATA ((wxBitmapRefData *)m_refData) + +class WXDLLEXPORT wxBitmapHandler: public wxObject +{ + DECLARE_DYNAMIC_CLASS(wxBitmapHandler) +public: + wxBitmapHandler() { m_name = ""; m_extension = ""; m_type = 0; }; + + virtual bool Create(wxBitmap *bitmap, void *data, long flags, int width, int height, int depth = 1); + virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags, + int desiredWidth, int desiredHeight); + virtual bool SaveFile(wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette = NULL); + + void SetName(const wxString& name) { m_name = name; } + void SetExtension(const wxString& ext) { m_extension = ext; } + void SetType(long type) { m_type = type; } + wxString GetName() const { return m_name; } + wxString GetExtension() const { return m_extension; } + long GetType() const { return m_type; } +protected: + wxString m_name; + wxString m_extension; + long m_type; +}; + +#define M_BITMAPHANDLERDATA ((wxBitmapRefData *)bitmap->GetRefData()) + +class WXDLLEXPORT wxBitmap: public wxGDIObject +{ + DECLARE_DYNAMIC_CLASS(wxBitmap) + + friend class WXDLLEXPORT wxBitmapHandler; + +public: + wxBitmap(); // Platform-specific + + // Copy constructors + wxBitmap(const wxBitmap& bitmap) + { Ref(bitmap); } + + // Initialize with raw XBM data + wxBitmap(const char bits[], int width, int height, int depth = 1); + + // from XPM + wxBitmap(const char **data) { (void)CreateFromXpm(data); } + wxBitmap(char **data) { (void)CreateFromXpm((const char **)data); } + + // Initialize with XPM data -- deprecated + wxBitmap(char **data, wxControl* control); + + // Load a file or resource + wxBitmap(const wxString& name, long type = wxBITMAP_TYPE_XPM); + + // Constructor for generalised creation from data + wxBitmap(void *data, long type, int width, int height, int depth = 1); + + // If depth is omitted, will create a bitmap compatible with the display + wxBitmap(int width, int height, int depth = -1); + + // Convert from wxImage: + wxBitmap(const wxImage& image, int depth = -1) { (void)CreateFromImage(image, depth); } + + ~wxBitmap(); + + virtual bool Create(int width, int height, int depth = -1); + virtual bool Create(void *data, long type, int width, int height, int depth = 1); + + wxBitmap GetSubBitmap( const wxRect& rect ) const; + + virtual bool LoadFile(const wxString& name, long type = wxBITMAP_TYPE_XPM); + virtual bool SaveFile(const wxString& name, int type, const wxPalette *cmap = NULL); + + wxImage ConvertToImage() const; + + bool Ok() const { return (M_BITMAPDATA && M_BITMAPDATA->m_ok); } + int GetWidth() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_width : 0); } + int GetHeight() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_height : 0); } + int GetDepth() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_depth : 0); } + int GetQuality() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_quality : 0); } + void SetWidth(int w); + void SetHeight(int h); + void SetDepth(int d); + void SetQuality(int q); + void SetOk(bool isOk); + + wxPalette* GetPalette() const { return (M_BITMAPDATA ? (& M_BITMAPDATA->m_bitmapPalette) : (wxPalette*) NULL); } + void SetPalette(const wxPalette& palette); + + wxMask *GetMask() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_bitmapMask : (wxMask*) NULL); } + void SetMask(wxMask *mask) ; + + wxBitmap& operator = (const wxBitmap& bitmap) { if (*this == bitmap) return (*this); Ref(bitmap); return *this; } + bool operator == (const wxBitmap& bitmap) const { return m_refData == bitmap.m_refData; } + bool operator != (const wxBitmap& bitmap) const { return m_refData != bitmap.m_refData; } + + // Format handling + static wxList& GetHandlers() { return sm_handlers; } + static void AddHandler(wxBitmapHandler *handler); + static void InsertHandler(wxBitmapHandler *handler); + static bool RemoveHandler(const wxString& name); + static wxBitmapHandler *FindHandler(const wxString& name); + static wxBitmapHandler *FindHandler(const wxString& extension, long bitmapType); + static wxBitmapHandler *FindHandler(long bitmapType); + + static void InitStandardHandlers(); + static void CleanUpHandlers(); + + // Motif implementation +public: + WXDisplay* GetDisplay() const { return M_BITMAPDATA->m_display; } + WXPixmap GetPixmap() const { return (WXPixmap) M_BITMAPDATA->m_pixmap; } + virtual WXPixmap GetLabelPixmap(WXWidget w) ; + virtual WXPixmap GetArmPixmap(WXWidget w) ; + virtual WXPixmap GetInsensPixmap(WXWidget w = (WXWidget) 0) ; + void SetPixmapNull() { M_BITMAPDATA->m_pixmap = 0; } + +protected: + static wxList sm_handlers; + +protected: + bool CreateFromXpm(const char **bits); + bool CreateFromImage(const wxImage& image, int depth); +}; + +// Creates a bitmap with transparent areas drawn in +// the given colour. +wxBitmap wxCreateMaskedBitmap(const wxBitmap& bitmap, wxColour& colour); + +#endif +// _WX_BITMAP_H_ diff --git a/include/wx/x11/brush.h b/include/wx/x11/brush.h new file mode 100644 index 0000000000..513d7fc9c3 --- /dev/null +++ b/include/wx/x11/brush.h @@ -0,0 +1,79 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: brush.h +// Purpose: wxBrush class +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_BRUSH_H_ +#define _WX_BRUSH_H_ + +#ifdef __GNUG__ +#pragma interface "brush.h" +#endif + +#include "wx/gdicmn.h" +#include "wx/gdiobj.h" +#include "wx/bitmap.h" + +class WXDLLEXPORT wxBrush; + +class WXDLLEXPORT wxBrushRefData: public wxGDIRefData +{ + friend class WXDLLEXPORT wxBrush; +public: + wxBrushRefData(); + wxBrushRefData(const wxBrushRefData& data); + ~wxBrushRefData(); + +protected: + int m_style; + wxBitmap m_stipple ; + wxColour m_colour; +}; + +#define M_BRUSHDATA ((wxBrushRefData *)m_refData) + +// Brush +class WXDLLEXPORT wxBrush: public wxGDIObject +{ + DECLARE_DYNAMIC_CLASS(wxBrush) + +public: + wxBrush(); + wxBrush(const wxColour& col, int style); + wxBrush(const wxBitmap& stipple); + inline wxBrush(const wxBrush& brush) { Ref(brush); } + ~wxBrush(); + + virtual void SetColour(const wxColour& col) ; + virtual void SetColour(unsigned char r, unsigned char g, unsigned char b) ; + virtual void SetStyle(int style) ; + virtual void SetStipple(const wxBitmap& stipple) ; + + inline wxBrush& operator = (const wxBrush& brush) { if (*this == brush) return (*this); Ref(brush); return *this; } + inline bool operator == (const wxBrush& brush) const { return m_refData == brush.m_refData; } + inline bool operator != (const wxBrush& brush) const { return m_refData != brush.m_refData; } + + inline wxColour& GetColour() const { return (M_BRUSHDATA ? M_BRUSHDATA->m_colour : wxNullColour); }; + inline int GetStyle() const { return (M_BRUSHDATA ? M_BRUSHDATA->m_style : 0); }; + inline wxBitmap *GetStipple() const { return (M_BRUSHDATA ? & M_BRUSHDATA->m_stipple : 0); }; + + virtual bool Ok() const { return (m_refData != NULL) ; } + + // Implementation + + // Useful helper: create the brush resource + bool RealizeResource(); + + // When setting properties, we must make sure we're not changing + // another object + void Unshare(); +}; + +#endif +// _WX_BRUSH_H_ diff --git a/include/wx/x11/clipbrd.h b/include/wx/x11/clipbrd.h new file mode 100644 index 0000000000..848bfe6565 --- /dev/null +++ b/include/wx/x11/clipbrd.h @@ -0,0 +1,84 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: clipbrd.h +// Purpose: Clipboard functionality. +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_CLIPBRD_H_ +#define _WX_CLIPBRD_H_ + +#ifdef __GNUG__ +#pragma interface "clipbrd.h" +#endif + +#if wxUSE_CLIPBOARD + +#include "wx/list.h" + +bool WXDLLEXPORT wxOpenClipboard(); +bool WXDLLEXPORT wxClipboardOpen(); +bool WXDLLEXPORT wxCloseClipboard(); +bool WXDLLEXPORT wxEmptyClipboard(); +bool WXDLLEXPORT wxIsClipboardFormatAvailable(wxDataFormat dataFormat); +bool WXDLLEXPORT wxSetClipboardData(wxDataFormat dataFormat, wxObject *obj, int width = 0, int height = 0); +wxObject* WXDLLEXPORT wxGetClipboardData(wxDataFormat dataFormat, long *len = NULL); +wxDataFormat WXDLLEXPORT wxEnumClipboardFormats(wxDataFormat dataFormat); +wxDataFormat WXDLLEXPORT wxRegisterClipboardFormat(char *formatName); +bool WXDLLEXPORT wxGetClipboardFormatName(wxDataFormat dataFormat, char *formatName, int maxCount); + +//----------------------------------------------------------------------------- +// wxClipboard +//----------------------------------------------------------------------------- + +class wxClipboard : public wxClipboardBase +{ +public: + wxClipboard(); + ~wxClipboard(); + + // open the clipboard before SetData() and GetData() + virtual bool Open(); + + // close the clipboard after SetData() and GetData() + virtual void Close(); + + // opened? + virtual bool IsOpened() const { return m_open; } + + // replaces the data on the clipboard with data + virtual bool SetData( wxDataObject *data ); + + // adds data to the clipboard + virtual bool AddData( wxDataObject *data ); + + // format available on the clipboard ? + virtual bool IsSupported( const wxDataFormat& format ); + + // fill data with data on the clipboard (if available) + virtual bool GetData( wxDataObject& data ); + + // clears wxTheClipboard and the system's clipboard if possible + virtual void Clear(); + + virtual void UsePrimarySelection(bool primary = TRUE) + { m_usePrimary = primary; } + + // implementation from now on + + bool m_open; + wxList m_data; + bool m_usePrimary; + +private: + DECLARE_DYNAMIC_CLASS(wxClipboard) +}; + +#endif // wxUSE_CLIPBOARD + +#endif +// _WX_CLIPBRD_H_ diff --git a/include/wx/x11/colour.h b/include/wx/x11/colour.h new file mode 100644 index 0000000000..0a3409aa7b --- /dev/null +++ b/include/wx/x11/colour.h @@ -0,0 +1,92 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: colour.h +// Purpose: wxColour class +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_COLOUR_H_ +#define _WX_COLOUR_H_ + +#ifdef __GNUG__ +#pragma interface "colour.h" +#endif + +#include "wx/object.h" +#include "wx/string.h" + +// Colour +class WXDLLEXPORT wxColour : public wxObject +{ + DECLARE_DYNAMIC_CLASS(wxColour) +public: + // ctors + // default + wxColour(); + // from RGB + wxColour( unsigned char red, unsigned char green, unsigned char blue ); + wxColour( unsigned long colRGB ) { Set(colRGB); } + + // implicit conversion from the colour name + wxColour( const wxString &colourName ) { InitFromName(colourName); } + wxColour( const char *colourName ) { InitFromName(colourName); } + + // copy ctors and assignment operators + wxColour( const wxColour& col ); + wxColour& operator = ( const wxColour& col ); + + // dtor + ~wxColour(); + + // Set() functions + void Set( unsigned char red, unsigned char green, unsigned char blue ); + void Set( unsigned long colRGB ) + { + // we don't need to know sizeof(long) here because we assume that the three + // least significant bytes contain the R, G and B values + Set((unsigned char)colRGB, + (unsigned char)(colRGB >> 8), + (unsigned char)(colRGB >> 16)); + } + + // 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) const { return (m_red == colour.m_red && m_green == colour.m_green && m_blue == colour.m_blue); } + + inline bool operator != (const wxColour& colour) const { 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. + // Returns the allocated pixel. + + // TODO: can this handle mono displays? If not, we should have an extra + // flag to specify whether this should be black or white by default. + + int AllocColour(WXDisplay* display, bool realloc = FALSE); + + void InitFromName(const wxString& col); + +private: + bool m_isInit; + unsigned char m_red; + unsigned char m_blue; + unsigned char m_green; + +public: + int m_pixel; +}; + +#endif +// _WX_COLOUR_H_ diff --git a/include/wx/x11/cursor.h b/include/wx/x11/cursor.h new file mode 100644 index 0000000000..c1d3bce5c3 --- /dev/null +++ b/include/wx/x11/cursor.h @@ -0,0 +1,84 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: cursor.h +// Purpose: wxCursor class +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_CURSOR_H_ +#define _WX_CURSOR_H_ + +#ifdef __GNUG__ +#pragma interface "cursor.h" +#endif + +#include "wx/bitmap.h" + +/* Cursor for one display, so we can choose the correct one for +* the current display. +*/ +class wxXCursor : public wxObject +{ + DECLARE_DYNAMIC_CLASS(wxXCursor) + +public: + WXDisplay* m_display; + WXCursor m_cursor; +}; + +class WXDLLEXPORT wxCursorRefData: public wxBitmapRefData +{ + friend class WXDLLEXPORT wxBitmap; + friend class WXDLLEXPORT wxCursor; +public: + wxCursorRefData(); + ~wxCursorRefData(); + + wxList m_cursors; // wxXCursor objects, one per display + wxStockCursor m_cursorId; // wxWindows standard cursor id +}; + +#define M_CURSORDATA ((wxCursorRefData *)m_refData) +#define M_CURSORHANDLERDATA ((wxCursorRefData *)bitmap->m_refData) + +// Cursor +class WXDLLEXPORT wxCursor: public wxBitmap +{ + DECLARE_DYNAMIC_CLASS(wxCursor) + +public: + wxCursor(); + + // Copy constructors + wxCursor(const wxCursor& cursor) { Ref(cursor); } + + wxCursor(const char bits[], int width, int height, int hotSpotX = -1, int hotSpotY = -1, + const char maskBits[] = NULL); + + wxCursor(const wxString& name, long flags = wxBITMAP_TYPE_XBM, + int hotSpotX = 0, int hotSpotY = 0); + + wxCursor(wxStockCursor id); + ~wxCursor(); + + virtual bool Ok() const { return ((m_refData != NULL) && M_CURSORDATA->m_ok); } + + wxCursor& operator = (const wxCursor& cursor) { if (*this == cursor) return (*this); Ref(cursor); return *this; } + bool operator == (const wxCursor& cursor) const { return m_refData == cursor.m_refData; } + bool operator != (const wxCursor& cursor) const { return m_refData != cursor.m_refData; } + + // Motif-specific. + // Create/get a cursor for the current display + WXCursor GetXCursor(WXDisplay* display) ; + // Make a cursor from standard id + WXCursor MakeCursor(WXDisplay* display, wxStockCursor id); +}; + +extern WXDLLEXPORT void wxSetCursor(const wxCursor& cursor); + +#endif +// _WX_CURSOR_H_ diff --git a/include/wx/x11/dataform.h b/include/wx/x11/dataform.h new file mode 100644 index 0000000000..eebf507e23 --- /dev/null +++ b/include/wx/x11/dataform.h @@ -0,0 +1,66 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: motif/dataform.h +// Purpose: declaration of the wxDataFormat class +// Author: Robert Roebling +// Modified by: +// Created: 19.10.99 (extracted from motif/dataobj.h) +// RCS-ID: $Id$ +// Copyright: (c) 1999 Robert Roebling +// Licence: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_MOTIF_DATAFORM_H +#define _WX_MOTIF_DATAFORM_H + +class wxDataFormat +{ +public: + // the clipboard formats under Xt are Atoms + typedef Atom NativeFormat; + + wxDataFormat(); + wxDataFormat( wxDataFormatId type ); + wxDataFormat( const wxString &id ); + wxDataFormat( const wxChar *id ); + wxDataFormat( NativeFormat format ); + + wxDataFormat& operator=(NativeFormat format) + { SetId(format); return *this; } + + // comparison (must have both versions) + bool operator==(NativeFormat format) const + { return m_format == (NativeFormat)format; } + bool operator!=(NativeFormat format) const + { return m_format != (NativeFormat)format; } + bool operator==(wxDataFormatId format) const + { return m_type == (wxDataFormatId)format; } + bool operator!=(wxDataFormatId format) const + { return m_type != (wxDataFormatId)format; } + + // explicit and implicit conversions to NativeFormat which is one of + // standard data types (implicit conversion is useful for preserving the + // compatibility with old code) + NativeFormat GetFormatId() const { return m_format; } + operator NativeFormat() const { return m_format; } + + void SetId( NativeFormat format ); + + // string ids are used for custom types - this SetId() must be used for + // application-specific formats + wxString GetId() const; + void SetId( const wxChar *id ); + + // implementation + wxDataFormatId GetType() const; + +private: + wxDataFormatId m_type; + NativeFormat m_format; + + void PrepareFormats(); + void SetType( wxDataFormatId type ); +}; + + +#endif // _WX_MOTIF_DATAFORM_H + diff --git a/include/wx/x11/dataobj.h b/include/wx/x11/dataobj.h new file mode 100644 index 0000000000..77064e648d --- /dev/null +++ b/include/wx/x11/dataobj.h @@ -0,0 +1,30 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: wx/motif/dataobj.h +// Purpose: declaration of the wxDataObject class for Motif +// Author: Julian Smart +// RCS-ID: $Id$ +// Copyright: (c) 1998 Julian Smart +// Licence: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_MOTIF_DATAOBJ_H_ +#define _WX_MOTIF_DATAOBJ_H_ + +#ifdef __GNUG__ +#pragma interface "dataobj.h" +#endif + +// ---------------------------------------------------------------------------- +// wxDataObject is the same as wxDataObjectBase under wxMotif +// ---------------------------------------------------------------------------- + +class wxDataObject : public wxDataObjectBase +{ +public: +#ifdef __DARWIN__ + ~wxDataObject() { } +#endif +}; + +#endif //_WX_MOTIF_DATAOBJ_H_ + diff --git a/include/wx/x11/dc.h b/include/wx/x11/dc.h new file mode 100644 index 0000000000..f456f8d57f --- /dev/null +++ b/include/wx/x11/dc.h @@ -0,0 +1,168 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dc.h +// Purpose: wxDC class +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_DC_H_ +#define _WX_DC_H_ + +#ifdef __GNUG__ +#pragma interface "dc.h" +#endif + +#include "wx/pen.h" +#include "wx/brush.h" +#include "wx/icon.h" +#include "wx/font.h" +#include "wx/gdicmn.h" + +//----------------------------------------------------------------------------- +// constants +//----------------------------------------------------------------------------- + +#ifndef MM_TEXT +#define MM_TEXT 0 +#define MM_ISOTROPIC 1 +#define MM_ANISOTROPIC 2 +#define MM_LOMETRIC 3 +#define MM_HIMETRIC 4 +#define MM_TWIPS 5 +#define MM_POINTS 6 +#define MM_METRIC 7 +#endif + +//----------------------------------------------------------------------------- +// wxDC +//----------------------------------------------------------------------------- + +class WXDLLEXPORT wxDC : public wxDCBase +{ + DECLARE_DYNAMIC_CLASS(wxDC) + +public: + wxDC(); + ~wxDC() { } + + // implement base class pure virtuals + // ---------------------------------- + + virtual void DestroyClippingRegion(); + + virtual wxSize GetPPI() const; + + virtual void SetMapMode(int mode); + virtual void SetUserScale(double x, double y); + virtual void SetLogicalScale(double x, double y); + virtual void SetLogicalOrigin(wxCoord x, wxCoord y); + virtual void SetDeviceOrigin(wxCoord x, wxCoord y); + virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp); + +protected: + virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y); + virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, + bool useMask = FALSE); + + virtual void DoSetClippingRegion(wxCoord x, wxCoord y, + wxCoord width, wxCoord height); + virtual void DoGetSize(int *width, int *height) const; + virtual void DoGetSizeMM(int* width, int* height) const; + +public: + void ComputeScaleAndOrigin(); + + wxCoord XDEV2LOG(wxCoord x) const + { + wxCoord new_x = x - m_deviceOriginX; + if (new_x > 0) + return (wxCoord)((double)(new_x) / m_scaleX + 0.5) * m_signX + m_logicalOriginX; + else + return (wxCoord)((double)(new_x) / m_scaleX - 0.5) * m_signX + m_logicalOriginX; + } + wxCoord XDEV2LOGREL(wxCoord x) const + { + if (x > 0) + return (wxCoord)((double)(x) / m_scaleX + 0.5); + else + return (wxCoord)((double)(x) / m_scaleX - 0.5); + } + wxCoord YDEV2LOG(wxCoord y) const + { + wxCoord new_y = y - m_deviceOriginY; + if (new_y > 0) + return (wxCoord)((double)(new_y) / m_scaleY + 0.5) * m_signY + m_logicalOriginY; + else + return (wxCoord)((double)(new_y) / m_scaleY - 0.5) * m_signY + m_logicalOriginY; + } + wxCoord YDEV2LOGREL(wxCoord y) const + { + if (y > 0) + return (wxCoord)((double)(y) / m_scaleY + 0.5); + else + return (wxCoord)((double)(y) / m_scaleY - 0.5); + } + wxCoord XLOG2DEV(wxCoord x) const + { + wxCoord new_x = x - m_logicalOriginX; + if (new_x > 0) + return (wxCoord)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX; + else + return (wxCoord)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX; + } + // Without device translation, for backing pixmap purposes + wxCoord XLOG2DEV_2(wxCoord x) const + { + wxCoord new_x = x - m_logicalOriginX; + if (new_x > 0) + return (wxCoord)((double)(new_x) * m_scaleX + 0.5) * m_signX; + else + return (wxCoord)((double)(new_x) * m_scaleX - 0.5) * m_signX; + } + wxCoord XLOG2DEVREL(wxCoord x) const + { + if (x > 0) + return (wxCoord)((double)(x) * m_scaleX + 0.5); + else + return (wxCoord)((double)(x) * m_scaleX - 0.5); + } + wxCoord YLOG2DEV(wxCoord y) const + { + wxCoord new_y = y - m_logicalOriginY; + if (new_y > 0) + return (wxCoord)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY; + else + return (wxCoord)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY; + } + // Without device translation, for backing pixmap purposes + wxCoord YLOG2DEV_2(wxCoord y) const + { + wxCoord new_y = y - m_logicalOriginY; + if (new_y > 0) + return (wxCoord)((double)(new_y) * m_scaleY + 0.5) * m_signY; + else + return (wxCoord)((double)(new_y) * m_scaleY - 0.5) * m_signY; + } + wxCoord YLOG2DEVREL(wxCoord y) const + { + if (y > 0) + return (wxCoord)((double)(y) * m_scaleY + 0.5); + else + return (wxCoord)((double)(y) * m_scaleY - 0.5); + } + +public: + // not sure what for, but what is a mm on a screen you don't know the size of? + double m_mm_to_pix_x,m_mm_to_pix_y; + + // recompute scale? + bool m_needComputeScaleX, m_needComputeScaleY; + +}; + +#endif +// _WX_DC_H_ diff --git a/include/wx/x11/dcclient.h b/include/wx/x11/dcclient.h new file mode 100644 index 0000000000..ec974c1bb3 --- /dev/null +++ b/include/wx/x11/dcclient.h @@ -0,0 +1,177 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dcclient.h +// Purpose: wxClientDC, wxPaintDC and wxWindowDC classes +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_DCCLIENT_H_ +#define _WX_DCCLIENT_H_ + +#ifdef __GNUG__ +#pragma interface "dcclient.h" +#endif + +#include "wx/dc.h" + +// ----------------------------------------------------------------------------- +// fwd declarations +// ----------------------------------------------------------------------------- + +class WXDLLEXPORT wxWindowDC; +class WXDLLEXPORT wxWindow; + +// Under Windows, wxClientDC, wxPaintDC and wxWindowDC are implemented +// differently. On many platforms, however, they will be the same. + +//----------------------------------------------------------------------------- +// wxWindowDC +//----------------------------------------------------------------------------- + +class WXDLLEXPORT wxWindowDC : public wxDC +{ + DECLARE_DYNAMIC_CLASS(wxWindowDC) + +public: + wxWindowDC(); + wxWindowDC( wxWindow *win ); + + ~wxWindowDC(); + + // TODO this function is Motif-only for now - should it go into base class? + void Clear(const wxRect& rect); + + // implement base class pure virtuals + // ---------------------------------- + + virtual void Clear(); + + virtual void SetFont(const wxFont& font); + virtual void SetPen(const wxPen& pen); + virtual void SetBrush(const wxBrush& brush); + virtual void SetBackground(const wxBrush& brush); + virtual void SetBackgroundMode(int mode); + virtual void SetPalette(const wxPalette& palette); + virtual void SetLogicalFunction( int function ); + + virtual void SetTextForeground(const wxColour& colour); + virtual void SetTextBackground(const wxColour& colour); + + virtual wxCoord GetCharHeight() const; + virtual wxCoord GetCharWidth() const; + virtual void DoGetTextExtent(const wxString& string, + wxCoord *x, wxCoord *y, + wxCoord *descent = NULL, + wxCoord *externalLeading = NULL, + wxFont *theFont = NULL) const; + + virtual bool CanDrawBitmap() const; + virtual bool CanGetTextExtent() const; + + virtual int GetDepth() const; + virtual wxSize GetPPI() const; + + virtual void DestroyClippingRegion(); + + // Helper function for setting clipping + void SetDCClipping(); + + // implementation from now on + // -------------------------- + + WXGC GetGC() const { return m_gc; } + WXGC GetBackingGC() const { return m_gcBacking; } + WXDisplay* GetDisplay() const { return m_display; } + bool GetAutoSetting() const { return m_autoSetting; } + void SetAutoSetting(bool flag) { m_autoSetting = flag; } + +protected: + virtual void DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, + int style = wxFLOOD_SURFACE); + + virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const; + + virtual void DoDrawPoint(wxCoord x, wxCoord y); + virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2); + + virtual void DoDrawArc(wxCoord x1, wxCoord y1, + wxCoord x2, wxCoord y2, + wxCoord xc, wxCoord yc); + virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h, + double sa, double ea); + + virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height); + virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y, + wxCoord width, wxCoord height, + double radius); + virtual void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height); + + virtual void DoCrossHair(wxCoord x, wxCoord y); + + virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y); + virtual void DoDrawRotatedText(const wxString &text, wxCoord x, wxCoord y, double angle); + + virtual bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, + wxDC *source, wxCoord xsrc, wxCoord ysrc, + int rop = wxCOPY, bool useMask = FALSE, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1); + + virtual void DoSetClippingRegionAsRegion(const wxRegion& region); + virtual void DoSetClippingRegion(wxCoord x, wxCoord y, + wxCoord width, wxCoord height); + + virtual void DoDrawLines(int n, wxPoint points[], + wxCoord xoffset, wxCoord yoffset); + virtual void DoDrawPolygon(int n, wxPoint points[], + wxCoord xoffset, wxCoord yoffset, + int fillStyle = wxODDEVEN_RULE); + + WXGC m_gc; + WXGC m_gcBacking; + WXDisplay* m_display; + wxWindow* m_window; + WXRegion m_currentRegion; // Current clipping region (incl. paint clip region) + WXRegion m_userRegion; // User-defined clipping region + WXPixmap m_pixmap; // Pixmap for drawing on + + // Not sure if we'll need all of these + int m_backgroundPixel; + wxColour m_currentColour; + // int m_currentBkMode; + int m_currentPenWidth ; + int m_currentPenJoin ; + int m_currentPenCap ; + int m_currentPenDashCount ; + wxMOTIFDash* m_currentPenDash ; + wxBitmap m_currentStipple ; + int m_currentStyle ; + int m_currentFill ; + int m_autoSetting ; // See comment in dcclient.cpp + WXFont m_oldFont; +}; + +class WXDLLEXPORT wxPaintDC: public wxWindowDC +{ + DECLARE_DYNAMIC_CLASS(wxPaintDC) + +public: + wxPaintDC() { } + wxPaintDC(wxWindow* win); + + ~wxPaintDC(); +}; + +class WXDLLEXPORT wxClientDC: public wxWindowDC +{ + DECLARE_DYNAMIC_CLASS(wxClientDC) + +public: + wxClientDC() { } + wxClientDC(wxWindow* win) : wxWindowDC(win) { } +}; + +#endif +// _WX_DCCLIENT_H_ diff --git a/include/wx/x11/dcmemory.h b/include/wx/x11/dcmemory.h new file mode 100644 index 0000000000..5d85ded03e --- /dev/null +++ b/include/wx/x11/dcmemory.h @@ -0,0 +1,43 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dcmemory.h +// Purpose: wxMemoryDC class +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_DCMEMORY_H_ +#define _WX_DCMEMORY_H_ + +#ifdef __GNUG__ +#pragma interface "dcmemory.h" +#endif + +#include "wx/dcclient.h" + +class wxMemoryDC : public wxWindowDC +{ + DECLARE_DYNAMIC_CLASS(wxMemoryDC) + +public: + wxMemoryDC(); + wxMemoryDC( wxDC *dc ); // Create compatible DC + ~wxMemoryDC(); + + virtual void SelectObject( const wxBitmap& bitmap ); + + void DoGetSize( int *width, int *height ) const; + + wxBitmap& GetBitmap() const { return (wxBitmap&) m_bitmap; } + +private: + friend class wxPaintDC; + + wxBitmap m_bitmap; +}; + +#endif +// _WX_DCMEMORY_H_ diff --git a/include/wx/x11/dcprint.h b/include/wx/x11/dcprint.h new file mode 100644 index 0000000000..2454826e8e --- /dev/null +++ b/include/wx/x11/dcprint.h @@ -0,0 +1,34 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dcprint.h +// Purpose: wxPrinterDC class +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_DCPRINT_H_ +#define _WX_DCPRINT_H_ + +#ifdef __GNUG__ +#pragma interface "dcprint.h" +#endif + +#include "wx/dc.h" + +class WXDLLEXPORT wxPrinterDC: public wxDC +{ +public: + DECLARE_CLASS(wxPrinterDC) + + // Create a printer DC + wxPrinterDC(const wxString& driver, const wxString& device, const wxString& output, bool interactive = TRUE, int orientation = wxPORTRAIT); + + ~wxPrinterDC(); +}; + +#endif +// _WX_DCPRINT_H_ + diff --git a/include/wx/x11/dcscreen.h b/include/wx/x11/dcscreen.h new file mode 100644 index 0000000000..27cf673db2 --- /dev/null +++ b/include/wx/x11/dcscreen.h @@ -0,0 +1,48 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dcscreen.h +// Purpose: wxScreenDC class +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_DCSCREEN_H_ +#define _WX_DCSCREEN_H_ + +#ifdef __GNUG__ +#pragma interface "dcscreen.h" +#endif + +#include "wx/dcclient.h" + +class WXDLLEXPORT wxScreenDC: public wxWindowDC +{ + DECLARE_DYNAMIC_CLASS(wxScreenDC) + +public: + // Create a DC representing the whole screen + wxScreenDC(); + ~wxScreenDC(); + + // Compatibility with X's requirements for + // drawing on top of all windows + static bool StartDrawingOnTop(wxWindow* window); + static bool StartDrawingOnTop(wxRect* rect = NULL); + static bool EndDrawingOnTop(); + +private: + static WXWindow sm_overlayWindow; + + // If we have started transparent drawing at a non-(0,0) point + // then we will have to adjust the device origin in the + // constructor. + static int sm_overlayWindowX; + static int sm_overlayWindowY; +}; + +#endif +// _WX_DCSCREEN_H_ + diff --git a/include/wx/x11/dnd.h b/include/wx/x11/dnd.h new file mode 100644 index 0000000000..b3944af30c --- /dev/null +++ b/include/wx/x11/dnd.h @@ -0,0 +1,178 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: dnd.h +// Purpose: declaration of wxDropTarget, wxDropSource classes +// Author: Julian Smart +// RCS-ID: $Id$ +// Copyright: (c) 1998 Vadim Zeitlin, Robert Roebling, Julian Smart +// Licence: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + + +#ifndef _WX_DND_H_ +#define _WX_DND_H_ + +#ifdef __GNUG__ +#pragma interface +#endif + +#include "wx/defs.h" + +#if wxUSE_DRAG_AND_DROP + +#include "wx/object.h" +#include "wx/string.h" +#include "wx/dataobj.h" +#include "wx/cursor.h" + +//------------------------------------------------------------------------- +// classes +//------------------------------------------------------------------------- + +class WXDLLEXPORT wxWindow; + +class WXDLLEXPORT wxDropTarget; +class WXDLLEXPORT wxTextDropTarget; +class WXDLLEXPORT wxFileDropTarget; +class WXDLLEXPORT wxPrivateDropTarget; + +class WXDLLEXPORT wxDropSource; + +//------------------------------------------------------------------------- +// wxDropTarget +//------------------------------------------------------------------------- + +class WXDLLEXPORT wxDropTarget: public wxObject +{ +public: + + wxDropTarget(); + ~wxDropTarget(); + + virtual void OnEnter() { } + virtual void OnLeave() { } + virtual bool OnDrop( long x, long y, const void *data, size_t size ) = 0; + + // Override these to indicate what kind of data you support: + + virtual size_t GetFormatCount() const = 0; + virtual wxDataFormat GetFormat(size_t n) const = 0; + + // implementation +}; + +//------------------------------------------------------------------------- +// wxTextDropTarget +//------------------------------------------------------------------------- + +class WXDLLEXPORT wxTextDropTarget: public wxDropTarget +{ +public: + + wxTextDropTarget() {}; + virtual bool OnDrop( long x, long y, const void *data, size_t size ); + virtual bool OnDropText( long x, long y, const char *psz ); + +protected: + + virtual size_t GetFormatCount() const; + virtual wxDataFormat GetFormat(size_t n) const; +}; + +//------------------------------------------------------------------------- +// wxPrivateDropTarget +//------------------------------------------------------------------------- + +class WXDLLEXPORT wxPrivateDropTarget: public wxDropTarget +{ +public: + + wxPrivateDropTarget(); + + // you have to override OnDrop to get at the data + + // the string ID identifies the format of clipboard or DnD data. a word + // processor would e.g. add a wxTextDataObject and a wxPrivateDataObject + // to the clipboard - the latter with the Id "WXWORD_FORMAT". + + void SetId( const wxString& id ) + { m_id = id; } + + wxString GetId() + { return m_id; } + +private: + + virtual size_t GetFormatCount() const; + virtual wxDataFormat GetFormat(size_t n) const; + + wxString m_id; +}; + +// ---------------------------------------------------------------------------- +// A drop target which accepts files (dragged from File Manager or Explorer) +// ---------------------------------------------------------------------------- + +class WXDLLEXPORT wxFileDropTarget: public wxDropTarget +{ +public: + + wxFileDropTarget() {}; + + virtual bool OnDrop( long x, long y, const void *data, size_t size ); + virtual bool OnDropFiles( long x, long y, + size_t nFiles, const char * const aszFiles[] ); + +protected: + + virtual size_t GetFormatCount() const; + virtual wxDataFormat GetFormat(size_t n) const; +}; + +//------------------------------------------------------------------------- +// wxDropSource +//------------------------------------------------------------------------- + +enum wxDragResult +{ + wxDragError, // error prevented the d&d operation from completing + wxDragNone, // drag target didn't accept the data + wxDragCopy, // the data was successfully copied + wxDragMove, // the data was successfully moved + wxDragCancel // the operation was cancelled by user (not an error) +}; + +class WXDLLEXPORT wxDropSource: public wxObject +{ +public: + + wxDropSource( wxWindow *win ); + wxDropSource( wxDataObject &data, wxWindow *win ); + + ~wxDropSource(void); + + void SetData( wxDataObject &data ); + wxDragResult DoDragDrop( bool bAllowMove = FALSE ); + + virtual bool GiveFeedback( wxDragResult WXUNUSED(effect), bool WXUNUSED(bScrolling) ) { return TRUE; }; + + // implementation +#if 0 + void RegisterWindow(void); + void UnregisterWindow(void); + + wxWindow *m_window; + wxDragResult m_retValue; + wxDataObject *m_data; + + wxCursor m_defaultCursor; + wxCursor m_goaheadCursor; +#endif +}; + +#endif + +// wxUSE_DRAG_AND_DROP + +#endif +//_WX_DND_H_ + diff --git a/include/wx/x11/font.h b/include/wx/x11/font.h new file mode 100644 index 0000000000..f75bf6c423 --- /dev/null +++ b/include/wx/x11/font.h @@ -0,0 +1,117 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: font.h +// Purpose: wxFont class +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_FONT_H_ +#define _WX_FONT_H_ + +#ifdef __GNUG__ +#pragma interface "font.h" +#endif + +class wxXFont; + +// Font +class wxFont : public wxFontBase +{ +public: + // ctors and such + wxFont() { Init(); } + wxFont(const wxFont& font) { Init(); Ref(font); } + + wxFont(int size, + int family, + int style, + int weight, + bool underlined = FALSE, + const wxString& face = wxEmptyString, + wxFontEncoding encoding = wxFONTENCODING_DEFAULT) + { + Init(); + + (void)Create(size, family, style, weight, underlined, face, encoding); + } + + wxFont(const wxNativeFontInfo& info); + + bool Create(int size, + int family, + int style, + int weight, + bool underlined = FALSE, + const wxString& face = wxEmptyString, + wxFontEncoding encoding = wxFONTENCODING_DEFAULT); + + // wxMOTIF-specific + bool Create(const wxString& fontname, + wxFontEncoding fontenc = wxFONTENCODING_DEFAULT); + bool Create(const wxNativeFontInfo& fontinfo); + + virtual ~wxFont(); + + // assignment + wxFont& operator=(const wxFont& font); + + // implement base class pure virtuals + virtual int GetPointSize() const; + virtual int GetFamily() const; + virtual int GetStyle() const; + virtual int GetWeight() const; + virtual bool GetUnderlined() const; + virtual wxString GetFaceName() const; + virtual wxFontEncoding GetEncoding() const; + virtual wxNativeFontInfo *GetNativeFontInfo() const; + + virtual void SetPointSize(int pointSize); + virtual void SetFamily(int family); + virtual void SetStyle(int style); + virtual void SetWeight(int weight); + virtual void SetFaceName(const wxString& faceName); + virtual void SetUnderlined(bool underlined); + virtual void SetEncoding(wxFontEncoding encoding); + virtual void SetNativeFontInfo( const wxNativeFontInfo& info ); + + // Implementation + + // Find an existing, or create a new, XFontStruct + // based on this wxFont and the given scale. Append the + // font to list in the private data for future reference. + + // TODO This is a fairly basic implementation, that doesn't + // allow for different facenames, and also doesn't do a mapping + // between 'standard' facenames (e.g. Arial, Helvetica, Times Roman etc.) + // and the fonts that are available on a particular system. + // Maybe we need to scan the user's machine to build up a profile + // of the fonts and a mapping file. + + // Return font struct, and optionally the Motif font list + wxXFont *GetInternalFont(double scale = 1.0, + WXDisplay* display = NULL) const; + + // These two are helper functions for convenient access of the above. + WXFontStructPtr GetFontStruct(double scale = 1.0, + WXDisplay* display = NULL) const; + WXFontList GetFontList(double scale = 1.0, + WXDisplay* display = NULL) const; + +protected: + // common part of all ctors + void Init(); + + // VZ: IMHO, we don't need it at all... + bool RealizeResource() { return TRUE; } + void Unshare(); + +private: + DECLARE_DYNAMIC_CLASS(wxFont) +}; + +#endif +// _WX_FONT_H_ diff --git a/include/wx/x11/gdiobj.h b/include/wx/x11/gdiobj.h new file mode 100644 index 0000000000..f55c95cec7 --- /dev/null +++ b/include/wx/x11/gdiobj.h @@ -0,0 +1,48 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: gdiobj.h +// Purpose: wxGDIObject class: base class for other GDI classes +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_GDIOBJ_H_ +#define _WX_GDIOBJ_H_ + +#include "wx/object.h" + +#ifdef __GNUG__ +#pragma interface "gdiobj.h" +#endif + +class WXDLLEXPORT wxGDIRefData: public wxObjectRefData { +public: + inline wxGDIRefData() + { + } +}; + +#define M_GDIDATA ((wxGDIRefData *)m_refData) + +class WXDLLEXPORT wxGDIObject: public wxObject +{ + DECLARE_DYNAMIC_CLASS(wxGDIObject) +public: + inline wxGDIObject() { m_visible = FALSE; }; + inline ~wxGDIObject() {}; + + inline bool IsNull() const { return (m_refData == 0); } + + virtual bool GetVisible() { return m_visible; } + virtual void SetVisible(bool v) { m_visible = v; } + +protected: + bool m_visible; // Can a pointer to this object be safely taken? + // - only if created within FindOrCreate... +}; + +#endif +// _WX_GDIOBJ_H_ diff --git a/include/wx/x11/glcanvas.h b/include/wx/x11/glcanvas.h new file mode 100644 index 0000000000..1932fef522 --- /dev/null +++ b/include/wx/x11/glcanvas.h @@ -0,0 +1,161 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: glcanvas.h +// Purpose: wxGLCanvas, for using OpenGL with wxWindows 2.0 for Motif. +// Uses the GLX extension. +// Author: Julian Smart and Wolfram Gloger +// Modified by: +// Created: 1995, 1999 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart, Wolfram Gloger +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma interface "glcanvas.h" +#endif + +#ifndef _WX_GLCANVAS_H_ +#define _WX_GLCANVAS_H_ + +#include "wx/setup.h" + +#if wxUSE_GLCANVAS + +#include "wx/gdicmn.h" +#include "wx/palette.h" +#include "wx/scrolwin.h" + +#include + +enum +{ + WX_GL_RGBA=1, /* use true color palette */ + WX_GL_BUFFER_SIZE, /* bits for buffer if not WX_GL_RGBA */ + WX_GL_LEVEL, /* 0 for main buffer, >0 for overlay, <0 for underlay */ + WX_GL_DOUBLEBUFFER, /* use doublebuffer */ + WX_GL_STEREO, /* use stereoscopic display */ + WX_GL_AUX_BUFFERS, /* number of auxiliary buffers */ + WX_GL_MIN_RED, /* use red buffer with most bits (> MIN_RED bits) */ + WX_GL_MIN_GREEN, /* use green buffer with most bits (> MIN_GREEN bits) */ + WX_GL_MIN_BLUE, /* use blue buffer with most bits (> MIN_BLUE bits) */ + WX_GL_MIN_ALPHA, /* use blue buffer with most bits (> MIN_ALPHA bits) */ + WX_GL_DEPTH_SIZE, /* bits for Z-buffer (0,16,32) */ + WX_GL_STENCIL_SIZE, /* bits for stencil buffer */ + WX_GL_MIN_ACCUM_RED, /* use red accum buffer with most bits (> MIN_ACCUM_RED bits) */ + WX_GL_MIN_ACCUM_GREEN, /* use green buffer with most bits (> MIN_ACCUM_GREEN bits) */ + WX_GL_MIN_ACCUM_BLUE, /* use blue buffer with most bits (> MIN_ACCUM_BLUE bits) */ + WX_GL_MIN_ACCUM_ALPHA /* use blue buffer with most bits (> MIN_ACCUM_ALPHA bits) */ +}; + +//--------------------------------------------------------------------------- +// classes +//--------------------------------------------------------------------------- + + +class WXDLLEXPORT wxGLContext: public wxObject +{ +public: + wxGLContext( bool isRGB, wxWindow *win, + const wxPalette& palette = wxNullPalette ); + wxGLContext( bool WXUNUSED(isRGB), wxWindow *win, + const wxPalette& WXUNUSED(palette), + const wxGLContext *other /* for sharing display lists */ + ); + ~wxGLContext(); + + void SetCurrent(); + void SetColour(const char *colour); + void SwapBuffers(); + + void SetupPixelFormat(); + void SetupPalette(const wxPalette& palette); + wxPalette CreateDefaultPalette(); + + inline wxPalette* GetPalette() const { return (wxPalette*) & m_palette; } + inline wxWindow* GetWindow() const { return m_window; } + // inline GtkWidget* GetWidget() const { return m_widget; } + inline GLXContext GetContext() const { return m_glContext; } + +public: + GLXContext m_glContext; + + // GtkWidget *m_widget; + wxPalette m_palette; + wxWindow* m_window; + + DECLARE_CLASS(wxGLContext) +}; + + +class WXDLLEXPORT wxGLCanvas: public wxScrolledWindow +{ +public: + inline wxGLCanvas() { + m_glContext = (wxGLContext*) NULL; + m_sharedContext = (wxGLContext*) NULL; + // m_glWidget = (GtkWidget*) NULL; + m_vi = (void*) NULL; + // m_exposed = FALSE; + } + wxGLCanvas( wxWindow *parent, wxWindowID id = -1, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = 0, const wxString& name = "GLCanvas", + int *attribList = (int*) NULL, + const wxPalette& palette = wxNullPalette ); + wxGLCanvas( wxWindow *parent, const wxGLContext *shared = (wxGLContext *)NULL, + wxWindowID id = -1, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = 0, const wxString& name = "GLCanvas", + int *attribList = (int*) NULL, + const wxPalette& palette = wxNullPalette ); + wxGLCanvas( wxWindow *parent, const wxGLCanvas *shared = (wxGLCanvas *)NULL, + wxWindowID id = -1, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = 0, const wxString& name = "GLCanvas", + int *attribList = (int*) NULL, + const wxPalette& palette = wxNullPalette ); + + bool Create( wxWindow *parent, + const wxGLContext *shared = (wxGLContext*)NULL, + const wxGLCanvas *shared_context_of = (wxGLCanvas*)NULL, + wxWindowID id = -1, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = 0, const wxString& name = "GLCanvas", + int *attribList = (int*) NULL, + const wxPalette& palette = wxNullPalette ); + + ~wxGLCanvas(); + + void SetCurrent(); + void SetColour(const char *colour); + void SwapBuffers(); + + // void OnSize(wxSizeEvent& event); + + // void OnInternalIdle(); + + inline wxGLContext* GetContext() const { return m_glContext; } + + // implementation + + wxGLContext *m_glContext, + *m_sharedContext; + wxGLCanvas *m_sharedContextOf; + void *m_vi; + // GtkWidget *m_glWidget; + // bool m_exposed; + + DECLARE_EVENT_TABLE() + DECLARE_CLASS(wxGLCanvas) + +}; + +#endif +// wxUSE_GLCANVAS + +#endif +// _WX_GLCANVAS_H_ diff --git a/include/wx/x11/icon.h b/include/wx/x11/icon.h new file mode 100644 index 0000000000..4ddc46c336 --- /dev/null +++ b/include/wx/x11/icon.h @@ -0,0 +1,57 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: icon.h +// Purpose: wxIcon class +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_ICON_H_ +#define _WX_ICON_H_ + +#ifdef __GNUG__ +#pragma interface "icon.h" +#endif + +#include "wx/bitmap.h" + +#define M_ICONDATA ((wxBitmapRefData *)m_refData) +#define M_ICONHANDLERDATA ((wxBitmapRefData *)bitmap->GetRefData()) + +// Icon +class WXDLLEXPORT wxIcon: public wxBitmap +{ + DECLARE_DYNAMIC_CLASS(wxIcon) + +public: + wxIcon(); + + // Copy constructors + inline wxIcon(const wxIcon& icon) { Ref(icon); } + + // Initialize with XBM data + 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_XPM, + int desiredWidth = -1, int desiredHeight = -1); + ~wxIcon(); + + bool LoadFile(const wxString& name, long flags = wxBITMAP_TYPE_XPM, + int desiredWidth = -1, int desiredHeight = -1); + + inline wxIcon& operator = (const wxIcon& icon) { if (*this == icon) return (*this); Ref(icon); return *this; } + inline bool operator == (const wxIcon& icon) const { return m_refData == icon.m_refData; } + inline bool operator != (const wxIcon& icon) const { return m_refData != icon.m_refData; } + + virtual bool Ok() const { return ((m_refData != NULL) && (M_ICONDATA->m_ok)); } +}; + +#endif +// _WX_ICON_H_ diff --git a/include/wx/x11/joystick.h b/include/wx/x11/joystick.h new file mode 100644 index 0000000000..7148fcd4c9 --- /dev/null +++ b/include/wx/x11/joystick.h @@ -0,0 +1,93 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: joystick.h +// Purpose: wxJoystick class +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_JOYSTICK_H_ +#define _WX_JOYSTICK_H_ + +#ifdef __GNUG__ +#pragma interface "joystick.h" +#endif + +#include "wx/event.h" + +class WXDLLEXPORT wxJoystick: public wxObject +{ + DECLARE_DYNAMIC_CLASS(wxJoystick) +public: +/* +* Public interface + */ + + wxJoystick(int joystick = wxJOYSTICK1) { m_joystick = joystick; }; + + // Attributes + //////////////////////////////////////////////////////////////////////////// + + wxPoint GetPosition() const; + int GetZPosition() const; + int GetButtonState() const; + int GetPOVPosition() const; + int GetPOVCTSPosition() const; + int GetRudderPosition() const; + int GetUPosition() const; + int GetVPosition() const; + int GetMovementThreshold() const; + void SetMovementThreshold(int threshold) ; + + // Capabilities + //////////////////////////////////////////////////////////////////////////// + + bool IsOk() const; // Checks that the joystick is functioning + int GetNumberJoysticks() const ; + int GetManufacturerId() const ; + int GetProductId() const ; + wxString GetProductName() const ; + int GetXMin() const; + int GetYMin() const; + int GetZMin() const; + int GetXMax() const; + int GetYMax() const; + int GetZMax() const; + int GetNumberButtons() const; + int GetNumberAxes() const; + int GetMaxButtons() const; + int GetMaxAxes() const; + int GetPollingMin() const; + int GetPollingMax() const; + int GetRudderMin() const; + int GetRudderMax() const; + int GetUMin() const; + int GetUMax() const; + int GetVMin() const; + int GetVMax() const; + + bool HasRudder() const; + bool HasZ() const; + bool HasU() const; + bool HasV() const; + bool HasPOV() const; + bool HasPOV4Dir() const; + bool HasPOVCTS() const; + + // Operations + //////////////////////////////////////////////////////////////////////////// + + // pollingFreq = 0 means that movement events are sent when above the threshold. + // If pollingFreq > 0, events are received every this many milliseconds. + bool SetCapture(wxWindow* win, int pollingFreq = 0); + bool ReleaseCapture(); + +protected: + int m_joystick; +}; + +#endif +// _WX_JOYSTICK_H_ diff --git a/include/wx/x11/mdi.h b/include/wx/x11/mdi.h new file mode 100644 index 0000000000..50bcf4f5d1 --- /dev/null +++ b/include/wx/x11/mdi.h @@ -0,0 +1,250 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: mdi.h +// Purpose: MDI (Multiple Document Interface) classes. +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_MDI_H_ +#define _WX_MDI_H_ + +#ifdef __GNUG__ +#pragma interface "mdi.h" +#endif + +/* +New MDI scheme using tabs. We can use a wxNotebook to implement the client +window. wxMDIChildFrame can be implemented as an XmMainWindow widget +as before, and is a child of the notebook _and_ of the parent frame... +but wxMDIChildFrame::GetParent should return the parent frame. + +*/ + +#include "wx/frame.h" +#include "wx/notebook.h" + +WXDLLEXPORT_DATA(extern const char*) wxFrameNameStr; +WXDLLEXPORT_DATA(extern const char*) wxStatusLineNameStr; + +class WXDLLEXPORT wxMDIClientWindow; +class WXDLLEXPORT wxMDIChildFrame; + +class WXDLLEXPORT wxMDIParentFrame: public wxFrame +{ + DECLARE_DYNAMIC_CLASS(wxMDIParentFrame) + + friend class WXDLLEXPORT wxMDIChildFrame; +public: + + wxMDIParentFrame(); + inline wxMDIParentFrame(wxWindow *parent, + wxWindowID id, + const wxString& title, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL, // Scrolling refers to client window + const wxString& name = wxFrameNameStr) + { + Create(parent, id, title, pos, size, style, name); + } + + ~wxMDIParentFrame(); + + bool Create(wxWindow *parent, + wxWindowID id, + const wxString& title, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL, + const wxString& name = wxFrameNameStr); + + void OnSize(wxSizeEvent& event); + void OnActivate(wxActivateEvent& event); + void OnSysColourChanged(wxSysColourChangedEvent& event); + void OnMenuHighlight(wxMenuEvent& event); + + void SetMenuBar(wxMenuBar *menu_bar); + + // Get the active MDI child window + wxMDIChildFrame *GetActiveChild() const ; + + // Get the client window + wxMDIClientWindow *GetClientWindow() const { return m_clientWindow; }; + + // Create the client window class (don't Create the window, + // just return a new class) + virtual wxMDIClientWindow *OnCreateClient() ; + + // MDI operations + virtual void Cascade(); + virtual void Tile(); + virtual void ArrangeIcons(); + virtual void ActivateNext(); + virtual void ActivatePrevious(); + + // Implementation + + // Set the active child + inline void SetActiveChild(wxMDIChildFrame* child) { m_activeChild = child; } + + // Set the child's menubar into the parent frame + void SetChildMenuBar(wxMDIChildFrame* frame); + + inline wxMenuBar* GetActiveMenuBar() const { return m_activeMenuBar; } + + // Redirect events to active child first + virtual bool ProcessEvent(wxEvent& event); + +protected: + virtual void DoSetSize(int x, int y, + int width, int height, + int sizeFlags = wxSIZE_AUTO); + virtual void DoSetClientSize(int width, int height); + + // Gets the size available for subwindows after menu size, toolbar size + // and status bar size have been subtracted. If you want to manage your own + // toolbar(s), don't call SetToolBar. + void DoGetClientSize(int *width, int *height) const; + +protected: + + wxMDIClientWindow* m_clientWindow; + wxMDIChildFrame* m_activeChild; + wxMenuBar* m_activeMenuBar; + + DECLARE_EVENT_TABLE() +}; + +class WXDLLEXPORT wxMDIChildFrame: public wxFrame +{ + DECLARE_DYNAMIC_CLASS(wxMDIChildFrame) + +public: + wxMDIChildFrame(); + wxMDIChildFrame(wxMDIParentFrame *parent, + wxWindowID id, + const wxString& title, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_FRAME_STYLE, + const wxString& name = wxFrameNameStr) + { + Create(parent, id, title, pos, size, style, name); + } + + ~wxMDIChildFrame(); + + bool Create(wxMDIParentFrame *parent, + wxWindowID id, + const wxString& title, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_FRAME_STYLE, + const wxString& name = wxFrameNameStr); + + // Set menu bar + void SetMenuBar(wxMenuBar *menu_bar); + void SetTitle(const wxString& title); + + // Set icon + virtual void SetIcon(const wxIcon& icon); + + // Override wxFrame operations + void CaptureMouse(); + void ReleaseMouse(); + void Raise(); + void Lower(void); + void SetSizeHints(int minW = -1, int minH = -1, int maxW = -1, int maxH = -1, int incW = -1, int incH = -1); + + // MDI operations + virtual void Maximize(); + virtual void Maximize(bool WXUNUSED(maximize)) { }; + inline void Minimize() { Iconize(TRUE); }; + virtual void Iconize(bool iconize); + virtual void Restore(); + virtual void Activate(); + virtual bool IsIconized() const ; + + virtual bool IsTopLevel() const { return FALSE; } + + // Is the frame maximized? Returns TRUE for + // wxMDIChildFrame due to the tabbed implementation. + virtual bool IsMaximized(void) const ; + + bool Show(bool show); + + WXWidget GetMainWidget() const { return m_mainWidget; }; + WXWidget GetTopWidget() const { return m_mainWidget; }; + WXWidget GetClientWidget() const { return m_mainWidget; }; + + /* + virtual void OnRaise(); + virtual void OnLower(); + */ + + void SetMDIParentFrame(wxMDIParentFrame* parentFrame) { m_mdiParentFrame = parentFrame; } + wxMDIParentFrame* GetMDIParentFrame() const { return m_mdiParentFrame; } + +protected: + wxMDIParentFrame* m_mdiParentFrame; + + virtual void DoSetSize(int x, int y, + int width, int height, + int sizeFlags = wxSIZE_AUTO); + virtual void DoSetClientSize(int width, int height); + + void DoGetClientSize(int *width, int *height) const; + void DoGetSize(int *width, int *height) const; + void DoGetPosition(int *x, int *y) const ; +}; + +/* The client window is a child of the parent MDI frame, and itself +* contains the child MDI frames. +* However, you create the MDI children as children of the MDI parent: +* only in the implementation does the client window become the parent +* of the children. Phew! So the children are sort of 'adopted'... +*/ + +class WXDLLEXPORT wxMDIClientWindow: public wxNotebook +{ + DECLARE_DYNAMIC_CLASS(wxMDIClientWindow) + +public: + wxMDIClientWindow() ; + wxMDIClientWindow(wxMDIParentFrame *parent, long style = 0) + { + CreateClient(parent, style); + } + + ~wxMDIClientWindow(); + + // Note: this is virtual, to allow overridden behaviour. + virtual bool CreateClient(wxMDIParentFrame *parent, long style = wxVSCROLL | wxHSCROLL); + + // Explicitly call default scroll behaviour + void OnScroll(wxScrollEvent& event); + + // Implementation + void OnPageChanged(wxNotebookEvent& event); + +protected: + virtual void DoSetSize(int x, int y, + int width, int height, + int sizeFlags = wxSIZE_AUTO); + virtual void DoSetClientSize(int width, int height); + + void DoGetClientSize(int *width, int *height) const; + void DoGetSize(int *width, int *height) const ; + void DoGetPosition(int *x, int *y) const ; + + +private: + DECLARE_EVENT_TABLE() +}; + +#endif +// _WX_MDI_H_ diff --git a/include/wx/x11/minifram.h b/include/wx/x11/minifram.h new file mode 100644 index 0000000000..cbe4f63269 --- /dev/null +++ b/include/wx/x11/minifram.h @@ -0,0 +1,46 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: minifram.h +// Purpose: wxMiniFrame class. A small frame for e.g. floating toolbars. +// If there is no equivalent on your platform, just make it a +// normal frame. +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_MINIFRAM_H_ +#define _WX_MINIFRAM_H_ + +#ifdef __GNUG__ +#pragma interface "minifram.h" +#endif + +#include "wx/frame.h" + +class WXDLLEXPORT wxMiniFrame: public wxFrame { + + DECLARE_DYNAMIC_CLASS(wxMiniFrame) + +public: + inline wxMiniFrame() {} + inline wxMiniFrame(wxWindow *parent, + wxWindowID id, + const wxString& title, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_FRAME_STYLE|wxTINY_CAPTION_HORIZ, + const wxString& name = wxFrameNameStr) + { + // Use wxFrame constructor in absence of more specific code. + Create(parent, id, title, pos, size, style, name); + } + + ~wxMiniFrame() {} +protected: +}; + +#endif +// _WX_MINIFRAM_H_ diff --git a/include/wx/x11/palette.h b/include/wx/x11/palette.h new file mode 100644 index 0000000000..c34767f8ce --- /dev/null +++ b/include/wx/x11/palette.h @@ -0,0 +1,81 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: palette.h +// Purpose: wxPalette class +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_PALETTE_H_ +#define _WX_PALETTE_H_ + +#ifdef __GNUG__ +#pragma interface "palette.h" +#endif + +#include "wx/gdiobj.h" +#include "wx/list.h" + +class WXDLLEXPORT wxPalette; + +// Palette for one display +class wxXPalette : public wxObject +{ + DECLARE_DYNAMIC_CLASS(wxXPalette) + +public: + wxXPalette(); + + WXDisplay* m_display; + int m_pix_array_n; + unsigned long* m_pix_array; + WXColormap m_cmap; + bool m_destroyable; +}; + +class WXDLLEXPORT wxPaletteRefData: public wxGDIRefData +{ + friend class WXDLLEXPORT wxPalette; +public: + wxPaletteRefData(); + ~wxPaletteRefData(); + +protected: + wxList m_palettes; +}; + +#define M_PALETTEDATA ((wxPaletteRefData *)m_refData) + +class WXDLLEXPORT wxPalette: public wxGDIObject +{ + DECLARE_DYNAMIC_CLASS(wxPalette) + +public: + wxPalette(); + wxPalette(const wxPalette& palette) { Ref(palette); } + + wxPalette(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue); + ~wxPalette(); + bool Create(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue); + int GetPixel(const unsigned char red, const unsigned char green, const unsigned char blue) const; + bool GetRGB(int pixel, unsigned char *red, unsigned char *green, unsigned char *blue) const; + + virtual bool Ok() const { return (m_refData != NULL) ; } + + wxPalette& operator = (const wxPalette& palette) { if (*this == palette) return (*this); Ref(palette); return *this; } + bool operator == (const wxPalette& palette) const { return m_refData == palette.m_refData; } + bool operator != (const wxPalette& palette) const { return m_refData != palette.m_refData; } + + // Motif-specific + WXColormap GetXColormap(WXDisplay* display = NULL) const; + bool TransferBitmap(void *data, int depth, int size); + bool TransferBitmap8(unsigned char *data, unsigned long size, void *dest, unsigned int bpp); + unsigned long *GetXPixArray(WXDisplay* display, int *pix_array_n); + void PutXColormap(WXDisplay* display, WXColormap cmap, bool destroyable); +}; + +#endif +// _WX_PALETTE_H_ diff --git a/include/wx/x11/pen.h b/include/wx/x11/pen.h new file mode 100644 index 0000000000..35247eb99c --- /dev/null +++ b/include/wx/x11/pen.h @@ -0,0 +1,102 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: pen.h +// Purpose: wxPen class +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_PEN_H_ +#define _WX_PEN_H_ + +#ifdef __GNUG__ +#pragma interface "pen.h" +#endif + +#include "wx/gdiobj.h" +#include "wx/colour.h" +#include "wx/bitmap.h" + +typedef char wxMOTIFDash; + +class WXDLLEXPORT wxPen; + +class WXDLLEXPORT wxPenRefData: public wxGDIRefData +{ + friend class WXDLLEXPORT wxPen; +public: + wxPenRefData(); + wxPenRefData(const wxPenRefData& data); + ~wxPenRefData(); + +protected: + int m_width; + int m_style; + int m_join ; + int m_cap ; + wxBitmap m_stipple ; + int m_nbDash ; + wxMOTIFDash *m_dash ; + wxColour m_colour; +}; + +#define M_PENDATA ((wxPenRefData *)m_refData) + +// Pen +class WXDLLEXPORT wxPen: public wxGDIObject +{ + DECLARE_DYNAMIC_CLASS(wxPen) +public: + wxPen(); + wxPen(const wxColour& col, int width, int style); + wxPen(const wxBitmap& stipple, int width); + inline wxPen(const wxPen& pen) { Ref(pen); } + ~wxPen(); + + inline wxPen& operator = (const wxPen& pen) { if (*this == pen) return (*this); Ref(pen); return *this; } + inline bool operator == (const wxPen& pen) const { return m_refData == pen.m_refData; } + inline bool operator != (const wxPen& pen) const { return m_refData != pen.m_refData; } + + virtual bool Ok() const { return (m_refData != NULL) ; } + + // Override in order to recreate the pen + void SetColour(const wxColour& col) ; + void SetColour(unsigned char r, unsigned char g, unsigned char b) ; + + void SetWidth(int width) ; + void SetStyle(int style) ; + void SetStipple(const wxBitmap& stipple) ; + void SetDashes(int nb_dashes, const wxDash *dash) ; + void SetJoin(int join) ; + void SetCap(int cap) ; + + inline wxColour& GetColour() const { return (M_PENDATA ? M_PENDATA->m_colour : wxNullColour); }; + inline int GetWidth() const { return (M_PENDATA ? M_PENDATA->m_width : 0); }; + inline int GetStyle() const { return (M_PENDATA ? M_PENDATA->m_style : 0); }; + inline int GetJoin() const { return (M_PENDATA ? M_PENDATA->m_join : 0); }; + inline int GetCap() const { return (M_PENDATA ? M_PENDATA->m_cap : 0); }; + inline int GetDashes(wxDash **ptr) const + { + *ptr = (M_PENDATA ? (wxDash*)M_PENDATA->m_dash : (wxDash*) NULL); + return (M_PENDATA ? M_PENDATA->m_nbDash : 0); + } + inline int GetDashCount() const { return (M_PENDATA->m_nbDash); } + inline wxDash* GetDash() const { return (wxDash*)M_PENDATA->m_dash; } + + inline wxBitmap *GetStipple() const { return (M_PENDATA ? (& M_PENDATA->m_stipple) : (wxBitmap*) NULL); }; + + // Implementation + + // Useful helper: create the brush resource + bool RealizeResource(); + + // When setting properties, we must make sure we're not changing + // another object + void Unshare(); +}; + +#endif +// _WX_PEN_H_ diff --git a/include/wx/x11/popupwin.h b/include/wx/x11/popupwin.h new file mode 100644 index 0000000000..239ee04212 --- /dev/null +++ b/include/wx/x11/popupwin.h @@ -0,0 +1,50 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: wx/msw/popupwin.h +// Purpose: wxPopupWindow class for wxMSW +// Author: Vadim Zeitlin +// Modified by: +// Created: 06.01.01 +// RCS-ID: $Id$ +// Copyright: (c) 2001 Vadim Zeitlin +// Licence: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_MSW_POPUPWIN_H_ +#define _WX_MSW_POPUPWIN_H_ + +// ---------------------------------------------------------------------------- +// wxPopupWindow +// ---------------------------------------------------------------------------- + +class WXDLLEXPORT wxPopupWindow : public wxPopupWindowBase +{ +public: + wxPopupWindow() { } + + wxPopupWindow(wxWindow *parent, int flags = wxBORDER_NONE) + { (void)Create(parent, flags); } + + bool Create(wxWindow *parent, int flags = wxBORDER_NONE) + { + return wxPopupWindowBase::Create(parent) && + wxWindow::Create(parent, -1, + wxDefaultPosition, wxDefaultSize, + (flags & wxBORDER_MASK) | wxPOPUP_WINDOW); + } + +protected: + virtual void DoGetPosition(int *x, int *y) const + { + // the position of a "top level" window such as this should be in + // screen coordinates, not in the client ones which MSW gives us + // (because we are a child window) + wxPopupWindowBase::DoGetPosition(x, y); + + GetParent()->ClientToScreen(x, y); + } + + DECLARE_DYNAMIC_CLASS(wxPopupWindow) +}; + +#endif // _WX_MSW_POPUPWIN_H_ + diff --git a/include/wx/x11/print.h b/include/wx/x11/print.h new file mode 100644 index 0000000000..0576e30923 --- /dev/null +++ b/include/wx/x11/print.h @@ -0,0 +1,56 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: print.h +// Purpose: wxPrinter, wxPrintPreview classes +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_PRINT_H_ +#define _WX_PRINT_H_ + +#ifdef __GNUG__ +#pragma interface "print.h" +#endif + +#include "wx/prntbase.h" + +/* +* Represents the printer: manages printing a wxPrintout object +*/ + +class WXDLLEXPORT wxPrinter: public wxPrinterBase +{ + DECLARE_DYNAMIC_CLASS(wxPrinter) + +public: + wxPrinter(wxPrintData *data = NULL); + ~wxPrinter(); + + virtual bool Print(wxWindow *parent, wxPrintout *printout, bool prompt = TRUE); + virtual bool PrintDialog(wxWindow *parent); + virtual bool Setup(wxWindow *parent); +}; + +/* +* wxPrintPreview +* Programmer creates an object of this class to preview a wxPrintout. +*/ + +class WXDLLEXPORT wxPrintPreview: public wxPrintPreviewBase +{ + DECLARE_CLASS(wxPrintPreview) + +public: + wxPrintPreview(wxPrintout *printout, wxPrintout *printoutForPrinting = NULL, wxPrintData *data = NULL); + ~wxPrintPreview(); + + virtual bool Print(bool interactive); + virtual void DetermineScaling(); +}; + +#endif +// _WX_PRINT_H_ diff --git a/include/wx/x11/private.h b/include/wx/x11/private.h new file mode 100644 index 0000000000..0a9bfe6823 --- /dev/null +++ b/include/wx/x11/private.h @@ -0,0 +1,120 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: private.h +// Purpose: Private declarations for wxMotif port +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_PRIVATE_H_ +#define _WX_PRIVATE_H_ + +#include "wx/defs.h" + +class wxMouseEvent; +class wxKeyEvent; + +// Put any private declarations here: native Motif types may be used because +// this header is included after Xm/Xm.h + +// ---------------------------------------------------------------------------- +// common callbacks +// ---------------------------------------------------------------------------- + +// All widgets should have this as their resize proc. +extern void wxWidgetResizeProc(Widget w, XConfigureEvent *event, String args[], int *num_args); + +// For repainting arbitrary windows +void wxUniversalRepaintProc(Widget w, XtPointer WXUNUSED(c_data), XEvent *event, char *); + +// ---------------------------------------------------------------------------- +// we maintain a hash table which contains the mapping from Widget to wxWindow +// corresponding to the window for this widget +// ---------------------------------------------------------------------------- + +extern void wxDeleteWindowFromTable(Widget w); +extern wxWindow *wxGetWindowFromTable(Widget w); +extern bool wxAddWindowToTable(Widget w, wxWindow *win); + +// ---------------------------------------------------------------------------- +// key events related functions +// ---------------------------------------------------------------------------- + +extern char wxFindMnemonic(const char* s); + +extern char * wxFindAccelerator (const char *s); +extern XmString wxFindAcceleratorText (const char *s); + +extern int wxCharCodeXToWX(KeySym keySym); +extern KeySym wxCharCodeWXToX(int id); + +// ---------------------------------------------------------------------------- +// TranslateXXXEvent() functions - translate Motif event to wxWindow one +// ---------------------------------------------------------------------------- +extern bool wxTranslateMouseEvent(wxMouseEvent& wxevent, wxWindow *win, Widget widget, XEvent *xevent); +extern 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); + +extern void wxDoChangeForegroundColour(WXWidget widget, wxColour& foregroundColour); +extern void wxDoChangeBackgroundColour(WXWidget widget, wxColour& backgroundColour, bool changeArmColour = FALSE); + +#define wxNO_COLORS 0x00 +#define wxBACK_COLORS 0x01 +#define wxFORE_COLORS 0x02 + +extern XColor itemColors[5] ; + +#define wxBACK_INDEX 0 +#define wxFORE_INDEX 1 +#define wxSELE_INDEX 2 +#define wxTOPS_INDEX 3 +#define wxBOTS_INDEX 4 + +// ---------------------------------------------------------------------------- +// utility classes +// ---------------------------------------------------------------------------- + +// XmString made easy to use in wxWindows (and has an added benefit of +// cleaning up automatically) +class wxXmString +{ +public: + wxXmString(const wxString& str) + { + m_string = XmStringCreateLtoR((char *)str.c_str(), + XmSTRING_DEFAULT_CHARSET); + } + + ~wxXmString() { XmStringFree(m_string); } + + // semi-implicit conversion to XmString (shouldn't rely on implicit + // conversion because many of Motif functions are macros) + XmString operator()() const { return m_string; } + +private: + XmString m_string; +}; + +// ---------------------------------------------------------------------------- +// macros to avoid casting WXFOO to Foo all the time +// ---------------------------------------------------------------------------- + +// argument is of type "wxWindow *" +#define GetWidget(w) ((Widget)(w)->GetHandle()) + +// ---------------------------------------------------------------------------- +// accessors for C modules +// ---------------------------------------------------------------------------- + +extern "C" XtAppContext wxGetAppContext(); + +#endif +// _WX_PRIVATE_H_ diff --git a/include/wx/x11/region.h b/include/wx/x11/region.h new file mode 100644 index 0000000000..052eb872f7 --- /dev/null +++ b/include/wx/x11/region.h @@ -0,0 +1,155 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: region.h +// Purpose: wxRegion class +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_REGION_H_ +#define _WX_REGION_H_ + +#ifdef __GNUG__ +#pragma interface "region.h" +#endif + +#include "wx/list.h" +#include "wx/gdiobj.h" +#include "wx/gdicmn.h" + +// ---------------------------------------------------------------------------- +// A list of rectangles type used by wxRegion and wxWindow +// ---------------------------------------------------------------------------- + +WX_DECLARE_LIST(wxRect, wxRectList); + + +enum wxRegionContain { + wxOutRegion = 0, wxPartRegion = 1, wxInRegion = 2 +}; + +// So far, for internal use only +enum wxRegionOp { + wxRGN_AND, // Creates the intersection of the two combined regions. + wxRGN_COPY, // Creates a copy of the region identified by hrgnSrc1. + wxRGN_DIFF, // Combines the parts of hrgnSrc1 that are not part of hrgnSrc2. + wxRGN_OR, // Creates the union of two combined regions. + wxRGN_XOR // Creates the union of two combined regions except for any overlapping areas. +}; + +class WXDLLEXPORT wxRegion : public wxGDIObject { + DECLARE_DYNAMIC_CLASS(wxRegion) + friend class WXDLLEXPORT wxRegionIterator; +public: + wxRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h); + wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight); + wxRegion(const wxRect& rect); + wxRegion(); + ~wxRegion(); + + //# Copying + inline wxRegion(const wxRegion& r) + { Ref(r); } + inline wxRegion& operator = (const wxRegion& r) + { Ref(r); return (*this); } + + //# Modify region + // Clear current region + void Clear(); + + // Union rectangle or region with this. + inline bool Union(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { return Combine(x, y, width, height, wxRGN_OR); } + inline bool Union(const wxRect& rect) { return Combine(rect, wxRGN_OR); } + inline bool Union(const wxRegion& region) { return Combine(region, wxRGN_OR); } + + // Intersect rectangle or region with this. + inline bool Intersect(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { return Combine(x, y, width, height, wxRGN_AND); } + inline bool Intersect(const wxRect& rect) { return Combine(rect, wxRGN_AND); } + inline bool Intersect(const wxRegion& region) { return Combine(region, wxRGN_AND); } + + // Subtract rectangle or region from this: + // Combines the parts of 'this' that are not part of the second region. + inline bool Subtract(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { return Combine(x, y, width, height, wxRGN_DIFF); } + inline bool Subtract(const wxRect& rect) { return Combine(rect, wxRGN_DIFF); } + inline bool Subtract(const wxRegion& region) { return Combine(region, wxRGN_DIFF); } + + // XOR: the union of two combined regions except for any overlapping areas. + inline bool Xor(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { return Combine(x, y, width, height, wxRGN_XOR); } + inline bool Xor(const wxRect& rect) { return Combine(rect, wxRGN_XOR); } + inline bool Xor(const wxRegion& region) { return Combine(region, wxRGN_XOR); } + + //# Information on region + // Outer bounds of region + void GetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const; + wxRect GetBox() const ; + + // Is region empty? + bool Empty() const; + inline bool IsEmpty() const { return Empty(); } + bool Ok() const { return (m_refData != NULL) ; } + + //# Tests + // Does the region contain the point (x,y)? + wxRegionContain Contains(wxCoord x, wxCoord y) const; + // Does the region contain the point pt? + wxRegionContain Contains(const wxPoint& pt) const; + // Does the region contain the rectangle (x, y, w, h)? + wxRegionContain Contains(wxCoord x, wxCoord y, wxCoord w, wxCoord h) const; + // Does the region contain the rectangle rect? + wxRegionContain Contains(const wxRect& rect) const; + + // Internal + bool Combine(wxCoord x, wxCoord y, wxCoord width, wxCoord height, wxRegionOp op); + bool Combine(const wxRegion& region, wxRegionOp op); + bool Combine(const wxRect& rect, wxRegionOp op); + + // Get the internal Region handle + WXRegion GetXRegion() const; + + // 'Naughty' functions that allow wxWindows to use a list of rects + // instead of the region, in certain circumstances (e.g. when + // making a region out of the update rectangles). + // These are used by wxPaintDC::wxPaintDC and wxRegionIterator::Reset. + bool UsingRects() const; + wxRect* GetRects(); + int GetRectCount() const; + void SetRects(const wxRectList& rectList); + void SetRects(int count, const wxRect* rects); +}; + +class WXDLLEXPORT wxRegionIterator : public wxObject { + DECLARE_DYNAMIC_CLASS(wxRegionIterator) +public: + wxRegionIterator(); + wxRegionIterator(const wxRegion& region); + ~wxRegionIterator(); + + void Reset() { m_current = 0; } + void Reset(const wxRegion& region); + + operator bool () const { return m_current < m_numRects; } + bool HaveRects() const { return m_current < m_numRects; } + + void operator ++ (); + void operator ++ (int); + + wxCoord GetX() const; + wxCoord GetY() const; + wxCoord GetW() const; + wxCoord GetWidth() const { return GetW(); } + wxCoord GetH() const; + wxCoord GetHeight() const { return GetH(); } + wxRect GetRect() const { return wxRect(GetX(), GetY(), GetWidth(), GetHeight()); } + +private: + size_t m_current; + size_t m_numRects; + wxRegion m_region; + wxRect* m_rects; +}; + +#endif +// _WX_REGION_H_ diff --git a/include/wx/x11/timer.h b/include/wx/x11/timer.h new file mode 100644 index 0000000000..2476a768e2 --- /dev/null +++ b/include/wx/x11/timer.h @@ -0,0 +1,44 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: timer.h +// Purpose: wxTimer class +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_TIMER_H_ +#define _WX_TIMER_H_ + +#ifdef __GNUG__ +#pragma interface "timer.h" +#endif + +class WXDLLEXPORT wxTimer : public wxTimerBase +{ + friend void wxTimerCallback(wxTimer * timer); + +public: + wxTimer() { Init(); } + wxTimer(wxEvtHandler *owner, int id = -1) : wxTimerBase(owner, id) + { Init(); } + ~wxTimer(); + + virtual bool Start(int milliseconds = -1, bool oneShot = FALSE); + virtual void Stop(); + + virtual bool IsRunning() const { return m_id != 0; } + +protected: + void Init(); + + long m_id; + +private: + DECLARE_DYNAMIC_CLASS(wxTimer) +}; + +#endif +// _WX_TIMER_H_ diff --git a/include/wx/x11/toolbar.h b/include/wx/x11/toolbar.h new file mode 100644 index 0000000000..f7864c43af --- /dev/null +++ b/include/wx/x11/toolbar.h @@ -0,0 +1,82 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: wx/motif/toolbar.h +// Purpose: wxToolBar class +// Author: Julian Smart +// Modified by: 13.12.99 by VZ during toolbar classes reorganization +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_TOOLBAR_H_ +#define _WX_TOOLBAR_H_ + +#ifdef __GNUG__ +#pragma interface "toolbar.h" +#endif + +class WXDLLEXPORT wxToolBar : public wxToolBarBase +{ +public: + // ctors and dtor + wxToolBar() { Init(); } + + wxToolBar(wxWindow *parent, + wxWindowID id, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxNO_BORDER | wxTB_HORIZONTAL, + const wxString& name = wxToolBarNameStr) + { + Init(); + + Create(parent, id, pos, size, style, name); + } + + bool Create(wxWindow *parent, + wxWindowID id, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxNO_BORDER | wxTB_HORIZONTAL, + const wxString& name = wxToolBarNameStr); + + virtual ~wxToolBar(); + + // override/implement base class virtuals + virtual wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y) const; + + virtual bool Realize(); + + // implementation from now on + + // find tool by widget + wxToolBarToolBase *FindToolByWidget(WXWidget w) const; + +protected: + // common part of all ctors + void Init(); + + // implement base class pure virtuals + virtual bool DoInsertTool(size_t pos, wxToolBarToolBase *tool); + virtual bool DoDeleteTool(size_t pos, wxToolBarToolBase *tool); + + virtual void DoEnableTool(wxToolBarToolBase *tool, bool enable); + virtual void DoToggleTool(wxToolBarToolBase *tool, bool toggle); + virtual void DoSetToggle(wxToolBarToolBase *tool, bool toggle); + + virtual wxToolBarToolBase *CreateTool(int id, + const wxBitmap& bitmap1, + const wxBitmap& bitmap2, + bool toggle, + wxObject *clientData, + const wxString& shortHelpString, + const wxString& longHelpString); + virtual wxToolBarToolBase *CreateTool(wxControl *control); + +private: + DECLARE_DYNAMIC_CLASS(wxToolBar) +}; + +#endif +// _WX_TOOLBAR_H_ diff --git a/include/wx/x11/toplevel.h b/include/wx/x11/toplevel.h new file mode 100644 index 0000000000..f0493408da --- /dev/null +++ b/include/wx/x11/toplevel.h @@ -0,0 +1,134 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: wx/motif/frame.h +// Purpose: wxFrame class +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_MOTIF_FRAME_H_ +#define _WX_MOTIF_FRAME_H_ + +#ifdef __GNUG__ +#pragma interface "frame.h" +#endif + +class WXDLLEXPORT wxFrame : public wxFrameBase +{ +public: + wxFrame() { Init(); } + wxFrame(wxWindow *parent, + wxWindowID id, + const wxString& title, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_FRAME_STYLE, + const wxString& name = wxFrameNameStr) + { + Init(); + + Create(parent, id, title, pos, size, style, name); + } + + bool Create(wxWindow *parent, + wxWindowID id, + const wxString& title, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_FRAME_STYLE, + const wxString& name = wxFrameNameStr); + + virtual ~wxFrame(); + + virtual bool Show(bool show = TRUE); + + // Set menu bar + void SetMenuBar(wxMenuBar *menu_bar); + + // Set title + void SetTitle(const wxString& title); + wxString GetTitle() const { return m_title; } + + // Set icon + virtual void SetIcon(const wxIcon& icon); + +#if wxUSE_STATUSBAR + virtual void PositionStatusBar(); +#endif // wxUSE_STATUSBAR + + // Create toolbar +#if wxUSE_TOOLBAR + virtual wxToolBar* CreateToolBar(long style = wxNO_BORDER|wxTB_HORIZONTAL, wxWindowID id = -1, const wxString& name = wxToolBarNameStr); + virtual void PositionToolBar(); +#endif // wxUSE_TOOLBAR + + // Iconize + virtual void Iconize(bool iconize); + + virtual bool IsIconized() const; + + // Is the frame maximized? Returns FALSE under Motif (but TRUE for + // wxMDIChildFrame due to the tabbed implementation). + virtual bool IsMaximized() const; + + virtual void Maximize(bool maximize); + + virtual void Raise(); + virtual void Lower(); + + virtual void Restore(); + + // Implementation only from now on + // ------------------------------- + + void OnSysColourChanged(wxSysColourChangedEvent& event); + void OnActivate(wxActivateEvent& event); + + virtual void ChangeFont(bool keepOriginalSize = TRUE); + virtual void ChangeBackgroundColour(); + virtual void ChangeForegroundColour(); + WXWidget GetMenuBarWidget() const; + WXWidget GetShellWidget() const { return m_frameShell; } + WXWidget GetWorkAreaWidget() const { return m_workArea; } + WXWidget GetClientAreaWidget() const { return m_clientArea; } + WXWidget GetTopWidget() const { return m_frameShell; } + + virtual WXWidget GetMainWidget() const { return m_frameWidget; } + + // The widget that can have children on it + WXWidget GetClientWidget() const; + bool GetVisibleStatus() const { return m_visibleStatus; } + + bool PreResize(); + +protected: + // common part of all ctors + void Init(); + + //// Motif-specific + WXWidget m_frameShell; + WXWidget m_frameWidget; + WXWidget m_workArea; + WXWidget m_clientArea; + wxString m_title; + bool m_visibleStatus; + bool m_iconized; + + virtual void DoGetClientSize(int *width, int *height) const; + virtual void DoGetSize(int *width, int *height) const; + virtual void DoGetPosition(int *x, int *y) const; + virtual void DoSetSize(int x, int y, + int width, int height, + int sizeFlags = wxSIZE_AUTO); + virtual void DoSetClientSize(int width, int height); + +private: + DECLARE_EVENT_TABLE() + DECLARE_DYNAMIC_CLASS(wxFrame) +}; + +#endif +// _WX_MOTIF_FRAME_H_ diff --git a/include/wx/x11/window.h b/include/wx/x11/window.h new file mode 100644 index 0000000000..d4cabf0cbc --- /dev/null +++ b/include/wx/x11/window.h @@ -0,0 +1,358 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: window.h +// Purpose: wxWindow class +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_WINDOW_H_ +#define _WX_WINDOW_H_ + +#ifdef __GNUG__ +#pragma interface "window.h" +#endif + +#include "wx/region.h" + +// ---------------------------------------------------------------------------- +// wxWindow class for Motif - see also wxWindowBase +// ---------------------------------------------------------------------------- + +class wxWindow : public wxWindowBase +{ + friend class WXDLLEXPORT wxDC; + friend class WXDLLEXPORT wxWindowDC; + +public: + wxWindow() { Init(); } + + wxWindow(wxWindow *parent, + wxWindowID id, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = 0, + const wxString& name = wxPanelNameStr) + { + Init(); + Create(parent, id, pos, size, style, name); + } + + virtual ~wxWindow(); + + bool Create(wxWindow *parent, + wxWindowID id, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = 0, + const wxString& name = wxPanelNameStr); + + // implement base class pure virtuals + virtual void SetTitle( const wxString& title); + virtual wxString GetTitle() const; + + virtual void Raise(); + virtual void Lower(); + + virtual bool Show( bool show = TRUE ); + virtual bool Enable( bool enable = TRUE ); + + virtual void SetFocus(); + + virtual void WarpPointer(int x, int y); + + virtual void Refresh( bool eraseBackground = TRUE, + const wxRect *rect = (const wxRect *) NULL ); + virtual void Clear(); + + virtual bool SetBackgroundColour( const wxColour &colour ); + virtual bool SetForegroundColour( const wxColour &colour ); + + virtual bool SetCursor( const wxCursor &cursor ); + virtual bool SetFont( const wxFont &font ); + + virtual int GetCharHeight() const; + virtual int GetCharWidth() const; + virtual void GetTextExtent(const wxString& string, + int *x, int *y, + int *descent = (int *) NULL, + int *externalLeading = (int *) NULL, + const wxFont *theFont = (const wxFont *) NULL) + const; + + virtual void SetScrollbar( int orient, int pos, int thumbVisible, + int range, bool refresh = TRUE ); + virtual void SetScrollPos( int orient, int pos, bool refresh = TRUE ); + virtual int GetScrollPos( int orient ) const; + virtual int GetScrollThumb( int orient ) const; + virtual int GetScrollRange( int orient ) const; + virtual void ScrollWindow( int dx, int dy, + const wxRect* rect = (wxRect *) NULL ); + + virtual void SetSizeHints(int minW, int minH, + int maxW = -1, int maxH = -1, + int incW = -1, int incH = -1); +#if wxUSE_DRAG_AND_DROP + virtual void SetDropTarget( wxDropTarget *dropTarget ); +#endif // wxUSE_DRAG_AND_DROP + + // Accept files for dragging + virtual void DragAcceptFiles(bool accept); + + // Get the unique identifier of a window + virtual WXWidget GetHandle() const { return GetMainWidget(); } + + // implementation from now on + // -------------------------- + + // accessors + // --------- + + // Get main widget for this window, e.g. a text widget + virtual WXWidget GetMainWidget() const; + // Get the widget that corresponds to the label (for font setting, label setting etc.) + virtual WXWidget GetLabelWidget() const; + // Get the client widget for this window (something we can create other + // windows on) + virtual WXWidget GetClientWidget() const; + // Get the top widget for this window, e.g. the scrolled widget parent of a + // multi-line text widget. Top means, top in the window hierarchy that + // implements this window. + virtual WXWidget GetTopWidget() const; + + // Get the underlying X window and display + WXWindow GetXWindow() const; + WXDisplay *GetXDisplay() const; + + // called from Motif callbacks - and should only be called from there + + void SetButton1(bool pressed) { m_button1Pressed = pressed; } + void SetButton2(bool pressed) { m_button2Pressed = pressed; } + void SetButton3(bool pressed) { m_button3Pressed = pressed; } + + void SetLastClick(int button, long timestamp) + { m_lastButton = button; m_lastTS = timestamp; } + + int GetLastClickedButton() const { return m_lastButton; } + long GetLastClickTime() const { return m_lastTS; } + + // Gives window a chance to do something in response to a size message, e.g. + // arrange status bar, toolbar etc. + virtual bool PreResize(); + + // Generates a paint event + virtual void DoPaint(); + + // update rectangle/region manipulation + // (for wxWindowDC and Motif callbacks only) + // ----------------------------------------- + + // read/write access to the update rect list + const wxRectList& GetUpdateRects() const { return m_updateRects; } + + // Adds a recangle to the updates list + void AddUpdateRect(int x, int y, int w, int h) + { m_updateRects.Append(new wxRect(x, y, w, h)); } + + // Empties the m_updateRects list + void ClearUpdateRects(); + + void ClearUpdateRegion() { m_updateRegion.Clear(); } + void SetUpdateRegion(const wxRegion& region) { m_updateRegion = region; } + + // sets the fore/background colour for the given widget + static void DoChangeForegroundColour(WXWidget widget, wxColour& foregroundColour); + static void DoChangeBackgroundColour(WXWidget widget, wxColour& backgroundColour, bool changeArmColour = FALSE); + + // For implementation purposes - sometimes decorations make the client area + // smaller + virtual wxPoint GetClientAreaOrigin() const; + +protected: + // event handlers (not virtual by design) + void OnIdle(wxIdleEvent& event); + + // Makes an adjustment to the window position (for example, a frame that has + // a toolbar that it manages itself). + virtual void AdjustForParentClientOrigin(int& x, int& y, int sizeFlags); + + wxWindow *GetChild(int number) const + { return GetChildren().Item(number)->GetData(); } + + // Responds to colour changes: passes event on to children. + void OnSysColourChanged(wxSysColourChangedEvent& event); + + // Motif-specific + + // CanvasXXXSiize functions + void CanvasGetSize(int* width, int* height) const; // If have drawing area + void CanvasGetClientSize(int *width, int *height) const; + void CanvasGetPosition(int *x, int *y) const; // If have drawing area + void CanvasSetClientSize(int width, int size); + void CanvasSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO); + + void SetMainWidget(WXWidget w) { m_mainWidget = w; } + + bool CanAddEventHandler() const { return m_canAddEventHandler; } + void SetCanAddEventHandler(bool flag) { m_canAddEventHandler = flag; } + +public: + WXPixmap GetBackingPixmap() const { return m_backingPixmap; } + void SetBackingPixmap(WXPixmap pixmap) { m_backingPixmap = pixmap; } + int GetPixmapWidth() const { return m_pixmapWidth; } + int GetPixmapHeight() const { return m_pixmapHeight; } + void SetPixmapWidth(int w) { m_pixmapWidth = w; } + void SetPixmapHeight(int h) { m_pixmapHeight = h; } + + // Change properties + virtual void ChangeFont(bool keepOriginalSize = TRUE); // Change to the current font (often overridden) + + // Change background and foreground colour using current background colour + // setting (Motif generates foreground based on background) + virtual void ChangeBackgroundColour(); + // Change foreground colour using current foreground colour setting + virtual void ChangeForegroundColour(); + +protected: + // Adds the widget to the hash table and adds event handlers. + bool AttachWidget(wxWindow* parent, WXWidget mainWidget, + WXWidget formWidget, int x, int y, int width, int height); + bool DetachWidget(WXWidget widget); + + // How to implement accelerators. If we find a key event, translate to + // wxWindows wxKeyEvent form. Find a widget for the window. Now find a + // wxWindow for the widget. If there isn't one, go up the widget hierarchy + // trying to find one. Once one is found, call ProcessAccelerator for the + // window. If it returns TRUE (processed the event), skip the X event, + // otherwise carry on up the wxWindows window hierarchy calling + // ProcessAccelerator. If all return FALSE, process the X event as normal. + // Eventually we can implement OnCharHook the same way, but concentrate on + // accelerators for now. ProcessAccelerator must look at the current + // accelerator table, and try to find what menu id or window (beneath it) + // has this ID. Then construct an appropriate command + // event and send it. +public: + virtual bool ProcessAccelerator(wxKeyEvent& event); + +protected: + // unmanage and destroy an X widget f it's !NULL (passing NULL is ok) + void UnmanageAndDestroy(WXWidget widget); + + // map or unmap an X widget (passing NULL is ok), returns TRUE if widget was + // mapped/unmapped + bool MapOrUnmap(WXWidget widget, bool map); + + // scrolling stuff + // --------------- + + // create/destroy window scrollbars + void CreateScrollbar(wxOrientation orientation); + void DestroyScrollbar(wxOrientation orientation); + + // get either hor or vert scrollbar widget + WXWidget GetScrollbar(wxOrientation orient) const + { return orient == wxHORIZONTAL ? m_hScrollBar : m_vScrollBar; } + + // set the scroll pos + void SetInternalScrollPos(wxOrientation orient, int pos) + { + if ( orient == wxHORIZONTAL ) + m_scrollPosX = pos; + else + m_scrollPosY = pos; + } + + // Motif-specific flags + // -------------------- + + bool m_needsRefresh:1; // repaint backing store? + bool m_canAddEventHandler:1; // ??? + bool m_button1Pressed:1; + bool m_button2Pressed:1; + bool m_button3Pressed:1; + + // For double-click detection + long m_lastTS; // last timestamp + int m_lastButton; // last pressed button + + // List of wxRects representing damaged region + wxRectList m_updateRects; + +protected: + WXWidget m_mainWidget; + WXWidget m_hScrollBar; + WXWidget m_vScrollBar; + WXWidget m_borderWidget; + WXWidget m_scrolledWindow; + WXWidget m_drawingArea; + bool m_winCaptured; + bool m_hScroll; + bool m_vScroll; + WXPixmap m_backingPixmap; + int m_pixmapWidth; + int m_pixmapHeight; + int m_pixmapOffsetX; + int m_pixmapOffsetY; + + // Store the last scroll pos, since in wxWin the pos isn't set automatically + // by system + int m_scrollPosX; + int m_scrollPosY; + + // implement the base class pure virtuals + virtual void DoClientToScreen( int *x, int *y ) const; + virtual void DoScreenToClient( int *x, int *y ) const; + virtual void DoGetPosition( int *x, int *y ) const; + virtual void DoGetSize( int *width, int *height ) const; + virtual void DoGetClientSize( int *width, int *height ) const; + virtual void DoSetSize(int x, int y, + int width, int height, + int sizeFlags = wxSIZE_AUTO); + virtual void DoSetClientSize(int width, int height); + virtual void DoMoveWindow(int x, int y, int width, int height); + virtual bool DoPopupMenu(wxMenu *menu, int x, int y); + + virtual void DoCaptureMouse(); + virtual void DoReleaseMouse(); + +#if wxUSE_TOOLTIPS + virtual void DoSetToolTip( wxToolTip *tip ); +#endif // wxUSE_TOOLTIPS + +private: + // common part of all ctors + void Init(); + + DECLARE_DYNAMIC_CLASS(wxWindow) + DECLARE_NO_COPY_CLASS(wxWindow) + DECLARE_EVENT_TABLE() +}; + +// ---------------------------------------------------------------------------- +// A little class to switch off `size optimization' while an instance of the +// object exists: this may be useful to temporarily disable the optimisation +// which consists to do nothing when the new size is equal to the old size - +// although quite useful usually to avoid flicker, sometimes it leads to +// undesired effects. +// +// Usage: create an instance of this class on the stack to disable the size +// optimisation, it will be reenabled as soon as the object goes out from scope. +// ---------------------------------------------------------------------------- + +class WXDLLEXPORT wxNoOptimize +{ +public: + wxNoOptimize() { ms_count++; } + ~wxNoOptimize() { ms_count--; } + + static bool CanOptimize() { return ms_count == 0; } + +protected: + static int ms_count; +}; + +#endif +// _WX_WINDOW_H_ diff --git a/src/x11/accel.cpp b/src/x11/accel.cpp new file mode 100644 index 0000000000..d90a47b958 --- /dev/null +++ b/src/x11/accel.cpp @@ -0,0 +1,116 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: accel.cpp +// Purpose: wxAcceleratorTable +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "accel.h" +#endif + +#include "wx/setup.h" +#include "wx/accel.h" +#include "wx/string.h" +#include "wx/utils.h" +#include + +IMPLEMENT_DYNAMIC_CLASS(wxAcceleratorTable, wxObject) + +class WXDLLEXPORT wxAcceleratorRefData: public wxObjectRefData +{ + friend class WXDLLEXPORT wxAcceleratorTable; +public: + wxAcceleratorRefData(); + ~wxAcceleratorRefData(); + +public: + int m_count; + wxAcceleratorEntry* m_entries; +}; + +#define M_ACCELDATA ((wxAcceleratorRefData *)m_refData) + +wxAcceleratorRefData::wxAcceleratorRefData() +{ + m_count = 0; + m_entries = (wxAcceleratorEntry*) NULL; +} + +wxAcceleratorRefData::~wxAcceleratorRefData() +{ + delete[] m_entries; + m_entries = (wxAcceleratorEntry*) NULL; + m_count = 0; +} + +wxAcceleratorTable::wxAcceleratorTable() +{ + m_refData = (wxAcceleratorRefData*) NULL; +} + +wxAcceleratorTable::~wxAcceleratorTable() +{ + // Data deleted in ~wxObject +} + +// Load from .rc resource +wxAcceleratorTable::wxAcceleratorTable(const wxString& WXUNUSED(resource)) +{ + m_refData = new wxAcceleratorRefData; +} + +// Create from an array +wxAcceleratorTable::wxAcceleratorTable(int n, wxAcceleratorEntry entries[]) +{ + wxAcceleratorRefData* data = new wxAcceleratorRefData; + m_refData = data; + + data->m_count = n; + data->m_entries = new wxAcceleratorEntry[n]; + int i; + for (i = 0; i < n; i++) + data->m_entries[i] = entries[i]; + +} + +bool wxAcceleratorTable::Ok() const +{ + return (m_refData != (wxAcceleratorRefData*) NULL); +} + +int wxAcceleratorTable::GetCount() const +{ + return M_ACCELDATA->m_count; +} + +wxAcceleratorEntry* wxAcceleratorTable::GetEntries() const +{ + return M_ACCELDATA->m_entries; +} + +// Implementation use only +bool wxAcceleratorEntry::MatchesEvent(const wxKeyEvent& event) const +{ + bool eventAltDown = event.AltDown(); + bool eventCtrlDown = event.ControlDown(); + bool eventShiftDown = event.ShiftDown(); + int eventKeyCode = event.KeyCode(); + + bool accAltDown = ((GetFlags() & wxACCEL_ALT) == wxACCEL_ALT); + bool accCtrlDown = ((GetFlags() & wxACCEL_CTRL) == wxACCEL_CTRL); + bool accShiftDown = ((GetFlags() & wxACCEL_SHIFT) == wxACCEL_SHIFT); + int accKeyCode = GetKeyCode(); + int accKeyCode2 = GetKeyCode(); + if (isascii(accKeyCode2)) + accKeyCode2 = tolower(accKeyCode2); + + return ((eventAltDown == accAltDown) && (eventCtrlDown == accCtrlDown) && + (eventShiftDown == accShiftDown) && + ((eventKeyCode == accKeyCode || eventKeyCode == accKeyCode2))) ; +} + diff --git a/src/x11/app.cpp b/src/x11/app.cpp new file mode 100644 index 0000000000..8b019fdf6e --- /dev/null +++ b/src/x11/app.cpp @@ -0,0 +1,796 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: app.cpp +// Purpose: wxApp +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ + #pragma implementation "app.h" +#endif + +#ifdef __VMS +#define XtParent XTPARENT +#define XtDisplay XTDISPLAY +#endif + +#include "wx/frame.h" +#include "wx/app.h" +#include "wx/utils.h" +#include "wx/gdicmn.h" +#include "wx/pen.h" +#include "wx/brush.h" +#include "wx/cursor.h" +#include "wx/icon.h" +#include "wx/palette.h" +#include "wx/dc.h" +#include "wx/dialog.h" +#include "wx/msgdlg.h" +#include "wx/log.h" +#include "wx/module.h" +#include "wx/memory.h" +#include "wx/log.h" +#include "wx/intl.h" + +#if wxUSE_THREADS + #include "wx/thread.h" +#endif + +#if wxUSE_WX_RESOURCES + #include "wx/resource.h" +#endif + +#ifdef __VMS__ +#pragma message disable nosimpint +#endif +#include +#include +#include +#include +#include +#ifdef __VMS__ +#pragma message enable nosimpint +#endif + +#include "wx/motif/private.h" + +#include + +extern char *wxBuffer; +extern wxList wxPendingDelete; + +wxApp *wxTheApp = NULL; + +wxHashTable *wxWidgetHashTable = NULL; + +IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler) + +BEGIN_EVENT_TABLE(wxApp, wxEvtHandler) + EVT_IDLE(wxApp::OnIdle) +END_EVENT_TABLE() + +#ifdef __WXDEBUG__ + typedef int (*XErrorHandlerFunc)(Display *, XErrorEvent *); + + XErrorHandlerFunc gs_pfnXErrorHandler = 0; + + static int wxXErrorHandler(Display *dpy, XErrorEvent *xevent) + { + // just forward to the default handler for now + return gs_pfnXErrorHandler(dpy, xevent); + } +#endif // __WXDEBUG__ + +long wxApp::sm_lastMessageTime = 0; + +bool wxApp::Initialize() +{ + wxBuffer = new char[BUFSIZ + 512]; + + wxClassInfo::InitializeClasses(); + + // GL: I'm annoyed ... I don't know where to put this and I don't want to + // create a module for that as it's part of the core. +#if wxUSE_THREADS + wxPendingEventsLocker = new wxCriticalSection(); +#endif + + wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING); + wxTheColourDatabase->Initialize(); + + wxInitializeStockLists(); + wxInitializeStockObjects(); + +#if wxUSE_WX_RESOURCES + wxInitializeResourceSystem(); +#endif + + // For PostScript printing +#if wxUSE_POSTSCRIPT + /* Done using wxModule now + wxInitializePrintSetupData(); + wxThePrintPaperDatabase = new wxPrintPaperDatabase; + wxThePrintPaperDatabase->CreateDatabase(); + */ +#endif + + wxBitmap::InitStandardHandlers(); + + wxWidgetHashTable = new wxHashTable(wxKEY_INTEGER); + + wxModule::RegisterModules(); + if (!wxModule::InitializeModules()) return FALSE; + + return TRUE; +} + +void wxApp::CleanUp() +{ + delete wxWidgetHashTable; + wxWidgetHashTable = NULL; + + wxModule::CleanUpModules(); + +#if wxUSE_WX_RESOURCES + wxCleanUpResourceSystem(); +#endif + + wxDeleteStockObjects() ; + + // Destroy all GDI lists, etc. + + wxDeleteStockLists(); + + delete wxTheColourDatabase; + wxTheColourDatabase = NULL; + +#if wxUSE_POSTSCRIPT + /* Done using wxModule now + wxInitializePrintSetupData(FALSE); + delete wxThePrintPaperDatabase; + wxThePrintPaperDatabase = NULL; + */ +#endif + + wxBitmap::CleanUpHandlers(); + + delete[] wxBuffer; + wxBuffer = NULL; + + wxClassInfo::CleanUpClasses(); + + delete wxTheApp; + wxTheApp = NULL; + + // GL: I'm annoyed ... I don't know where to put this and I don't want to + // create a module for that as it's part of the core. +#if wxUSE_THREADS + delete wxPendingEvents; + delete wxPendingEventsLocker; +#endif + +#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT + // At this point we want to check if there are any memory + // blocks that aren't part of the wxDebugContext itself, + // as a special case. Then when dumping we need to ignore + // wxDebugContext, too. + if (wxDebugContext::CountObjectsLeft(TRUE) > 0) + { + wxLogDebug("There were memory leaks.\n"); + wxDebugContext::Dump(); + wxDebugContext::PrintStatistics(); + } +#endif + + // do it as the very last thing because everything else can log messages + wxLog::DontCreateOnDemand(); + // do it as the very last thing because everything else can log messages + delete wxLog::SetActiveTarget(NULL); +} + +int wxEntry( int argc, char *argv[] ) +{ +#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT + // This seems to be necessary since there are 'rogue' + // objects present at this point (perhaps global objects?) + // Setting a checkpoint will ignore them as far as the + // memory checking facility is concerned. + // Of course you may argue that memory allocated in globals should be + // checked, but this is a reasonable compromise. + wxDebugContext::SetCheckpoint(); +#endif + + if (!wxApp::Initialize()) + return FALSE; + + if (!wxTheApp) + { + if (!wxApp::GetInitializerFunction()) + { + printf( "wxWindows error: No initializer - use IMPLEMENT_APP macro.\n" ); + return 0; + }; + + wxTheApp = (wxApp*) (* wxApp::GetInitializerFunction()) (); + }; + + if (!wxTheApp) + { + printf( "wxWindows error: wxTheApp == NULL\n" ); + return 0; + }; + + wxTheApp->SetClassName(wxFileNameFromPath(argv[0])); + wxTheApp->SetAppName(wxFileNameFromPath(argv[0])); + + wxTheApp->argc = argc; + wxTheApp->argv = argv; + + // GUI-specific initialization, such as creating an app context. + wxTheApp->OnInitGui(); + + // Here frames insert themselves automatically into wxTopLevelWindows by + // getting created in OnInit(). + + int retValue = 0; + if (wxTheApp->OnInit()) + { + if (wxTheApp->Initialized()) retValue = wxTheApp->OnRun(); + } + + // flush the logged messages if any + wxLog *pLog = wxLog::GetActiveTarget(); + if ( pLog != NULL && pLog->HasPendingMessages() ) + pLog->Flush(); + + delete wxLog::SetActiveTarget(new wxLogStderr); // So dialog boxes aren't used + // for further messages + + if (wxTheApp->GetTopWindow()) + { + delete wxTheApp->GetTopWindow(); + wxTheApp->SetTopWindow(NULL); + } + + wxTheApp->DeletePendingObjects(); + + wxTheApp->OnExit(); + + wxApp::CleanUp(); + + return retValue; +}; + +// Static member initialization +wxAppInitializerFunction wxAppBase::m_appInitFn = (wxAppInitializerFunction) NULL; + +wxApp::wxApp() +{ + m_topWindow = NULL; + wxTheApp = this; + m_className = ""; + m_wantDebugOutput = TRUE ; + m_appName = ""; + argc = 0; + argv = NULL; + m_exitOnFrameDelete = TRUE; + + m_mainColormap = (WXColormap) NULL; + m_appContext = (WXAppContext) NULL; + m_topLevelWidget = (WXWidget) NULL; + m_maxRequestSize = 0; + m_initialDisplay = (WXDisplay*) 0; +} + +bool wxApp::Initialized() +{ + if (GetTopWindow()) + return TRUE; + else + return FALSE; +} + +int wxApp::MainLoop() +{ + m_keepGoing = TRUE; + + /* + * Sit around forever waiting to process X-events. Property Change + * event are handled special, because they have to refer to + * the root window rather than to a widget. therefore we can't + * use an Xt-eventhandler. + */ + + XSelectInput(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()), + XDefaultRootWindow(XtDisplay((Widget) wxTheApp->GetTopLevelWidget())), + PropertyChangeMask); + + XEvent event; + + // Use this flag to allow breaking the loop via wxApp::ExitMainLoop() + while (m_keepGoing) + { + XtAppNextEvent( (XtAppContext) wxTheApp->GetAppContext(), &event); + + ProcessXEvent((WXEvent*) & event); + + if (XtAppPending( (XtAppContext) wxTheApp->GetAppContext() ) == 0) + { + if (!ProcessIdle()) + { +#if wxUSE_THREADS + // leave the main loop to give other threads a chance to + // perform their GUI work + wxMutexGuiLeave(); + wxUsleep(20); + wxMutexGuiEnter(); +#endif + } + } + + } + + return 0; +} + +// Processes an X event. +void wxApp::ProcessXEvent(WXEvent* _event) +{ + XEvent* event = (XEvent*) _event; + + if (event->type == KeyPress) + { +#if 0 // def __WXDEBUG__ + Widget widget = XtWindowToWidget(event->xany.display, event->xany.window); + wxLogDebug("Got key press event for 0x%08x (parent = 0x%08x)", + widget, XtParent(widget)); +#endif // DEBUG + + if (CheckForAccelerator(_event)) + { + // Do nothing! We intercepted and processed the event as an + // accelerator. + return; + } +#if 1 + // It seemed before that this hack was redundant and + // key down events were being generated by wxCanvasInputEvent. + // But no longer - why ??? + // + else if (CheckForKeyDown(_event)) + { + // We intercepted and processed the key down event + return; + } +#endif + else + { + XtDispatchEvent(event); + return; + } + } + else if (event->type == KeyRelease) + { + // TODO: work out why we still need this ! -michael + // + if (CheckForKeyUp(_event)) + { + // We intercepted and processed the key up event + return; + } + else + { + XtDispatchEvent(event); + return; + } + } + else if (event->type == PropertyNotify) + { + HandlePropertyChange(_event); + return; + } + else if (event->type == ResizeRequest) + { + /* Terry Gitnick - 1/21/98 + * If resize event, don't resize until the last resize event for this + * window is recieved. Prevents flicker as windows are resized. + */ + + Display *disp = XtDisplay((Widget) wxTheApp->GetTopLevelWidget()); + Window win = event->xany.window; + XEvent report; + + // to avoid flicker + report = * event; + while( XCheckTypedWindowEvent (disp, win, ResizeRequest, &report)); + + // TODO: when implementing refresh optimization, we can use + // XtAddExposureToRegion to expand the window's paint region. + + XtDispatchEvent(event); + } + else + { + XtDispatchEvent(event); + } +} + +// Returns TRUE if more time is needed. +bool wxApp::ProcessIdle() +{ + wxIdleEvent event; + event.SetEventObject(this); + ProcessEvent(event); + + return event.MoreRequested(); +} + +void wxApp::ExitMainLoop() +{ + m_keepGoing = FALSE; +} + +// Is a message/event pending? +bool wxApp::Pending() +{ + XFlush(XtDisplay( (Widget) wxTheApp->GetTopLevelWidget() )); + + // Fix by Doug from STI, to prevent a stall if non-X event + // is found. + return ((XtAppPending( (XtAppContext) GetAppContext() ) & XtIMXEvent) != 0) ; +} + +// Dispatch a message. +void wxApp::Dispatch() +{ + // XtAppProcessEvent( (XtAppContext) wxTheApp->GetAppContext(), XtIMAll); + + XEvent event; + XtAppNextEvent((XtAppContext) GetAppContext(), &event); + ProcessXEvent((WXEvent*) & event); +} + +// This should be redefined in a derived class for +// handling property change events for XAtom IPC. +void wxApp::HandlePropertyChange(WXEvent *event) +{ + // by default do nothing special + XtDispatchEvent((XEvent*) event); /* let Motif do the work */ +} + +void wxApp::OnIdle(wxIdleEvent& event) +{ + static bool inOnIdle = FALSE; + + // Avoid recursion (via ProcessEvent default case) + if (inOnIdle) + return; + + inOnIdle = TRUE; + + // If there are pending events, we must process them: pending events + // are either events to the threads other than main or events posted + // with wxPostEvent() functions + // GRG: I have moved this here so that all pending events are processed + // before starting to delete any objects. This behaves better (in + // particular, wrt wxPostEvent) and is coherent with wxGTK's current + // behaviour. Also removed the '#if wxUSE_THREADS' around it. + // Changed Mar/2000 before 2.1.14 + + // Flush pending events. + ProcessPendingEvents(); + + // 'Garbage' collection of windows deleted with Close(). + DeletePendingObjects(); + + // flush the logged messages if any + wxLog *pLog = wxLog::GetActiveTarget(); + if ( pLog != NULL && pLog->HasPendingMessages() ) + pLog->Flush(); + + // Send OnIdle events to all windows + bool needMore = SendIdleEvents(); + + if (needMore) + event.RequestMore(TRUE); + + inOnIdle = FALSE; +} + +void wxWakeUpIdle() +{ + // **** please implement me! **** + // Wake up the idle handler processor, even if it is in another thread... +} + + +// Send idle event to all top-level windows +bool wxApp::SendIdleEvents() +{ + bool needMore = FALSE; + + wxWindowList::Node* node = wxTopLevelWindows.GetFirst(); + while (node) + { + wxWindow* win = node->GetData(); + if (SendIdleEvents(win)) + needMore = TRUE; + node = node->GetNext(); + } + + return needMore; +} + +// Send idle event to window and all subwindows +bool wxApp::SendIdleEvents(wxWindow* win) +{ + bool needMore = FALSE; + + wxIdleEvent event; + event.SetEventObject(win); + win->ProcessEvent(event); + + if (event.MoreRequested()) + needMore = TRUE; + + wxNode* node = win->GetChildren().First(); + while (node) + { + wxWindow* win = (wxWindow*) node->Data(); + if (SendIdleEvents(win)) + needMore = TRUE; + + node = node->Next(); + } + return needMore ; +} + +void wxApp::DeletePendingObjects() +{ + wxNode *node = wxPendingDelete.First(); + while (node) + { + wxObject *obj = (wxObject *)node->Data(); + + delete obj; + + if (wxPendingDelete.Member(obj)) + delete node; + + // Deleting one object may have deleted other pending + // objects, so start from beginning of list again. + node = wxPendingDelete.First(); + } +} + +// Create an application context +bool wxApp::OnInitGui() +{ + XtToolkitInitialize() ; + wxTheApp->m_appContext = (WXAppContext) XtCreateApplicationContext() ; + Display *dpy = XtOpenDisplay((XtAppContext) wxTheApp->m_appContext,(String)NULL,NULL, + (const char*) wxTheApp->GetClassName(), NULL, 0, +# if XtSpecificationRelease < 5 + (Cardinal*) &argc, +# else + &argc, +# endif + argv); + + if (!dpy) { + wxString className(wxTheApp->GetClassName()); + wxLogError(_("wxWindows could not open display for '%s': exiting."), + (const char*) className); + exit(-1); + } + m_initialDisplay = (WXDisplay*) dpy; + +#ifdef __WXDEBUG__ + // install the X error handler + gs_pfnXErrorHandler = XSetErrorHandler(wxXErrorHandler); +#endif // __WXDEBUG__ + + wxTheApp->m_topLevelWidget = (WXWidget) XtAppCreateShell((String)NULL, (const char*) wxTheApp->GetClassName(), + applicationShellWidgetClass,dpy, + NULL,0) ; + + // Add general resize proc + XtActionsRec rec; + rec.string = "resize"; + rec.proc = (XtActionProc)wxWidgetResizeProc; + XtAppAddActions((XtAppContext) wxTheApp->m_appContext, &rec, 1); + + GetMainColormap(dpy); + m_maxRequestSize = XMaxRequestSize((Display*) dpy); + + return TRUE; +} + +WXColormap wxApp::GetMainColormap(WXDisplay* display) +{ + if (!display) /* Must be called first with non-NULL display */ + return m_mainColormap; + + int defaultScreen = DefaultScreen((Display*) display); + Screen* screen = XScreenOfDisplay((Display*) display, defaultScreen); + + Colormap c = DefaultColormapOfScreen(screen); + + if (!m_mainColormap) + m_mainColormap = (WXColormap) c; + + return (WXColormap) c; +} + +// Returns TRUE if an accelerator has been processed +bool wxApp::CheckForAccelerator(WXEvent* event) +{ + XEvent* xEvent = (XEvent*) event; + if (xEvent->xany.type == KeyPress) + { + // Find a wxWindow for this window + // TODO: should get display for the window, not the current display + Widget widget = XtWindowToWidget((Display*) wxGetDisplay(), xEvent->xany.window); + wxWindow* win = NULL; + + // Find the first wxWindow that corresponds to this event window + while (widget && !(win = wxGetWindowFromTable(widget))) + widget = XtParent(widget); + + if (!widget || !win) + return FALSE; + + wxKeyEvent keyEvent(wxEVT_CHAR); + wxTranslateKeyEvent(keyEvent, win, (Widget) 0, xEvent); + + // Now we have a wxKeyEvent and we have a wxWindow. + // Go up the hierarchy until we find a matching accelerator, + // or we get to the top. + while (win) + { + if (win->ProcessAccelerator(keyEvent)) + return TRUE; + win = win->GetParent(); + } + return FALSE; + } + return FALSE; +} + +bool wxApp::CheckForKeyDown(WXEvent* event) +{ + XEvent* xEvent = (XEvent*) event; + if (xEvent->xany.type == KeyPress) + { + Widget widget = XtWindowToWidget((Display*) wxGetDisplay(), + xEvent->xany.window); + wxWindow* win = NULL; + + // Find the first wxWindow that corresponds to this event window + while (widget && !(win = wxGetWindowFromTable(widget))) + widget = XtParent(widget); + + if (!widget || !win) + return FALSE; + + wxKeyEvent keyEvent(wxEVT_KEY_DOWN); + wxTranslateKeyEvent(keyEvent, win, (Widget) 0, xEvent); + + return win->ProcessEvent( keyEvent ); + } + + return FALSE; +} + +bool wxApp::CheckForKeyUp(WXEvent* event) +{ + XEvent* xEvent = (XEvent*) event; + if (xEvent->xany.type == KeyRelease) + { + Widget widget = XtWindowToWidget((Display*) wxGetDisplay(), + xEvent->xany.window); + wxWindow* win = NULL; + + // Find the first wxWindow that corresponds to this event window + while (widget && !(win = wxGetWindowFromTable(widget))) + widget = XtParent(widget); + + if (!widget || !win) + return FALSE; + + wxKeyEvent keyEvent(wxEVT_KEY_UP); + wxTranslateKeyEvent(keyEvent, win, (Widget) 0, xEvent); + + return win->ProcessEvent( keyEvent ); + } + + return FALSE; +} + +void wxExit() +{ + int retValue = 0; + if (wxTheApp) + retValue = wxTheApp->OnExit(); + + wxApp::CleanUp(); + /* + * Exit in some platform-specific way. Not recommended that the app calls this: + * only for emergencies. + */ + exit(retValue); +} + +// Yield to other processes + +bool wxApp::Yield(bool onlyIfNeeded) +{ + bool s_inYield = FALSE; + + if ( s_inYield ) + { + if ( !onlyIfNeeded ) + { + wxFAIL_MSG( wxT("wxYield called recursively" ) ); + } + + return FALSE; + } + + s_inYield = TRUE; + + while (wxTheApp && wxTheApp->Pending()) + wxTheApp->Dispatch(); + + s_inYield = FALSE; + + return TRUE; +} + +// TODO use XmGetPixmap (?) to get the really standard icons! + +// XPM hack: make the arrays const +#define static static const + +#include "wx/generic/info.xpm" +#include "wx/generic/error.xpm" +#include "wx/generic/question.xpm" +#include "wx/generic/warning.xpm" + +#undef static + +wxIcon +wxApp::GetStdIcon(int which) const +{ + switch(which) + { + case wxICON_INFORMATION: + return wxIcon(info_xpm); + + case wxICON_QUESTION: + return wxIcon(question_xpm); + + case wxICON_EXCLAMATION: + return wxIcon(warning_xpm); + + default: + wxFAIL_MSG("requested non existent standard icon"); + // still fall through + + case wxICON_HAND: + return wxIcon(error_xpm); + } +} + +// ---------------------------------------------------------------------------- +// accessors for C modules +// ---------------------------------------------------------------------------- + +extern "C" XtAppContext wxGetAppContext() +{ + return (XtAppContext)wxTheApp->GetAppContext(); +} diff --git a/src/x11/bitmap.cpp b/src/x11/bitmap.cpp new file mode 100644 index 0000000000..dc6bb3bb82 --- /dev/null +++ b/src/x11/bitmap.cpp @@ -0,0 +1,1558 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: bitmap.cpp +// Purpose: wxBitmap +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "bitmap.h" +#endif + +#ifdef __VMS +#define XtParent XTPARENT +#endif + +#include "wx/setup.h" +#include "wx/utils.h" +#include "wx/palette.h" +#include "wx/bitmap.h" +#include "wx/icon.h" +#include "wx/log.h" +#include "wx/control.h" +#include "wx/dcmemory.h" +#include "wx/image.h" +#include "wx/app.h" + +#ifdef __VMS__ +#pragma message disable nosimpint +#endif +#include +#ifdef __VMS__ +#pragma message enable nosimpint +#endif + +#include "wx/motif/private.h" + +#if wxHAVE_LIB_XPM + #include +#endif +#include + + +IMPLEMENT_DYNAMIC_CLASS(wxBitmap, wxGDIObject) +IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject) + +wxBitmapRefData::wxBitmapRefData() +{ + m_ok = FALSE; + m_width = 0; + m_height = 0; + m_depth = 0; + m_quality = 0; + m_numColors = 0; + m_bitmapMask = NULL; + + m_pixmap = (WXPixmap) 0; + m_display = (WXDisplay*) 0; + + m_freePixmap = TRUE; //TODO: necessary? + m_freeColors = (unsigned long*) 0; + m_freeColorsCount = 0; + + // These 5 variables are for wxControl + m_insensPixmap = (WXPixmap) 0; + m_labelPixmap = (WXPixmap) 0; + m_armPixmap = (WXPixmap) 0; + m_image = (WXImage*) 0; + m_insensImage = (WXImage*) 0; +} + +wxBitmapRefData::~wxBitmapRefData() +{ + if (m_labelPixmap) + XmDestroyPixmap (DefaultScreenOfDisplay ((Display*) m_display), (Pixmap) m_labelPixmap); + + if (m_armPixmap) + XmDestroyPixmap (DefaultScreenOfDisplay ((Display*) m_display), (Pixmap) m_armPixmap); + + if (m_insensPixmap) + XmDestroyPixmap (DefaultScreenOfDisplay ((Display*) m_display), (Pixmap) m_insensPixmap); + + if (m_image) + { + XmUninstallImage ((XImage*) m_image); + XtFree ((char *) (XImage*) m_image); + } + + if (m_insensImage) + { + XmUninstallImage ((XImage*) m_insensImage); + delete[] ((XImage*) m_insensImage)->data; + XtFree ((char *) (XImage*) m_insensImage); + } + if (m_pixmap && m_freePixmap) + XFreePixmap ((Display*) m_display, (Pixmap) m_pixmap); + + if (m_freeColors) + { + int screen = DefaultScreen((Display*) m_display); + Colormap cmp = DefaultColormap((Display*) m_display,screen); + long llp; + for(llp = 0;llp < m_freeColorsCount;llp++) + XFreeColors((Display*) m_display, cmp, &m_freeColors[llp], 1, 0L); + delete m_freeColors; + }; + + if (m_bitmapMask) + delete m_bitmapMask; + m_bitmapMask = NULL; +} + +wxList wxBitmap::sm_handlers; + +#define M_BMPDATA ((wxBitmapRefData *)m_refData) + +wxBitmap::wxBitmap() +{ + m_refData = NULL; +} + +wxBitmap::~wxBitmap() +{ +} + +wxBitmap::wxBitmap(const char bits[], int width, int height, int depth) +{ + m_refData = new wxBitmapRefData; + + (void) Create((void*) bits, wxBITMAP_TYPE_XBM_DATA, width, height, depth); +} + +wxBitmap::wxBitmap(int w, int h, int d) +{ + (void)Create(w, h, d); +} + +wxBitmap::wxBitmap(void *data, long type, int width, int height, int depth) +{ + (void) Create(data, type, width, height, depth); +} + +wxBitmap::wxBitmap(const wxString& filename, long type) +{ + LoadFile(filename, (int)type); +} + +// Create from XPM data +static wxControl* sg_Control = NULL; +wxBitmap::wxBitmap(char **data, wxControl* control) +{ + // Pass the control to the Create function using a global + sg_Control = control; + + (void) Create((void *)data, wxBITMAP_TYPE_XPM_DATA, 0, 0, 0); + + sg_Control = (wxControl*) NULL; +} + +bool wxBitmap::CreateFromXpm(const char **bits) +{ + wxCHECK_MSG( bits, FALSE, _T("NULL pointer in wxBitmap::CreateFromXpm") ); + + return Create(bits, wxBITMAP_TYPE_XPM_DATA, 0, 0, 0); +} + +bool wxBitmap::Create(int w, int h, int d) +{ + UnRef(); + + m_refData = new wxBitmapRefData; + + if (d < 1) + d = wxDisplayDepth(); + + M_BITMAPDATA->m_width = w; + M_BITMAPDATA->m_height = h; + M_BITMAPDATA->m_depth = d; + M_BITMAPDATA->m_freePixmap = TRUE; + + Display *dpy = (Display*) wxGetDisplay(); + + M_BITMAPDATA->m_display = dpy; /* MATTHEW: [4] Remember the display */ + + M_BITMAPDATA->m_pixmap = (WXPixmap) XCreatePixmap (dpy, RootWindow (dpy, DefaultScreen (dpy)), + w, h, d); + + M_BITMAPDATA->m_ok = (M_BITMAPDATA->m_pixmap != (WXPixmap) 0) ; + return M_BITMAPDATA->m_ok; +} + +bool wxBitmap::LoadFile(const wxString& filename, long type) +{ + UnRef(); + + m_refData = new wxBitmapRefData; + + wxBitmapHandler *handler = FindHandler(type); + + if ( handler == NULL ) { + wxImage image; + if (!image.LoadFile( filename, type )) return FALSE; + if (image.Ok()) + { + *this = image.ConvertToBitmap(); + return TRUE; + } + else return FALSE; + } + + return handler->LoadFile(this, filename, type, -1, -1); +} + +bool wxBitmap::Create(void *data, long type, int width, int height, int depth) +{ + UnRef(); + + m_refData = new wxBitmapRefData; + + wxBitmapHandler *handler = FindHandler(type); + + if ( handler == NULL ) { + wxLogWarning("no data bitmap handler for type %d defined.", type); + + return FALSE; + } + + return handler->Create(this, data, type, width, height, depth); +} + +bool wxBitmap::SaveFile(const wxString& filename, int type, const wxPalette *palette) +{ + wxBitmapHandler *handler = FindHandler(type); + + if ( handler == NULL ) { // try wxImage + wxImage image( *this ); + if (image.Ok()) return image.SaveFile( filename, type ); + else return FALSE; + } + + return handler->SaveFile(this, filename, type, palette); +} + +void wxBitmap::SetWidth(int w) +{ + if (!M_BITMAPDATA) + m_refData = new wxBitmapRefData; + + M_BITMAPDATA->m_width = w; +} + +void wxBitmap::SetHeight(int h) +{ + if (!M_BITMAPDATA) + m_refData = new wxBitmapRefData; + + M_BITMAPDATA->m_height = h; +} + +void wxBitmap::SetDepth(int d) +{ + if (!M_BITMAPDATA) + m_refData = new wxBitmapRefData; + + M_BITMAPDATA->m_depth = d; +} + +void wxBitmap::SetQuality(int q) +{ + if (!M_BITMAPDATA) + m_refData = new wxBitmapRefData; + + M_BITMAPDATA->m_quality = q; +} + +void wxBitmap::SetOk(bool isOk) +{ + if (!M_BITMAPDATA) + m_refData = new wxBitmapRefData; + + M_BITMAPDATA->m_ok = isOk; +} + +void wxBitmap::SetPalette(const wxPalette& palette) +{ + if (!M_BITMAPDATA) + m_refData = new wxBitmapRefData; + + M_BITMAPDATA->m_bitmapPalette = palette ; +} + +void wxBitmap::SetMask(wxMask *mask) +{ + if (!M_BITMAPDATA) + m_refData = new wxBitmapRefData; + + M_BITMAPDATA->m_bitmapMask = mask ; +} + +wxBitmap wxBitmap::GetSubBitmap( const wxRect& rect) const +{ + wxCHECK_MSG( Ok() && + (rect.x >= 0) && (rect.y >= 0) && + (rect.x+rect.width <= M_BMPDATA->m_width) && (rect.y+rect.height <= M_BMPDATA->m_height), + wxNullBitmap, wxT("invalid bitmap or bitmap region") ); + + wxBitmap ret( rect.width, rect.height, 0 ); + wxASSERT_MSG( ret.Ok(), wxT("GetSubBitmap error") ); + + // The remaining still TODO + return ret; +} + +void wxBitmap::AddHandler(wxBitmapHandler *handler) +{ + sm_handlers.Append(handler); +} + +void wxBitmap::InsertHandler(wxBitmapHandler *handler) +{ + sm_handlers.Insert(handler); +} + +bool wxBitmap::RemoveHandler(const wxString& name) +{ + wxBitmapHandler *handler = FindHandler(name); + if ( handler ) + { + sm_handlers.DeleteObject(handler); + return TRUE; + } + else + return FALSE; +} + +wxBitmapHandler *wxBitmap::FindHandler(const wxString& name) +{ + wxNode *node = sm_handlers.First(); + while ( node ) + { + wxBitmapHandler *handler = (wxBitmapHandler *)node->Data(); + if ( handler->GetName() == name ) + return handler; + node = node->Next(); + } + return NULL; +} + +wxBitmapHandler *wxBitmap::FindHandler(const wxString& extension, long bitmapType) +{ + wxNode *node = sm_handlers.First(); + while ( node ) + { + wxBitmapHandler *handler = (wxBitmapHandler *)node->Data(); + if ( handler->GetExtension() == extension && + (bitmapType == -1 || handler->GetType() == bitmapType) ) + return handler; + node = node->Next(); + } + return NULL; +} + +wxBitmapHandler *wxBitmap::FindHandler(long bitmapType) +{ + wxNode *node = sm_handlers.First(); + while ( node ) + { + wxBitmapHandler *handler = (wxBitmapHandler *)node->Data(); + if (handler->GetType() == bitmapType) + return handler; + node = node->Next(); + } + return NULL; +} + +/* +* wxMask +*/ + +wxMask::wxMask() +{ + m_pixmap = (WXPixmap) 0; +} + +// Construct a mask from a bitmap and a colour indicating +// the transparent area +wxMask::wxMask(const wxBitmap& bitmap, const wxColour& colour) +{ + m_pixmap = (WXPixmap) 0; + + Create(bitmap, colour); +} + +// Construct a mask from a bitmap and a palette index indicating +// the transparent area +wxMask::wxMask(const wxBitmap& bitmap, int paletteIndex) +{ + m_pixmap = (WXPixmap) 0; + + Create(bitmap, paletteIndex); +} + +// Construct a mask from a mono bitmap (copies the bitmap). +wxMask::wxMask(const wxBitmap& bitmap) +{ + m_pixmap = (WXPixmap) 0; + + Create(bitmap); +} + +wxMask::~wxMask() +{ + // TODO: this may be the wrong display + if ( m_pixmap ) + XFreePixmap ((Display*) wxGetDisplay(), (Pixmap) m_pixmap); +} + +// Create a mask from a mono bitmap (copies the bitmap). +bool wxMask::Create(const wxBitmap& WXUNUSED(bitmap)) +{ + // TODO + return FALSE; +} + +// Create a mask from a bitmap and a palette index indicating +// the transparent area +bool wxMask::Create(const wxBitmap& WXUNUSED(bitmap), int WXUNUSED(paletteIndex)) +{ + // TODO + return FALSE; +} + +// Create a mask from a bitmap and a colour indicating +// the transparent area +bool wxMask::Create(const wxBitmap& WXUNUSED(bitmap), const wxColour& WXUNUSED(colour)) +{ + // TODO + return FALSE; +} + +/* +* wxBitmapHandler +*/ + +IMPLEMENT_DYNAMIC_CLASS(wxBitmapHandler, wxObject) + +bool wxBitmapHandler::Create(wxBitmap *WXUNUSED(bitmap), void *WXUNUSED(data), long WXUNUSED(type), + int WXUNUSED(width), int WXUNUSED(height), int WXUNUSED(depth)) +{ + return FALSE; +} + +bool wxBitmapHandler::LoadFile(wxBitmap *WXUNUSED(bitmap), const wxString& WXUNUSED(name), long WXUNUSED(type), + int WXUNUSED(desiredWidth), int WXUNUSED(desiredHeight)) +{ + return FALSE; +} + +bool wxBitmapHandler::SaveFile(wxBitmap *WXUNUSED(bitmap), const wxString& WXUNUSED(name), int WXUNUSED(type), + const wxPalette *WXUNUSED(palette)) +{ + return FALSE; +} + +/* +* Standard handlers +*/ + +class WXDLLEXPORT wxXBMFileHandler: public wxBitmapHandler +{ + DECLARE_DYNAMIC_CLASS(wxXBMFileHandler) +public: + inline wxXBMFileHandler() + { + m_name = "XBM file"; + m_extension = "xbm"; + m_type = wxBITMAP_TYPE_XBM; + }; + + virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags, + int desiredWidth, int desiredHeight); +}; +IMPLEMENT_DYNAMIC_CLASS(wxXBMFileHandler, wxBitmapHandler) + +bool wxXBMFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long WXUNUSED(flags), + int WXUNUSED(desiredWidth), int WXUNUSED(desiredHeight)) +{ + M_BITMAPHANDLERDATA->m_freePixmap = TRUE; + + int hotX, hotY; + unsigned int w, h; + Pixmap pixmap; + + Display *dpy = (Display*) wxGetDisplay(); + M_BITMAPDATA->m_display = (WXDisplay*) dpy; + + int value = XReadBitmapFile (dpy, RootWindow (dpy, DefaultScreen (dpy)), + (char*) (const char*) name, &w, &h, &pixmap, &hotX, &hotY); + M_BITMAPHANDLERDATA->m_width = w; + M_BITMAPHANDLERDATA->m_height = h; + M_BITMAPHANDLERDATA->m_depth = 1; + M_BITMAPHANDLERDATA->m_pixmap = (WXPixmap) pixmap; + + if ((value == BitmapFileInvalid) || + (value == BitmapOpenFailed) || + (value == BitmapNoMemory)) + { + M_BITMAPHANDLERDATA->m_ok = FALSE; + M_BITMAPHANDLERDATA->m_pixmap = (WXPixmap) 0; + } + else + M_BITMAPHANDLERDATA->m_ok = TRUE; + + return M_BITMAPHANDLERDATA->m_ok ; +} + +class WXDLLEXPORT wxXBMDataHandler: public wxBitmapHandler +{ + DECLARE_DYNAMIC_CLASS(wxXBMDataHandler) +public: + inline wxXBMDataHandler() + { + m_name = "XBM data"; + m_extension = "xbm"; + m_type = wxBITMAP_TYPE_XBM_DATA; + }; + + virtual bool Create(wxBitmap *bitmap, void *data, long flags, int width, int height, int depth = 1); +}; +IMPLEMENT_DYNAMIC_CLASS(wxXBMDataHandler, wxBitmapHandler) + +bool wxXBMDataHandler::Create( wxBitmap *bitmap, void *data, long WXUNUSED(flags), + int width, int height, int WXUNUSED(depth)) +{ + M_BITMAPHANDLERDATA->m_width = width; + M_BITMAPHANDLERDATA->m_height = height; + M_BITMAPHANDLERDATA->m_depth = 1; + M_BITMAPHANDLERDATA->m_freePixmap = TRUE; + + Display *dpy = (Display*) wxGetDisplay(); + M_BITMAPHANDLERDATA->m_display = (WXDisplay*) dpy; + + M_BITMAPHANDLERDATA->m_pixmap = (WXPixmap) XCreateBitmapFromData (dpy, RootWindow (dpy, DefaultScreen (dpy)), (char*) data, width, height); + M_BITMAPHANDLERDATA->m_ok = (M_BITMAPHANDLERDATA->m_pixmap != (WXPixmap) 0) ; + + // code for wxControl. TODO: can we avoid doing this until we need it? + // E.g. have CreateButtonPixmaps which is called on demand. + XImage* image = (XImage *) XtMalloc (sizeof (XImage)); + image->width = width; + image->height = height; + image->data = (char*) data; + image->depth = 1; + image->xoffset = 0; + image->format = XYBitmap; + image->byte_order = LSBFirst; + image->bitmap_unit = 8; + image->bitmap_bit_order = LSBFirst; + image->bitmap_pad = 8; + image->bytes_per_line = (width + 7) >> 3; + + char tmp[128]; + sprintf (tmp, "Im%x", (unsigned int) image); + XmInstallImage (image, tmp); + + // Build our manually stipped pixmap. + + int bpl = (width + 7) / 8; + char *data1 = new char[height * bpl]; + char* bits = (char*) data; + int i; + for (i = 0; i < height; i++) + { + int mask = i % 2 ? 0x55 : 0xaa; + int j; + for (j = 0; j < bpl; j++) + data1[i * bpl + j] = bits[i * bpl + j] & mask; + } + XImage* insensImage = (XImage *) XtMalloc (sizeof (XImage)); + insensImage->width = width; + insensImage->height = height; + insensImage->data = data1; + insensImage->depth = 1; + insensImage->xoffset = 0; + insensImage->format = XYBitmap; + insensImage->byte_order = LSBFirst; + insensImage->bitmap_unit = 8; + insensImage->bitmap_bit_order = LSBFirst; + insensImage->bitmap_pad = 8; + insensImage->bytes_per_line = bpl; + + sprintf (tmp, "Not%x", (unsigned int)insensImage); + XmInstallImage (insensImage, tmp); + + M_BITMAPHANDLERDATA->m_image = (WXImage*) image; + M_BITMAPHANDLERDATA->m_insensImage = (WXImage*) insensImage; + + return TRUE; +} + +#if wxHAVE_LIB_XPM +class WXDLLEXPORT wxXPMFileHandler: public wxBitmapHandler +{ + DECLARE_DYNAMIC_CLASS(wxXPMFileHandler) +public: + inline wxXPMFileHandler() + { + m_name = "XPM file"; + m_extension = "xpm"; + m_type = wxBITMAP_TYPE_XPM; + }; + + virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags, + int desiredWidth, int desiredHeight); + virtual bool SaveFile(wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette = NULL); +}; + +IMPLEMENT_DYNAMIC_CLASS(wxXPMFileHandler, wxBitmapHandler) + +bool wxXPMFileHandler::LoadFile( wxBitmap *bitmap, const wxString& name, long WXUNUSED(flags), + int WXUNUSED(desiredWidth), int WXUNUSED(desiredHeight) ) +{ + Display *dpy = (Display*) wxGetDisplay(); + M_BITMAPHANDLERDATA->m_display = (WXDisplay*) dpy; + + XpmAttributes xpmAttr; + Pixmap pixmap; + Pixmap mask = 0; + + M_BITMAPHANDLERDATA->m_ok = FALSE; + xpmAttr.valuemask = XpmReturnInfos | XpmCloseness; + xpmAttr.closeness = 40000; + int errorStatus = XpmReadFileToPixmap(dpy, + RootWindow(dpy, DefaultScreen(dpy)), (char*) (const char*) name, + &pixmap, &mask, &xpmAttr); + + if (errorStatus == XpmSuccess) + { + M_BITMAPHANDLERDATA->m_pixmap = (WXPixmap) pixmap; + if ( mask ) + { + M_BITMAPHANDLERDATA->m_bitmapMask = new wxMask; + 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 :-) ... + } else + { + M_BITMAPHANDLERDATA->m_depth = 1; // mono + } + */ + + M_BITMAPHANDLERDATA->m_depth = depthRet; + + M_BITMAPHANDLERDATA->m_numColors = xpmAttr.npixels; + + XpmFreeAttributes(&xpmAttr); + + M_BITMAPHANDLERDATA->m_ok = TRUE; + return TRUE; + } else + { + // XpmDebugError(errorStatus, name); + M_BITMAPHANDLERDATA->m_ok = FALSE; + return FALSE; + } +} + +bool wxXPMFileHandler::SaveFile( wxBitmap *bitmap, const wxString& name, int WXUNUSED(type), + const wxPalette *WXUNUSED(palette)) +{ + if (M_BITMAPHANDLERDATA->m_ok && M_BITMAPHANDLERDATA->m_pixmap) + { + Display *dpy = (Display*) M_BITMAPHANDLERDATA->m_display; + int errorStatus = XpmWriteFileFromPixmap(dpy, (char*) (const char*) name, + (Pixmap) M_BITMAPHANDLERDATA->m_pixmap, + (M_BITMAPHANDLERDATA->m_bitmapMask ? (Pixmap) M_BITMAPHANDLERDATA->m_bitmapMask->GetPixmap() : (Pixmap) 0), + (XpmAttributes *) NULL); + if (errorStatus == XpmSuccess) + return TRUE; + else + return FALSE; + } + else + return FALSE; +} + +class WXDLLEXPORT wxXPMDataHandler: public wxBitmapHandler +{ + DECLARE_DYNAMIC_CLASS(wxXPMDataHandler) +public: + inline wxXPMDataHandler() + { + m_name = "XPM data"; + m_extension = "xpm"; + m_type = wxBITMAP_TYPE_XPM_DATA; + }; + + virtual bool Create(wxBitmap *bitmap, void *data, long flags, int width, int height, int depth = 1); +}; +IMPLEMENT_DYNAMIC_CLASS(wxXPMDataHandler, wxBitmapHandler) + +bool wxXPMDataHandler::Create( wxBitmap *bitmap, void *data, long WXUNUSED(flags), + int width, int height, int WXUNUSED(depth)) +{ + M_BITMAPHANDLERDATA->m_width = width; + M_BITMAPHANDLERDATA->m_height = height; + M_BITMAPHANDLERDATA->m_depth = 1; + M_BITMAPHANDLERDATA->m_freePixmap = TRUE; + + Display *dpy = (Display*) wxGetDisplay(); + M_BITMAPHANDLERDATA->m_display = (WXDisplay*) dpy; + + XpmAttributes xpmAttr; + + xpmAttr.valuemask = XpmReturnInfos; /* nothing yet, but get infos back */ + + XpmColorSymbol symbolicColors[4]; + if (sg_Control && sg_Control->GetMainWidget()) + { + symbolicColors[0].name = "foreground"; + symbolicColors[0].value = NULL; + symbolicColors[1].name = "background"; + symbolicColors[1].value = NULL; + XtVaGetValues((Widget) sg_Control->GetMainWidget(), + XmNforeground, &symbolicColors[0].pixel, + XmNbackground, &symbolicColors[1].pixel,NULL); + xpmAttr.numsymbols = 2; + xpmAttr.colorsymbols = symbolicColors; + xpmAttr.valuemask |= XpmColorSymbols; // add flag + } + + Pixmap pixmap; + Pixmap mask = 0; + int ErrorStatus = XpmCreatePixmapFromData(dpy, RootWindow(dpy, DefaultScreen(dpy)), + (char**) data, &pixmap, &mask, &xpmAttr); + if (ErrorStatus == XpmSuccess) + { + // 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 :-) ... + } else + { + M_BITMAPHANDLERDATA->m_depth = 1; // mono + } + */ + + M_BITMAPHANDLERDATA->m_depth = depthRet; + + M_BITMAPHANDLERDATA->m_numColors = xpmAttr.npixels; + XpmFreeAttributes(&xpmAttr); + M_BITMAPHANDLERDATA->m_ok = TRUE; + M_BITMAPHANDLERDATA->m_pixmap = (WXPixmap) pixmap; + if ( mask ) + { + M_BITMAPHANDLERDATA->m_bitmapMask = new wxMask; + M_BITMAPHANDLERDATA->m_bitmapMask->SetPixmap((WXPixmap) mask); + } + } + else + { + // XpmDebugError(ErrorStatus, NULL); + M_BITMAPHANDLERDATA->m_ok = FALSE; + } + return M_BITMAPHANDLERDATA->m_ok ; +} + +#endif // wxHAVE_LIB_XPM + +void wxBitmap::CleanUpHandlers() +{ + wxNode *node = sm_handlers.First(); + while ( node ) + { + wxBitmapHandler *handler = (wxBitmapHandler *)node->Data(); + wxNode *next = node->Next(); + delete handler; + delete node; + node = next; + } +} + +void wxBitmap::InitStandardHandlers() +{ + // Initialize all standard bitmap or derived class handlers here. + AddHandler(new wxXBMFileHandler); + AddHandler(new wxXBMDataHandler); + + // XPM is considered standard for Motif, although it can be omitted if + // libXpm is not installed +#if wxHAVE_LIB_XPM + AddHandler(new wxXPMFileHandler); + AddHandler(new wxXPMDataHandler); +#endif // wxHAVE_LIB_XPM +} + +WXPixmap wxBitmap::GetLabelPixmap (WXWidget w) +{ + if (M_BITMAPDATA->m_image == (WXPixmap) 0) + return M_BITMAPDATA->m_pixmap; + + Display *dpy = (Display*) M_BITMAPDATA->m_display; + +#ifdef FOO + /* + If we do: + if (labelPixmap) return labelPixmap; + things can be wrong, because colors can have been changed. + + If we do: + if (labelPixmap) + XmDestroyPixmap(DefaultScreenOfDisplay(dpy),labelPixmap) ; + we got BadDrawable if the pixmap is referenced by multiples widgets + + this is a catch22!! + + So, before doing thing really clean, I just do nothing; if the pixmap is + referenced by many widgets, Motif performs caching functions. + And if pixmap is referenced with multiples colors, we just have some + memory leaks... I hope we can deal with them... + */ + // Must be destroyed, because colours can have been changed! + if (M_BITMAPDATA->m_labelPixmap) + XmDestroyPixmap (DefaultScreenOfDisplay (dpy), M_BITMAPDATA->m_labelPixmap); +#endif + + char tmp[128]; + sprintf (tmp, "Im%x", (unsigned int) M_BITMAPDATA->m_image); + + Pixel fg, bg; + Widget widget = (Widget) w; + + while (XmIsGadget ( widget )) + widget = XtParent (widget); + XtVaGetValues (widget, XmNbackground, &bg, XmNforeground, &fg, NULL); + + M_BITMAPDATA->m_labelPixmap = (WXPixmap) XmGetPixmap (DefaultScreenOfDisplay (dpy), tmp, fg, bg); + + return M_BITMAPDATA->m_labelPixmap; +} + +WXPixmap wxBitmap::GetArmPixmap (WXWidget w) +{ + if (M_BITMAPDATA->m_image == (WXPixmap) 0) + return M_BITMAPDATA->m_pixmap; + + Display *dpy = (Display*) M_BITMAPDATA->m_display; +#ifdef FOO + // See GetLabelPixmap () comment + + // Must be destroyed, because colours can have been changed! + if (M_BITMAPDATA->m_armPixmap) + XmDestroyPixmap (DefaultScreenOfDisplay (dpy), M_BITMAPDATA->m_armPixmap); +#endif + + char tmp[128]; + sprintf (tmp, "Im%x", (unsigned int) M_BITMAPDATA->m_image); + + Pixel fg, bg; + Widget widget = (Widget) w; + + XtVaGetValues (widget, XmNarmColor, &bg, NULL); + while (XmIsGadget (widget)) + widget = XtParent (widget); + XtVaGetValues (widget, XmNforeground, &fg, NULL); + + M_BITMAPDATA->m_armPixmap = (WXPixmap) XmGetPixmap (DefaultScreenOfDisplay (dpy), tmp, fg, bg); + + return M_BITMAPDATA->m_armPixmap; +} + +WXPixmap wxBitmap::GetInsensPixmap (WXWidget w) +{ + Display *dpy = (Display*) M_BITMAPDATA->m_display; + + if (M_BITMAPDATA->m_insensPixmap) + return M_BITMAPDATA->m_insensPixmap; + + if (!w) + { + M_BITMAPDATA->m_insensPixmap = (WXPixmap) XCreateInsensitivePixmap(dpy, (Pixmap) M_BITMAPDATA->m_pixmap); + if (M_BITMAPDATA->m_insensPixmap) + return M_BITMAPDATA->m_insensPixmap; + else + return M_BITMAPDATA->m_pixmap; + } + + if (M_BITMAPDATA->m_insensImage == (WXPixmap) 0) + return M_BITMAPDATA->m_pixmap; + +#ifdef FOO + See GetLabelPixmap () comment + // Must be destroyed, because colours can have been changed! + if (M_BITMAPDATA->m_insensPixmap) + XmDestroyPixmap (DefaultScreenOfDisplay (dpy), (Pixmap) M_BITMAPDATA->m_insensPixmap); +#endif + + char tmp[128]; + sprintf (tmp, "Not%x", (unsigned int) M_BITMAPDATA->m_insensImage); + + Pixel fg, bg; + Widget widget = (Widget) w; + + while (XmIsGadget (widget)) + widget = XtParent (widget); + XtVaGetValues (widget, XmNbackground, &bg, XmNforeground, &fg, NULL); + + M_BITMAPDATA->m_insensPixmap = (WXPixmap) XmGetPixmap (DefaultScreenOfDisplay (dpy), tmp, fg, bg); + + return M_BITMAPDATA->m_insensPixmap; +} + +// We may need this sometime... + +/**************************************************************************** + + NAME + XCreateInsensitivePixmap - create a grayed-out copy of a pixmap + + SYNOPSIS + Pixmap XCreateInsensitivePixmap( Display *display, Pixmap pixmap ) + + DESCRIPTION + This function creates a grayed-out copy of the argument pixmap, suitable + for use as a XmLabel's XmNlabelInsensitivePixmap resource. + + RETURN VALUES + The return value is the new Pixmap id or zero on error. Errors include + a NULL display argument or an invalid Pixmap argument. + + ERRORS + If one of the XLib functions fail, it will produce a X error. The + default X error handler prints a diagnostic and calls exit(). + + SEE ALSO + XCopyArea(3), XCreateBitmapFromData(3), XCreateGC(3), XCreatePixmap(3), + XFillRectangle(3), exit(2) + + AUTHOR + John R Veregge - john@puente.jpl.nasa.gov + Advanced Engineering and Prototyping Group (AEG) + Information Systems Technology Section (395) + Jet Propulsion Lab - Calif Institute of Technology + +*****************************************************************************/ + +Pixmap +XCreateInsensitivePixmap( Display *display, Pixmap pixmap ) + +{ + static char stipple_data[] = + { + 0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55, 0xAA, 0xAA, + 0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55, 0xAA, 0xAA, + 0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55, 0xAA, 0xAA, + 0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55, 0xAA, 0xAA + }; + GC gc; + Pixmap ipixmap, stipple; + unsigned width, height, depth; + + Window window; /* These return values */ + unsigned border; /* from XGetGeometry() */ + int x, y; /* are not needed. */ + + ipixmap = 0; + + if ( NULL == display || 0 == pixmap ) + return ipixmap; + + if ( 0 == XGetGeometry( display, pixmap, &window, &x, &y, + &width, &height, &border, &depth ) + ) + return ipixmap; /* BadDrawable: probably an invalid pixmap */ + + /* Get the stipple pixmap to be used to 'gray-out' the argument pixmap. + */ + stipple = XCreateBitmapFromData( display, pixmap, stipple_data, 16, 16 ); + if ( 0 != stipple ) + { + gc = XCreateGC( display, pixmap, (XtGCMask)0, (XGCValues*)NULL ); + if ( NULL != gc ) + { + /* Create an identical copy of the argument pixmap. + */ + ipixmap = XCreatePixmap( display, pixmap, width, height, depth ); + if ( 0 != ipixmap ) + { + /* Copy the argument pixmap into the new pixmap. + */ + XCopyArea( display, pixmap, ipixmap, + gc, 0, 0, width, height, 0, 0 ); + + /* Refill the new pixmap using the stipple algorithm/pixmap. + */ + XSetStipple( display, gc, stipple ); + XSetFillStyle( display, gc, FillStippled ); + XFillRectangle( display, ipixmap, gc, 0, 0, width, height ); + } + XFreeGC( display, gc ); + } + XFreePixmap( display, stipple ); + } + return ipixmap; +} + +// Creates a bitmap with transparent areas drawn in +// the given colour. +wxBitmap wxCreateMaskedBitmap(const wxBitmap& bitmap, wxColour& colour) +{ + wxBitmap newBitmap(bitmap.GetWidth(), + bitmap.GetHeight(), + bitmap.GetDepth()); + wxMemoryDC destDC; + wxMemoryDC srcDC; + srcDC.SelectObject(bitmap); + destDC.SelectObject(newBitmap); + + wxBrush brush(colour, wxSOLID); + destDC.SetOptimization(FALSE); + destDC.SetBackground(brush); + destDC.Clear(); + destDC.Blit(0, 0, bitmap.GetWidth(), bitmap.GetHeight(), & srcDC, 0, 0, wxCOPY, TRUE); + + return newBitmap; +} + + + + +//----------------------------------------------------------------------------- +// wxImage conversion routines +//----------------------------------------------------------------------------- + +/* + +Date: Wed, 05 Jan 2000 11:45:40 +0100 +From: Frits Boel +To: julian.smart@ukonline.co.uk +Subject: Patch for Motif ConvertToBitmap + +Hi Julian, + +I've been working on a wxWin application for image processing. From the +beginning, I was surprised by the (lack of) speed of ConvertToBitmap, +till I looked in the source code of image.cpp. I saw that converting a +wxImage to a bitmap with 8-bit pixels is done with comparing every pixel +to the 256 colors of the palet. A very time-consuming piece of code! + +Because I wanted a faster application, I've made a 'patch' for this. In +short: every pixel of the image is compared to a sorted list with +colors. If the color is found in the list, the palette entry is +returned; if the color is not found, the color palette is searched and +then the palette entry is returned and the color added to the sorted +list. + +Maybe there is another method for this, namely changing the palette +itself (if the colors are known, as is the case with tiffs with a +colormap). I did not look at this, maybe someone else did? + +The code of the patch is attached, have a look on it, and maybe you will +ship it with the next release of wxMotif? + +Regards, + +Frits Boel +Software engineer at Hubrecht Laboratory, The Netherlands. + +*/ + +class wxSearchColor +{ +public: + wxSearchColor( void ); + wxSearchColor( int size, XColor *colors ); + ~wxSearchColor( void ); + + int SearchColor( int r, int g, int b ); +private: + int AddColor( unsigned int value, int pos ); + + int size; + XColor *colors; + unsigned int *color; + int *entry; + + int bottom; + int top; +}; + +wxSearchColor::wxSearchColor( void ) +{ + size = 0; + colors = (XColor*) NULL; + color = (unsigned int *) NULL; + entry = (int*) NULL; + + bottom = 0; + top = 0; +} + +wxSearchColor::wxSearchColor( int size_, XColor *colors_ ) +{ + int i; + size = size_; + colors = colors_; + color = new unsigned int[size]; + entry = new int [size]; + + for (i = 0; i < size; i++ ) { + entry[i] = -1; + } + + bottom = top = ( size >> 1 ); +} + +wxSearchColor::~wxSearchColor( void ) +{ + if ( color ) delete color; + if ( entry ) delete entry; +} + +int wxSearchColor::SearchColor( int r, int g, int b ) +{ + unsigned int value = ( ( ( r * 256 ) + g ) * 256 ) + b; + int begin = bottom; + int end = top; + int middle = 0; + + while ( begin <= end ) { + + middle = ( begin + end ) >> 1; + + if ( value == color[middle] ) { + return( entry[middle] ); + } else if ( value < color[middle] ) { + end = middle - 1; + } else { + begin = middle + 1; + } + + } + + return AddColor( value, middle ); +} + +int wxSearchColor::AddColor( unsigned int value, int pos ) +{ + int i; + int pixel = -1; + int max = 3 * (65536); + for ( i = 0; i < 256; i++ ) { + int rdiff = ((value >> 8) & 0xFF00 ) - colors[i].red; + int gdiff = ((value ) & 0xFF00 ) - colors[i].green; + int bdiff = ((value << 8) & 0xFF00 ) - colors[i].blue; + int sum = abs (rdiff) + abs (gdiff) + abs (bdiff); + if (sum < max) { pixel = i; max = sum; } + } + + if ( entry[pos] < 0 ) { + color[pos] = value; + entry[pos] = pixel; + } else if ( value < color[pos] ) { + + if ( bottom > 0 ) { + for ( i = bottom; i < pos; i++ ) { + color[i-1] = color[i]; + entry[i-1] = entry[i]; + } + bottom--; + color[pos-1] = value; + entry[pos-1] = pixel; + } else if ( top < size-1 ) { + for ( i = top; i >= pos; i-- ) { + color[i+1] = color[i]; + entry[i+1] = entry[i]; + } + top++; + color[pos] = value; + entry[pos] = pixel; + } + + } else { + + if ( top < size-1 ) { + for ( i = top; i > pos; i-- ) { + color[i+1] = color[i]; + entry[i+1] = entry[i]; + } + top++; + color[pos+1] = value; + entry[pos+1] = pixel; + } else if ( bottom > 0 ) { + for ( i = bottom; i < pos; i++ ) { + color[i-1] = color[i]; + entry[i-1] = entry[i]; + } + bottom--; + color[pos] = value; + entry[pos] = pixel; + } + + } + + return( pixel ); +} + + +bool wxBitmap::CreateFromImage( const wxImage& image, int depth ) +{ + wxCHECK_MSG( image.Ok(), FALSE, wxT("invalid image") ) + wxCHECK_MSG( depth == -1, FALSE, wxT("invalid bitmap depth") ) + + m_refData = new wxBitmapRefData(); + + int width = image.GetWidth(); + int height = image.GetHeight(); + + SetHeight( height ); + SetWidth( width ); + + Display *dpy = (Display*) wxGetDisplay(); + Visual* vis = DefaultVisual( dpy, DefaultScreen( dpy ) ); + int bpp = DefaultDepth( dpy, DefaultScreen( dpy ) ); + + // Create image + + XImage *data_image = XCreateImage( dpy, vis, bpp, ZPixmap, 0, 0, width, height, 32, 0 ); + data_image->data = (char*) malloc( data_image->bytes_per_line * data_image->height ); + + Create( width, height, bpp ); + + // Create mask + + XImage *mask_image = (XImage*) NULL; + if (image.HasMask()) + { + mask_image = XCreateImage( dpy, vis, 1, ZPixmap, 0, 0, width, height, 32, 0 ); + mask_image->data = (char*) malloc( mask_image->bytes_per_line * mask_image->height ); + } + + // Retrieve depth info + + XVisualInfo vinfo_template; + XVisualInfo *vi; + + vinfo_template.visual = vis; + vinfo_template.visualid = XVisualIDFromVisual( vis ); + vinfo_template.depth = bpp; + int nitem = 0; + + vi = XGetVisualInfo( dpy, VisualIDMask|VisualDepthMask, &vinfo_template, &nitem ); + + wxCHECK_MSG( vi, FALSE, wxT("no visual") ); + + XFree( vi ); + + if ((bpp == 16) && (vi->red_mask != 0xf800)) bpp = 15; + if (bpp < 8) bpp = 8; + + // Render + + enum byte_order { RGB, RBG, BRG, BGR, GRB, GBR }; + byte_order b_o = RGB; + + if (bpp >= 24) + { + if ((vi->red_mask > vi->green_mask) && (vi->green_mask > vi->blue_mask)) b_o = RGB; + else if ((vi->red_mask > vi->blue_mask) && (vi->blue_mask > vi->green_mask)) b_o = RGB; + else if ((vi->blue_mask > vi->red_mask) && (vi->red_mask > vi->green_mask)) b_o = BRG; + else if ((vi->blue_mask > vi->green_mask) && (vi->green_mask > vi->red_mask)) b_o = BGR; + else if ((vi->green_mask > vi->red_mask) && (vi->red_mask > vi->blue_mask)) b_o = GRB; + else if ((vi->green_mask > vi->blue_mask) && (vi->blue_mask > vi->red_mask)) b_o = GBR; + } + + int r_mask = image.GetMaskRed(); + int g_mask = image.GetMaskGreen(); + int b_mask = image.GetMaskBlue(); + + XColor colors[256]; + if (bpp == 8) + { + Colormap cmap = (Colormap) wxTheApp->GetMainColormap( dpy ); + + for (int i = 0; i < 256; i++) colors[i].pixel = i; + XQueryColors( dpy, cmap, colors, 256 ); + } + + wxSearchColor scolor( 256, colors ); + unsigned char* data = image.GetData(); + + bool hasMask = image.HasMask(); + + int index = 0; + for (int y = 0; y < height; y++) + { + for (int x = 0; x < width; x++) + { + int r = data[index]; + index++; + int g = data[index]; + index++; + int b = data[index]; + index++; + + if (hasMask) + { + if ((r == r_mask) && (b == b_mask) && (g == g_mask)) + XPutPixel( mask_image, x, y, 0 ); + else + XPutPixel( mask_image, x, y, 1 ); + } + + switch (bpp) + { + case 8: + { +#if 0 // Old, slower code + int pixel = -1; + /* + if (wxTheApp->m_colorCube) + { + pixel = wxTheApp->m_colorCube + [ ((r & 0xf8) << 7) + ((g & 0xf8) << 2) + ((b & 0xf8) >> 3) ]; + } + else + { + */ + int max = 3 * (65536); + for (int i = 0; i < 256; i++) + { + int rdiff = (r << 8) - colors[i].red; + int gdiff = (g << 8) - colors[i].green; + int bdiff = (b << 8) - colors[i].blue; + int sum = abs (rdiff) + abs (gdiff) + abs (bdiff); + if (sum < max) { pixel = i; max = sum; } + } + /* + } + */ +#endif + + // And this is all to get the 'right' color... + int pixel = scolor.SearchColor( r, g, b ); + XPutPixel( data_image, x, y, pixel ); + break; + } + case 15: + { + int pixel = ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | ((b & 0xf8) >> 3); + XPutPixel( data_image, x, y, pixel ); + break; + } + case 16: + { + int pixel = ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | ((b & 0xf8) >> 3); + XPutPixel( data_image, x, y, pixel ); + break; + } + case 32: + case 24: + { + int pixel = 0; + switch (b_o) + { + case RGB: pixel = (r << 16) | (g << 8) | b; break; + case RBG: pixel = (r << 16) | (b << 8) | g; break; + case BRG: pixel = (b << 16) | (r << 8) | g; break; + case BGR: pixel = (b << 16) | (g << 8) | r; break; + case GRB: pixel = (g << 16) | (r << 8) | b; break; + case GBR: pixel = (g << 16) | (b << 8) | r; break; + } + XPutPixel( data_image, x, y, pixel ); + } + default: break; + } + } // for + } // for + + // Blit picture + + XGCValues gcvalues; + gcvalues.foreground = BlackPixel( dpy, DefaultScreen( dpy ) ); + GC gc = XCreateGC( dpy, RootWindow ( dpy, DefaultScreen(dpy) ), GCForeground, &gcvalues ); + XPutImage( dpy, (Drawable)GetPixmap(), gc, data_image, 0, 0, 0, 0, width, height ); + + XDestroyImage( data_image ); + XFreeGC( dpy, gc ); + + // Blit mask + if (image.HasMask()) + { + wxBitmap maskBitmap(width, height, 1); + + GC gcMask = XCreateGC( dpy, (Pixmap) maskBitmap.GetPixmap(), (XtGCMask) 0, (XGCValues*)NULL ); + XPutImage( dpy, (Drawable)maskBitmap.GetPixmap(), gcMask, mask_image, 0, 0, 0, 0, width, height ); + + XDestroyImage( mask_image ); + XFreeGC( dpy, gcMask ); + + wxMask* mask = new wxMask; + mask->SetPixmap(maskBitmap.GetPixmap()); + + SetMask(mask); + + maskBitmap.SetPixmapNull(); + } + + + return TRUE; +} + +wxImage wxBitmap::ConvertToImage() const +{ + wxImage image; + + wxCHECK_MSG( Ok(), wxNullImage, wxT("invalid bitmap") ); + + Display *dpy = (Display*) wxGetDisplay(); + Visual* vis = DefaultVisual( dpy, DefaultScreen( dpy ) ); + int bpp = DefaultDepth( dpy, DefaultScreen( dpy ) ); + + XImage *ximage = XGetImage( dpy, + (Drawable)GetPixmap(), + 0, 0, + GetWidth(), GetHeight(), + AllPlanes, ZPixmap ); + + wxCHECK_MSG( ximage, wxNullImage, wxT("couldn't create image") ); + + image.Create( GetWidth(), GetHeight() ); + char unsigned *data = image.GetData(); + + if (!data) + { + XDestroyImage( ximage ); + wxFAIL_MSG( wxT("couldn't create image") ); + return wxNullImage; + } + + /* + GdkImage *gdk_image_mask = (GdkImage*) NULL; + if (GetMask()) + { + gdk_image_mask = gdk_image_get( GetMask()->GetBitmap(), + 0, 0, + GetWidth(), GetHeight() ); + + image.SetMaskColour( 16, 16, 16 ); // anything unlikely and dividable + } + */ + + // Retrieve depth info + + XVisualInfo vinfo_template; + XVisualInfo *vi; + + vinfo_template.visual = vis; + vinfo_template.visualid = XVisualIDFromVisual( vis ); + vinfo_template.depth = bpp; + int nitem = 0; + + vi = XGetVisualInfo( dpy, VisualIDMask|VisualDepthMask, &vinfo_template, &nitem ); + + wxCHECK_MSG( vi, wxNullImage, wxT("no visual") ); + + if ((bpp == 16) && (vi->red_mask != 0xf800)) bpp = 15; + + XFree( vi ); + + XColor colors[256]; + if (bpp == 8) + { + Colormap cmap = (Colormap)wxTheApp->GetMainColormap( dpy ); + + for (int i = 0; i < 256; i++) colors[i].pixel = i; + XQueryColors( dpy, cmap, colors, 256 ); + } + + long pos = 0; + for (int j = 0; j < GetHeight(); j++) + { + for (int i = 0; i < GetWidth(); i++) + { + int pixel = XGetPixel( ximage, i, j ); + if (bpp <= 8) + { + data[pos] = colors[pixel].red >> 8; + data[pos+1] = colors[pixel].green >> 8; + data[pos+2] = colors[pixel].blue >> 8; + } else if (bpp == 15) + { + data[pos] = (pixel >> 7) & 0xf8; + data[pos+1] = (pixel >> 2) & 0xf8; + data[pos+2] = (pixel << 3) & 0xf8; + } else if (bpp == 16) + { + data[pos] = (pixel >> 8) & 0xf8; + data[pos+1] = (pixel >> 3) & 0xfc; + data[pos+2] = (pixel << 3) & 0xf8; + } else + { + data[pos] = (pixel >> 16) & 0xff; + data[pos+1] = (pixel >> 8) & 0xff; + data[pos+2] = pixel & 0xff; + } + + /* + if (gdk_image_mask) + { + int mask_pixel = gdk_image_get_pixel( gdk_image_mask, i, j ); + if (mask_pixel == 0) + { + data[pos] = 16; + data[pos+1] = 16; + data[pos+2] = 16; + } + } + */ + + pos += 3; + } + } + + XDestroyImage( ximage ); + /* + if (gdk_image_mask) gdk_image_destroy( gdk_image_mask ); + */ + + return image; +} diff --git a/src/x11/brush.cpp b/src/x11/brush.cpp new file mode 100644 index 0000000000..685b376427 --- /dev/null +++ b/src/x11/brush.cpp @@ -0,0 +1,123 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: src/motif/brush.cpp +// Purpose: wxBrush +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "brush.h" +#endif + +#include "wx/setup.h" +#include "wx/utils.h" +#include "wx/brush.h" + +IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject) + +wxBrushRefData::wxBrushRefData() +{ + m_style = wxSOLID; +} + +wxBrushRefData::wxBrushRefData(const wxBrushRefData& data) +{ + m_style = data.m_style; + m_stipple = data.m_stipple; + m_colour = data.m_colour; +} + +wxBrushRefData::~wxBrushRefData() +{ +} + +// Brushes +wxBrush::wxBrush() +{ +} + +wxBrush::~wxBrush() +{ +} + +wxBrush::wxBrush(const wxColour& col, int Style) +{ + m_refData = new wxBrushRefData; + + M_BRUSHDATA->m_colour = col; + M_BRUSHDATA->m_style = Style; + + RealizeResource(); +} + +wxBrush::wxBrush(const wxBitmap& stipple) +{ + m_refData = new wxBrushRefData; + + M_BRUSHDATA->m_style = wxSTIPPLE; + M_BRUSHDATA->m_stipple = stipple; + + RealizeResource(); +} + +void wxBrush::Unshare() +{ + // Don't change shared data + if (!m_refData) + { + m_refData = new wxBrushRefData(); + } + else + { + wxBrushRefData* ref = new wxBrushRefData(*(wxBrushRefData*)m_refData); + UnRef(); + m_refData = ref; + } +} + +void wxBrush::SetColour(const wxColour& col) +{ + Unshare(); + + M_BRUSHDATA->m_colour = col; + + RealizeResource(); +} + +void wxBrush::SetColour(unsigned char r, unsigned char g, unsigned char b) +{ + Unshare(); + + M_BRUSHDATA->m_colour.Set(r, g, b); + + RealizeResource(); +} + +void wxBrush::SetStyle(int Style) +{ + Unshare(); + + M_BRUSHDATA->m_style = Style; + + RealizeResource(); +} + +void wxBrush::SetStipple(const wxBitmap& Stipple) +{ + Unshare(); + + M_BRUSHDATA->m_stipple = Stipple; + + RealizeResource(); +} + +bool wxBrush::RealizeResource() +{ + // Nothing more to do + return TRUE; +} + diff --git a/src/x11/clipbrd.cpp b/src/x11/clipbrd.cpp new file mode 100644 index 0000000000..41afb324d3 --- /dev/null +++ b/src/x11/clipbrd.cpp @@ -0,0 +1,525 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: clipbrd.cpp +// Purpose: Clipboard functionality +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation +#pragma implementation "clipbrd.h" +#endif + +#include "wx/defs.h" + +#if wxUSE_CLIPBOARD + +#include "wx/app.h" +#include "wx/frame.h" +#include "wx/bitmap.h" +#include "wx/utils.h" +#include "wx/metafile.h" +#include "wx/clipbrd.h" +#include "wx/dataobj.h" + +#ifdef __VMS__ +#pragma message disable nosimpint +#endif +#include +#include +#ifdef __VMS__ +#pragma message enable nosimpint +#endif + +#include + +// IMPLEMENT_DYNAMIC_CLASS(wxClipboard, wxObject) +// IMPLEMENT_ABSTRACT_CLASS(wxClipboardClient, wxObject) + +static bool gs_clipboardIsOpen = FALSE; + +bool wxOpenClipboard() +{ + if (!gs_clipboardIsOpen) + { + gs_clipboardIsOpen = TRUE; + return TRUE; + } + else + return FALSE; +} + +bool wxCloseClipboard() +{ + if (gs_clipboardIsOpen) + { + gs_clipboardIsOpen = FALSE; + return TRUE; + } + else + return FALSE; +} + +bool wxEmptyClipboard() +{ + // No equivalent in Motif + return TRUE; +} + +bool wxClipboardOpen() +{ + return gs_clipboardIsOpen; +} + +bool wxIsClipboardFormatAvailable(wxDataFormat dataFormat) +{ + // Only text is supported. + if (dataFormat != wxDF_TEXT) + return FALSE; + + unsigned long numBytes = 0; + long privateId = 0; + + Window window = (Window) 0; + if (wxTheApp->GetTopWindow()) + window = XtWindow( (Widget) wxTheApp->GetTopWindow()->GetTopWidget() ); + + int success = XmClipboardRetrieve((Display*) wxGetDisplay(), + window, "TEXT", (XtPointer) 0, 0, & numBytes, & privateId) ; + + // Assume only text is supported. If we have anything at all, + // or the clipboard is locked so we're not sure, we say we support it. + if (success == ClipboardNoData) + return FALSE; + else + return TRUE; +} + +bool wxSetClipboardData(wxDataFormat dataFormat, wxObject *obj, int WXUNUSED(width), int WXUNUSED(height)) +{ + if (dataFormat != wxDF_TEXT) + return FALSE; + + char* data = (char*) obj; + + XmString text = XmStringCreateSimple ("CLIPBOARD"); + Window window = (Window) 0; + if (wxTheApp->GetTopWindow()) + window = XtWindow( (Widget) wxTheApp->GetTopWindow()->GetTopWidget() ); + + long itemId = 0; + int result = 0; + + while ((result = + XmClipboardStartCopy((Display*) wxGetDisplay(), + window, + text, + XtLastTimestampProcessed((Display*) wxGetDisplay()), + (Widget) 0, + (XmCutPasteProc) 0, + & itemId)) != ClipboardSuccess) + + ; + + XmStringFree (text); + + long dataId = 0; + while ((result = + XmClipboardCopy((Display*) wxGetDisplay(), + window, + itemId, + "TEXT", + (XtPointer) data, + strlen(data) + 1, + 0, + & dataId)) != ClipboardSuccess) + + ; + + while (( result = + XmClipboardEndCopy((Display*) wxGetDisplay(), + window, itemId) ) != ClipboardSuccess) + + ; + + return TRUE; +} + +wxObject *wxGetClipboardData(wxDataFormat dataFormat, long *len) +{ + if (dataFormat != wxDF_TEXT) + return (wxObject*) NULL; + + bool done = FALSE; + long id = 0; + unsigned long numBytes = 0; + int result = 0; + Window window = (Window) 0; + if (wxTheApp->GetTopWindow()) + window = XtWindow( (Widget) wxTheApp->GetTopWindow()->GetTopWidget() ); + + int currentDataSize = 256; + char* data = new char[currentDataSize]; + + while (!done) + { + if (result == ClipboardTruncate) + { + delete[] data; + currentDataSize = 2*currentDataSize; + data = new char[currentDataSize]; + } + result = XmClipboardRetrieve((Display*) wxGetDisplay(), + window, + "TEXT", + (XtPointer) data, + currentDataSize, + &numBytes, + &id); + + switch (result) + { + case ClipboardSuccess: + { + if (len) + *len = strlen(data) + 1; + return (wxObject*) data; + break; + } + case ClipboardTruncate: + case ClipboardLocked: + { + break; + } + default: + case ClipboardNoData: + { + return (wxObject*) NULL; + break; + } + } + + } + + return NULL; +} + +wxDataFormat wxEnumClipboardFormats(wxDataFormat dataFormat) +{ + // Only wxDF_TEXT supported + if (dataFormat == wxDF_TEXT) + return wxDF_TEXT; + else + return wxDF_INVALID; +} + +wxDataFormat wxRegisterClipboardFormat(char *WXUNUSED(formatName)) +{ + // Not supported + return (wxDataFormat) wxDF_INVALID; +} + +bool wxGetClipboardFormatName(wxDataFormat dataFormat, char *formatName, int WXUNUSED(maxCount)) +{ + // Only wxDF_TEXT supported + if (dataFormat == wxDF_TEXT) + { + strcpy(formatName, "TEXT"); + return TRUE; + } + else + return FALSE; +} + +//----------------------------------------------------------------------------- +// wxClipboard +//----------------------------------------------------------------------------- + +IMPLEMENT_DYNAMIC_CLASS(wxClipboard,wxObject) + +wxClipboard::wxClipboard() +{ + m_open = FALSE; +} + +wxClipboard::~wxClipboard() +{ + Clear(); +} + +void wxClipboard::Clear() +{ + wxNode* node = m_data.First(); + while (node) + { + wxDataObject* data = (wxDataObject*) node->Data(); + delete data; + node = node->Next(); + } + m_data.Clear(); +} + +bool wxClipboard::Open() +{ + wxCHECK_MSG( !m_open, FALSE, "clipboard already open" ); + + m_open = TRUE; + + return wxOpenClipboard(); +} + +bool wxClipboard::SetData( wxDataObject *data ) +{ + wxCHECK_MSG( data, FALSE, "data is invalid" ); + wxCHECK_MSG( m_open, FALSE, "clipboard not open" ); + + Clear(); + + return AddData( data ); +} + +bool wxClipboard::AddData( wxDataObject *data ) +{ + wxCHECK_MSG( data, FALSE, "data is invalid" ); + wxCHECK_MSG( m_open, FALSE, "clipboard not open" ); + + wxDataFormat::NativeFormat format = data->GetPreferredFormat().GetType(); + switch ( format ) + { + case wxDF_TEXT: + case wxDF_OEMTEXT: + { + wxTextDataObject* textDataObject = (wxTextDataObject*) data; + wxString str(textDataObject->GetText()); + return wxSetClipboardData(format, (wxObject*) (const char*) str); + } +#if 0 + case wxDF_BITMAP: + case wxDF_DIB: + { + wxBitmapDataObject* bitmapDataObject = (wxBitmapDataObject*) data; + wxBitmap bitmap(bitmapDataObject->GetBitmap()); + return wxSetClipboardData(data->GetType(), & bitmap); + break; + } +#endif // 0 + } + + return FALSE; +} + +void wxClipboard::Close() +{ + wxCHECK_RET( m_open, "clipboard not open" ); + + m_open = FALSE; + wxCloseClipboard(); +} + +bool wxClipboard::IsSupported( const wxDataFormat& format) +{ + return wxIsClipboardFormatAvailable(format); +} + +bool wxClipboard::GetData( wxDataObject& data ) +{ + wxCHECK_MSG( m_open, FALSE, "clipboard not open" ); + + wxDataFormat::NativeFormat format = data.GetPreferredFormat().GetType(); + switch ( format ) + { + case wxDF_TEXT: + case wxDF_OEMTEXT: + { + wxTextDataObject& textDataObject = (wxTextDataObject &) data; + char* s = (char*) wxGetClipboardData(format); + if (s) + { + textDataObject.SetText(s); + delete[] s; + return TRUE; + } + else + return FALSE; + break; + } +/* + case wxDF_BITMAP: + case wxDF_DIB: + { + wxBitmapDataObject* bitmapDataObject = (wxBitmapDataObject*) data; + wxBitmap* bitmap = (wxBitmap*) wxGetClipboardData(data->GetType()); + if (bitmap) + { + bitmapDataObject->SetBitmap(* bitmap); + delete bitmap; + return TRUE; + } + else + return FALSE; + break; + } +*/ + default: + { + return FALSE; + } + } + return FALSE; +} + +#if 0 + +/* +* Old clipboard implementation by Matthew Flatt +*/ + +wxClipboard *wxTheClipboard = NULL; + +void wxInitClipboard() +{ + if (!wxTheClipboard) + wxTheClipboard = new wxClipboard; +} + +wxClipboard::wxClipboard() +{ + clipOwner = NULL; + cbString = NULL; +} + +wxClipboard::~wxClipboard() +{ + if (clipOwner) + clipOwner->BeingReplaced(); + if (cbString) + delete[] cbString; +} + +static int FormatStringToID(char *str) +{ + if (!strcmp(str, "TEXT")) + return wxDF_TEXT; + + return wxRegisterClipboardFormat(str); +} + +void wxClipboard::SetClipboardClient(wxClipboardClient *client, long time) +{ + bool got_selection; + + if (clipOwner) + clipOwner->BeingReplaced(); + clipOwner = client; + if (cbString) { + delete[] cbString; + cbString = NULL; + } + + if (wxOpenClipboard()) { + char **formats, *data; + int i; + int ftype; + long size; + + formats = clipOwner->formats.ListToArray(FALSE); + for (i = clipOwner->formats.Number(); i--; ) { + ftype = FormatStringToID(formats[i]); + data = clipOwner->GetData(formats[i], &size); + if (!wxSetClipboardData(ftype, (wxObject *)data, size, 1)) { + got_selection = FALSE; + break; + } + } + + if (i < 0) + got_selection = wxCloseClipboard(); + } else + got_selection = FALSE; + + got_selection = FALSE; // Assume another process takes over + + if (!got_selection) { + clipOwner->BeingReplaced(); + clipOwner = NULL; + } +} + +wxClipboardClient *wxClipboard::GetClipboardClient() +{ + return clipOwner; +} + +void wxClipboard::SetClipboardString(char *str, long time) +{ + bool got_selection; + + if (clipOwner) { + clipOwner->BeingReplaced(); + clipOwner = NULL; + } + if (cbString) + delete[] cbString; + + cbString = str; + + if (wxOpenClipboard()) { + if (!wxSetClipboardData(wxDF_TEXT, (wxObject *)str)) + got_selection = FALSE; + else + got_selection = wxCloseClipboard(); + } else + got_selection = FALSE; + + got_selection = FALSE; // Assume another process takes over + + if (!got_selection) { + delete[] cbString; + cbString = NULL; + } +} + +char *wxClipboard::GetClipboardString(long time) +{ + char *str; + long length; + + str = GetClipboardData("TEXT", &length, time); + if (!str) { + str = new char[1]; + *str = 0; + } + + return str; +} + +char *wxClipboard::GetClipboardData(char *format, long *length, long time) +{ + if (clipOwner) { + if (clipOwner->formats.Member(format)) + return clipOwner->GetData(format, length); + else + return NULL; + } else if (cbString) { + if (!strcmp(format, "TEXT")) + return copystring(cbString); + else + return NULL; + } else { + if (wxOpenClipboard()) { + receivedString = (char *)wxGetClipboardData(FormatStringToID(format), + length); + wxCloseClipboard(); + } else + receivedString = NULL; + + return receivedString; + } +} +#endif + +#endif // wxUSE_CLIPBOARD diff --git a/src/x11/colour.cpp b/src/x11/colour.cpp new file mode 100644 index 0000000000..bd112d6a4a --- /dev/null +++ b/src/x11/colour.cpp @@ -0,0 +1,214 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: colour.cpp +// Purpose: wxColour class +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +//// TODO: make wxColour a ref-counted object, +//// so pixel values get shared. + +#ifdef __GNUG__ +#pragma implementation "colour.h" +#endif + +#include "wx/gdicmn.h" +#include "wx/colour.h" +#include "wx/app.h" + +#ifdef __VMS__ +#pragma message disable nosimpint +#endif +#include +#ifdef __VMS__ +#pragma message enable nosimpint +#endif + +#include "wx/motif/private.h" + +IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject) + +// Colour + +wxColour::wxColour () +{ + m_isInit = FALSE; + m_red = m_blue = m_green = 0; + m_pixel = -1; +} + +wxColour::wxColour (unsigned char r, unsigned char g, unsigned char b) +{ + m_red = r; + m_green = g; + m_blue = b; + m_isInit = TRUE; + m_pixel = -1; +} + +wxColour::wxColour (const wxColour& col) +{ + m_red = col.m_red; + m_green = col.m_green; + m_blue = col.m_blue; + m_isInit = col.m_isInit; + m_pixel = col.m_pixel; +} + +wxColour& wxColour::operator =(const wxColour& col) +{ + m_red = col.m_red; + m_green = col.m_green; + m_blue = col.m_blue; + m_isInit = col.m_isInit; + m_pixel = col.m_pixel; + return *this; +} + +void wxColour::InitFromName(const wxString& col) +{ + wxColour *the_colour = wxTheColourDatabase->FindColour (col); + if (the_colour) + { + m_red = the_colour->Red (); + m_green = the_colour->Green (); + m_blue = the_colour->Blue (); + m_pixel = the_colour->m_pixel; + m_isInit = TRUE; + } + else + { + m_red = 0; + m_green = 0; + m_blue = 0; + m_isInit = FALSE; + } +} + +wxColour::~wxColour () +{ +} + +void wxColour::Set (unsigned char r, unsigned char g, unsigned char b) +{ + m_red = r; + m_green = g; + m_blue = b; + m_isInit = TRUE; + m_pixel = -1; +} + +// Allocate a colour, or nearest colour, using the given display. +// If realloc is TRUE, ignore the existing pixel, otherwise just return +// the existing one. +// Returns the old or allocated pixel. + +// TODO: can this handle mono displays? If not, we should have an extra +// flag to specify whether this should be black or white by default. + +int wxColour::AllocColour(WXDisplay* display, bool realloc) +{ + if ((m_pixel != -1) && !realloc) + return m_pixel; + + XColor color; + color.red = (unsigned short) Red (); + color.red |= color.red << 8; + color.green = (unsigned short) Green (); + color.green |= color.green << 8; + color.blue = (unsigned short) Blue (); + color.blue |= color.blue << 8; + + color.flags = DoRed | DoGreen | DoBlue; + + WXColormap cmap = wxTheApp->GetMainColormap(display); + + if (!XAllocColor ((Display*) display, (Colormap) cmap, &color)) + { + m_pixel = wxGetBestMatchingPixel((Display*) display, &color,(Colormap) cmap); + return m_pixel; + } + else + { + m_pixel = (int) color.pixel; + return m_pixel; + } +} + +/*------------------------------------------- +Markus Emmenegger +Find the pixel value with an assigned color closest to the desired color +Used if color cell allocation fails +As the returned pixel value may be in use by another application, +the color might change anytime. +But in many cases, that is still better than always using black. +-- +Chris Breeze +Improvements: +1) More efficient calculation of RGB distance of colour cell from +the desired colour. There is no need to take the sqrt of 'dist', and +since we are only interested in the top 8-bits of R, G and B we +can perform integer arithmetic. +2) Attempt to allocate a read-only colour when a close match is found. +A read-only colour will not change. +3) Fall back to the closest match if no read-only colours are available. + + Possible further improvements: + 1) Scan the lookup table and sort the colour cells in order of + increasing + distance from the desired colour. Then attempt to allocate a + read-only + colour starting from the nearest match. + 2) Linear RGB distance is not a particularly good method of colour + matching + (though it is quick). Converting the colour to HLS and then comparing + may give better matching. +-------------------------------------------*/ + +int wxGetBestMatchingPixel(Display *display, XColor *desiredColor, Colormap cmap) +{ + if (cmap == (Colormap) NULL) + cmap = (Colormap) wxTheApp->GetMainColormap(display); + + int numPixVals = XDisplayCells(display, DefaultScreen (display)); + int mindist = 256 * 256 * 3; + int bestpixel = (int) BlackPixel (display, DefaultScreen (display)); + int red = desiredColor->red >> 8; + int green = desiredColor->green >> 8; + int blue = desiredColor->blue >> 8; + const int threshold = 2 * 2 * 3; // allow an error of up to 2 in R,G & B + + for (int pixelcount = 0; pixelcount < numPixVals; pixelcount++) + { + XColor matching_color; + matching_color.pixel = pixelcount; + XQueryColor(display,cmap,&matching_color); + + int delta_red = red - (matching_color.red >> 8); + int delta_green = green - (matching_color.green >> 8); + int delta_blue = blue - (matching_color.blue >> 8); + + int dist = delta_red * delta_red + + delta_green * delta_green + + delta_blue * delta_blue; + + if (dist <= threshold) + { + // try to allocate a read-only colour... + if (XAllocColor (display, cmap, &matching_color)) + { + return matching_color.pixel; + } + } + if (dist < mindist) + { + bestpixel = pixelcount; + mindist = dist; + } + } + return bestpixel; +} diff --git a/src/x11/cursor.cpp b/src/x11/cursor.cpp new file mode 100644 index 0000000000..24ce2516a0 --- /dev/null +++ b/src/x11/cursor.cpp @@ -0,0 +1,440 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: cursor.cpp +// Purpose: wxCursor class +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "cursor.h" +#endif + +#include "wx/cursor.h" +#include "wx/gdicmn.h" +#include "wx/icon.h" +#include "wx/app.h" +#include "wx/utils.h" + +#ifdef __VMS__ +#pragma message disable nosimpint +#endif +#include +#include +#ifdef __VMS__ +#pragma message enable nosimpint +#endif + +#include "wx/motif/private.h" + +IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxBitmap) +IMPLEMENT_DYNAMIC_CLASS(wxXCursor, wxObject) + +wxCursorRefData::wxCursorRefData() +{ + m_width = 32; m_height = 32; + m_cursorId = wxCURSOR_NONE; +} + +wxCursorRefData::~wxCursorRefData() +{ + wxNode* node = m_cursors.First(); + while (node) + { + wxXCursor* c = (wxXCursor*) node->Data(); + // TODO: how to delete cursor? + // XDestroyCursor((Display*) c->m_display, (Cursor) c->m_cursor); // ?? + delete c; + node = node->Next(); + } +} + +wxCursor::wxCursor() +{ +} + +wxCursor::wxCursor(const char bits[], int width, int height, + int hotSpotX, int hotSpotY, const char maskBits[]) +{ + m_refData = new wxCursorRefData; + + Display *dpy = (Display*) wxGetDisplay(); + int screen_num = DefaultScreen (dpy); + + Pixmap pixmap = XCreatePixmapFromBitmapData (dpy, + RootWindow (dpy, DefaultScreen(dpy)), + (char*) bits, width, height, + 1 , 0 , 1); + + Pixmap mask_pixmap = None; + if (maskBits != NULL) + { + mask_pixmap = XCreatePixmapFromBitmapData (dpy, + RootWindow (dpy, DefaultScreen(dpy)), + (char*) maskBits, width, height, + 1 , 0 , 1); + } + + XColor foreground_color; + XColor background_color; + foreground_color.pixel = BlackPixel(dpy, screen_num); + background_color.pixel = WhitePixel(dpy, screen_num); + Colormap cmap = (Colormap) wxTheApp->GetMainColormap((WXDisplay*) dpy); + XQueryColor(dpy, cmap, &foreground_color); + XQueryColor(dpy, cmap, &background_color); + + Cursor cursor = XCreatePixmapCursor (dpy, + pixmap, + mask_pixmap, + &foreground_color, + &background_color, + hotSpotX , + hotSpotY); + + XFreePixmap( dpy, pixmap ); + if (mask_pixmap != None) + { + XFreePixmap( dpy, mask_pixmap ); + } + + if (cursor) + { + wxXCursor *c = new wxXCursor; + + c->m_cursor = (WXCursor) cursor; + c->m_display = (WXDisplay*) dpy; + M_CURSORDATA->m_cursors.Append(c); + M_CURSORDATA->m_ok = TRUE; + } + else + { + M_CURSORDATA->m_ok = TRUE; + } +} + +wxCursor::wxCursor(const wxString& name, long flags, int hotSpotX, int hotSpotY) +{ + // Must be an XBM file + if (flags != wxBITMAP_TYPE_XBM) + return; + + m_refData = new wxCursorRefData; + + int hotX = -1, hotY = -1; + unsigned int w, h; + Pixmap pixmap; + + Display *dpy = (Display*) wxGetDisplay(); + int screen_num = DefaultScreen (dpy); + + int value = XReadBitmapFile (dpy, RootWindow (dpy, DefaultScreen (dpy)), + (char*) (const char*) name, &w, &h, &pixmap, &hotX, &hotY); + + M_BITMAPDATA->m_width = w; + M_BITMAPDATA->m_height = h; + M_BITMAPDATA->m_depth = 1; + + if ((value == BitmapFileInvalid) || + (value == BitmapOpenFailed) || + (value == BitmapNoMemory)) + { + } + else + { + XColor foreground_color; + XColor background_color; + foreground_color.pixel = BlackPixel(dpy, screen_num); + background_color.pixel = WhitePixel(dpy, screen_num); + Colormap cmap = (Colormap) wxTheApp->GetMainColormap((WXDisplay*) dpy); + XQueryColor(dpy, cmap, &foreground_color); + XQueryColor(dpy, cmap, &background_color); + + // TODO: how do we determine whether hotX, hotY were read correctly? + if (hotX < 0 || hotY < 0) + { + hotX = hotSpotX; + hotY = hotSpotY; + } + if (hotX < 0 || hotY < 0) + { + hotX = 0; + hotY = 0; + } + + Pixmap mask_pixmap = None; + Cursor cursor = XCreatePixmapCursor (dpy, + pixmap, + mask_pixmap, + &foreground_color, + &background_color, + hotX, + hotY); + + XFreePixmap( dpy, pixmap ); + if (cursor) + { + wxXCursor *c = new wxXCursor; + + c->m_cursor = (WXCursor) cursor; + c->m_display = (WXDisplay*) dpy; + M_CURSORDATA->m_cursors.Append(c); + M_CURSORDATA->m_ok = TRUE; + } + } + +} + +// Cursors by stock number +wxCursor::wxCursor(wxStockCursor id) +{ + m_refData = new wxCursorRefData; + M_CURSORDATA->m_cursorId = id; + M_CURSORDATA->m_ok = TRUE; + + WXDisplay* display = wxGetDisplay(); + if (!display) + return; + + WXCursor cursor = GetXCursor(display); + if (cursor) + { + wxXCursor* c = new wxXCursor; + c->m_cursor = cursor; + c->m_display = wxGetDisplay(); + M_CURSORDATA->m_cursors.Append(c); + M_CURSORDATA->m_ok = TRUE; + } +} + +wxCursor::~wxCursor() +{ +} + +// Motif-specific: create/get a cursor for the current display +WXCursor wxCursor::GetXCursor(WXDisplay* display) +{ + if (!M_CURSORDATA) + return (WXCursor) 0; + wxNode* node = M_CURSORDATA->m_cursors.First(); + while (node) + { + wxXCursor* c = (wxXCursor*) node->Data(); + if (c->m_display == display) + return c->m_cursor; + node = node->Next(); + } + + // No cursor for this display, so let's see if we're an id-type cursor. + + if (M_CURSORDATA->m_cursorId != wxCURSOR_NONE) + { + WXCursor cursor = MakeCursor(display, M_CURSORDATA->m_cursorId); + if (cursor) + { + wxXCursor* c = new wxXCursor; + c->m_cursor = cursor; + c->m_display = display; + M_CURSORDATA->m_cursors.Append(c); + return cursor; + } + else + return (WXCursor) 0; + } + + // Not an id-type cursor, so we don't know how to create it. + return (WXCursor) 0; +} + +// Make a cursor from standard id +WXCursor wxCursor::MakeCursor(WXDisplay* display, wxStockCursor id) +{ + Display* dpy = (Display*) display; + Cursor cursor = (Cursor) 0; + + switch (id) + { + case wxCURSOR_WAIT: + { + cursor = XCreateFontCursor (dpy, XC_watch); + break; + } + case wxCURSOR_CROSS: + { + cursor = XCreateFontCursor (dpy, XC_crosshair); + break; + } + case wxCURSOR_CHAR: + { + // Nothing + break; + } + case wxCURSOR_HAND: + { + cursor = XCreateFontCursor (dpy, XC_hand1); + break; + } + case wxCURSOR_BULLSEYE: + { + cursor = XCreateFontCursor (dpy, XC_target); + break; + } + case wxCURSOR_PENCIL: + { + cursor = XCreateFontCursor (dpy, XC_pencil); + break; + } + case wxCURSOR_MAGNIFIER: + { + cursor = XCreateFontCursor (dpy, XC_sizing); + break; + } + case wxCURSOR_IBEAM: + { + cursor = XCreateFontCursor (dpy, XC_xterm); + break; + } + case wxCURSOR_NO_ENTRY: + { + cursor = XCreateFontCursor (dpy, XC_pirate); + break; + } + case wxCURSOR_LEFT_BUTTON: + { + cursor = XCreateFontCursor (dpy, XC_leftbutton); + break; + } + case wxCURSOR_RIGHT_BUTTON: + { + cursor = XCreateFontCursor (dpy, XC_rightbutton); + break; + } + case wxCURSOR_MIDDLE_BUTTON: + { + cursor = XCreateFontCursor (dpy, XC_middlebutton); + break; + } + case wxCURSOR_QUESTION_ARROW: + { + cursor = XCreateFontCursor (dpy, XC_question_arrow); + break; + } + case wxCURSOR_SIZING: + { + cursor = XCreateFontCursor (dpy, XC_sizing); + break; + } + case wxCURSOR_WATCH: + { + cursor = XCreateFontCursor (dpy, XC_watch); + break; + } + case wxCURSOR_SPRAYCAN: + { + cursor = XCreateFontCursor (dpy, XC_spraycan); + break; + } + case wxCURSOR_PAINT_BRUSH: + { + cursor = XCreateFontCursor (dpy, XC_spraycan); + break; + } + case wxCURSOR_SIZENWSE: + case wxCURSOR_SIZENESW: + { + // Not available in X + cursor = XCreateFontCursor (dpy, XC_crosshair); + break; + } + case wxCURSOR_SIZEWE: + { + cursor = XCreateFontCursor (dpy, XC_sb_h_double_arrow); + break; + } + case wxCURSOR_SIZENS: + { + cursor = XCreateFontCursor (dpy, XC_sb_v_double_arrow); + break; + } + case wxCURSOR_POINT_LEFT: + { + cursor = XCreateFontCursor (dpy, XC_sb_left_arrow); + break; + } + case wxCURSOR_POINT_RIGHT: + { + cursor = XCreateFontCursor (dpy, XC_sb_right_arrow); + break; + } + // (JD Huggins) added more stock cursors for X + // X-only cursors BEGIN + case wxCURSOR_CROSS_REVERSE: + { + cursor = XCreateFontCursor(dpy, XC_cross_reverse); + break; + } + case wxCURSOR_DOUBLE_ARROW: + { + cursor = XCreateFontCursor(dpy, XC_double_arrow); + break; + } + case wxCURSOR_BASED_ARROW_UP: + { + cursor = XCreateFontCursor(dpy, XC_based_arrow_up); + break; + } + case wxCURSOR_BASED_ARROW_DOWN: + { + cursor = XCreateFontCursor(dpy, XC_based_arrow_down); + break; + } + default: + case wxCURSOR_ARROW: + { + cursor = XCreateFontCursor (dpy, XC_top_left_arrow); + break; + } + case wxCURSOR_BLANK: + { + GC gc; + XGCValues gcv; + Pixmap empty_pixmap; + XColor blank_color; + + empty_pixmap = XCreatePixmap (dpy, RootWindow (dpy, DefaultScreen (dpy)), + 16, 16, 1); + gcv.function = GXxor; + gc = XCreateGC (dpy, + empty_pixmap, + GCFunction, + &gcv); + XCopyArea (dpy, + empty_pixmap, + empty_pixmap, + gc, + 0, 0, + 16, 16, + 0, 0); + XFreeGC (dpy, gc); + cursor = XCreatePixmapCursor (dpy, + empty_pixmap, + empty_pixmap, + &blank_color, + &blank_color, + 8, 8); + + break; + } + } + return (WXCursor) cursor; +} + +// Global cursor setting +void wxSetCursor(const wxCursor& WXUNUSED(cursor)) +{ + // Nothing to do for Motif (no global cursor) +} + + diff --git a/src/x11/data.cpp b/src/x11/data.cpp new file mode 100644 index 0000000000..eb1c8e0713 --- /dev/null +++ b/src/x11/data.cpp @@ -0,0 +1,138 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: data.cpp +// Purpose: Various data +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "wx/wx.h" +#include "wx/dcps.h" + +#define _MAXPATHLEN 500 + +// Useful buffer, initialized in CommonInit +char *wxBuffer = NULL; + +// Windows List +wxWindowList wxTopLevelWindows; + +// List of windows pending deletion +wxList wxPendingDelete; + +int wxPageNumber; + +// GDI Object Lists +wxBrushList *wxTheBrushList = NULL; +wxPenList *wxThePenList = NULL; +wxFontList *wxTheFontList = NULL; +wxBitmapList *wxTheBitmapList = NULL; + +wxColourDatabase *wxTheColourDatabase = NULL; + +// Stock objects +wxFont *wxNORMAL_FONT; +wxFont *wxSMALL_FONT; +wxFont *wxITALIC_FONT; +wxFont *wxSWISS_FONT; +wxPen *wxRED_PEN; + +wxPen *wxCYAN_PEN; +wxPen *wxGREEN_PEN; +wxPen *wxBLACK_PEN; +wxPen *wxWHITE_PEN; +wxPen *wxTRANSPARENT_PEN; +wxPen *wxBLACK_DASHED_PEN; +wxPen *wxGREY_PEN; +wxPen *wxMEDIUM_GREY_PEN; +wxPen *wxLIGHT_GREY_PEN; + +wxBrush *wxBLUE_BRUSH; +wxBrush *wxGREEN_BRUSH; +wxBrush *wxWHITE_BRUSH; +wxBrush *wxBLACK_BRUSH; +wxBrush *wxTRANSPARENT_BRUSH; +wxBrush *wxCYAN_BRUSH; +wxBrush *wxRED_BRUSH; +wxBrush *wxGREY_BRUSH; +wxBrush *wxMEDIUM_GREY_BRUSH; +wxBrush *wxLIGHT_GREY_BRUSH; + +wxColour *wxBLACK; +wxColour *wxWHITE; +wxColour *wxRED; +wxColour *wxBLUE; +wxColour *wxGREEN; +wxColour *wxCYAN; +wxColour *wxLIGHT_GREY; + +wxCursor *wxSTANDARD_CURSOR = NULL; +wxCursor *wxHOURGLASS_CURSOR = NULL; +wxCursor *wxCROSS_CURSOR = NULL; + +// 'Null' objects +wxAcceleratorTable wxNullAcceleratorTable; +wxBitmap wxNullBitmap; +wxIcon wxNullIcon; +wxCursor wxNullCursor; +wxPen wxNullPen; +wxBrush wxNullBrush; +wxPalette wxNullPalette; +wxFont wxNullFont; +wxColour wxNullColour; + +// Default window names +const char *wxButtonNameStr = "button"; +const char *wxCanvasNameStr = "canvas"; +const char *wxCheckBoxNameStr = "check"; +const char *wxChoiceNameStr = "choice"; +const char *wxComboBoxNameStr = "comboBox"; +const char *wxDialogNameStr = "dialog"; +const char *wxFrameNameStr = "frame"; +const char *wxGaugeNameStr = "gauge"; +const char *wxStaticBoxNameStr = "groupBox"; +const char *wxListBoxNameStr = "listBox"; +const char *wxStaticTextNameStr = "message"; +const char *wxStaticBitmapNameStr = "message"; +const char *wxMultiTextNameStr = "multitext"; +const char *wxPanelNameStr = "panel"; +const char *wxRadioBoxNameStr = "radioBox"; +const char *wxRadioButtonNameStr = "radioButton"; +const char *wxBitmapRadioButtonNameStr = "radioButton"; +const char *wxScrollBarNameStr = "scrollBar"; +const char *wxSliderNameStr = "slider"; +const char *wxStaticNameStr = "static"; +const char *wxTextCtrlWindowNameStr = "textWindow"; +const char *wxTextCtrlNameStr = "text"; +const char *wxVirtListBoxNameStr = "virtListBox"; +const char *wxButtonBarNameStr = "buttonbar"; +const char *wxEnhDialogNameStr = "Shell"; +const char *wxToolBarNameStr = "toolbar"; +const char *wxStatusLineNameStr = "status_line"; +#if 0 // this is defined in string.cpp +const char *wxEmptyString = ""; +#endif +const char *wxGetTextFromUserPromptStr = "Input Text"; +const char *wxMessageBoxCaptionStr = "Message"; +const char *wxFileSelectorPromptStr = "Select a file"; +const char *wxFileSelectorDefaultWildcardStr = "*.*"; +const char *wxInternalErrorStr = "wxWindows Internal Error"; +const char *wxFatalErrorStr = "wxWindows Fatal Error"; +const char *wxDirDialogNameStr = "wxDirCtrl"; +const char *wxDirDialogDefaultFolderStr = "/"; +const wxChar *wxTreeCtrlNameStr = wxT("wxTreeCtrl"); + +// See wx/utils.h +const char *wxFloatToStringStr = "%.2f"; +const char *wxDoubleToStringStr = "%.2f"; + + +const wxSize wxDefaultSize(-1, -1); +const wxPoint wxDefaultPosition(-1, -1); diff --git a/src/x11/dataobj.cpp b/src/x11/dataobj.cpp new file mode 100644 index 0000000000..90e41f267a --- /dev/null +++ b/src/x11/dataobj.cpp @@ -0,0 +1,200 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: dataobj.cpp +// Purpose: wxDataObject class +// Author: Julian Smart +// Id: $Id$ +// Copyright: (c) 1998 Julian Smart +// Licence: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "dataobj.h" +#endif + +#include "wx/defs.h" + +#if wxUSE_CLIPBOARD + +#include "wx/dataobj.h" +#include "wx/app.h" + +#ifdef __VMS__ +#pragma message disable nosimpint +#endif +#include +#ifdef __VMS__ +#pragma message enable nosimpint +#endif +#include "wx/utils.h" + +//------------------------------------------------------------------------- +// global data +//------------------------------------------------------------------------- + +Atom g_textAtom = 0; +Atom g_pngAtom = 0; +Atom g_fileAtom = 0; + +//------------------------------------------------------------------------- +// wxDataFormat +//------------------------------------------------------------------------- + +wxDataFormat::wxDataFormat() +{ + // do *not* call PrepareFormats() from here for 2 reasons: + // + // 1. we will have time to do it later because some other Set function + // must be called before we really need them + // + // 2. doing so prevents us from declaring global wxDataFormats because + // calling PrepareFormats (and thus gdk_atom_intern) before GDK is + // initialised will result in a crash + m_type = wxDF_INVALID; + m_format = (Atom) 0; +} + +wxDataFormat::wxDataFormat( wxDataFormatId type ) +{ + PrepareFormats(); + SetType( type ); +} + +wxDataFormat::wxDataFormat( const wxChar *id ) +{ + PrepareFormats(); + SetId( id ); +} + +wxDataFormat::wxDataFormat( const wxString &id ) +{ + PrepareFormats(); + SetId( id ); +} + +wxDataFormat::wxDataFormat( NativeFormat format ) +{ + PrepareFormats(); + SetId( format ); +} + +void wxDataFormat::SetType( wxDataFormatId type ) +{ + PrepareFormats(); + m_type = type; + + if (m_type == wxDF_TEXT) + m_format = g_textAtom; + else + if (m_type == wxDF_BITMAP) + m_format = g_pngAtom; + else + if (m_type == wxDF_FILENAME) + m_format = g_fileAtom; + else + { + wxFAIL_MSG( wxT("invalid dataformat") ); + } +} + +wxDataFormatId wxDataFormat::GetType() const +{ + return m_type; +} + +wxString wxDataFormat::GetId() const +{ + char *t = XGetAtomName ((Display*) wxGetDisplay(), m_format); + wxString ret( t ); // this will convert from ascii to Unicode + if (t) + XFree( t ); + return ret; +} + +void wxDataFormat::SetId( NativeFormat format ) +{ + PrepareFormats(); + m_format = format; + + if (m_format == g_textAtom) + m_type = wxDF_TEXT; + else + if (m_format == g_pngAtom) + m_type = wxDF_BITMAP; + else + if (m_format == g_fileAtom) + m_type = wxDF_FILENAME; + else + m_type = wxDF_PRIVATE; +} + +void wxDataFormat::SetId( const wxChar *id ) +{ + PrepareFormats(); + m_type = wxDF_PRIVATE; + wxString tmp( id ); + m_format = XInternAtom( (Display*) wxGetDisplay(), wxMBSTRINGCAST tmp.mbc_str(), FALSE ); // what is the string cast for? +} + +void wxDataFormat::PrepareFormats() +{ + if (!g_textAtom) + g_textAtom = XInternAtom( (Display*) wxGetDisplay(), "STRING", FALSE ); + if (!g_pngAtom) + g_pngAtom = XInternAtom( (Display*) wxGetDisplay(), "image/png", FALSE ); + if (!g_fileAtom) + g_fileAtom = XInternAtom( (Display*) wxGetDisplay(), "file:ALL", FALSE ); +} + +#if 0 + +// ---------------------------------------------------------------------------- +// wxPrivateDataObject +// ---------------------------------------------------------------------------- + +IMPLEMENT_DYNAMIC_CLASS( wxPrivateDataObject, wxDataObject ) + +void wxPrivateDataObject::Free() +{ + if ( m_data ) + free(m_data); +} + +wxPrivateDataObject::wxPrivateDataObject() +{ + wxString id = wxT("application/"); + id += wxTheApp->GetAppName(); + + m_format.SetId( id ); + + m_size = 0; + m_data = (void *)NULL; +} + +void wxPrivateDataObject::SetData( const void *data, size_t size ) +{ + Free(); + + m_size = size; + m_data = malloc(size); + + memcpy( m_data, data, size ); +} + +void wxPrivateDataObject::WriteData( void *dest ) const +{ + WriteData( m_data, dest ); +} + +size_t wxPrivateDataObject::GetSize() const +{ + return m_size; +} + +void wxPrivateDataObject::WriteData( const void *data, void *dest ) const +{ + memcpy( dest, data, GetSize() ); +} + +#endif // 0 + +#endif // wxUSE_CLIPBOARD diff --git a/src/x11/dc.cpp b/src/x11/dc.cpp new file mode 100644 index 0000000000..cc5c5359a4 --- /dev/null +++ b/src/x11/dc.cpp @@ -0,0 +1,232 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dc.cpp +// Purpose: wxDC class +// Author: Julian Smart +// Modified by: +// Created: 01/02/97 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ + #pragma implementation "dc.h" +#endif + +#include "wx/dc.h" +#include "wx/dcmemory.h" +#include "wx/defs.h" + + IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject) + +//----------------------------------------------------------------------------- +// constants +//----------------------------------------------------------------------------- + +#define mm2inches 0.0393700787402 +#define inches2mm 25.4 +#define mm2twips 56.6929133859 +#define twips2mm 0.0176388888889 +#define mm2pt 2.83464566929 +#define pt2mm 0.352777777778 + +//----------------------------------------------------------------------------- +// wxDC +//----------------------------------------------------------------------------- + +wxDC::wxDC() +{ + m_ok = FALSE; + + m_mm_to_pix_x = 1.0; + m_mm_to_pix_y = 1.0; + + m_backgroundMode = wxTRANSPARENT; + + m_isInteractive = FALSE; +} + +void wxDC::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y) +{ + wxCHECK_RET( Ok(), "invalid dc" ); + wxCHECK_RET( icon.Ok(), "invalid icon" ); + + DoDrawBitmap(icon, x, y, TRUE); +} + +void wxDC::DoDrawBitmap( const wxBitmap& bitmap, wxCoord x, wxCoord y, bool useMask ) +{ + wxCHECK_RET( bitmap.Ok(), "invalid bitmap" ); + + wxMemoryDC memDC; + memDC.SelectObject(bitmap); + +#if 0 + // Not sure if we need this. The mask should leave the masked areas as per + // the original background of this DC. + if (useMask) + { + // There might be transparent areas, so make these the same colour as this + // DC + memDC.SetBackground(* GetBackground()); + memDC.Clear(); + } +#endif // 0 + + Blit(x, y, bitmap.GetWidth(), bitmap.GetHeight(), &memDC, 0, 0, wxCOPY, useMask); + + memDC.SelectObject(wxNullBitmap); +} + +void wxDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) +{ + m_clipping = TRUE; + m_clipX1 = x; + m_clipY1 = y; + m_clipX2 = x + width; + m_clipY2 = y + height; +} + +void wxDC::DestroyClippingRegion() +{ + m_clipping = FALSE; +} + +void wxDC::DoGetSize( int* width, int* height ) const +{ + if ( width ) + *width = m_maxX - m_minX; + if ( height ) + *height = m_maxY - m_minY; +} + +void wxDC::DoGetSizeMM( int* width, int* height ) const +{ + int w, h; + GetSize( &w, &h ); + + if ( width ) + *width = int( double(w) / (m_scaleX*m_mm_to_pix_x) ); + if ( height ) + *height = int( double(h) / (m_scaleY*m_mm_to_pix_y) ); +} + +// Resolution in pixels per logical inch +wxSize wxDC::GetPPI() const +{ + // TODO (should probably be pure virtual) + return wxSize(0, 0); +} + +void wxDC::SetMapMode( int mode ) +{ + switch (mode) + { + case wxMM_TWIPS: + SetLogicalScale( twips2mm*m_mm_to_pix_x, twips2mm*m_mm_to_pix_y ); + break; + case wxMM_POINTS: + SetLogicalScale( pt2mm*m_mm_to_pix_x, pt2mm*m_mm_to_pix_y ); + break; + case wxMM_METRIC: + SetLogicalScale( m_mm_to_pix_x, m_mm_to_pix_y ); + break; + case wxMM_LOMETRIC: + SetLogicalScale( m_mm_to_pix_x/10.0, m_mm_to_pix_y/10.0 ); + break; + default: + case wxMM_TEXT: + SetLogicalScale( 1.0, 1.0 ); + break; + } + if (mode != wxMM_TEXT) + { + m_needComputeScaleX = TRUE; + m_needComputeScaleY = TRUE; + } +} + +void wxDC::SetUserScale( double x, double y ) +{ + // allow negative ? -> no + m_userScaleX = x; + m_userScaleY = y; + ComputeScaleAndOrigin(); +} + +void wxDC::SetLogicalScale( double x, double y ) +{ + // allow negative ? + m_logicalScaleX = x; + m_logicalScaleY = y; + ComputeScaleAndOrigin(); +} + +void wxDC::SetLogicalOrigin( wxCoord x, wxCoord y ) +{ + m_logicalOriginX = x * m_signX; // is this still correct ? + m_logicalOriginY = y * m_signY; + ComputeScaleAndOrigin(); +} + +void wxDC::SetDeviceOrigin( wxCoord x, wxCoord y ) +{ + // only wxPostScripDC has m_signX = -1, we override SetDeviceOrigin there + m_deviceOriginX = x; + m_deviceOriginY = y; + ComputeScaleAndOrigin(); +} + +void wxDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp ) +{ + m_signX = xLeftRight ? 1 : -1; + m_signY = yBottomUp ? -1 : 1; + ComputeScaleAndOrigin(); +} + +wxCoord wxDCBase::DeviceToLogicalX(wxCoord x) const +{ + return ((wxDC *)this)->XDEV2LOG(x); +} + +wxCoord wxDCBase::DeviceToLogicalY(wxCoord y) const +{ + return ((wxDC *)this)->YDEV2LOG(y); +} + +wxCoord wxDCBase::DeviceToLogicalXRel(wxCoord x) const +{ + return ((wxDC *)this)->XDEV2LOGREL(x); +} + +wxCoord wxDCBase::DeviceToLogicalYRel(wxCoord y) const +{ + return ((wxDC *)this)->YDEV2LOGREL(y); +} + +wxCoord wxDCBase::LogicalToDeviceX(wxCoord x) const +{ + return ((wxDC *)this)->XLOG2DEV(x); +} + +wxCoord wxDCBase::LogicalToDeviceY(wxCoord y) const +{ + return ((wxDC *)this)->YLOG2DEV(y); +} + +wxCoord wxDCBase::LogicalToDeviceXRel(wxCoord x) const +{ + return ((wxDC *)this)->XLOG2DEVREL(x); +} + +wxCoord wxDCBase::LogicalToDeviceYRel(wxCoord y) const +{ + return ((wxDC *)this)->YLOG2DEVREL(y); +} + +void wxDC::ComputeScaleAndOrigin() +{ + m_scaleX = m_logicalScaleX * m_userScaleX; + m_scaleY = m_logicalScaleY * m_userScaleY; +} + diff --git a/src/x11/dcclient.cpp b/src/x11/dcclient.cpp new file mode 100644 index 0000000000..f442f9ebca --- /dev/null +++ b/src/x11/dcclient.cpp @@ -0,0 +1,2408 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dcclient.cpp +// Purpose: wxClientDC class +// Author: Julian Smart +// Modified by: +// Created: 01/02/97 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +/* + About pens, brushes, and the autoSetting flag: + + Under X, pens and brushes control some of the same X drawing parameters. + Therefore, it is impossible to independently maintain the current pen and the + current brush. Also, some settings depend on the current logical function. The + m_currentFill, etc. instance variables remember state across the brush and + pen. + + Since pens are used more than brushes, the autoSetting flag is used to + indicate that a brush was recently used, and SetPen must be called to + reinstall the current pen's parameters. If autoSetting includes 0x2, then the + pens color may need to be set based on XOR. + + There is, unfortunately, some confusion between setting the current pen/brush + and actually installing the brush/pen parameters. Both functionalies are + perform by SetPen and SetBrush. C'est la vie. +*/ + +// ============================================================================ +// declarations +// ============================================================================ + +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- + +#ifdef __GNUG__ + #pragma implementation "dcclient.h" +#endif + +#include "wx/dcclient.h" +#include "wx/dcmemory.h" +#include "wx/window.h" +#include "wx/app.h" +#include "wx/image.h" + +#include + +#ifdef __VMS__ +#pragma message disable nosimpint +#endif +#include +#ifdef __VMS__ +#pragma message enable nosimpint +#endif + +#include "wx/motif/private.h" + +#ifdef __EMX__ + #include // for M_PI +#endif // __EMX__ + +#include "bdiag.xbm" +#include "fdiag.xbm" +#include "cdiag.xbm" +#include "horiz.xbm" +#include "verti.xbm" +#include "cross.xbm" + +static Pixmap bdiag, cdiag, fdiag, cross, horiz, verti; + +// ---------------------------------------------------------------------------- +// constants +// ---------------------------------------------------------------------------- + +// Fudge factor (VZ: what??) +#define WX_GC_CF 1 + +// ---------------------------------------------------------------------------- +// macros +// ---------------------------------------------------------------------------- + + IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxWindowDC) + IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC) + IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC) + +// ---------------------------------------------------------------------------- +// prototypes +// ---------------------------------------------------------------------------- + +static void XCopyRemote(Display *src_display, Display *dest_display, + Drawable src, Drawable dest, + GC destgc, + int srcx, int srcy, + unsigned int w, unsigned int h, + int destx, int desty, + bool more, XImage **cache); + +// ============================================================================ +// implementation +// ============================================================================ + +/* + * compare two doubles and return the larger rounded + * to the nearest int + */ +static int roundmax(double a, double b) +{ + return (int)((a > b ? a : b) + 0.5); +} + +/* + * compare two doubles and return the smaller rounded + * to the nearest int + */ +static int roundmin(double a, double b) +{ + return (int)((a < b ? a : b) - 0.5); +} + + +// ---------------------------------------------------------------------------- +// wxWindowDC +// ---------------------------------------------------------------------------- + +wxWindowDC::wxWindowDC() +{ + m_gc = (WXGC) 0; + m_gcBacking = (WXGC) 0; + m_window = NULL; + m_backgroundPixel = -1; + m_currentPenWidth = 1; + m_currentPenJoin = -1; + m_currentPenDashCount = -1; + m_currentPenDash = (wxMOTIFDash*) NULL; + m_currentStyle = -1; + m_currentFill = -1; + // m_currentBkMode = wxTRANSPARENT; + m_colour = wxColourDisplay(); + m_display = (WXDisplay*) NULL; + m_currentRegion = (WXRegion) 0; + m_userRegion = (WXRegion) 0; + m_pixmap = (WXPixmap) 0; + m_autoSetting = 0; + m_oldFont = (WXFont) 0; +} + +wxWindowDC::wxWindowDC( wxWindow *window ) +{ + wxASSERT_MSG( (window != (wxWindow*) NULL), "You must pass a valid wxWindow to wxWindowDC/wxClientDC/wxPaintDC constructor." ); + + m_window = window; + m_font = window->GetFont(); + m_gc = (WXGC) 0; + m_gcBacking = (WXGC) 0; + m_backgroundPixel = -1; + m_currentPenWidth = 1; + m_currentPenJoin = -1; + m_currentPenDashCount = -1; + m_currentPenDash = (wxMOTIFDash*) NULL; + m_currentStyle = -1; + m_currentFill = -1; + // m_currentBkMode = wxTRANSPARENT; + m_colour = wxColourDisplay(); + m_currentRegion = (WXRegion) 0; + m_userRegion = (WXRegion) 0; + m_ok = TRUE; + m_autoSetting = 0; + + m_display = window->GetXDisplay(); + m_pixmap = window->GetXWindow(); + Display* display = (Display*) m_display; + + XSetWindowColormap (display, (Pixmap) m_pixmap, (Colormap) wxTheApp->GetMainColormap(m_display)); + + XGCValues gcvalues; + gcvalues.foreground = BlackPixel (display, DefaultScreen (display)); + gcvalues.background = WhitePixel (display, DefaultScreen (display)); + gcvalues.graphics_exposures = False; + gcvalues.subwindow_mode = IncludeInferiors; + gcvalues.line_width = 1; + m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)), + GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode, + &gcvalues); + + if (m_window->GetBackingPixmap()) + { + m_gcBacking = (WXGC) XCreateGC (display, RootWindow (display, + DefaultScreen (display)), + GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode, + &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; + + SetBackground(wxBrush(m_window->GetBackgroundColour(), wxSOLID)); +} + +wxWindowDC::~wxWindowDC() +{ + if (m_gc && (m_oldFont != (WXFont) 0) && ((long) m_oldFont != -1)) + { + XSetFont ((Display*) m_display, (GC) m_gc, (Font) m_oldFont); + + if (m_window && m_window->GetBackingPixmap()) + XSetFont ((Display*) m_display,(GC) m_gcBacking, (Font) m_oldFont); + } + + if (m_gc) + XFreeGC ((Display*) m_display, (GC) m_gc); + m_gc = (WXGC) 0; + + if (m_gcBacking) + XFreeGC ((Display*) m_display, (GC) m_gcBacking); + m_gcBacking = (WXGC) 0; + + if (m_currentRegion) + XDestroyRegion ((Region) m_currentRegion); + m_currentRegion = (WXRegion) 0; + + if (m_userRegion) + XDestroyRegion ((Region) m_userRegion); + m_userRegion = (WXRegion) 0; +} + +void wxWindowDC::DoFloodFill( wxCoord WXUNUSED(x1), wxCoord WXUNUSED(y1), + const wxColour& WXUNUSED(col), int WXUNUSED(style) ) +{ + wxFAIL_MSG("not implemented"); +} + +bool wxWindowDC::DoGetPixel( wxCoord x1, wxCoord y1, wxColour *col ) const +{ + // Generic (and therefore rather inefficient) method. + // Could be improved. + wxMemoryDC memdc; + wxBitmap bitmap(1, 1); + memdc.SelectObject(bitmap); + memdc.Blit(0, 0, 1, 1, (wxDC*) this, x1, y1); + memdc.SelectObject(wxNullBitmap); + wxImage image(bitmap); + col->Set(image.GetRed(0, 0), image.GetGreen(0, 0), image.GetBlue(0, 0)); + return TRUE; +} + +void wxWindowDC::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 ) +{ + wxCHECK_RET( Ok(), "invalid dc" ); + + int x1d, y1d, x2d, y2d; + + // FreeGetPixelCache(); + + x1d = XLOG2DEV(x1); + y1d = YLOG2DEV(y1); + x2d = XLOG2DEV(x2); + y2d = YLOG2DEV(y2); + + if (m_autoSetting) + SetPen (m_pen); + + XDrawLine ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, x1d, y1d, x2d, y2d); + + if (m_window && m_window->GetBackingPixmap()) + XDrawLine ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking, + XLOG2DEV_2(x1), YLOG2DEV_2(y1), + XLOG2DEV_2(x2), YLOG2DEV_2(y2)); + + CalcBoundingBox(x1, y1); + CalcBoundingBox(x2, y2); +} + +void wxWindowDC::DoCrossHair( wxCoord x, wxCoord y ) +{ + wxCHECK_RET( Ok(), "invalid dc" ); + + if (m_autoSetting) + SetPen (m_pen); + + int xx = XLOG2DEV (x); + int yy = YLOG2DEV (y); + int ww, hh; + wxDisplaySize (&ww, &hh); + XDrawLine ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, 0, yy, + ww, yy); + XDrawLine ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xx, 0, + xx, hh); + + if (m_window && m_window->GetBackingPixmap()) + { + xx = XLOG2DEV_2 (x); + yy = YLOG2DEV_2 (y); + XDrawLine ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking, + 0, yy, + ww, yy); + XDrawLine ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking, + xx, 0, + xx, hh); + } +} + +void wxWindowDC::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc ) +{ + wxCHECK_RET( Ok(), "invalid dc" ); + + // FreeGetPixelCache(); + + int xx1 = XLOG2DEV (x1); + int yy1 = YLOG2DEV (y1); + int xx2 = XLOG2DEV (x2); + int yy2 = YLOG2DEV (y2); + int xxc = XLOG2DEV (xc); + int yyc = YLOG2DEV (yc); + int xxc_2 = XLOG2DEV_2 (xc); + int yyc_2 = YLOG2DEV_2 (yc); + + wxCoord dx = xx1 - xxc; + wxCoord dy = yy1 - yyc; + double radius = sqrt ((double)(dx * dx + dy * dy)); + wxCoord r = (wxCoord) radius; + + double radius1, radius2; + + if (xx1 == xx2 && yy1 == yy2) + { + radius1 = 0.0; + radius2 = 360.0; + } + else if (radius == 0.0) + radius1 = radius2 = 0.0; + else + { + if (xx1 - xxc == 0) + if (yy1 - yyc < 0) + radius1 = 90.0; + else + radius1 = -90.0; + else + radius1 = -atan2 ((double) (yy1 - yyc), (double) (xx1 - xxc)) * 360.0 / (2 * M_PI); + + if (xx2 - xxc == 0) + if (yy2 - yyc < 0) + radius2 = 90.0; + else + radius2 = -90.0; + else + radius2 = -atan2 ((double) (yy2 - yyc), (double) (xx2 - xxc)) * 360.0 / (2 * M_PI); + } + radius1 *= 64.0; + radius2 *= 64.0; + int alpha1 = (int) radius1; + int alpha2 = (int) (radius2 - radius1); + while (alpha2 <= 0) + alpha2 += 360 * 64; + while (alpha2 > 360 * 64) + alpha2 -= 360 * 64; + + if (m_brush.Ok() && m_brush.GetStyle () != wxTRANSPARENT) + { + SetBrush (m_brush); + XFillArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) (GC) m_gc, + xxc - r, yyc - r, 2 * r, 2 * r, alpha1, alpha2); + + if (m_window && m_window->GetBackingPixmap()) + XFillArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking, + xxc_2 - r, yyc_2 - r, 2 * r, 2 * r, alpha1, alpha2); + + } + + if (m_pen.Ok() && m_pen.GetStyle () != wxTRANSPARENT) + { + if (m_autoSetting) + SetPen (m_pen); + XDrawArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, + xxc - r, yyc - r, 2 * r, 2 * r, alpha1, alpha2); + + if (m_window && m_window->GetBackingPixmap()) + XDrawArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking, + xxc_2 - r, yyc_2 - r, 2 * r, 2 * r, alpha1, alpha2); + } + CalcBoundingBox (x1, y1); + CalcBoundingBox (x2, y2); +} + +void wxWindowDC::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord width, wxCoord height, double sa, double ea ) +{ + wxCHECK_RET( Ok(), "invalid dc" ); + + int xd, yd, wd, hd; + + xd = XLOG2DEV(x); + yd = YLOG2DEV(y); + wd = XLOG2DEVREL(width); + hd = YLOG2DEVREL(height); + + if (sa>=360 || sa<=-360) sa=sa-int(sa/360)*360; + if (ea>=360 || ea<=-360) ea=ea-int(ea/360)*360; + int start = int(sa*64); + int end = int(ea*64); + if (start<0) start+=360*64; + if (end <0) end +=360*64; + if (end>start) end-=start; + else end+=360*64-start; + + if (m_brush.Ok() && m_brush.GetStyle () != wxTRANSPARENT) + { + m_autoSetting = TRUE; // must be reset + + SetBrush (m_brush); + XFillArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd, wd, hd, start, end); + + if (m_window && m_window->GetBackingPixmap()) + XFillArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking, + XLOG2DEV_2 (x), YLOG2DEV_2 (y),wd,hd,start,end); + } + + if (m_pen.Ok() && m_pen.GetStyle () != wxTRANSPARENT) + { + if (m_autoSetting) + SetPen (m_pen); + XDrawArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd, wd, hd, start,end); + if (m_window && m_window->GetBackingPixmap()) + XDrawArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking, + XLOG2DEV_2 (x), YLOG2DEV_2 (y),wd,hd,start,end); + } + CalcBoundingBox (x, y); + CalcBoundingBox (x + width, y + height); +} + +void wxWindowDC::DoDrawPoint( wxCoord x, wxCoord y ) +{ + wxCHECK_RET( Ok(), "invalid dc" ); + + // FreeGetPixelCache(); + + if (m_pen.Ok() && m_autoSetting) + SetPen (m_pen); + + XDrawPoint ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, XLOG2DEV (x), YLOG2DEV (y)); + if (m_window && m_window->GetBackingPixmap()) + XDrawPoint ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, XLOG2DEV_2 (x), YLOG2DEV_2 (y)); + + CalcBoundingBox (x, y); +} + +void wxWindowDC::DoDrawLines( int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset ) +{ + wxCHECK_RET( Ok(), "invalid dc" ); + + // FreeGetPixelCache(); + + if (m_pen.Ok() && m_pen.GetStyle () != wxTRANSPARENT) + { + if (m_autoSetting) + SetPen (m_pen); + + XPoint *xpoints = new XPoint[n]; + int i; + + for (i = 0; i < n; i++) + { + xpoints[i].x = XLOG2DEV (points[i].x + xoffset); + xpoints[i].y = YLOG2DEV (points[i].y + yoffset); + } + XDrawLines ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xpoints, n, 0); + + if (m_window && m_window->GetBackingPixmap()) + { + for (i = 0; i < n; i++) + { + xpoints[i].x = XLOG2DEV_2 (points[i].x + xoffset); + xpoints[i].y = YLOG2DEV_2 (points[i].y + yoffset); + } + XDrawLines ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, xpoints, n, 0); + } + delete[]xpoints; + } +} + +void wxWindowDC::DoDrawPolygon( int n, wxPoint points[], + wxCoord xoffset, wxCoord yoffset, int fillStyle ) +{ + wxCHECK_RET( Ok(), "invalid dc" ); + + // FreeGetPixelCache(); + + XPoint *xpoints1 = new XPoint[n + 1]; + XPoint *xpoints2 = new XPoint[n + 1]; + int i; + for (i = 0; i < n; i++) + { + xpoints1[i].x = XLOG2DEV (points[i].x + xoffset); + xpoints1[i].y = YLOG2DEV (points[i].y + yoffset); + xpoints2[i].x = XLOG2DEV_2 (points[i].x + xoffset); + xpoints2[i].y = YLOG2DEV_2 (points[i].y + yoffset); + CalcBoundingBox (points[i].x + xoffset, points[i].y + yoffset); + } + + // Close figure for XDrawLines (not needed for XFillPolygon) + xpoints1[i].x = xpoints1[0].x; + xpoints1[i].y = xpoints1[0].y; + xpoints2[i].x = xpoints2[0].x; + xpoints2[i].y = xpoints2[0].y; + + if (m_brush.Ok() && m_brush.GetStyle () != wxTRANSPARENT) + { + SetBrush (m_brush); + XSetFillRule ((Display*) m_display, (GC) m_gc, fillStyle == wxODDEVEN_RULE ? EvenOddRule : WindingRule); + XFillPolygon ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xpoints1, n, Complex, 0); + XSetFillRule ((Display*) m_display, (GC) m_gc, EvenOddRule); // default mode + if (m_window && m_window->GetBackingPixmap()) + { + XSetFillRule ((Display*) m_display,(GC) m_gcBacking, + fillStyle == wxODDEVEN_RULE ? EvenOddRule : WindingRule); + XFillPolygon ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, xpoints2, n, Complex, 0); + XSetFillRule ((Display*) m_display,(GC) m_gcBacking, EvenOddRule); // default mode + } + } + + if (m_pen.Ok() && m_pen.GetStyle () != wxTRANSPARENT) + { + if (m_autoSetting) + SetPen (m_pen); + XDrawLines ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xpoints1, n + 1, 0); + + if (m_window && m_window->GetBackingPixmap()) + XDrawLines ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, xpoints2, n + 1, 0); + } + + delete[]xpoints1; + delete[]xpoints2; +} + +void wxWindowDC::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) +{ + wxCHECK_RET( Ok(), "invalid dc" ); + + // FreeGetPixelCache(); + + int xd, yd, wfd, hfd, wd, hd; + + xd = XLOG2DEV(x); + yd = YLOG2DEV(y); + wfd = XLOG2DEVREL(width); + wd = wfd - WX_GC_CF; + hfd = YLOG2DEVREL(height); + hd = hfd - WX_GC_CF; + + if (wfd == 0 || hfd == 0) return; + if (wd < 0) { wd = - wd; xd = xd - wd; } + if (hd < 0) { hd = - hd; yd = yd - hd; } + + if (m_brush.Ok() && m_brush.GetStyle () != wxTRANSPARENT) + { + SetBrush (m_brush); + XFillRectangle ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd, wfd, hfd); + + if (m_window && m_window->GetBackingPixmap()) + XFillRectangle ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, + XLOG2DEV_2 (x), YLOG2DEV_2 (y), + wfd, hfd); + } + + if (m_pen.Ok() && m_pen.GetStyle () != wxTRANSPARENT) + { + if (m_autoSetting) + SetPen (m_pen); + XDrawRectangle ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd, wd, hd); + + if (m_window && m_window->GetBackingPixmap()) + XDrawRectangle ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, + XLOG2DEV_2 (x), YLOG2DEV_2 (y), + wd, hd); + } + CalcBoundingBox (x, y); + CalcBoundingBox (x + width, y + height); +} + +void wxWindowDC::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius ) +{ + wxCHECK_RET( Ok(), "invalid dc" ); + + // FreeGetPixelCache(); + + // If radius is negative, it's a proportion of the smaller dimension. + + if (radius < 0.0) radius = - radius * ((width < height) ? width : height); + + int xd = XLOG2DEV (x); + int yd = YLOG2DEV (y); + int rd = XLOG2DEVREL ((long) radius); + int wd = XLOG2DEVREL (width) - WX_GC_CF; + int hd = YLOG2DEVREL (height) - WX_GC_CF; + + int rw_d = rd * 2; + int rh_d = rw_d; + + // If radius is zero use DrawRectangle() instead to avoid + // X drawing errors with small radii + if (rd == 0) + { + DrawRectangle( x, y, width, height ); + return; + } + + // Draw nothing if transformed w or h is 0 + if (wd == 0 || hd == 0) return; + + // CMB: adjust size if outline is drawn otherwise the result is + // 1 pixel too wide and high + if (m_pen.GetStyle() != wxTRANSPARENT) + { + wd--; + hd--; + } + + // CMB: ensure dd is not larger than rectangle otherwise we + // get an hour glass shape + if (rw_d > wd) rw_d = wd; + if (rw_d > hd) rw_d = hd; + rd = rw_d / 2; + + // For backing pixmap + int xd2 = XLOG2DEV_2 (x); + int yd2 = YLOG2DEV_2 (y); + int rd2 = XLOG2DEVREL ((long) radius); + int wd2 = XLOG2DEVREL (width) ; + int hd2 = YLOG2DEVREL (height) ; + + int rw_d2 = rd2 * 2; + int rh_d2 = rw_d2; + + if (m_brush.Ok() && m_brush.GetStyle () != wxTRANSPARENT) + { + SetBrush (m_brush); + + XFillRectangle ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd + rd, yd, + wd - rw_d, hd); + XFillRectangle ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd + rd, + wd, hd - rh_d); + + // Arcs start from 3 o'clock, positive angles anticlockwise + // Top-left + XFillArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd, + rw_d, rh_d, 90 * 64, 90 * 64); + // Top-right + XFillArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd + wd - rw_d, yd, + // rw_d, rh_d, 0, 90 * 64); + rw_d, rh_d, 0, 91 * 64); + // Bottom-right + XFillArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd + wd - rw_d, + yd + hd - rh_d, + // rw_d, rh_d, 270 * 64, 90 * 64); + rw_d, rh_d, 269 * 64, 92 * 64); + // Bottom-left + XFillArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd + hd - rh_d, + rw_d, rh_d, 180 * 64, 90 * 64); + + if (m_window && m_window->GetBackingPixmap()) + { + XFillRectangle ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, + xd2 + rd2, yd2, wd2 - rw_d2, hd2); + XFillRectangle ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, + xd2, yd2 + rd2, wd2, hd2 - rh_d2); + + XFillArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, + xd2, yd2, rw_d2, rh_d2, 90 * 64, 90 * 64); + XFillArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, + xd2 + wd2 - rw_d2, yd2, + // rw_d2, rh_d2, 0, 90 * 64); + rw_d2, rh_d2, 0, 91 * 64); + XFillArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, + xd2 + wd2 - rw_d2, + yd2 + hd2 - rh_d2, + // rw_d2, rh_d2, 270 * 64, 90 * 64); + rw_d2, rh_d2, 269 * 64, 92 * 64); + XFillArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, + xd2, yd2 + hd2 - rh_d2, + rw_d2, rh_d2, 180 * 64, 90 * 64); + } + } + + if (m_pen.Ok() && m_pen.GetStyle () != wxTRANSPARENT) + { + SetPen (m_pen); + XDrawLine ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd + rd, yd, + xd + wd - rd + 1, yd); + XDrawLine ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd + rd, yd + hd, + xd + wd - rd, yd + hd); + + XDrawLine ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd + rd, + xd, yd + hd - rd); + XDrawLine ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd + wd, yd + rd, + xd + wd, yd + hd - rd + 1); + XDrawArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd, + rw_d, rh_d, 90 * 64, 90 * 64); + XDrawArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd + wd - rw_d, yd, + // rw_d, rh_d, 0, 90 * 64); + rw_d, rh_d, 0, 91 * 64); + XDrawArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd + wd - rw_d, + yd + hd - rh_d, + rw_d, rh_d, 269 * 64, 92 * 64); + XDrawArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd + hd - rh_d, + rw_d, rh_d, 180 * 64, 90 * 64); + + if (m_window && m_window->GetBackingPixmap()) + { + XDrawLine ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, + xd2 + rd2, yd2, + xd2 + wd2 - rd2 + 1, yd2); + XDrawLine ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, + xd2 + rd2, yd2 + hd2, + xd2 + wd2 - rd2, yd2 + hd2); + + XDrawLine ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, + xd2, yd2 + rd2, + xd2, yd2 + hd2 - rd2); + XDrawLine ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, + xd2 + wd2, yd2 + rd2, + xd2 + wd2, yd2 + hd2 - rd2 + 1); + XDrawArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, + xd2, yd2, + rw_d2, rh_d2, 90 * 64, 90 * 64); + XDrawArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, + xd2 + wd2 - rw_d2, yd2, + // rw_d2, rh_d2, 0, 90 * 64); + rw_d2, rh_d2, 0, 91 * 64); + XDrawArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, + xd2 + wd2 - rw_d2, + yd2 + hd2 - rh_d2, + rw_d2, rh_d2, 269 * 64, 92 * 64); + XDrawArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, + xd2, yd2 + hd2 - rh_d2, + rw_d2, rh_d2, 180 * 64, 90 * 64); + } + } + CalcBoundingBox (x, y); + CalcBoundingBox (x + width, y + height); + + +} + +void wxWindowDC::DoDrawEllipse( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) +{ + wxCHECK_RET( Ok(), "invalid dc" ); + + // Check for negative width and height + if (height < 0) + { + y = y + height; + height = - height ; + } + + if (width < 0) + { + x = x + width; + width = - width ; + } + + // FreeGetPixelCache(); + + static const int angle = 23040; + + int xd, yd, wd, hd; + + xd = XLOG2DEV(x); + yd = YLOG2DEV(y); + wd = XLOG2DEVREL(width) ; + hd = YLOG2DEVREL(height) ; + + if (m_brush.Ok() && m_brush.GetStyle () != wxTRANSPARENT) + { + SetBrush (m_brush); + XFillArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd, wd, hd, 0, angle); + if (m_window && m_window->GetBackingPixmap()) + XFillArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, + XLOG2DEV_2 (x), YLOG2DEV_2 (y), + XLOG2DEVREL (width) - WX_GC_CF, + YLOG2DEVREL (height) - WX_GC_CF, 0, angle); + } + + if (m_pen.Ok() && m_pen.GetStyle () != wxTRANSPARENT) + { + if (m_autoSetting) + SetPen (m_pen); + XDrawArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd, wd, hd, 0, angle); + if (m_window && m_window->GetBackingPixmap()) + XDrawArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, + XLOG2DEV_2 (x), YLOG2DEV_2 (y), + XLOG2DEVREL (width) - WX_GC_CF, + YLOG2DEVREL (height) - WX_GC_CF, 0, angle); + } + CalcBoundingBox (x, y); + CalcBoundingBox (x + width, y + height); + +} + +bool wxWindowDC::CanDrawBitmap() const +{ + wxCHECK_MSG( Ok(), FALSE, "invalid dc" ); + + return TRUE; +} + +#if 0 +void wxWindowDC::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y) +{ + // FreeGetPixelCache(); + + // Be sure that foreground pixels (1) of + // the Icon will be painted with pen colour. [m_pen.SetColour()] + // Background pixels (0) will be painted with + // last selected background color. [::SetBackground] + if (m_pen.Ok() && m_autoSetting) + SetPen (m_pen); + + int width, height; + Pixmap iconPixmap = (Pixmap) icon.GetPixmap(); + width = icon.GetWidth(); + height = icon.GetHeight(); + if (icon.GetDisplay() == m_display) + { + if (icon.GetDepth() <= 1) + { + XCopyPlane ((Display*) m_display, iconPixmap, (Pixmap) m_pixmap, (GC) m_gc, + 0, 0, width, height, + (int) XLOG2DEV (x), (int) YLOG2DEV (y), 1); + } + else + { + XCopyArea ((Display*) m_display, iconPixmap, (Pixmap) m_pixmap, (GC) m_gc, + 0, 0, width, height, + (int) XLOG2DEV (x), (int) YLOG2DEV (y)); + } + + + if (m_window && m_window->GetBackingPixmap()) + { + if (icon.GetDepth() <= 1) + { + XCopyPlane ((Display*) m_display, iconPixmap, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, + 0, 0, width, height, (int) XLOG2DEV_2 (x), (int) YLOG2DEV_2 (y), 1); + } + else + { + XCopyArea ((Display*) m_display, iconPixmap, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, + 0, 0, width, height, + (int) XLOG2DEV_2 (x), (int) YLOG2DEV_2 (y)); + } + } + } else { /* Remote copy (different (Display*) m_displays) */ + XImage *cache = NULL; + if (m_window && m_window->GetBackingPixmap()) + XCopyRemote((Display*) icon.GetDisplay(), (Display*) m_display, iconPixmap, (Pixmap) m_window->GetBackingPixmap(), + (GC) m_gcBacking, 0, 0, width, height, + (int) XLOG2DEV_2 (x), (int) YLOG2DEV_2 (y), TRUE, &cache); + XCopyRemote((Display*) icon.GetDisplay(), (Display*) m_display, iconPixmap, (Pixmap) m_pixmap, (GC) m_gc, + 0, 0, width, height, + (int) XLOG2DEV (x), (int) YLOG2DEV (y), FALSE, &cache); + } + CalcBoundingBox (x, y); +} +#endif // 0 + +// TODO: use scaled Blit e.g. as per John Price's implementation in Contrib/Utilities +bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, + wxDC *source, wxCoord xsrc, wxCoord ysrc, int rop, bool useMask, + wxCoord xsrcMask, wxCoord ysrcMask ) +{ + wxCHECK_MSG( Ok(), FALSE, "invalid dc" ); + + wxWindowDC* sourceDC = wxDynamicCast(source, wxWindowDC); + + wxASSERT_MSG( sourceDC, "Blit source DC must be wxWindowDC or derived class." ); + + // FreeGetPixelCache(); + + // Be sure that foreground pixels (1) of the Icon will be painted with pen + // colour. [m_pen.SetColour()] Background pixels (0) will be painted with + // last selected background color. [::SetBackground] + if (m_pen.Ok() && m_autoSetting) + SetPen (m_pen); + + // Do bitmap scaling if necessary + + wxBitmap *scaledBitmap = (wxBitmap*) NULL; + Pixmap sourcePixmap = (Pixmap) NULL; + double scaleX, scaleY; + GetUserScale(& scaleX, & scaleY); + + /* TODO: use the mask origin when drawing transparently */ + if (xsrcMask == -1 && ysrcMask == -1) + { + xsrcMask = xsrc; ysrcMask = ysrc; + } + + // Sorry, can't scale masks just yet + if (!useMask && (scaleX != 1.0 || scaleY != 1.0) && sourceDC->IsKindOf(CLASSINFO(wxMemoryDC))) + { + wxMemoryDC* memDC = (wxMemoryDC*) sourceDC; + wxBitmap& bitmap = memDC->GetBitmap(); + + wxASSERT_MSG( (bitmap.Ok()), "Bad source bitmap in wxWindowDC::Blit"); + + wxImage image(bitmap); + if (!image.Ok()) + { + sourcePixmap = (Pixmap) bitmap.GetPixmap(); + } + else + { + int scaledW = (int) (bitmap.GetWidth() * scaleX); + int scaledH = (int) (bitmap.GetHeight() * scaleY); + + image = image.Scale(scaledW, scaledH); + scaledBitmap = new wxBitmap(image.ConvertToBitmap()); + sourcePixmap = (Pixmap) scaledBitmap->GetPixmap(); + } + } + else + sourcePixmap = (Pixmap) sourceDC->m_pixmap; + + if (m_pixmap && sourcePixmap) + { + /* MATTHEW: [9] */ + int orig = m_logicalFunction; + + SetLogicalFunction (rop); + + if (m_display != sourceDC->m_display) + { + XImage *cache = NULL; + + if (m_window && m_window->GetBackingPixmap()) + XCopyRemote((Display*) sourceDC->m_display, (Display*) m_display, + (Pixmap) sourcePixmap, (Pixmap) m_window->GetBackingPixmap(), + (GC) m_gcBacking, + source->LogicalToDeviceX (xsrc), + source->LogicalToDeviceY (ysrc), + source->LogicalToDeviceXRel(width), + source->LogicalToDeviceYRel(height), + XLOG2DEV_2 (xdest), YLOG2DEV_2 (ydest), + TRUE, &cache); + + if ( useMask && source->IsKindOf(CLASSINFO(wxMemoryDC)) ) + { + wxMemoryDC *memDC = (wxMemoryDC *)source; + wxBitmap& sel = memDC->GetBitmap(); + if ( sel.Ok() && sel.GetMask() && sel.GetMask()->GetPixmap() ) + { + XSetClipMask ((Display*) m_display, (GC) m_gc, (Pixmap) sel.GetMask()->GetPixmap()); + XSetClipOrigin ((Display*) m_display, (GC) m_gc, XLOG2DEV (xdest), YLOG2DEV (ydest)); + } + } + + XCopyRemote((Display*) sourceDC->m_display, (Display*) m_display, (Pixmap) sourcePixmap, (Pixmap) m_pixmap, (GC) m_gc, + source->LogicalToDeviceX (xsrc), + source->LogicalToDeviceY (ysrc), + source->LogicalToDeviceXRel(width), + source->LogicalToDeviceYRel(height), + XLOG2DEV (xdest), YLOG2DEV (ydest), + FALSE, &cache); + + if ( useMask ) + { + XSetClipMask ((Display*) m_display, (GC) m_gc, None); + XSetClipOrigin ((Display*) m_display, (GC) m_gc, 0, 0); + } + + } else + { + if (m_window && m_window->GetBackingPixmap()) + { + // +++ MARKUS (mho@comnets.rwth-aachen): error on blitting bitmaps with depth 1 + if (source->IsKindOf(CLASSINFO(wxMemoryDC)) && ((wxMemoryDC*) source)->GetBitmap().GetDepth() == 1) + { + XCopyPlane ((Display*) m_display, (Pixmap) sourcePixmap, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, + source->LogicalToDeviceX (xsrc), + source->LogicalToDeviceY (ysrc), + source->LogicalToDeviceXRel(width), + source->LogicalToDeviceYRel(height), + XLOG2DEV_2 (xdest), YLOG2DEV_2 (ydest), 1); + } + else + { + XCopyArea ((Display*) m_display, (Pixmap) sourcePixmap, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, + source->LogicalToDeviceX (xsrc), + source->LogicalToDeviceY (ysrc), + source->LogicalToDeviceXRel(width), + source->LogicalToDeviceYRel(height), + XLOG2DEV_2 (xdest), YLOG2DEV_2 (ydest)); + } + } + if ( useMask && source->IsKindOf(CLASSINFO(wxMemoryDC)) ) + { + wxMemoryDC *memDC = (wxMemoryDC *)source; + wxBitmap& sel = memDC->GetBitmap(); + if ( sel.Ok() && sel.GetMask() && sel.GetMask()->GetPixmap() ) + { + XSetClipMask ((Display*) m_display, (GC) m_gc, (Pixmap) sel.GetMask()->GetPixmap()); + XSetClipOrigin ((Display*) m_display, (GC) m_gc, XLOG2DEV (xdest), YLOG2DEV (ydest)); + } + } + + // Check if we're copying from a mono bitmap + if (source->IsKindOf(CLASSINFO(wxMemoryDC)) && + ((wxMemoryDC*)source)->GetBitmap().Ok() && (((wxMemoryDC*)source)->GetBitmap().GetDepth () == 1)) + { + XCopyPlane ((Display*) m_display, (Pixmap) sourcePixmap, (Pixmap) m_pixmap, (GC) m_gc, + source->LogicalToDeviceX (xsrc), + source->LogicalToDeviceY (ysrc), + source->LogicalToDeviceXRel(width), + source->LogicalToDeviceYRel(height), + XLOG2DEV (xdest), YLOG2DEV (ydest), 1); + } + else + { + XCopyArea ((Display*) m_display, (Pixmap) sourcePixmap, (Pixmap) m_pixmap, (GC) m_gc, + source->LogicalToDeviceX (xsrc), + source->LogicalToDeviceY (ysrc), + source->LogicalToDeviceXRel(width), + source->LogicalToDeviceYRel(height), + XLOG2DEV (xdest), YLOG2DEV (ydest)); + + } + if ( useMask ) + { + XSetClipMask ((Display*) m_display, (GC) m_gc, None); + XSetClipOrigin ((Display*) m_display, (GC) m_gc, 0, 0); + } + + } /* Remote/local (Display*) m_display */ + CalcBoundingBox (xdest, ydest); + CalcBoundingBox (xdest + width, ydest + height); + + SetLogicalFunction(orig); + + if (scaledBitmap) delete scaledBitmap; + + return TRUE; + } + if (scaledBitmap) delete scaledBitmap; + + return FALSE; +} + +void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) +{ + wxCHECK_RET( Ok(), "invalid dc" ); + + // Since X draws from the baseline of the text, must add the text height + int cx = 0; + int cy = 0; + int ascent = 0; + int slen; + + slen = strlen(text); + + if (m_font.Ok()) + { + WXFontStructPtr pFontStruct = m_font.GetFontStruct(m_userScaleY*m_logicalScaleY, m_display); + int direction, descent; + XCharStruct overall_return; +#if 0 + if (use16) + (void)XTextExtents16((XFontStruct*) pFontStruct, (XChar2b *)(const char*) text, slen, &direction, + &ascent, &descent, &overall_return); + else +#endif // 0 + (void)XTextExtents((XFontStruct*) pFontStruct, (char*) (const char*) text, slen, &direction, + &ascent, &descent, &overall_return); + + cx = overall_return.width; + cy = ascent + descent; + } + + // First draw a rectangle representing the text background, if a text + // background is specified + if (m_textBackgroundColour.Ok () && (m_backgroundMode != wxTRANSPARENT)) + { + wxColour oldPenColour = m_currentColour; + m_currentColour = m_textBackgroundColour; + bool sameColour = (oldPenColour.Ok () && m_textBackgroundColour.Ok () && + (oldPenColour.Red () == m_textBackgroundColour.Red ()) && + (oldPenColour.Blue () == m_textBackgroundColour.Blue ()) && + (oldPenColour.Green () == m_textBackgroundColour.Green ())); + + // This separation of the big && test required for gcc2.7/HP UX 9.02 + // or pixel value can be corrupted! + sameColour = (sameColour && + (oldPenColour.GetPixel() == m_textBackgroundColour.GetPixel())); + + if (!sameColour || !GetOptimization()) + { + int pixel = m_textBackgroundColour.AllocColour(m_display); + m_currentColour = m_textBackgroundColour; + + // Set the GC to the required colour + if (pixel > -1) + { + XSetForeground ((Display*) m_display, (GC) m_gc, pixel); + if (m_window && m_window->GetBackingPixmap()) + XSetForeground ((Display*) m_display,(GC) m_gcBacking, pixel); + } + } + else + m_textBackgroundColour = oldPenColour ; + + XFillRectangle ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, XLOG2DEV (x), YLOG2DEV (y), cx, cy); + if (m_window && m_window->GetBackingPixmap()) + XFillRectangle ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, + XLOG2DEV_2 (x), YLOG2DEV_2 (y), cx, cy); + } + + // Now set the text foreground and draw the text + if (m_textForegroundColour.Ok ()) + { + wxColour oldPenColour = m_currentColour; + m_currentColour = m_textForegroundColour; + bool sameColour = (oldPenColour.Ok () && m_currentColour.Ok () && + (oldPenColour.Red () == m_currentColour.Red ()) && + (oldPenColour.Blue () == m_currentColour.Blue ()) && + (oldPenColour.Green () == m_currentColour.Green ()) && + (oldPenColour.GetPixel() == m_currentColour.GetPixel())); + + if (!sameColour || !GetOptimization()) + { + int pixel = -1; + if (!m_colour) // Mono display + { + // Unless foreground is really white, draw it in black + unsigned char red = m_textForegroundColour.Red (); + unsigned char blue = m_textForegroundColour.Blue (); + unsigned char green = m_textForegroundColour.Green (); + if (red == (unsigned char) 255 && blue == (unsigned char) 255 + && green == (unsigned char) 255) + { + m_currentColour = *wxWHITE; + pixel = (int) WhitePixel ((Display*) m_display, DefaultScreen ((Display*) m_display)); + m_currentColour.SetPixel(pixel); + m_textForegroundColour.SetPixel(pixel); + } + else + { + m_currentColour = *wxBLACK; + pixel = (int) BlackPixel ((Display*) m_display, DefaultScreen ((Display*) m_display)); + m_currentColour.SetPixel(pixel); + m_textForegroundColour.SetPixel(pixel); + } + } + else + { + pixel = m_textForegroundColour.AllocColour((Display*) m_display); + m_currentColour.SetPixel(pixel); + } + + // Set the GC to the required colour + if (pixel > -1) + { + XSetForeground ((Display*) m_display, (GC) m_gc, pixel); + if (m_window && m_window->GetBackingPixmap()) + XSetForeground ((Display*) m_display,(GC) m_gcBacking, pixel); + } + } + else + m_textForegroundColour = oldPenColour; + } + + // We need to add the ascent, not the whole height, since X draws at the + // point above the descender. +#if 0 + if (use16) + XDrawString16((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, XLOG2DEV (x), YLOG2DEV (y) + ascent, + (XChar2b *)(char*) (const char*) text, slen); + else +#endif // 0 + XDrawString((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, XLOG2DEV (x), YLOG2DEV (y) + ascent, text, slen); + + if (m_window && m_window->GetBackingPixmap()) { +#if 0 + if (use16) + XDrawString16((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking, + XLOG2DEV_2 (x), YLOG2DEV_2 (y) + ascent, + (XChar2b *)(char*) (const char*) text, slen); + else +#endif // 0 + XDrawString((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking, + XLOG2DEV_2 (x), YLOG2DEV_2 (y) + ascent, (char*) (const char*) text, slen); + } + + wxCoord w, h; + GetTextExtent (text, &w, &h); + CalcBoundingBox (x + w, y + h); + CalcBoundingBox (x, y); +} + +void wxWindowDC::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord y, double angle ) +{ + if (angle == 0.0) + { + DrawText(text, x, y); + return; + } + + wxCHECK_RET( Ok(), "invalid dc" ); + + // Since X draws from the baseline of the text, must add the text height + int cx = 0; + int cy = 0; + int ascent = 0; + int slen; + + slen = strlen(text); + + if (m_font.Ok()) + { + // Calculate text extent. + WXFontStructPtr pFontStruct = m_font.GetFontStruct(m_userScaleY*m_logicalScaleY, m_display); + int direction, descent; + XCharStruct overall_return; +#if 0 + if (use16) + (void)XTextExtents16((XFontStruct*) pFontStruct, (XChar2b *)(const char*) text, slen, &direction, + &ascent, &descent, &overall_return); + else +#endif // 0 + (void)XTextExtents((XFontStruct*) pFontStruct, (char*) (const char*) text, slen, &direction, + &ascent, &descent, &overall_return); + + cx = overall_return.width; + cy = ascent + descent; + } + + wxBitmap src(cx, cy); + wxMemoryDC dc; + dc.SelectObject(src); + dc.SetFont(GetFont()); + dc.SetBackground(*wxWHITE_BRUSH); + dc.SetBrush(*wxBLACK_BRUSH); + dc.Clear(); + dc.DrawText(text, 0, 0); + dc.SetFont(wxNullFont); + + // Calculate the size of the rotated bounding box. + double dx = cos(angle / 180.0 * M_PI); + double dy = sin(angle / 180.0 * M_PI); + double x4 = -cy * dy; + double y4 = cy * dx; + double x3 = cx * dx; + double y3 = cx * dy; + double x2 = x3 + x4; + double y2 = y3 + y4; + double x1 = x; + double y1 = y; + + // Create image from the source bitmap after writing the text into it. + wxImage image(src); + + int minx = roundmin(0, roundmin(x4, roundmin(x2, x3))); + int miny = roundmin(0, roundmin(y4, roundmin(y2, y3))); + int maxx = roundmax(0, roundmax(x4, roundmax(x2, x3))); + int maxy = roundmax(0, roundmax(y4, roundmax(y2, y3))); + + // This rotates counterclockwise around the top left corner. + for (int rx = minx; rx < maxx; rx++) + { + for (int ry = miny; ry < maxy; ry++) + { + // transform dest coords to source coords + int sx = (int) (rx * dx + ry * dy + 0.5); + int sy = (int) (ry * dx - rx * dy + 0.5); + if (sx >= 0 && sx < cx && sy >= 0 && sy < cy) + { + // draw black pixels, ignore white ones (i.e. transparent b/g) + if (image.GetRed(sx, sy) == 0) + { + DrawPoint((wxCoord) (x1 + maxx - rx), (wxCoord) (cy + y1 - ry)); + } + else + { + // Background + //DrawPoint(x1 + maxx - rx, cy + y1 + maxy - ry); + } + } + } + } + +#if 0 + // First draw a rectangle representing the text background, if a text + // background is specified + if (m_textBackgroundColour.Ok () && (m_backgroundMode != wxTRANSPARENT)) + { + wxColour oldPenColour = m_currentColour; + m_currentColour = m_textBackgroundColour; + bool sameColour = (oldPenColour.Ok () && m_textBackgroundColour.Ok () && + (oldPenColour.Red () == m_textBackgroundColour.Red ()) && + (oldPenColour.Blue () == m_textBackgroundColour.Blue ()) && + (oldPenColour.Green () == m_textBackgroundColour.Green ())); + + // This separation of the big && test required for gcc2.7/HP UX 9.02 + // or pixel value can be corrupted! + sameColour = (sameColour && + (oldPenColour.GetPixel() == m_textBackgroundColour.GetPixel())); + + if (!sameColour || !GetOptimization()) + { + int pixel = m_textBackgroundColour.AllocColour(m_display); + m_currentColour = m_textBackgroundColour; + + // Set the GC to the required colour + if (pixel > -1) + { + XSetForeground ((Display*) m_display, (GC) m_gc, pixel); + if (m_window && m_window->GetBackingPixmap()) + XSetForeground ((Display*) m_display,(GC) m_gcBacking, pixel); + } + } + else + m_textBackgroundColour = oldPenColour ; + + XFillRectangle ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, XLOG2DEV (x), YLOG2DEV (y), cx, cy); + if (m_window && m_window->GetBackingPixmap()) + XFillRectangle ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, + XLOG2DEV_2 (x), YLOG2DEV_2 (y), cx, cy); + } +#endif + + long w, h; + // XXX use pixmap size + GetTextExtent (text, &w, &h); + CalcBoundingBox (x + w, y + h); + CalcBoundingBox (x, y); +} + +bool wxWindowDC::CanGetTextExtent() const +{ + return TRUE; +} + +void wxWindowDC::DoGetTextExtent( const wxString &string, wxCoord *width, wxCoord *height, + wxCoord *descent, wxCoord *externalLeading, + wxFont *font ) const +{ + wxCHECK_RET( Ok(), "invalid dc" ); + + wxFont* theFont = font; + if (!theFont) + theFont = (wxFont *)&m_font; // const_cast + + if (!theFont->Ok()) + { + // TODO: this should be an error log function + wxFAIL_MSG("set a valid font before calling GetTextExtent!"); + + if (width) *width = -1; + if (height) *height = -1; + return; + } + + WXFontStructPtr pFontStruct = theFont->GetFontStruct(m_userScaleY*m_logicalScaleY, m_display); + + int direction, ascent, descent2; + XCharStruct overall; + int slen; + +#if 0 + if (use16) + slen = str16len(string); + else +#endif // 0 + slen = strlen(string); + +#if 0 + if (use16) + XTextExtents16((XFontStruct*) pFontStruct, (XChar2b *) (char*) (const char*) string, slen, &direction, + &ascent, &descent2, &overall); + else +#endif // 0 + XTextExtents((XFontStruct*) pFontStruct, (char*) (const char*) string, slen, &direction, + &ascent, &descent2, &overall); + + if (width) *width = XDEV2LOGREL (overall.width); + if (height) *height = YDEV2LOGREL (ascent + descent2); + if (descent) + *descent = descent2; + if (externalLeading) + *externalLeading = 0; +} + +wxCoord wxWindowDC::GetCharWidth() const +{ + wxCHECK_MSG( Ok(), 0, "invalid dc" ); + wxCHECK_MSG( m_font.Ok(), 0, "invalid font" ); + + WXFontStructPtr pFontStruct = m_font.GetFontStruct(m_userScaleY * m_logicalScaleY, m_display); + + int direction, ascent, descent; + XCharStruct overall; + XTextExtents ((XFontStruct*) pFontStruct, "x", 1, &direction, &ascent, + &descent, &overall); + return XDEV2LOGREL(overall.width); +} + +wxCoord wxWindowDC::GetCharHeight() const +{ + wxCHECK_MSG( Ok(), 0, "invalid dc" ); + wxCHECK_MSG( m_font.Ok(), 0, "invalid font" ); + + WXFontStructPtr pFontStruct = m_font.GetFontStruct(m_userScaleY*m_logicalScaleY, m_display); + + int direction, ascent, descent; + XCharStruct overall; + XTextExtents ((XFontStruct*) pFontStruct, "x", 1, &direction, &ascent, + &descent, &overall); + // return XDEV2LOGREL(overall.ascent + overall.descent); + return XDEV2LOGREL(ascent + descent); +} + +void wxWindowDC::Clear() +{ + wxCHECK_RET( Ok(), "invalid dc" ); + + int w, h; + if (m_window) + { + m_window->GetSize(&w, &h); + + if (m_window && m_window->GetBackingPixmap()) + { + w = m_window->GetPixmapWidth(); + h = m_window->GetPixmapHeight(); + } + } + else + { + if (this->IsKindOf(CLASSINFO(wxMemoryDC))) + { + wxMemoryDC* memDC = (wxMemoryDC*) this; + w = memDC->GetBitmap().GetWidth(); + h = memDC->GetBitmap().GetHeight(); + } + else + return; + } + + wxBrush saveBrush = m_brush; + SetBrush (m_backgroundBrush); + + XFillRectangle ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, 0, 0, w, h); + + if (m_window && m_window->GetBackingPixmap()) + XFillRectangle ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, 0, 0, w, h); + + m_brush = saveBrush; +} + +void wxWindowDC::Clear(const wxRect& rect) +{ + wxCHECK_RET( Ok(), "invalid dc" ); + + int x = rect.x; int y = rect.y; + int w = rect.width; int h = rect.height; + + wxBrush saveBrush = m_brush; + SetBrush (m_backgroundBrush); + + XFillRectangle ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, x, y, w, h); + + if (m_window && m_window->GetBackingPixmap()) + XFillRectangle ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, x, y, w, h); + + m_brush = saveBrush; +} + +void wxWindowDC::SetFont( const wxFont &font ) +{ + wxCHECK_RET( Ok(), "invalid dc" ); + + m_font = font; + + if (!m_font.Ok()) + { + if ((m_oldFont != (WXFont) 0) && ((wxCoord) m_oldFont != -1)) + { + XSetFont ((Display*) m_display, (GC) m_gc, (Font) m_oldFont); + + if (m_window && m_window->GetBackingPixmap()) + XSetFont ((Display*) m_display,(GC) m_gcBacking, (Font) m_oldFont); + } + return; + } + + WXFontStructPtr pFontStruct = m_font.GetFontStruct(m_userScaleY*m_logicalScaleY, m_display); + + Font fontId = ((XFontStruct*)pFontStruct)->fid; + XSetFont ((Display*) m_display, (GC) m_gc, fontId); + + if (m_window && m_window->GetBackingPixmap()) + XSetFont ((Display*) m_display,(GC) m_gcBacking, fontId); +} + +void wxWindowDC::SetPen( const wxPen &pen ) +{ + wxCHECK_RET( Ok(), "invalid dc" ); + + m_pen = pen; + if (!m_pen.Ok()) + return; + + wxBitmap oldStipple = m_currentStipple; + int oldStyle = m_currentStyle; + int oldFill = m_currentFill; + int old_pen_width = m_currentPenWidth; + int old_pen_join = m_currentPenJoin; + int old_pen_cap = m_currentPenCap; + int old_pen_nb_dash = m_currentPenDashCount; + wxMOTIFDash *old_pen_dash = m_currentPenDash; + + wxColour oldPenColour = m_currentColour; + m_currentColour = m_pen.GetColour (); + m_currentStyle = m_pen.GetStyle (); + m_currentFill = m_pen.GetStyle (); // TODO? + m_currentPenWidth = m_pen.GetWidth (); + m_currentPenJoin = m_pen.GetJoin (); + m_currentPenCap = m_pen.GetCap (); + m_currentPenDashCount = m_pen.GetDashCount(); + m_currentPenDash = (wxMOTIFDash*)m_pen.GetDash(); + + if (m_currentStyle == wxSTIPPLE) + m_currentStipple = * m_pen.GetStipple (); + + bool sameStyle = (oldStyle == m_currentStyle && + oldFill == m_currentFill && + old_pen_join == m_currentPenJoin && + old_pen_cap == m_currentPenCap && + old_pen_nb_dash == m_currentPenDashCount && + old_pen_dash == m_currentPenDash && + old_pen_width == m_currentPenWidth); + + bool sameColour = (oldPenColour.Ok () && + (oldPenColour.Red () == m_currentColour.Red ()) && + (oldPenColour.Blue () == m_currentColour.Blue ()) && + (oldPenColour.Green () == m_currentColour.Green ()) && + (oldPenColour.GetPixel() == m_currentColour.GetPixel())); + + if (!sameStyle || !GetOptimization()) + { + int scaled_width = (int) XLOG2DEVREL (m_pen.GetWidth ()); + if (scaled_width < 0) + scaled_width = 0; + + int style; + int join; + int cap; + static const wxMOTIFDash dotted[] = {2, 5}; + static const wxMOTIFDash short_dashed[] = {4, 4}; + static const wxMOTIFDash long_dashed[] = {4, 8}; + static const wxMOTIFDash dotted_dashed[] = {6, 6, 2, 6}; + + // We express dash pattern in pen width unit, so we are + // independent of zoom factor and so on... + int req_nb_dash; + const wxMOTIFDash *req_dash; + + switch (m_pen.GetStyle ()) + { + case wxUSER_DASH: + req_nb_dash = m_currentPenDashCount; + req_dash = m_currentPenDash; + style = LineOnOffDash; + break; + case wxDOT: + req_nb_dash = 2; + req_dash = dotted; + style = LineOnOffDash; + break; + case wxSHORT_DASH: + req_nb_dash = 2; + req_dash = short_dashed; + style = LineOnOffDash; + break; + case wxLONG_DASH: + req_nb_dash = 2; + req_dash = long_dashed; + style = LineOnOffDash; + break; + case wxDOT_DASH: + req_nb_dash = 4; + req_dash = dotted_dashed; + style = LineOnOffDash; + break; + case wxSTIPPLE: + case wxSOLID: + case wxTRANSPARENT: + default: + style = LineSolid; + req_dash = (wxMOTIFDash*)NULL; + req_nb_dash = 0; + } + + if (req_dash && req_nb_dash) + { + wxMOTIFDash *real_req_dash = new wxMOTIFDash[req_nb_dash]; + if (real_req_dash) + { + int factor = scaled_width == 0 ? 1 : scaled_width; + for (int i = 0; i < req_nb_dash; i++) + real_req_dash[i] = req_dash[i] * factor; + XSetDashes ((Display*) m_display, (GC) m_gc, 0, real_req_dash, req_nb_dash); + + if (m_window && m_window->GetBackingPixmap()) + XSetDashes ((Display*) m_display,(GC) m_gcBacking, 0, real_req_dash, req_nb_dash); + delete[]real_req_dash; + } + else + { + // No Memory. We use non-scaled dash pattern... + XSetDashes ((Display*) m_display, (GC) m_gc, 0, req_dash, req_nb_dash); + + if (m_window && m_window->GetBackingPixmap()) + XSetDashes ((Display*) m_display,(GC) m_gcBacking, 0, req_dash, req_nb_dash); + } + } + + switch (m_pen.GetCap ()) + { + case wxCAP_PROJECTING: + cap = CapProjecting; + break; + case wxCAP_BUTT: + cap = CapButt; + break; + case wxCAP_ROUND: + default: + cap = (scaled_width <= 1) ? CapNotLast : CapRound; + break; + } + + switch (m_pen.GetJoin ()) + { + case wxJOIN_BEVEL: + join = JoinBevel; + break; + case wxJOIN_MITER: + join = JoinMiter; + break; + case wxJOIN_ROUND: + default: + join = JoinRound; + break; + } + + XSetLineAttributes ((Display*) m_display, (GC) m_gc, scaled_width, style, cap, join); + + if (m_window && m_window->GetBackingPixmap()) + XSetLineAttributes ((Display*) m_display,(GC) m_gcBacking, scaled_width, style, cap, join); + } + + if (IS_HATCH(m_currentFill) && ((m_currentFill != oldFill) || !GetOptimization())) + { + Pixmap myStipple; + + oldStipple = wxNullBitmap; // For later reset!! + + switch (m_currentFill) + { + case wxBDIAGONAL_HATCH: + if (bdiag == (Pixmap) 0) + bdiag = XCreateBitmapFromData ((Display*) m_display, + RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)), + bdiag_bits, bdiag_width, bdiag_height); + myStipple = bdiag; + break; + case wxFDIAGONAL_HATCH: + if (fdiag == (Pixmap) 0) + fdiag = XCreateBitmapFromData ((Display*) m_display, + RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)), + fdiag_bits, fdiag_width, fdiag_height); + myStipple = fdiag; + break; + case wxCROSS_HATCH: + if (cross == (Pixmap) 0) + cross = XCreateBitmapFromData ((Display*) m_display, + RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)), + cross_bits, cross_width, cross_height); + myStipple = cross; + break; + case wxHORIZONTAL_HATCH: + if (horiz == (Pixmap) 0) + horiz = XCreateBitmapFromData ((Display*) m_display, + RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)), + horiz_bits, horiz_width, horiz_height); + myStipple = horiz; + break; + case wxVERTICAL_HATCH: + if (verti == (Pixmap) 0) + verti = XCreateBitmapFromData ((Display*) m_display, + RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)), + verti_bits, verti_width, verti_height); + myStipple = verti; + break; + case wxCROSSDIAG_HATCH: + default: + if (cdiag == (Pixmap) 0) + cdiag = XCreateBitmapFromData ((Display*) m_display, + RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)), + cdiag_bits, cdiag_width, cdiag_height); + myStipple = cdiag; + break; + } + XSetStipple ((Display*) m_display, (GC) m_gc, myStipple); + + if (m_window && m_window->GetBackingPixmap()) + XSetStipple ((Display*) m_display,(GC) m_gcBacking, myStipple); + } + else if (m_currentStipple.Ok() + && ((m_currentStipple != oldStipple) || !GetOptimization())) + { + XSetStipple ((Display*) m_display, (GC) m_gc, (Pixmap) m_currentStipple.GetPixmap()); + + if (m_window && m_window->GetBackingPixmap()) + XSetStipple ((Display*) m_display,(GC) m_gcBacking, (Pixmap) m_currentStipple.GetPixmap()); + } + + if ((m_currentFill != oldFill) || !GetOptimization()) + { + int fill_style; + + if (m_currentFill == wxSTIPPLE) + fill_style = FillStippled; + else if (IS_HATCH (m_currentFill)) + fill_style = FillStippled; + else + fill_style = FillSolid; + XSetFillStyle ((Display*) m_display, (GC) m_gc, fill_style); + if (m_window && m_window->GetBackingPixmap()) + XSetFillStyle ((Display*) m_display,(GC) m_gcBacking, fill_style); + } + + // must test m_logicalFunction, because it involves background! + if (!sameColour || !GetOptimization() + || ((m_logicalFunction == wxXOR) || (m_autoSetting & 0x2))) + { + int pixel = -1; + if (m_pen.GetStyle () == wxTRANSPARENT) + pixel = m_backgroundPixel; + else if (!m_colour) + { + unsigned char red = m_pen.GetColour ().Red (); + unsigned char blue = m_pen.GetColour ().Blue (); + unsigned char green = m_pen.GetColour ().Green (); + if (red == (unsigned char) 255 && blue == (unsigned char) 255 + && green == (unsigned char) 255) + { + pixel = (int) WhitePixel ((Display*) m_display, DefaultScreen ((Display*) m_display)); + m_currentColour = *wxWHITE; + m_pen.GetColour().SetPixel(pixel); + m_currentColour.SetPixel(pixel); + } + else + { + pixel = (int) BlackPixel ((Display*) m_display, DefaultScreen ((Display*) m_display)); + m_currentColour = *wxBLACK; + m_pen.GetColour().SetPixel(pixel); + } + } + else + { + pixel = m_pen.GetColour ().AllocColour(m_display); + m_currentColour.SetPixel(pixel); + } + + // Finally, set the GC to the required colour + if (pixel > -1) + { + if (m_logicalFunction == wxXOR) + { + XGCValues values; + XGetGCValues ((Display*) m_display, (GC) m_gc, GCBackground, &values); + XSetForeground ((Display*) m_display, (GC) m_gc, pixel ^ values.background); + if (m_window && m_window->GetBackingPixmap()) + XSetForeground ((Display*) m_display,(GC) m_gcBacking, pixel ^ values.background); + } + else + { + XSetForeground ((Display*) m_display, (GC) m_gc, pixel); + if (m_window && m_window->GetBackingPixmap()) + XSetForeground ((Display*) m_display,(GC) m_gcBacking, pixel); + } + } + } + else + m_pen.GetColour().SetPixel(oldPenColour.GetPixel()); + + m_autoSetting = 0; +} + +void wxWindowDC::SetBrush( const wxBrush &brush ) +{ + wxCHECK_RET( Ok(), "invalid dc" ); + + m_brush = brush; + + if (!m_brush.Ok() || m_brush.GetStyle () == wxTRANSPARENT) + return; + + int oldFill = m_currentFill; + wxBitmap oldStipple = m_currentStipple; + + m_autoSetting |= 0x1; + + m_currentFill = m_brush.GetStyle (); + if (m_currentFill == wxSTIPPLE) + m_currentStipple = * m_brush.GetStipple (); + + wxColour oldBrushColour(m_currentColour); + m_currentColour = m_brush.GetColour (); + + bool sameColour = (oldBrushColour.Ok () && + (oldBrushColour.Red () == m_currentColour.Red ()) && + (oldBrushColour.Blue () == m_currentColour.Blue ()) && + (oldBrushColour.Green () == m_currentColour.Green ()) && + (oldBrushColour.GetPixel() == m_currentColour.GetPixel())); + + if ((oldFill != m_brush.GetStyle ()) || !GetOptimization()) + { + switch (brush.GetStyle ()) + { + case wxTRANSPARENT: + break; + case wxBDIAGONAL_HATCH: + case wxCROSSDIAG_HATCH: + case wxFDIAGONAL_HATCH: + case wxCROSS_HATCH: + case wxHORIZONTAL_HATCH: + case wxVERTICAL_HATCH: + case wxSTIPPLE: + { + // Chris Breeze 23/07/97: use background mode to determine whether + // fill style should be solid or transparent + int style = (m_backgroundMode == wxSOLID ? FillOpaqueStippled : FillStippled); + XSetFillStyle ((Display*) m_display, (GC) m_gc, style); + if (m_window && m_window->GetBackingPixmap()) + XSetFillStyle ((Display*) m_display,(GC) m_gcBacking, style); + } + break; + case wxSOLID: + default: + XSetFillStyle ((Display*) m_display, (GC) m_gc, FillSolid); + if (m_window && m_window->GetBackingPixmap()) + XSetFillStyle ((Display*) m_display,(GC) m_gcBacking, FillSolid); + } + } + + if (IS_HATCH(m_currentFill) && ((m_currentFill != oldFill) || !GetOptimization())) + { + Pixmap myStipple; + + switch (m_currentFill) + { + case wxBDIAGONAL_HATCH: + if (bdiag == (Pixmap) 0) + bdiag = XCreateBitmapFromData ((Display*) m_display, + RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)), + bdiag_bits, bdiag_width, bdiag_height); + myStipple = bdiag; + break; + case wxFDIAGONAL_HATCH: + if (fdiag == (Pixmap) 0) + fdiag = XCreateBitmapFromData ((Display*) m_display, + RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)), + fdiag_bits, fdiag_width, fdiag_height); + myStipple = fdiag; + break; + case wxCROSS_HATCH: + if (cross == (Pixmap) 0) + cross = XCreateBitmapFromData ((Display*) m_display, + RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)), + cross_bits, cross_width, cross_height); + myStipple = cross; + break; + case wxHORIZONTAL_HATCH: + if (horiz == (Pixmap) 0) + horiz = XCreateBitmapFromData ((Display*) m_display, + RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)), + horiz_bits, horiz_width, horiz_height); + myStipple = horiz; + break; + case wxVERTICAL_HATCH: + if (verti == (Pixmap) 0) + verti = XCreateBitmapFromData ((Display*) m_display, + RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)), + verti_bits, verti_width, verti_height); + myStipple = verti; + break; + case wxCROSSDIAG_HATCH: + default: + if (cdiag == (Pixmap) 0) + cdiag = XCreateBitmapFromData ((Display*) m_display, + RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)), + cdiag_bits, cdiag_width, cdiag_height); + myStipple = cdiag; + break; + } + XSetStipple ((Display*) m_display, (GC) m_gc, myStipple); + + if (m_window && m_window->GetBackingPixmap()) + XSetStipple ((Display*) m_display,(GC) m_gcBacking, myStipple); + } + // X can forget the stipple value when resizing a window (apparently) + // so always set the stipple. + else if (m_currentStipple.Ok()) // && m_currentStipple != oldStipple) + { + XSetStipple ((Display*) m_display, (GC) m_gc, (Pixmap) m_currentStipple.GetPixmap()); + if (m_window && m_window->GetBackingPixmap()) + XSetStipple ((Display*) m_display,(GC) m_gcBacking, (Pixmap) m_currentStipple.GetPixmap()); + } + + // must test m_logicalFunction, because it involves background! + if (!sameColour || !GetOptimization() || m_logicalFunction == wxXOR) + { + int pixel = -1; + if (!m_colour) + { + // Policy - on a monochrome screen, all brushes are white, + // except when they're REALLY black!!! + unsigned char red = m_brush.GetColour ().Red (); + unsigned char blue = m_brush.GetColour ().Blue (); + unsigned char green = m_brush.GetColour ().Green (); + + if (red == (unsigned char) 0 && blue == (unsigned char) 0 + && green == (unsigned char) 0) + { + pixel = (int) BlackPixel ((Display*) m_display, DefaultScreen ((Display*) m_display)); + m_currentColour = *wxBLACK; + m_brush.GetColour().SetPixel(pixel); + m_currentColour.SetPixel(pixel); + } + else + { + pixel = (int) WhitePixel ((Display*) m_display, DefaultScreen ((Display*) m_display)); + m_currentColour = *wxWHITE; + m_brush.GetColour().SetPixel(pixel); + m_currentColour.SetPixel(pixel); + } + + // N.B. comment out the above line and uncomment the following lines + // if you want non-white colours to be black on a monochrome display. + /* + if (red == (unsigned char )255 && blue == (unsigned char)255 + && green == (unsigned char)255) + pixel = (int)WhitePixel((Display*) m_display, DefaultScreen((Display*) m_display)); + else + pixel = (int)BlackPixel((Display*) m_display, DefaultScreen((Display*) m_display)); + */ + } + else if (m_brush.GetStyle () != wxTRANSPARENT) + { + pixel = m_brush.GetColour().AllocColour(m_display); + m_currentColour.SetPixel(pixel); + } + if (pixel > -1) + { + // Finally, set the GC to the required colour + if (m_logicalFunction == wxXOR) + { + XGCValues values; + XGetGCValues ((Display*) m_display, (GC) m_gc, GCBackground, &values); + XSetForeground ((Display*) m_display, (GC) m_gc, pixel ^ values.background); + if (m_window && m_window->GetBackingPixmap()) + XSetForeground ((Display*) m_display,(GC) m_gcBacking, pixel ^ values.background); + } + else + { + XSetForeground ((Display*) m_display, (GC) m_gc, pixel); + if (m_window && m_window->GetBackingPixmap()) + XSetForeground ((Display*) m_display,(GC) m_gcBacking, pixel); + } + } + } + else + m_brush.GetColour().SetPixel(oldBrushColour.GetPixel()); +} + +void wxWindowDC::SetBackground( const wxBrush &brush ) +{ + wxCHECK_RET( Ok(), "invalid dc" ); + + m_backgroundBrush = brush; + + if (!m_backgroundBrush.Ok()) + return; + + int pixel = m_backgroundBrush.GetColour().AllocColour(m_display); + + // New behaviour, 10/2/99: setting the background brush of a DC + // doesn't affect the window background colour. +/* + // 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.) + XSetBackground ((Display*) m_display, (GC) m_gc, pixel); + if (m_window && m_window->GetBackingPixmap()) + XSetBackground ((Display*) m_display,(GC) m_gcBacking, pixel); +} + +void wxWindowDC::SetLogicalFunction( int function ) +{ + wxCHECK_RET( Ok(), "invalid dc" ); + + int x_function; + + /* MATTHEW: [9] */ + if (m_logicalFunction == function) + return; + + switch (function) + { + case wxCLEAR: + x_function = GXclear; + break; + case wxXOR: + x_function = GXxor; + break; + case wxINVERT: + x_function = GXinvert; + break; + case wxOR_REVERSE: + x_function = GXorReverse; + break; + case wxAND_REVERSE: + x_function = GXandReverse; + break; + case wxAND: + x_function = GXand; + break; + case wxOR: + x_function = GXor; + break; + case wxAND_INVERT: + x_function = GXandInverted; + break; + case wxNO_OP: + x_function = GXnoop; + break; + case wxNOR: + x_function = GXnor; + break; + case wxEQUIV: + x_function = GXequiv; + break; + case wxSRC_INVERT: + x_function = GXcopyInverted; + break; + case wxOR_INVERT: + x_function = GXorInverted; + break; + case wxNAND: + x_function = GXnand; + break; + case wxSET: + x_function = GXset; + break; + case wxCOPY: + default: + x_function = GXcopy; + break; + } + + XSetFunction((Display*) m_display, (GC) m_gc, x_function); + if (m_window && m_window->GetBackingPixmap()) + XSetFunction((Display*) m_display, (GC) m_gcBacking, x_function); + + if ((m_logicalFunction == wxXOR) != (function == wxXOR)) + /* MATTHEW: [9] Need to redo pen simply */ + m_autoSetting |= 0x2; + + m_logicalFunction = function; + +} + +void wxWindowDC::SetTextForeground( const wxColour &col ) +{ + wxCHECK_RET( Ok(), "invalid dc" ); + + if (m_textForegroundColour == col) + return; + + m_textForegroundColour = col; + +} + +void wxWindowDC::SetTextBackground( const wxColour &col ) +{ + wxCHECK_RET( Ok(), "invalid dc" ); + + if (m_textBackgroundColour == col) + return; + + m_textBackgroundColour = col; + if (!m_textBackgroundColour.Ok()) + return; +} + +void wxWindowDC::SetBackgroundMode( int mode ) +{ + m_backgroundMode = mode; +} + +void wxWindowDC::SetPalette( const wxPalette& palette ) +{ + if (m_window) + { + if (palette.Ok()) + /* Use GetXColormap */ + XSetWindowColormap ((Display*) m_display, (Window) m_window->GetXWindow(), + (Colormap) palette.GetXColormap()); + else + /* Use wxGetMainColormap */ + XSetWindowColormap ((Display*) m_display, (Window) m_window->GetXWindow(), + (Colormap) wxTheApp->GetMainColormap(m_display)); + } +} + +// Helper function +void wxWindowDC::SetDCClipping() +{ + // m_userRegion is the region set by calling SetClippingRegion + + if (m_currentRegion) + XDestroyRegion ((Region) m_currentRegion); + + // We need to take into account + // clipping imposed on a window by a repaint. + // We'll combine it with the user region. But for now, + // just use the currently-defined user clipping region. + if (m_userRegion || (m_window && m_window->GetUpdateRegion().Ok()) ) + m_currentRegion = (WXRegion) XCreateRegion (); + else + m_currentRegion = (WXRegion) NULL; + + if ((m_window && m_window->GetUpdateRegion().Ok()) && m_userRegion) + XIntersectRegion ((Region) m_window->GetUpdateRegion().GetXRegion(), (Region) m_userRegion, (Region) m_currentRegion); + else if (m_userRegion) + XIntersectRegion ((Region) m_userRegion, (Region) m_userRegion, (Region) m_currentRegion); + else if (m_window && m_window->GetUpdateRegion().Ok()) + XIntersectRegion ((Region) m_window->GetUpdateRegion().GetXRegion(), (Region) m_window->GetUpdateRegion().GetXRegion(), + (Region) m_currentRegion); + + if (m_currentRegion) + { + XSetRegion ((Display*) m_display, (GC) m_gc, (Region) m_currentRegion); + } + else + { + XSetClipMask ((Display*) m_display, (GC) m_gc, None); + } + +} + +void wxWindowDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) +{ + wxDC::DoSetClippingRegion( x, y, width, height ); + + if (m_userRegion) + XDestroyRegion ((Region) m_userRegion); + m_userRegion = (WXRegion) XCreateRegion (); + XRectangle r; + r.x = XLOG2DEV (x); + r.y = YLOG2DEV (y); + r.width = XLOG2DEVREL(width); + r.height = YLOG2DEVREL(height); + XUnionRectWithRegion (&r, (Region) m_userRegion, (Region) m_userRegion); + + SetDCClipping (); + + // Needs to work differently for Pixmap: without this, + // there's a nasty (Display*) m_display bug. 8/12/94 + if (m_window && m_window->GetBackingPixmap()) + { + XRectangle rects[1]; + rects[0].x = XLOG2DEV_2(x); + rects[0].y = YLOG2DEV_2(y); + rects[0].width = XLOG2DEVREL(width); + rects[0].height = YLOG2DEVREL(height); + XSetClipRectangles((Display*) m_display, (GC) m_gcBacking, 0, 0, rects, 1, Unsorted); + } +} + +void wxWindowDC::DoSetClippingRegionAsRegion( const wxRegion& region ) +{ + wxRect box = region.GetBox(); + + wxDC::DoSetClippingRegion( box.x, box.y, box.width, box.height ); + + if (m_userRegion) + XDestroyRegion ((Region) m_userRegion); + m_userRegion = (WXRegion) XCreateRegion (); + + XUnionRegion((Region) m_userRegion, (Region) region.GetXRegion(), (Region) m_userRegion); + + SetDCClipping (); + + // Needs to work differently for Pixmap: without this, + // there's a nasty (Display*) m_display bug. 8/12/94 + if (m_window && m_window->GetBackingPixmap()) + { + XRectangle rects[1]; + rects[0].x = XLOG2DEV_2(box.x); + rects[0].y = YLOG2DEV_2(box.y); + rects[0].width = XLOG2DEVREL(box.width); + rects[0].height = YLOG2DEVREL(box.height); + XSetClipRectangles((Display*) m_display, (GC) m_gcBacking, 0, 0, rects, 1, Unsorted); + } +} + + +void wxWindowDC::DestroyClippingRegion() +{ + wxDC::DestroyClippingRegion(); + + if (m_userRegion) + XDestroyRegion ((Region) m_userRegion); + m_userRegion = NULL; + + SetDCClipping (); + + XGCValues gc_val; + gc_val.clip_mask = None; + if (m_window && m_window->GetBackingPixmap()) + XChangeGC((Display*) m_display, (GC) m_gcBacking, GCClipMask, &gc_val); +} + +// Resolution in pixels per logical inch +wxSize wxWindowDC::GetPPI() const +{ + return wxSize(100, 100); +} + +int wxWindowDC::GetDepth() const +{ + // TODO + return 24; +} + + + + +// ---------------------------------------------------------------------------- +// wxPaintDC +// ---------------------------------------------------------------------------- + +wxPaintDC::wxPaintDC(wxWindow* win) : wxWindowDC(win) +{ + wxRegion* region = NULL; + + // Combine all the update rects into a region + const wxRectList& updateRects(win->GetUpdateRects()); + if ( updateRects.GetCount() != 0 ) + { + for ( wxRectList::Node *node = updateRects.GetFirst(); + node; + node = node->GetNext() ) + { + wxRect* rect = node->GetData(); + + if (!region) + region = new wxRegion(*rect); + else + // TODO: is this correct? In SetDCClipping above, + // XIntersectRegion is used to combine paint and user + // regions. XIntersectRegion appears to work in that case... + region->Union(*rect); + } + } + else + { + int cw, ch; + win->GetClientSize(&cw, &ch); + region = new wxRegion(wxRect(0, 0, cw, ch)); + } + + win->SetUpdateRegion(*region); + + wxRegion& theRegion(win->GetUpdateRegion()); + theRegion.SetRects(updateRects); // We also store in terms of rects, for iteration to work. + + // Set the clipping region. Any user-defined region will be combined with this + // one in SetDCClipping. + XSetRegion ((Display*) m_display, (GC) m_gc, (Region) region->GetXRegion()); + + delete region; +} + +wxPaintDC::~wxPaintDC() +{ + XSetClipMask ((Display*) m_display, (GC) m_gc, None); + if (m_window) + m_window->ClearUpdateRegion(); +} + +// ---------------------------------------------------------------------------- +// private functions +// ---------------------------------------------------------------------------- + +/* + Used when copying between drawables on different (Display*) m_displays. Not + very fast, but better than giving up. +*/ + +static void XCopyRemote(Display *src_display, Display *dest_display, + Drawable src, Drawable dest, + GC destgc, + int srcx, int srcy, + unsigned int w, unsigned int h, + int destx, int desty, + bool more, XImage **cache) +{ + XImage *image, *destimage; + Colormap destcm, srccm; + static const int CACHE_SIZE = 256; + + unsigned int i, j; + unsigned long cachesrc[CACHE_SIZE], cachedest[CACHE_SIZE]; + int k, cache_pos, all_cache; + + if (!cache || !*cache) + image = XGetImage(src_display, src, srcx, srcy, w, h, AllPlanes, ZPixmap); + else + image = *cache; + + destimage = XGetImage(dest_display, dest, destx, desty, w, h, AllPlanes, ZPixmap); + + srccm = (Colormap) wxTheApp->GetMainColormap((WXDisplay*) src_display); + destcm = (Colormap) wxTheApp->GetMainColormap((WXDisplay*) dest_display); + + cache_pos = 0; + all_cache = FALSE; + + for (i = 0; i < w; i++) + for (j = 0; j < h; j++) { + unsigned long pixel; + XColor xcol; + + pixel = XGetPixel(image, i, j); + for (k = cache_pos; k--; ) + if (cachesrc[k] == pixel) { + pixel = cachedest[k]; + goto install; + } + if (all_cache) + for (k = CACHE_SIZE; k-- > cache_pos; ) + if (cachesrc[k] == pixel) { + pixel = cachedest[k]; + goto install; + } + + cachesrc[cache_pos] = xcol.pixel = pixel; + XQueryColor(src_display, srccm, &xcol); + if (!XAllocColor(dest_display, destcm, &xcol)) + xcol.pixel = 0; + cachedest[cache_pos] = pixel = xcol.pixel; + + if (++cache_pos >= CACHE_SIZE) { + cache_pos = 0; + all_cache = TRUE; + } + +install: + XPutPixel(destimage, i, j, pixel); + } + + XPutImage(dest_display, dest, destgc, destimage, 0, 0, destx, desty, w, h); + XDestroyImage(destimage); + + if (more) + *cache = image; + else + XDestroyImage(image); +} + +#if 0 + +/* Helper function for 16-bit fonts */ +static int str16len(const char *s) +{ + int count = 0; + + while (s[0] && s[1]) { + count++; + s += 2; + } + + return count; +} + +#endif // 0 diff --git a/src/x11/dcmemory.cpp b/src/x11/dcmemory.cpp new file mode 100644 index 0000000000..8694f0b6ec --- /dev/null +++ b/src/x11/dcmemory.cpp @@ -0,0 +1,159 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dcmemory.cpp +// Purpose: wxMemoryDC class +// Author: Julian Smart +// Modified by: +// Created: 01/02/97 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "dcmemory.h" +#endif + +#include "wx/dcmemory.h" +#include "wx/settings.h" +#include "wx/utils.h" + +#ifdef __VMS__ +#pragma message disable nosimpint +#endif +#include +#ifdef __VMS__ +#pragma message enable nosimpint +#endif + +#include "wx/motif/private.h" + +//----------------------------------------------------------------------------- +// wxMemoryDC +//----------------------------------------------------------------------------- + +IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC, wxWindowDC) + +wxMemoryDC::wxMemoryDC(void) +{ + 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.subwindow_mode = IncludeInferiors; + gcvalues.line_width = 1; + m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)), + GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode, + &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); + SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); +}; + +wxMemoryDC::wxMemoryDC( wxDC* dc ) +{ + 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.subwindow_mode = IncludeInferiors; + gcvalues.line_width = 1; + m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)), + GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode, + &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_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.subwindow_mode = IncludeInferiors; + gcvalues.line_width = 1; + m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)), + GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode, + &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; + }; +}; + +void wxMemoryDC::DoGetSize( int *width, int *height ) const +{ + if (m_bitmap.Ok()) + { + if (width) (*width) = m_bitmap.GetWidth(); + if (height) (*height) = m_bitmap.GetHeight(); + } + else + { + if (width) (*width) = 0; + if (height) (*height) = 0; + }; +}; + + diff --git a/src/x11/dcscreen.cpp b/src/x11/dcscreen.cpp new file mode 100644 index 0000000000..1da45d5e39 --- /dev/null +++ b/src/x11/dcscreen.cpp @@ -0,0 +1,134 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dcscreen.cpp +// Purpose: wxScreenDC class +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "dcscreen.h" +#endif + +#include "wx/window.h" +#include "wx/frame.h" +#include "wx/dcscreen.h" +#include "wx/utils.h" + +#ifdef __VMS__ +#pragma message disable nosimpint +#endif +#include +#ifdef __VMS__ +#pragma message enable nosimpint +#endif + +#include "wx/motif/private.h" + +IMPLEMENT_DYNAMIC_CLASS(wxScreenDC, wxWindowDC) + +WXWindow wxScreenDC::sm_overlayWindow = 0; +int wxScreenDC::sm_overlayWindowX = 0; +int wxScreenDC::sm_overlayWindowY = 0; + +// Create a DC representing the whole screen +wxScreenDC::wxScreenDC() +{ + m_display = wxGetDisplay(); + Display* display = (Display*) m_display; + + if (sm_overlayWindow) + { + m_pixmap = sm_overlayWindow; + m_deviceOriginX = - sm_overlayWindowX; + m_deviceOriginY = - sm_overlayWindowY; + } + else + m_pixmap = (WXPixmap) RootWindow(display, DefaultScreen(display)); + + XGCValues gcvalues; + gcvalues.foreground = BlackPixel (display, DefaultScreen (display)); + gcvalues.background = WhitePixel (display, DefaultScreen (display)); + gcvalues.graphics_exposures = False; + gcvalues.subwindow_mode = IncludeInferiors; + gcvalues.line_width = 1; + m_gc = XCreateGC (display, RootWindow (display, DefaultScreen (display)), + GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode, + &gcvalues); + + m_backgroundPixel = (int) gcvalues.background; + m_ok = TRUE; +} + +wxScreenDC::~wxScreenDC() +{ + EndDrawingOnTop(); +} + +bool wxScreenDC::StartDrawingOnTop(wxWindow* window) +{ + wxRect rect; + int x, y, width, height; + window->GetPosition(& x, & y); + if (window->GetParent() && !window->IsKindOf(CLASSINFO(wxFrame))) + window->GetParent()->ClientToScreen(& x, & y); + window->GetSize(& width, & height); + rect.x = x; rect.y = y; + rect.width = width; rect.height = height; + + return StartDrawingOnTop(& rect); +} + +bool wxScreenDC::StartDrawingOnTop(wxRect* rect) +{ + if (sm_overlayWindow) + return FALSE; + + Display *dpy = (Display*) wxGetDisplay(); + Pixmap screenPixmap = RootWindow(dpy, DefaultScreen(dpy)); + + int x = 0; + int y = 0; + int width, height; + wxDisplaySize(&width, &height); + + if (rect) + { + x = rect->x; y = rect->y; + width = rect->width; height = rect->height; + } + sm_overlayWindowX = x; + sm_overlayWindowY = y; + + XSetWindowAttributes attributes; + attributes.override_redirect = True; + unsigned long valueMask = CWOverrideRedirect; + + sm_overlayWindow = (WXWindow) XCreateWindow(dpy, screenPixmap, x, y, width, height, 0, + wxDisplayDepth(), InputOutput, + DefaultVisual(dpy, 0), valueMask, + & attributes); + + if (sm_overlayWindow) + { + XMapWindow(dpy, (Window) sm_overlayWindow); + return TRUE; + } + else + return FALSE; +} + +bool wxScreenDC::EndDrawingOnTop() +{ + if (sm_overlayWindow) + { + XDestroyWindow((Display*) wxGetDisplay(), (Window) sm_overlayWindow); + sm_overlayWindow = 0; + return TRUE; + } + else + return FALSE; +} diff --git a/src/x11/dnd.cpp b/src/x11/dnd.cpp new file mode 100644 index 0000000000..e9e57e42f8 --- /dev/null +++ b/src/x11/dnd.cpp @@ -0,0 +1,238 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: dnd.cpp +// Purpose: wxDropTarget, wxDropSource classes +// Author: Julian Smart +// Id: $Id$ +// Copyright: (c) 1998 Julian Smart +// Licence: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "dnd.h" +#endif + +#include "wx/setup.h" + +#if wxUSE_DRAG_AND_DROP + +#include "wx/dnd.h" +#include "wx/window.h" +#include "wx/app.h" +#include "wx/gdicmn.h" +#include "wx/intl.h" +#include "wx/utils.h" +#include "wx/log.h" + +#include + +// ---------------------------------------------------------------------------- +// global +// ---------------------------------------------------------------------------- + +// ---------------------------------------------------------------------------- +// wxDropTarget +// ---------------------------------------------------------------------------- + +wxDropTarget::wxDropTarget() +{ +} + +wxDropTarget::~wxDropTarget() +{ +} + +// ---------------------------------------------------------------------------- +// wxTextDropTarget +// ---------------------------------------------------------------------------- + +bool wxTextDropTarget::OnDrop( long x, long y, const void *data, size_t WXUNUSED(size) ) +{ + OnDropText( x, y, (const char*)data ); + return TRUE; +} + +bool wxTextDropTarget::OnDropText( long x, long y, const char *psz ) +{ + wxLogDebug( "Got dropped text: %s.", psz ); + wxLogDebug( "At x: %d, y: %d.", (int)x, (int)y ); + return TRUE; +} + +size_t wxTextDropTarget::GetFormatCount() const +{ + return 1; +} + +wxDataFormat wxTextDropTarget::GetFormat(size_t WXUNUSED(n)) const +{ + return wxDF_TEXT; +} + +// ---------------------------------------------------------------------------- +// wxFileDropTarget +// ---------------------------------------------------------------------------- + +bool wxFileDropTarget::OnDropFiles( long x, long y, size_t nFiles, const char * const aszFiles[] ) +{ + wxLogDebug( "Got %d dropped files.", (int)nFiles ); + wxLogDebug( "At x: %d, y: %d.", (int)x, (int)y ); + size_t i; + for (i = 0; i < nFiles; i++) + { + wxLogDebug( aszFiles[i] ); + } + return TRUE; +} + +bool wxFileDropTarget::OnDrop(long x, long y, const void *data, size_t size ) +{ + size_t number = 0; + char *text = (char*) data; + size_t i; + for (i = 0; i < size; i++) + if (text[i] == 0) number++; + + if (number == 0) return TRUE; + + char **files = new char*[number]; + + text = (char*) data; + for ( i = 0; i < number; i++) + { + files[i] = text; + int len = strlen( text ); + text += len+1; + } + + bool ret = OnDropFiles( x, y, 1, files ); + + free( files ); + + return ret; +} + +size_t wxFileDropTarget::GetFormatCount() const +{ + return 1; +} + +wxDataFormat wxFileDropTarget::GetFormat(size_t WXUNUSED(n)) const +{ + return wxDF_FILENAME; +} + +//------------------------------------------------------------------------- +// wxDropSource +//------------------------------------------------------------------------- + +wxDropSource::wxDropSource( wxWindow *win ) +{ +#if 0 + m_window = win; + m_data = (wxDataObject *) NULL; + m_retValue = wxDragCancel; + + m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY ); + m_goaheadCursor = wxCursor( wxCURSOR_HAND ); +#endif +} + +wxDropSource::wxDropSource( wxDataObject &data, wxWindow *win ) +{ +#if 0 + g_blockEventsOnDrag = TRUE; + + m_window = win; + m_widget = win->m_widget; + if (win->m_wxwindow) m_widget = win->m_wxwindow; + m_retValue = wxDragCancel; + + m_data = &data; + + m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY ); + m_goaheadCursor = wxCursor( wxCURSOR_HAND ); +#endif +} + +void wxDropSource::SetData( wxDataObject &data ) +{ +// m_data = &data; +} + +wxDropSource::~wxDropSource(void) +{ +// if (m_data) delete m_data; +} + +wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) ) +{ + // wxASSERT_MSG( m_data, "wxDragSource: no data" ); + + return wxDragNone; +#if 0 + if (!m_data) return (wxDragResult) wxDragNone; + if (m_data->GetDataSize() == 0) return (wxDragResult) wxDragNone; + + RegisterWindow(); + + // TODO + + UnregisterWindow(); + + g_blockEventsOnDrag = FALSE; + + return m_retValue; +#endif +} + +#if 0 +void wxDropSource::RegisterWindow(void) +{ + if (!m_data) return; + + wxString formats; + + wxDataFormat df = m_data->GetPreferredFormat(); + + switch (df) + { + case wxDF_TEXT: + formats += "text/plain"; + break; + case wxDF_FILENAME: + formats += "file:ALL"; + break; + default: + break; + } + + char *str = WXSTRINGCAST formats; + + // TODO +} + +void wxDropSource::UnregisterWindow(void) +{ + if (!m_widget) return; + + // TODO +} +#endif + +wxPrivateDropTarget::wxPrivateDropTarget() +{ + m_id = wxTheApp->GetAppName(); +} + +size_t wxPrivateDropTarget::GetFormatCount() const +{ + return 1; +} + +wxDataFormat wxPrivateDropTarget::GetFormat(size_t n) const +{ + return wxDF_INVALID; +} + +#endif + // wxUSE_DRAG_AND_DROP diff --git a/src/x11/font.cpp b/src/x11/font.cpp new file mode 100644 index 0000000000..0af197f78d --- /dev/null +++ b/src/x11/font.cpp @@ -0,0 +1,551 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: src/motif/font.cpp +// Purpose: wxFont class +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +// ============================================================================ +// declarations +// ============================================================================ + +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- + +#ifdef __GNUG__ + #pragma implementation "font.h" +#endif + +#ifdef __VMS +#pragma message disable nosimpint +#include "wx/vms_x_fix.h" +#endif +#include +#ifdef __VMS +#pragma message enable nosimpint +#endif + +#include "wx/defs.h" +#include "wx/string.h" +#include "wx/font.h" +#include "wx/gdicmn.h" +#include "wx/utils.h" // for wxGetDisplay() +#include "wx/fontutil.h" // for wxNativeFontInfo +#include "wx/tokenzr.h" +#include "wx/settings.h" + +IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject) + +// ---------------------------------------------------------------------------- +// private classes +// ---------------------------------------------------------------------------- + +// For every wxFont, there must be a font for each display and scale requested. +// So these objects are stored in wxFontRefData::m_fonts +class wxXFont : public wxObject +{ +public: + wxXFont(); + ~wxXFont(); + + WXFontStructPtr m_fontStruct; // XFontStruct + WXFontList m_fontList; // Motif XmFontList + WXDisplay* m_display; // XDisplay + int m_scale; // Scale * 100 +}; + +class wxFontRefData: public wxGDIRefData +{ +friend class wxFont; + +public: + wxFontRefData(int size = wxDEFAULT, + int family = wxDEFAULT, + int style = wxDEFAULT, + int weight = wxDEFAULT, + bool underlined = FALSE, + const wxString& faceName = wxEmptyString, + wxFontEncoding encoding = wxFONTENCODING_DEFAULT) + { + Init(size, family, style, weight, underlined, faceName, encoding); + } + + wxFontRefData(const wxFontRefData& data) + { + Init(data.m_pointSize, data.m_family, data.m_style, data.m_weight, + data.m_underlined, data.m_faceName, data.m_encoding); + } + + ~wxFontRefData(); + +protected: + // common part of all ctors + void Init(int size, + int family, + int style, + int weight, + bool underlined, + const wxString& faceName, + wxFontEncoding encoding); + + // font attributes + int m_pointSize; + int m_family; + int m_style; + int m_weight; + bool m_underlined; + wxString m_faceName; + wxFontEncoding m_encoding; + + wxNativeFontInfo m_nativeFontInfo; + + // A list of wxXFonts + wxList m_fonts; +}; + +// ============================================================================ +// implementation +// ============================================================================ + +// ---------------------------------------------------------------------------- +// wxXFont +// ---------------------------------------------------------------------------- + +wxXFont::wxXFont() +{ + m_fontStruct = (WXFontStructPtr) 0; + m_fontList = (WXFontList) 0; + m_display = (WXDisplay*) 0; + m_scale = 100; +} + +wxXFont::~wxXFont() +{ + XmFontList fontList = (XmFontList) m_fontList; + + XmFontListFree (fontList); + + // TODO: why does freeing the font produce a segv??? + // Note that XFreeFont wasn't called in wxWin 1.68 either. + // XFontStruct* fontStruct = (XFontStruct*) m_fontStruct; + // XFreeFont((Display*) m_display, fontStruct); +} + +// ---------------------------------------------------------------------------- +// wxFontRefData +// ---------------------------------------------------------------------------- + +void wxFontRefData::Init(int pointSize, + int family, + int style, + int weight, + bool underlined, + const wxString& faceName, + wxFontEncoding encoding) +{ + if (family == wxDEFAULT) + m_family = wxSWISS; + else + m_family = family; + + m_faceName = faceName; + + if (style == wxDEFAULT) + m_style = wxNORMAL; + else + m_style = style; + + if (weight == wxDEFAULT) + m_weight = wxNORMAL; + else + m_weight = weight; + + if (pointSize == wxDEFAULT) + m_pointSize = 12; + else + m_pointSize = pointSize; + + m_underlined = underlined; + m_encoding = encoding; +} + +wxFontRefData::~wxFontRefData() +{ + wxNode* node = m_fonts.First(); + while (node) + { + wxXFont* f = (wxXFont*) node->Data(); + delete f; + node = node->Next(); + } + m_fonts.Clear(); +} + +// ---------------------------------------------------------------------------- +// wxFont +// ---------------------------------------------------------------------------- + +wxFont::wxFont(const wxNativeFontInfo& info) +{ + Init(); + + (void)Create(info.GetXFontName()); +} + +void wxFont::Init() +{ +} + +bool wxFont::Create(int pointSize, + int family, + int style, + int weight, + bool underlined, + const wxString& faceName, + wxFontEncoding encoding) +{ + UnRef(); + m_refData = new wxFontRefData(pointSize, family, style, weight, + underlined, faceName, encoding); + + RealizeResource(); + + return TRUE; +} + +bool wxFont::Create(const wxString& fontname, wxFontEncoding enc) +{ + if( !fontname ) + { + *this = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT); + return TRUE; + } + + m_refData = new wxFontRefData(); + + M_FONTDATA->m_nativeFontInfo.SetXFontName(fontname); // X font name + + wxString tmp; + + wxStringTokenizer tn( fontname, wxT("-") ); + + tn.GetNextToken(); // skip initial empty token + tn.GetNextToken(); // foundry + + + M_FONTDATA->m_faceName = tn.GetNextToken(); // family + + tmp = tn.GetNextToken().MakeUpper(); // weight + if (tmp == wxT("BOLD")) M_FONTDATA->m_weight = wxBOLD; + if (tmp == wxT("BLACK")) M_FONTDATA->m_weight = wxBOLD; + if (tmp == wxT("EXTRABOLD")) M_FONTDATA->m_weight = wxBOLD; + if (tmp == wxT("DEMIBOLD")) M_FONTDATA->m_weight = wxBOLD; + if (tmp == wxT("ULTRABOLD")) M_FONTDATA->m_weight = wxBOLD; + + if (tmp == wxT("LIGHT")) M_FONTDATA->m_weight = wxLIGHT; + if (tmp == wxT("THIN")) M_FONTDATA->m_weight = wxLIGHT; + + tmp = tn.GetNextToken().MakeUpper(); // slant + if (tmp == wxT("I")) M_FONTDATA->m_style = wxITALIC; + if (tmp == wxT("O")) M_FONTDATA->m_style = wxITALIC; + + tn.GetNextToken(); // set width + tn.GetNextToken(); // add. style + tn.GetNextToken(); // pixel size + + tmp = tn.GetNextToken(); // pointsize + if (tmp != wxT("*")) + { + long num = wxStrtol (tmp.c_str(), (wxChar **) NULL, 10); + M_FONTDATA->m_pointSize = (int)(num / 10); + } + + tn.GetNextToken(); // x-res + tn.GetNextToken(); // y-res + + tmp = tn.GetNextToken().MakeUpper(); // spacing + + if (tmp == wxT("M")) + M_FONTDATA->m_family = wxMODERN; + else if (M_FONTDATA->m_faceName == wxT("TIMES")) + M_FONTDATA->m_family = wxROMAN; + else if (M_FONTDATA->m_faceName == wxT("HELVETICA")) + M_FONTDATA->m_family = wxSWISS; + else if (M_FONTDATA->m_faceName == wxT("LUCIDATYPEWRITER")) + M_FONTDATA->m_family = wxTELETYPE; + else if (M_FONTDATA->m_faceName == wxT("LUCIDA")) + M_FONTDATA->m_family = wxDECORATIVE; + else if (M_FONTDATA->m_faceName == wxT("UTOPIA")) + M_FONTDATA->m_family = wxSCRIPT; + + tn.GetNextToken(); // avg width + + // deal with font encoding + M_FONTDATA->m_encoding = enc; + if ( M_FONTDATA->m_encoding == wxFONTENCODING_SYSTEM ) + { + wxString registry = tn.GetNextToken().MakeUpper(), + encoding = tn.GetNextToken().MakeUpper(); + + if ( registry == _T("ISO8859") ) + { + int cp; + if ( wxSscanf(encoding, wxT("%d"), &cp) == 1 ) + { + M_FONTDATA->m_encoding = + (wxFontEncoding)(wxFONTENCODING_ISO8859_1 + cp - 1); + } + } + else if ( registry == _T("MICROSOFT") ) + { + int cp; + if ( wxSscanf(encoding, wxT("cp125%d"), &cp) == 1 ) + { + M_FONTDATA->m_encoding = + (wxFontEncoding)(wxFONTENCODING_CP1250 + cp); + } + } + else if ( registry == _T("KOI8") ) + { + M_FONTDATA->m_encoding = wxFONTENCODING_KOI8; + } + //else: unknown encoding - may be give a warning here? + else + return FALSE; + } + return TRUE; +} + +wxFont::~wxFont() +{ +} + +// ---------------------------------------------------------------------------- +// change the font attributes +// ---------------------------------------------------------------------------- + +void wxFont::Unshare() +{ + // Don't change shared data + if (!m_refData) + { + m_refData = new wxFontRefData(); + } + else + { + wxFontRefData* ref = new wxFontRefData(*(wxFontRefData*)m_refData); + UnRef(); + m_refData = ref; + } +} + +void wxFont::SetPointSize(int pointSize) +{ + Unshare(); + + M_FONTDATA->m_pointSize = pointSize; + M_FONTDATA->m_nativeFontInfo.GetXFontName().Clear(); // invalid now + + RealizeResource(); +} + +void wxFont::SetFamily(int family) +{ + Unshare(); + + M_FONTDATA->m_family = family; + M_FONTDATA->m_nativeFontInfo.GetXFontName().Clear(); // invalid now + + RealizeResource(); +} + +void wxFont::SetStyle(int style) +{ + Unshare(); + + M_FONTDATA->m_style = style; + M_FONTDATA->m_nativeFontInfo.GetXFontName().Clear(); // invalid now + + RealizeResource(); +} + +void wxFont::SetWeight(int weight) +{ + Unshare(); + + M_FONTDATA->m_weight = weight; + M_FONTDATA->m_nativeFontInfo.GetXFontName().Clear(); // invalid now + + RealizeResource(); +} + +void wxFont::SetFaceName(const wxString& faceName) +{ + Unshare(); + + M_FONTDATA->m_faceName = faceName; + M_FONTDATA->m_nativeFontInfo.GetXFontName().Clear(); // invalid now + + RealizeResource(); +} + +void wxFont::SetUnderlined(bool underlined) +{ + Unshare(); + + M_FONTDATA->m_underlined = underlined; + + RealizeResource(); +} + +void wxFont::SetEncoding(wxFontEncoding encoding) +{ + Unshare(); + + M_FONTDATA->m_encoding = encoding; + M_FONTDATA->m_nativeFontInfo.GetXFontName().Clear(); // invalid now + + RealizeResource(); +} + +void wxFont::SetNativeFontInfo(const wxNativeFontInfo& info) +{ + Unshare(); + + M_FONTDATA->m_nativeFontInfo = info; +} + +// ---------------------------------------------------------------------------- +// query font attributes +// ---------------------------------------------------------------------------- + +int wxFont::GetPointSize() const +{ + wxCHECK_MSG( Ok(), 0, wxT("invalid font") ); + + return M_FONTDATA->m_pointSize; +} + +wxString wxFont::GetFaceName() const +{ + wxCHECK_MSG( Ok(), wxT(""), wxT("invalid font") ); + + return M_FONTDATA->m_faceName ; +} + +int wxFont::GetFamily() const +{ + wxCHECK_MSG( Ok(), 0, wxT("invalid font") ); + + return M_FONTDATA->m_family; +} + +int wxFont::GetStyle() const +{ + wxCHECK_MSG( Ok(), 0, wxT("invalid font") ); + + return M_FONTDATA->m_style; +} + +int wxFont::GetWeight() const +{ + wxCHECK_MSG( Ok(), 0, wxT("invalid font") ); + + return M_FONTDATA->m_weight; +} + +bool wxFont::GetUnderlined() const +{ + wxCHECK_MSG( Ok(), FALSE, wxT("invalid font") ); + + return M_FONTDATA->m_underlined; +} + +wxFontEncoding wxFont::GetEncoding() const +{ + wxCHECK_MSG( Ok(), wxFONTENCODING_DEFAULT, wxT("invalid font") ); + + return M_FONTDATA->m_encoding; +} + +wxNativeFontInfo *wxFont::GetNativeFontInfo() const +{ + wxCHECK_MSG( Ok(), (wxNativeFontInfo *)NULL, wxT("invalid font") ); + + if(M_FONTDATA->m_nativeFontInfo.GetXFontName().IsEmpty()) + GetInternalFont(); + + return new wxNativeFontInfo(M_FONTDATA->m_nativeFontInfo); +} + +// ---------------------------------------------------------------------------- +// real implementation +// ---------------------------------------------------------------------------- + +// Find an existing, or create a new, XFontStruct +// based on this wxFont and the given scale. Append the +// font to list in the private data for future reference. +wxXFont* wxFont::GetInternalFont(double scale, WXDisplay* display) const +{ + if ( !Ok() ) + return (wxXFont *)NULL; + + long intScale = long(scale * 100.0 + 0.5); // key for wxXFont + int pointSize = (M_FONTDATA->m_pointSize * 10 * intScale) / 100; + + // search existing fonts first + wxNode* node = M_FONTDATA->m_fonts.First(); + while (node) + { + wxXFont* f = (wxXFont*) node->Data(); + if ((!display || (f->m_display == display)) && (f->m_scale == intScale)) + return f; + node = node->Next(); + } + + // not found, create a new one + XFontStruct *font = (XFontStruct *) + wxLoadQueryNearestFont(pointSize, + M_FONTDATA->m_family, + M_FONTDATA->m_style, + M_FONTDATA->m_weight, + M_FONTDATA->m_underlined, + wxT(""), + M_FONTDATA->m_encoding); + + if ( !font ) + { + wxFAIL_MSG( wxT("Could not allocate even a default font -- something is wrong.") ); + + return (wxXFont*) NULL; + } + + wxXFont* f = new wxXFont; + f->m_fontStruct = (WXFontStructPtr)font; + f->m_display = ( display ? display : wxGetDisplay() ); + f->m_scale = intScale; + f->m_fontList = XmFontListCreate ((XFontStruct*) font, XmSTRING_DEFAULT_CHARSET); + M_FONTDATA->m_fonts.Append(f); + + return f; +} + +WXFontStructPtr wxFont::GetFontStruct(double scale, WXDisplay* display) const +{ + wxXFont* f = GetInternalFont(scale, display); + + return (f ? f->m_fontStruct : (WXFontStructPtr) 0); +} + +WXFontList wxFont::GetFontList(double scale, WXDisplay* display) const +{ + wxXFont* f = GetInternalFont(scale, display); + + return (f ? f->m_fontList : (WXFontList) 0); +} + diff --git a/src/x11/gdiobj.cpp b/src/x11/gdiobj.cpp new file mode 100644 index 0000000000..63613b5727 --- /dev/null +++ b/src/x11/gdiobj.cpp @@ -0,0 +1,18 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: gdiobj.cpp +// Purpose: wxGDIObject class +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "gdiobj.h" +#endif + +#include "wx/gdiobj.h" + +IMPLEMENT_DYNAMIC_CLASS(wxGDIObject, wxObject) diff --git a/src/x11/glcanvas.cpp b/src/x11/glcanvas.cpp new file mode 100644 index 0000000000..776eb9746c --- /dev/null +++ b/src/x11/glcanvas.cpp @@ -0,0 +1,395 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: glcanvas.cpp +// Purpose: wxGLCanvas, for using OpenGL with wxWindows 2.0 for Motif. +// Uses the GLX extension. +// Author: Julian Smart and Wolfram Gloger +// Modified by: +// Created: 1995, 1999 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart, Wolfram Gloger +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "glcanvas.h" +#endif + +#include "wx/setup.h" + +#if wxUSE_GLCANVAS + +#include "wx/glcanvas.h" +#include "wx/utils.h" +#include "wx/app.h" + +#ifdef __VMS +# pragma message disable nosimpint +#endif +#include +#ifdef __VMS +# pragma message enable nosimpint +#endif +#include "wx/motif/private.h" + +#ifdef OLD_MESA +// workaround for bug in Mesa's glx.c +static int bitcount( unsigned long n ) +{ + int bits; + for (bits=0; n>0;) { + if(n & 1) bits++; + n = n >> 1; + } + return bits; +} +#endif + +/* + * GLContext implementation + */ + +IMPLEMENT_CLASS(wxGLContext,wxObject) + +wxGLContext::wxGLContext( bool WXUNUSED(isRGB), wxWindow *win, + const wxPalette& WXUNUSED(palette) ) +{ + m_window = win; + // m_widget = win->m_wxwindow; + + wxGLCanvas *gc = (wxGLCanvas*) win; + XVisualInfo *vi = (XVisualInfo *) gc->m_vi; + + wxCHECK_RET( vi, "invalid visual for OpenGl" ); + + m_glContext = glXCreateContext( (Display *)m_window->GetXDisplay(), vi, + None, GL_TRUE); + + wxCHECK_RET( m_glContext, "Couldn't create OpenGl context" ); +} + +wxGLContext::wxGLContext( + bool WXUNUSED(isRGB), wxWindow *win, + const wxPalette& WXUNUSED(palette), + const wxGLContext *other /* for sharing display lists */ +) +{ + m_window = win; + // m_widget = win->m_wxwindow; + + wxGLCanvas *gc = (wxGLCanvas*) win; + XVisualInfo *vi = (XVisualInfo *) gc->m_vi; + + wxCHECK_RET( vi, "invalid visual for OpenGl" ); + + if( other != 0 ) + m_glContext = glXCreateContext( (Display *)m_window->GetXDisplay(), vi, + other->m_glContext, GL_TRUE ); + else + m_glContext = glXCreateContext( (Display *)m_window->GetXDisplay(), vi, + None, GL_TRUE ); + + wxCHECK_RET( m_glContext, "Couldn't create OpenGl context" ); +} + +wxGLContext::~wxGLContext() +{ + if (!m_glContext) return; + + if (m_glContext == glXGetCurrentContext()) + { + glXMakeCurrent( (Display*) m_window->GetXDisplay(), None, NULL); + } + + glXDestroyContext( (Display*) m_window->GetXDisplay(), m_glContext ); +} + +void wxGLContext::SwapBuffers() +{ + if (m_glContext) + { + Display* display = (Display*) m_window->GetXDisplay(); + glXSwapBuffers(display, (Window) m_window->GetXWindow()); + } +} + +void wxGLContext::SetCurrent() +{ + if (m_glContext) + { + Display* display = (Display*) m_window->GetXDisplay(); + glXMakeCurrent(display, (Window) m_window->GetXWindow(), + m_glContext );; + } +} + +void wxGLContext::SetColour(const char *colour) +{ + wxColour *the_colour = wxTheColourDatabase->FindColour(colour); + if(the_colour) { + GLboolean b; + glGetBooleanv(GL_RGBA_MODE, &b); + if(b) { + glColor3ub(the_colour->Red(), + the_colour->Green(), + the_colour->Blue()); + } else { + GLint pix = (GLint)the_colour->m_pixel; + if(pix == -1) { + XColor exact_def; + exact_def.red = (unsigned short)the_colour->Red() << 8; + exact_def.green = (unsigned short)the_colour->Green() << 8; + exact_def.blue = (unsigned short)the_colour->Blue() << 8; + exact_def.flags = DoRed | DoGreen | DoBlue; + if(!XAllocColor((Display*) m_window->GetXDisplay(), + (Colormap) wxTheApp->GetMainColormap(m_window->GetXDisplay()), + &exact_def)) { + wxDebugMsg("wxGLCanvas: cannot allocate color\n"); + return; + } + pix = the_colour->m_pixel = exact_def.pixel; + } + glIndexi(pix); + } + } +} + +void wxGLContext::SetupPixelFormat() +{ +} + +void wxGLContext::SetupPalette( const wxPalette& WXUNUSED(palette) ) +{ +} + +wxPalette wxGLContext::CreateDefaultPalette() +{ + return wxNullPalette; +} + + + + +/* + * GLCanvas implementation + */ + +IMPLEMENT_CLASS(wxGLCanvas, wxScrolledWindow) + +BEGIN_EVENT_TABLE(wxGLCanvas, wxScrolledWindow) +// EVT_SIZE(wxGLCanvas::OnSize) +END_EVENT_TABLE() + + +wxGLCanvas::wxGLCanvas( wxWindow *parent, wxWindowID id, + const wxPoint& pos, const wxSize& size, + long style, const wxString& name, + int *attribList, + const wxPalette& palette ) +: wxScrolledWindow(parent, id, pos, size, style, name) +{ + Create( parent, NULL, NULL, id, pos, size, style, name, attribList, palette ); +} + +wxGLCanvas::wxGLCanvas( wxWindow *parent, + const wxGLContext *shared, + wxWindowID id, + const wxPoint& pos, const wxSize& size, + long style, const wxString& name, + int *attribList, + const wxPalette& palette ) +: wxScrolledWindow(parent, id, pos, size, style, name) +{ + Create( parent, shared, NULL, id, pos, size, style, name, attribList, palette ); +} + +wxGLCanvas::wxGLCanvas( wxWindow *parent, + const wxGLCanvas *shared, + wxWindowID id, + const wxPoint& pos, const wxSize& size, + long style, const wxString& name, + int *attribList, + const wxPalette& palette ) +: wxScrolledWindow(parent, id, pos, size, style, name) +{ + Create( parent, NULL, shared, id, pos, size, style, name, attribList, palette ); +} + + +/* +bool wxGLCanvas::Create(wxWindow *parent, + const wxGLContext *shared, const wxGLCanvas *shared_context_of, + wxWindowID id = -1, const wxPoint& pos, + const wxSize& size, long style, + const wxString& name, int *attribList, const wxPalette& palette): + wxScrolledWindow(parent, id, pos, size, style, name) +*/ + +bool wxGLCanvas::Create( wxWindow *parent, + const wxGLContext *shared, + const wxGLCanvas *shared_context_of, + wxWindowID id, + const wxPoint& pos, const wxSize& size, + long style, const wxString& name, + int *attribList, + const wxPalette& palette) +{ + XVisualInfo *vi, vi_templ; + XWindowAttributes xwa; + int val, n; + + m_sharedContext = (wxGLContext*)shared; // const_cast + m_sharedContextOf = (wxGLCanvas*)shared_context_of; // const_cast + m_glContext = (wxGLContext*) NULL; + + Display* display = (Display*) GetXDisplay(); + + // Check for the presence of the GLX extension + if(!glXQueryExtension(display, NULL, NULL)) { + wxDebugMsg("wxGLCanvas: GLX extension is missing\n"); + return false; + } + + if(attribList) { + int data[512], arg=0, p=0; + + while( (attribList[arg]!=0) && (p<512) ) + { + switch( attribList[arg++] ) + { + case WX_GL_RGBA: data[p++] = GLX_RGBA; break; + case WX_GL_BUFFER_SIZE: + data[p++]=GLX_BUFFER_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_LEVEL: + data[p++]=GLX_LEVEL; data[p++]=attribList[arg++]; break; + case WX_GL_DOUBLEBUFFER: data[p++] = GLX_DOUBLEBUFFER; break; + case WX_GL_STEREO: data[p++] = GLX_STEREO; break; + case WX_GL_AUX_BUFFERS: + data[p++]=GLX_AUX_BUFFERS; data[p++]=attribList[arg++]; break; + case WX_GL_MIN_RED: + data[p++]=GLX_RED_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_MIN_GREEN: + data[p++]=GLX_GREEN_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_MIN_BLUE: + data[p++]=GLX_BLUE_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_MIN_ALPHA: + data[p++]=GLX_ALPHA_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_DEPTH_SIZE: + data[p++]=GLX_DEPTH_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_STENCIL_SIZE: + data[p++]=GLX_STENCIL_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_MIN_ACCUM_RED: + data[p++]=GLX_ACCUM_RED_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_MIN_ACCUM_GREEN: + data[p++]=GLX_ACCUM_GREEN_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_MIN_ACCUM_BLUE: + data[p++]=GLX_ACCUM_BLUE_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_MIN_ACCUM_ALPHA: + data[p++]=GLX_ACCUM_ALPHA_SIZE; data[p++]=attribList[arg++]; break; + default: + break; + } + } + data[p] = 0; + + attribList = (int*) data; + // Get an appropriate visual + vi = glXChooseVisual(display, DefaultScreen(display), attribList); + if(!vi) return false; + + // Here we should make sure that vi is the same visual as the + // one used by the xwindow drawable in wxCanvas. However, + // there is currently no mechanism for this in wx_canvs.cc. + } else { + // By default, we use the visual of xwindow + // NI: is this really senseful ? opengl in e.g. color index mode ? + XGetWindowAttributes(display, (Window) GetXWindow(), &xwa); + vi_templ.visualid = XVisualIDFromVisual(xwa.visual); + vi = XGetVisualInfo(display, VisualIDMask, &vi_templ, &n); + if(!vi) return false; + glXGetConfig(display, vi, GLX_USE_GL, &val); + if(!val) return false; + // Basically, this is it. It should be possible to use vi + // in glXCreateContext() below. But this fails with Mesa. + // I notified the Mesa author about it; there may be a fix. +#ifdef OLD_MESA + // Construct an attribute list matching the visual + int a_list[32]; + n = 0; + if(vi->c_class==TrueColor || vi->c_class==DirectColor) { // RGBA visual + a_list[n++] = GLX_RGBA; + a_list[n++] = GLX_RED_SIZE; + a_list[n++] = bitcount(vi->red_mask); + a_list[n++] = GLX_GREEN_SIZE; + a_list[n++] = bitcount(vi->green_mask); + a_list[n++] = GLX_BLUE_SIZE; + a_list[n++] = bitcount(vi->blue_mask); + glXGetConfig(display, vi, GLX_ALPHA_SIZE, &val); + a_list[n++] = GLX_ALPHA_SIZE; + a_list[n++] = val; + } else { // Color index visual + glXGetConfig(display, vi, GLX_BUFFER_SIZE, &val); + a_list[n++] = GLX_BUFFER_SIZE; + a_list[n++] = val; + } + a_list[n] = None; + // XFree(vi); + vi = glXChooseVisual(display, DefaultScreen(display), a_list); + if(!vi) return false; +#endif /* OLD_MESA */ + } + + m_vi = vi; // safe for later use + + wxCHECK_MSG( m_vi, FALSE, "required visual couldn't be found" ); + + // Create the GLX context and make it current + + wxGLContext *share= m_sharedContext; + if (share==NULL && m_sharedContextOf) + share = m_sharedContextOf->GetContext(); + + m_glContext = new wxGLContext( TRUE, this, wxNullPalette, share ); + +#ifndef OLD_MESA + // XFree(vi); +#endif + SetCurrent(); + + return true; +} + +wxGLCanvas::~wxGLCanvas(void) +{ + XVisualInfo *vi = (XVisualInfo *) m_vi; + + if (vi) XFree( vi ); + if (m_glContext) delete m_glContext; + + // Display* display = (Display*) GetXDisplay(); + // if(glx_cx) glXDestroyContext(display, glx_cx); +} + +void wxGLCanvas::SwapBuffers() +{ + if( m_glContext ) m_glContext->SwapBuffers(); + + // Display* display = (Display*) GetXDisplay(); + // if(glx_cx) glXSwapBuffers(display, (Window) GetXWindow()); +} + +void wxGLCanvas::SetCurrent() +{ + if( m_glContext ) m_glContext->SetCurrent(); + + // Display* display = (Display*) GetXDisplay(); + // if(glx_cx) glXMakeCurrent(display, (Window) GetXWindow(), glx_cx); +} + +void wxGLCanvas::SetColour(const char *col) +{ + if( m_glContext ) m_glContext->SetColour(col); +} + +#endif + // wxUSE_GLCANVAS + diff --git a/src/x11/gsockx11.c b/src/x11/gsockx11.c new file mode 100644 index 0000000000..1297cecdee --- /dev/null +++ b/src/x11/gsockx11.c @@ -0,0 +1,126 @@ +/* ------------------------------------------------------------------------- + * Project: GSocket (Generic Socket) for WX + * Name: gsockmot.c + * Purpose: GSocket: Motif part + * CVSID: $Id$ + * ------------------------------------------------------------------------- */ + +#include "wx/setup.h" + +#if wxUSE_SOCKETS + +#include +#include +#include "wx/gsocket.h" +#include "wx/unix/gsockunx.h" + +extern XtAppContext wxGetAppContext(); + +static void _GSocket_Motif_Input(XtPointer data, int *fid, + XtInputId *id) +{ + GSocket *socket = (GSocket *)data; + + _GSocket_Detected_Read(socket); +} + +static void _GSocket_Motif_Output(XtPointer data, int *fid, + XtInputId *id) +{ + GSocket *socket = (GSocket *)data; + + _GSocket_Detected_Write(socket); +} + +int _GSocket_GUI_Init(GSocket *socket) +{ + int *m_id; + + socket->m_gui_dependent = (char *)malloc(sizeof(int)*2); + m_id = (int *)(socket->m_gui_dependent); + + m_id[0] = -1; + m_id[1] = -1; + + return TRUE; +} + +void _GSocket_GUI_Destroy(GSocket *socket) +{ + free(socket->m_gui_dependent); +} + +void _GSocket_Install_Callback(GSocket *socket, GSocketEvent event) +{ + int *m_id = (int *)(socket->m_gui_dependent); + int c; + + if (socket->m_fd == -1) + return; + + switch (event) + { + case GSOCK_LOST: /* fall-through */ + case GSOCK_INPUT: c = 0; break; + case GSOCK_OUTPUT: c = 1; break; + case GSOCK_CONNECTION: c = ((socket->m_server) ? 0 : 1); break; + default: return; + } + + if (m_id[c] != -1) + XtRemoveInput(m_id[c]); + + if (c == 0) + { + m_id[0] = XtAppAddInput(wxGetAppContext(), socket->m_fd, + (XtPointer *)XtInputReadMask, + (XtInputCallbackProc) _GSocket_Motif_Input, + (XtPointer) socket); + } + else + { + m_id[1] = XtAppAddInput(wxGetAppContext(), socket->m_fd, + (XtPointer *)XtInputWriteMask, + (XtInputCallbackProc) _GSocket_Motif_Output, + (XtPointer) socket); + } +} + +void _GSocket_Uninstall_Callback(GSocket *socket, GSocketEvent event) +{ + int *m_id = (int *)(socket->m_gui_dependent); + int c; + + switch (event) + { + case GSOCK_LOST: /* fall-through */ + case GSOCK_INPUT: c = 0; break; + case GSOCK_OUTPUT: c = 1; break; + case GSOCK_CONNECTION: c = ((socket->m_server) ? 0 : 1); break; + default: return; + } + + if (m_id[c] != -1) + XtRemoveInput(m_id[c]); + + m_id[c] = -1; +} + +void _GSocket_Enable_Events(GSocket *socket) +{ + _GSocket_Install_Callback(socket, GSOCK_INPUT); + _GSocket_Install_Callback(socket, GSOCK_OUTPUT); +} + +void _GSocket_Disable_Events(GSocket *socket) +{ + _GSocket_Uninstall_Callback(socket, GSOCK_INPUT); + _GSocket_Uninstall_Callback(socket, GSOCK_OUTPUT); +} + +#else /* !wxUSE_SOCKETS */ + +/* some compilers don't like having empty source files */ +static int wxDummyGsockVar = 0; + +#endif /* wxUSE_SOCKETS/!wxUSE_SOCKETS */ diff --git a/src/x11/icon.cpp b/src/x11/icon.cpp new file mode 100644 index 0000000000..96905576b3 --- /dev/null +++ b/src/x11/icon.cpp @@ -0,0 +1,82 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: icon.cpp +// Purpose: wxIcon class +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "icon.h" +#endif + +#include "wx/icon.h" +#include "wx/window.h" + +#ifdef __VMS__ +#pragma message disable nosimpint +#endif +#include +#include +#ifdef __VMS__ +#pragma message enable nosimpint +#endif + +#include "wx/motif/private.h" + +IMPLEMENT_DYNAMIC_CLASS(wxIcon, wxBitmap) + +/* +* Icons +*/ + +wxIcon::wxIcon() +{ +} + +// Create from XBM data +wxIcon::wxIcon(const char bits[], int width, int height) +{ + (void) Create((void*) bits, wxBITMAP_TYPE_XBM_DATA, width, height, 1); +} + +// Create from XPM data +wxIcon::wxIcon(char **data) +{ + (void) Create((void*) data, wxBITMAP_TYPE_XPM_DATA, 0, 0, 0); +} + +wxIcon::wxIcon(const char **data) +{ + (void) Create((void*) data, wxBITMAP_TYPE_XPM_DATA, 0, 0, 0); +} + +wxIcon::wxIcon(const wxString& icon_file, long flags, + int desiredWidth, int desiredHeight) + +{ + LoadFile(icon_file, flags, desiredWidth, desiredHeight); +} + +wxIcon::~wxIcon() +{ +} + +bool wxIcon::LoadFile(const wxString& filename, long type, + int desiredWidth, int desiredHeight) +{ + UnRef(); + + m_refData = new wxBitmapRefData; + + wxBitmapHandler *handler = FindHandler(type); + + if ( handler ) + return handler->LoadFile(this, filename, type, desiredWidth, desiredHeight); + else + return FALSE; +} + diff --git a/src/x11/joystick.cpp b/src/x11/joystick.cpp new file mode 100644 index 0000000000..b9b6fae1d0 --- /dev/null +++ b/src/x11/joystick.cpp @@ -0,0 +1,284 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: joystick.cpp +// Purpose: wxJoystick class +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "joystick.h" +#endif + +// Not implemented in wxMotif +#if 0 + +#include "wx/joystick.h" + +IMPLEMENT_DYNAMIC_CLASS(wxJoystick, wxObject) + +// Attributes +//////////////////////////////////////////////////////////////////////////// + +wxPoint wxJoystick::GetPosition() const +{ + // TODO + return wxPoint(0, 0); +} + +int wxJoystick::GetZPosition() const +{ + // TODO + return 0; +} + +int wxJoystick::GetButtonState() const +{ + // TODO + return 0; +} + +int wxJoystick::GetPOVPosition() const +{ + // TODO + return 0; +} + +int wxJoystick::GetPOVCTSPosition() const +{ + // TODO + return 0; +} + +int wxJoystick::GetRudderPosition() const +{ + // TODO + return 0; +} + +int wxJoystick::GetUPosition() const +{ + // TODO + return 0; +} + +int wxJoystick::GetVPosition() const +{ + // TODO + return 0; +} + +int wxJoystick::GetMovementThreshold() const +{ + // TODO + return 0; +} + +void wxJoystick::SetMovementThreshold(int threshold) +{ + // TODO +} + +// Capabilities +//////////////////////////////////////////////////////////////////////////// + +bool wxJoystick::IsOk() const +{ + // TODO + return FALSE; +} + +int wxJoystick::GetNumberJoysticks() const +{ + // TODO + return 0; +} + +int wxJoystick::GetManufacturerId() const +{ + // TODO + return 0; +} + +int wxJoystick::GetProductId() const +{ + // TODO + return 0; +} + +wxString wxJoystick::GetProductName() const +{ + // TODO + return wxString(""); +} + +int wxJoystick::GetXMin() const +{ + // TODO + return 0; +} + +int wxJoystick::GetYMin() const +{ + // TODO + return 0; +} + +int wxJoystick::GetZMin() const +{ + // TODO + return 0; +} + +int wxJoystick::GetXMax() const +{ + // TODO + return 0; +} + +int wxJoystick::GetYMax() const +{ + // TODO + return 0; +} + +int wxJoystick::GetZMax() const +{ + // TODO + return 0; +} + +int wxJoystick::GetNumberButtons() const +{ + // TODO + return 0; +} + +int wxJoystick::GetNumberAxes() const +{ + // TODO + return 0; +} + +int wxJoystick::GetMaxButtons() const +{ + // TODO + return 0; +} + +int wxJoystick::GetMaxAxes() const +{ + // TODO + return 0; +} + +int wxJoystick::GetPollingMin() const +{ + // TODO + return 0; +} + +int wxJoystick::GetPollingMax() const +{ + // TODO + return 0; +} + +int wxJoystick::GetRudderMin() const +{ + // TODO + return 0; +} + +int wxJoystick::GetRudderMax() const +{ + // TODO + return 0; +} + +int wxJoystick::GetUMin() const +{ + // TODO + return 0; +} + +int wxJoystick::GetUMax() const +{ + // TODO + return 0; +} + +int wxJoystick::GetVMin() const +{ + // TODO + return 0; +} + +int wxJoystick::GetVMax() const +{ + // TODO + return 0; +} + +bool wxJoystick::HasRudder() const +{ + // TODO + return FALSE; +} + +bool wxJoystick::HasZ() const +{ + // TODO + return FALSE; +} + +bool wxJoystick::HasU() const +{ + // TODO + return FALSE; +} + +bool wxJoystick::HasV() const +{ + // TODO + return FALSE; +} + +bool wxJoystick::HasPOV() const +{ + // TODO + return FALSE; +} + +bool wxJoystick::HasPOV4Dir() const +{ + // TODO + return FALSE; +} + +bool wxJoystick::HasPOVCTS() const +{ + // TODO + return FALSE; +} + +// Operations +//////////////////////////////////////////////////////////////////////////// + +bool wxJoystick::SetCapture(wxWindow* win, int pollingFreq) +{ + // TODO + return FALSE; +} + +bool wxJoystick::ReleaseCapture() +{ + // TODO + return FALSE; +} + +#endif + // 0 diff --git a/src/x11/main.cpp b/src/x11/main.cpp new file mode 100644 index 0000000000..e2eea40e29 --- /dev/null +++ b/src/x11/main.cpp @@ -0,0 +1,18 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: main.cpp +// Purpose: Entry point +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#include "wx/app.h" + +int main(int argc, char* argv[]) +{ + return wxEntry(argc, argv); +} + diff --git a/src/x11/makefile.unx b/src/x11/makefile.unx new file mode 100644 index 0000000000..60d21f875b --- /dev/null +++ b/src/x11/makefile.unx @@ -0,0 +1,356 @@ +############################################################################## +# Microwindows template Makefile +# Copyright (c) 2000 Martin Jolicoeur, Greg Haerr +############################################################################## + +TOP=$(MICROWINDOWS) +ifeq "$(MICROWINDOWS)" "" +TOP=/home/julians/local/microwindows/microwindows-0.89pre8/src +endif + +CONFIG = $(TOP)/config +WXDIR = ../.. +OBJSUFF = o +SRCSUFF = cpp +WXLIB=$(WXDIR)/lib/libwx.a +AROPTIONS = ruv +RANLIB = ranlib +RM = rm -f + +GENDIR = $(WXDIR)/src/generic +COMMDIR = $(WXDIR)/src/common +HTMLDIR = $(WXDIR)/src/html +ZLIBDIR = $(WXDIR)/src/zlib +PNGDIR = $(WXDIR)/src/png +JPEGDIR = $(WXDIR)/src/jpeg +TIFFDIR = $(WXDIR)/src/tiff +OLEDIR = $(WXDIR)/src/msw/ole +MICROWINDIR = $(WXDIR)/src/msw +UNIXDIR = $(WXDIR)/src/unix +UNIVDIR = $(WXDIR)/src/univ + +ZLIBLIB = $(WXDIR)/lib/libzlib.a +PNGLIB = $(WXDIR)/lib/libpng.a +JPEGLIB = $(WXDIR)/lib/libjpeg.a +TIFFLIB = $(WXDIR)/lib/libtiff.a + +GENERICOBJS = \ + $(GENDIR)/accel.$(OBJSUFF) \ + $(GENDIR)/busyinfo.$(OBJSUFF) \ + $(GENDIR)/calctrl.$(OBJSUFF) \ + $(GENDIR)/choicdgg.$(OBJSUFF) \ + $(GENDIR)/colrdlgg.$(OBJSUFF) \ + $(GENDIR)/dirctrlg.$(OBJSUFF) \ + $(GENDIR)/dragimgg.$(OBJSUFF) \ + $(GENDIR)/fontdlgg.$(OBJSUFF) \ + $(GENDIR)/grid.$(OBJSUFF) \ + $(GENDIR)/gridctrl.$(OBJSUFF) \ + $(GENDIR)/gridsel.$(OBJSUFF) \ + $(GENDIR)/imaglist.$(OBJSUFF) \ + $(GENDIR)/laywin.$(OBJSUFF) \ + $(GENDIR)/listctrl.$(OBJSUFF) \ + $(GENDIR)/logg.$(OBJSUFF) \ + $(GENDIR)/msgdlgg.$(OBJSUFF) \ + $(GENDIR)/numdlgg.$(OBJSUFF) \ + $(GENDIR)/panelg.$(OBJSUFF) \ + $(GENDIR)/progdlgg.$(OBJSUFF) \ + $(GENDIR)/sashwin.$(OBJSUFF) \ + $(GENDIR)/scrlwing.$(OBJSUFF) \ + $(GENDIR)/spinctlg.$(OBJSUFF) \ + $(GENDIR)/splash.$(OBJSUFF) \ + $(GENDIR)/splitter.$(OBJSUFF) \ + $(GENDIR)/tabg.$(OBJSUFF) \ + $(GENDIR)/tbarsmpl.$(OBJSUFF) \ + $(GENDIR)/textdlgg.$(OBJSUFF) \ + $(GENDIR)/tipdlg.$(OBJSUFF) \ + $(GENDIR)/tipwin.$(OBJSUFF) \ + $(GENDIR)/treectlg.$(OBJSUFF) \ + $(GENDIR)/treelay.$(OBJSUFF) \ + $(GENDIR)/wizard.$(OBJSUFF) + +COMMONOBJS = \ + $(COMMDIR)/appcmn.$(OBJSUFF) \ + $(COMMDIR)/choiccmn.$(OBJSUFF) \ + $(COMMDIR)/clntdata.$(OBJSUFF) \ + $(COMMDIR)/clipcmn.$(OBJSUFF) \ + $(COMMDIR)/cmdline.$(OBJSUFF) \ + $(COMMDIR)/cmdproc.$(OBJSUFF) \ + $(COMMDIR)/cmndata.$(OBJSUFF) \ + $(COMMDIR)/config.$(OBJSUFF) \ + $(COMMDIR)/containr.$(OBJSUFF) \ + $(COMMDIR)/cshelp.$(OBJSUFF) \ + $(COMMDIR)/ctrlcmn.$(OBJSUFF) \ + $(COMMDIR)/ctrlsub.$(OBJSUFF) \ + $(COMMDIR)/datetime.$(OBJSUFF) \ + $(COMMDIR)/datstrm.$(OBJSUFF) \ + $(COMMDIR)/dcbase.$(OBJSUFF) \ + $(COMMDIR)/dircmn.$(OBJSUFF) \ + $(COMMDIR)/dlgcmn.$(OBJSUFF) \ + $(COMMDIR)/dobjcmn.$(OBJSUFF) \ + $(COMMDIR)/docview.$(OBJSUFF) \ + $(COMMDIR)/dynarray.$(OBJSUFF) \ + $(COMMDIR)/dynlib.$(OBJSUFF) \ + $(COMMDIR)/effects.$(OBJSUFF) \ + $(COMMDIR)/encconv.$(OBJSUFF) \ + $(COMMDIR)/event.$(OBJSUFF) \ + $(COMMDIR)/extended.$(OBJSUFF) \ + $(COMMDIR)/ffile.$(OBJSUFF) \ + $(COMMDIR)/file.$(OBJSUFF) \ + $(COMMDIR)/fileconf.$(OBJSUFF) \ + $(COMMDIR)/filefn.$(OBJSUFF) \ + $(COMMDIR)/filename.$(OBJSUFF) \ + $(COMMDIR)/filesys.$(OBJSUFF) \ + $(COMMDIR)/fontcmn.$(OBJSUFF) \ + $(COMMDIR)/fontmap.$(OBJSUFF) \ + $(COMMDIR)/framecmn.$(OBJSUFF) \ + $(COMMDIR)/gaugecmn.$(OBJSUFF) \ + $(COMMDIR)/gdicmn.$(OBJSUFF) \ + $(COMMDIR)/geometry.$(OBJSUFF) \ + $(COMMDIR)/gifdecod.$(OBJSUFF) \ + $(COMMDIR)/hash.$(OBJSUFF) \ + $(COMMDIR)/helpbase.$(OBJSUFF) \ + $(COMMDIR)/imagall.$(OBJSUFF) \ + $(COMMDIR)/imagbmp.$(OBJSUFF) \ + $(COMMDIR)/image.$(OBJSUFF) \ + $(COMMDIR)/imaggif.$(OBJSUFF) \ + $(COMMDIR)/imagjpeg.$(OBJSUFF) \ + $(COMMDIR)/imagpcx.$(OBJSUFF) \ + $(COMMDIR)/imagpng.$(OBJSUFF) \ + $(COMMDIR)/imagpnm.$(OBJSUFF) \ + $(COMMDIR)/imagtiff.$(OBJSUFF) \ + $(COMMDIR)/imagxpm.$(OBJSUFF) \ + $(COMMDIR)/intl.$(OBJSUFF) \ + $(COMMDIR)/ipcbase.$(OBJSUFF) \ + $(COMMDIR)/layout.$(OBJSUFF) \ + $(COMMDIR)/lboxcmn.$(OBJSUFF) \ + $(COMMDIR)/list.$(OBJSUFF) \ + $(COMMDIR)/log.$(OBJSUFF) \ + $(COMMDIR)/longlong.$(OBJSUFF) \ + $(COMMDIR)/matrix.$(OBJSUFF) \ + $(COMMDIR)/memory.$(OBJSUFF) \ + $(COMMDIR)/menucmn.$(OBJSUFF) \ + $(COMMDIR)/mimecmn.$(OBJSUFF) \ + $(COMMDIR)/module.$(OBJSUFF) \ + $(COMMDIR)/mstream.$(OBJSUFF) \ + $(COMMDIR)/nbkbase.$(OBJSUFF) \ + $(COMMDIR)/object.$(OBJSUFF) \ + $(COMMDIR)/paper.$(OBJSUFF) \ + $(COMMDIR)/popupcmn.$(OBJSUFF) \ + $(COMMDIR)/prntbase.$(OBJSUFF) \ + $(COMMDIR)/process.$(OBJSUFF) \ + $(COMMDIR)/quantize.$(OBJSUFF) \ + $(COMMDIR)/radiocmn.$(OBJSUFF) \ + $(COMMDIR)/resource.$(OBJSUFF) \ + $(COMMDIR)/sizer.$(OBJSUFF) \ + $(COMMDIR)/statbar.$(OBJSUFF) \ + $(COMMDIR)/strconv.$(OBJSUFF) \ + $(COMMDIR)/stream.$(OBJSUFF) \ + $(COMMDIR)/string.$(OBJSUFF) \ + $(COMMDIR)/sysopt.$(OBJSUFF) \ + $(COMMDIR)/tbarbase.$(OBJSUFF) \ + $(COMMDIR)/textbuf.$(OBJSUFF) \ + $(COMMDIR)/textcmn.$(OBJSUFF) \ + $(COMMDIR)/textfile.$(OBJSUFF) \ + $(COMMDIR)/timercmn.$(OBJSUFF) \ + $(COMMDIR)/tokenzr.$(OBJSUFF) \ + $(COMMDIR)/toplvcmn.$(OBJSUFF) \ + $(COMMDIR)/treebase.$(OBJSUFF) \ + $(COMMDIR)/txtstrm.$(OBJSUFF) \ + $(COMMDIR)/utilscmn.$(OBJSUFF) \ + $(UNIXDIR)/utilsunx.$(OBJSUFF) \ + $(COMMDIR)/valgen.$(OBJSUFF) \ + $(COMMDIR)/validate.$(OBJSUFF) \ + $(COMMDIR)/valtext.$(OBJSUFF) \ + $(COMMDIR)/variant.$(OBJSUFF) \ + $(COMMDIR)/wfstream.$(OBJSUFF) \ + $(COMMDIR)/wincmn.$(OBJSUFF) \ + $(COMMDIR)/wxchar.$(OBJSUFF) \ + $(COMMDIR)/xpmdecod.$(OBJSUFF) + +HTMLOBJS = \ + $(HTMLDIR)/helpctrl.$(OBJSUFF) \ + $(HTMLDIR)/helpdata.$(OBJSUFF) \ + $(HTMLDIR)/helpfrm.$(OBJSUFF) \ + $(HTMLDIR)/htmlcell.$(OBJSUFF) \ + $(HTMLDIR)/htmlfilt.$(OBJSUFF) \ + $(HTMLDIR)/htmlpars.$(OBJSUFF) \ + $(HTMLDIR)/htmltag.$(OBJSUFF) \ + $(HTMLDIR)/htmlwin.$(OBJSUFF) \ + $(HTMLDIR)/htmprint.$(OBJSUFF) \ + $(HTMLDIR)/m_dflist.$(OBJSUFF) \ + $(HTMLDIR)/m_fonts.$(OBJSUFF) \ + $(HTMLDIR)/m_hline.$(OBJSUFF) \ + $(HTMLDIR)/m_image.$(OBJSUFF) \ + $(HTMLDIR)/m_layout.$(OBJSUFF) \ + $(HTMLDIR)/m_links.$(OBJSUFF) \ + $(HTMLDIR)/m_list.$(OBJSUFF) \ + $(HTMLDIR)/m_meta.$(OBJSUFF) \ + $(HTMLDIR)/m_pre.$(OBJSUFF) \ + $(HTMLDIR)/m_tables.$(OBJSUFF) \ + $(HTMLDIR)/winpars.$(OBJSUFF) + +MSWOBJS = \ + $(MICROWINDIR)/app.$(OBJSUFF) \ + $(MICROWINDIR)/bitmap.$(OBJSUFF) \ + $(MICROWINDIR)/brush.$(OBJSUFF) \ + $(MICROWINDIR)/caret.$(OBJSUFF) \ + $(MICROWINDIR)/clipbrd.$(OBJSUFF) \ + $(MICROWINDIR)/colour.$(OBJSUFF) \ + $(MICROWINDIR)/cursor.$(OBJSUFF) \ + $(MICROWINDIR)/data.$(OBJSUFF) \ + $(MICROWINDIR)/dc.$(OBJSUFF) \ + $(MICROWINDIR)/dcclient.$(OBJSUFF) \ + $(MICROWINDIR)/dcmemory.$(OBJSUFF) \ + $(MICROWINDIR)/dcprint.$(OBJSUFF) \ + $(MICROWINDIR)/dcscreen.$(OBJSUFF) \ + $(MICROWINDIR)/dde.$(OBJSUFF) \ + $(MICROWINDIR)/dialog.$(OBJSUFF) \ + $(MICROWINDIR)/dialup.$(OBJSUFF) \ + $(UNIXDIR)/dir.$(OBJSUFF) \ + $(MICROWINDIR)/evtloop.$(OBJSUFF) \ + $(MICROWINDIR)/font.$(OBJSUFF) \ + $(MICROWINDIR)/fontenum.$(OBJSUFF) \ + $(MICROWINDIR)/fontutil.$(OBJSUFF) \ + $(MICROWINDIR)/gdiimage.$(OBJSUFF) \ + $(MICROWINDIR)/gdiobj.$(OBJSUFF) \ + $(MICROWINDIR)/icon.$(OBJSUFF) \ + $(MICROWINDIR)/main.$(OBJSUFF) \ + $(MICROWINDIR)/microwin.$(OBJSUFF) \ + $(MICROWINDIR)/palette.$(OBJSUFF) \ + $(MICROWINDIR)/pen.$(OBJSUFF) \ + $(MICROWINDIR)/region.$(OBJSUFF) \ + $(MICROWINDIR)/settings.$(OBJSUFF) \ + $(MICROWINDIR)/snglinst.$(OBJSUFF) \ + $(MICROWINDIR)/thread.$(OBJSUFF) \ + $(MICROWINDIR)/timer.$(OBJSUFF) \ + $(MICROWINDIR)/toplevel.$(OBJSUFF) \ + $(MICROWINDIR)/utils.$(OBJSUFF) \ + $(MICROWINDIR)/window.$(OBJSUFF) \ + $(OLEDIR)/dataobj.$(OBJSUFF) + +UNIVOBJS_TODO = $(UNIVDIR)/choice.$(OBJSUFF) \ + $(UNIVDIR)/colordlg.$(OBJSUFF) \ + + +UNIVOBJS = \ + $(UNIVDIR)/bmpbuttn.$(OBJSUFF) \ + $(UNIVDIR)/button.$(OBJSUFF) \ + $(UNIVDIR)/checkbox.$(OBJSUFF) \ + $(UNIVDIR)/checklst.$(OBJSUFF) \ + $(UNIVDIR)/colschem.$(OBJSUFF) \ + $(UNIVDIR)/combobox.$(OBJSUFF) \ + $(UNIVDIR)/control.$(OBJSUFF) \ + $(UNIVDIR)/framuniv.$(OBJSUFF) \ + $(UNIVDIR)/gauge.$(OBJSUFF) \ + $(UNIVDIR)/inphand.$(OBJSUFF) \ + $(UNIVDIR)/inpcons.$(OBJSUFF) \ + $(UNIVDIR)/listbox.$(OBJSUFF) \ + $(UNIVDIR)/menu.$(OBJSUFF) \ + $(UNIVDIR)/notebook.$(OBJSUFF) \ + $(UNIVDIR)/radiobox.$(OBJSUFF) \ + $(UNIVDIR)/radiobut.$(OBJSUFF) \ + $(UNIVDIR)/renderer.$(OBJSUFF) \ + $(UNIVDIR)/scrarrow.$(OBJSUFF) \ + $(UNIVDIR)/scrolbar.$(OBJSUFF) \ + $(UNIVDIR)/scrthumb.$(OBJSUFF) \ + $(UNIVDIR)/slider.$(OBJSUFF) \ + $(UNIVDIR)/spinbutt.$(OBJSUFF) \ + $(UNIVDIR)/statbmp.$(OBJSUFF) \ + $(UNIVDIR)/statbox.$(OBJSUFF) \ + $(UNIVDIR)/statline.$(OBJSUFF) \ + $(UNIVDIR)/stattext.$(OBJSUFF) \ + $(UNIVDIR)/statusbr.$(OBJSUFF) \ + $(UNIVDIR)/textctrl.$(OBJSUFF) \ + $(UNIVDIR)/theme.$(OBJSUFF) \ + $(UNIVDIR)/topluniv.$(OBJSUFF) \ + $(UNIVDIR)/winuniv.$(OBJSUFF) \ + $(UNIVDIR)/themes/gtk.$(OBJSUFF) \ + $(UNIVDIR)/themes/win32.$(OBJSUFF) + +include $(CONFIG) + +######################## Additional Flags section ############################ + +# Directories list for header files +INCLUDEDIRS += -I$(WXDIR)/include +# Defines for preprocessor +DEFINES += -DMWIN -D__WXMSW__ -D__WXMICROWIN__ -D__WXUNIVERSAL__ -D__WIN32__ -D__WIN95__ -DHAVE_BOOL -DMICROWIN_TODO=1 -D__UNIX__ -DHAVE_NANOSLEEP -DMICROWIN_NOCONTROLS -D__WXDEBUG__ -DwxSIZE_T_IS_UINT -DWXWIN_OS_DESCRIPTION="\"MicroWindows\"" + +# Compilation flags for C files OTHER than include directories +CFLAGS += +# Preprocessor flags OTHER than defines +CPPFLAGS += +# Linking flags +LDFLAGS += + +############################# targets section ################################ + +# If you want to create a library with the objects files, define the name here +LIBNAME = + +# If we put it below OBJS=, Makefile.rules includes .depend +# and it continually looks for .c files to satisfy .o.cpp +# dependency. What's going on there? +include $(TOP)/Makefile.rules + +# List of objects to compile +OBJS = $(COMMONOBJS) $(MSWOBJS) $(GENERICOBJS) $(UNIVOBJS) + +all: $(WXLIB) + +######################### Makefile.rules section ############################# + + + +######################## Tools targets section ############################### + +#ntest: $(OBJS) $(NANOXCLIENTLIBS) $(TOP)/config +# $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -o $@ $(NANOXCLIENTLIBS) + +$(WXLIB): $(OBJS) + ar $(AROPTIONS) $@ $(OBJS) + $(RANLIB) $@ + +#.SUFFIXES: .cpp .cxx .c + +#.c.o: +# $(CC) -c $(CFLAGS) $(CFLAGS) -o $@ $*.c + +.cxx.o: + $(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $*.cxx + +.cpp.o: + $(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $*.cpp + +#$(COMMDIR)/appcmn.o: $(COMMDIR)/appcmn.cpp +# $(CC) -c $(CPPFLAGS) -o $@ $*.cpp + +#appcmn.o: $(COMMDIR)/appcmn.cpp +# $(CC) $(CPPFLAGS) -c -o $@ $< + +cleanwx: + -$(RM) *.o + -$(RM) *.bak + -$(RM) core + -$(RM) ole/*.o + -$(RM) ../common/y_tab.c + -$(RM) ../common/lex_yy.c + -$(RM) ../common/*.o + -$(RM) ../common/*.bak + -$(RM) ../generic/*.o + -$(RM) ../generic/*.bak + -$(RM) ../univ/*.o + -$(RM) ../univ/*.bak + -$(RM) ../univ/themes/*.o + -$(RM) ../univ/themes/*.bak + -$(RM) ../unix/*.o + -$(RM) ../unix/*.bak + -$(RM) ../html/*.o + -$(RM) ../zlib/*.o + -$(RM) ../zlib/*.bak + -$(RM) ../png/*.o + -$(RM) ../png/*.bak + -$(RM) ../jpeg/*.o + -$(RM) ../jpeg/*.bak + -$(RM) ../tiff/*.o + -$(RM) ../tiff/*.bak diff --git a/src/x11/menu.cpp b/src/x11/menu.cpp new file mode 100644 index 0000000000..84410f4f5f --- /dev/null +++ b/src/x11/menu.cpp @@ -0,0 +1,767 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: menu.cpp +// Purpose: wxMenu, wxMenuBar, wxMenuItem +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + + +// ============================================================================ +// declarations +// ============================================================================ + +#ifdef __GNUG__ + #pragma implementation "menu.h" +#endif + +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- + +#include "wx/defs.h" + +#include "wx/menu.h" +#include "wx/menuitem.h" +#include "wx/log.h" +#include "wx/utils.h" +#include "wx/app.h" +#include "wx/frame.h" +#include "wx/settings.h" + +#ifdef __VMS__ +#pragma message disable nosimpint +#define XtDisplay XTDISPLAY +#define XtWindow XTWINDOW +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef __VMS__ +#pragma message enable nosimpint +#endif + +#include "wx/motif/private.h" + +// other standard headers +#include + +IMPLEMENT_DYNAMIC_CLASS(wxMenu, wxEvtHandler) +IMPLEMENT_DYNAMIC_CLASS(wxMenuBar, wxEvtHandler) + +// ============================================================================ +// implementation +// ============================================================================ + +// ---------------------------------------------------------------------------- +// Menus +// ---------------------------------------------------------------------------- + +// Construct a menu with optional title (then use append) +void wxMenu::Init() +{ + // Motif-specific members + m_numColumns = 1; + m_menuWidget = (WXWidget) NULL; + m_popupShell = (WXWidget) NULL; + m_buttonWidget = (WXWidget) NULL; + m_menuId = 0; + m_topLevelMenu = (wxMenu*) NULL; + m_ownedByMenuBar = FALSE; + + if ( !!m_title ) + { + Append(wxID_SEPARATOR, m_title) ; + AppendSeparator() ; + } + + m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_MENU); + m_foregroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_MENUTEXT); + m_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); +} + +// The wxWindow destructor will take care of deleting the submenus. +wxMenu::~wxMenu() +{ + if (m_menuWidget) + { + if (m_menuParent) + DestroyMenu(TRUE); + else + DestroyMenu(FALSE); + } + + // Not sure if this is right + if (m_menuParent && m_menuBar) + { + m_menuParent = NULL; + // m_menuBar = NULL; + } +} + +void wxMenu::Break() +{ + m_numColumns++; +} + +// function appends a new item or submenu to the menu +bool wxMenu::DoAppend(wxMenuItem *pItem) +{ + if (m_menuWidget) + { + // this is a dynamic Append + pItem->CreateItem(m_menuWidget, m_menuBar, m_topLevelMenu); + } + + if ( pItem->IsSubMenu() ) + { + pItem->GetSubMenu()->m_topLevelMenu = m_topLevelMenu; + } + + return wxMenuBase::DoAppend(pItem); +} + +wxMenuItem *wxMenu::DoRemove(wxMenuItem *item) +{ + item->DestroyItem(TRUE); + + return wxMenuBase::DoRemove(item); +} + +bool wxMenu::DoInsert(size_t pos, wxMenuItem *item) +{ + if ( !wxMenuBase::DoInsert(pos, item) ) + return FALSE; + + wxFAIL_MSG(wxT("not implemented")); + + return FALSE; +} + +void wxMenu::SetTitle(const wxString& label) +{ + m_title = label; + + wxMenuItemList::Node *node = GetMenuItems().GetFirst(); + if ( !node ) + return; + + wxMenuItem *item = node->GetData (); + Widget widget = (Widget) item->GetButtonWidget(); + if ( !widget ) + return; + + wxXmString title_str(label); + XtVaSetValues(widget, + XmNlabelString, title_str(), + NULL); +} + +bool wxMenu::ProcessCommand(wxCommandEvent & event) +{ + bool processed = FALSE; + +#if wxUSE_MENU_CALLBACK + // Try a callback + if (m_callback) + { + (void) (*(m_callback)) (*this, event); + processed = TRUE; + } +#endif // wxUSE_MENU_CALLBACK + + // Try the menu's event handler + if ( !processed && GetEventHandler()) + { + processed = GetEventHandler()->ProcessEvent(event); + } + // Try the window the menu was popped up from (and up + // through the hierarchy) + if ( !processed && GetInvokingWindow()) + processed = GetInvokingWindow()->ProcessEvent(event); + + return processed; +} + +// ---------------------------------------------------------------------------- +// Menu Bar +// ---------------------------------------------------------------------------- + +void wxMenuBar::Init() +{ + m_eventHandler = this; + m_menuBarFrame = NULL; + m_mainWidget = (WXWidget) NULL; + m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_MENU); + m_foregroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_MENUTEXT); + m_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); +} + +wxMenuBar::wxMenuBar(int n, wxMenu *menus[], const wxString titles[]) +{ + Init(); + + for ( int i = 0; i < n; i++ ) + { + m_menus.Append(menus[i]); + m_titles.Add(titles[i]); + } +} + +wxMenuBar::~wxMenuBar() +{ + // nothing to do: wxMenuBarBase will delete the menus +} + +void wxMenuBar::EnableTop(size_t WXUNUSED(pos), bool WXUNUSED(flag)) +{ + // wxFAIL_MSG("TODO"); +// wxLogWarning("wxMenuBar::EnableTop not yet implemented."); +} + +void wxMenuBar::SetLabelTop(size_t pos, const wxString& label) +{ + wxMenu *menu = GetMenu(pos); + if ( !menu ) + return; + + Widget w = (Widget)menu->GetButtonWidget(); + if (w) + { + wxXmString label_str(label); + + XtVaSetValues(w, + XmNlabelString, label_str(), + NULL); + } +} + +wxString wxMenuBar::GetLabelTop(size_t pos) const +{ + wxString str; + + wxMenu *menu = GetMenu(pos); + if ( menu ) + { + Widget w = (Widget)menu->GetButtonWidget(); + if (w) + { + XmString text; + XtVaGetValues(w, + XmNlabelString, &text, + NULL); + + char *s; + if ( XmStringGetLtoR(text, XmSTRING_DEFAULT_CHARSET, &s) ) + { + str = s; + + XtFree(s); + } + } + } + + return str; +} + +bool wxMenuBar::Append(wxMenu * menu, const wxString& title) +{ + wxCHECK_MSG( menu, FALSE, wxT("invalid menu") ); + wxCHECK_MSG( !menu->GetParent() && !menu->GetButtonWidget(), FALSE, + wxT("menu already appended") ); + + if ( m_menuBarFrame ) + { + WXWidget w = menu->CreateMenu(this, GetMainWidget(), menu, title, TRUE); + wxCHECK_MSG( w, FALSE, wxT("failed to create menu") ); + menu->SetButtonWidget(w); + } + + //menu->SetMenuBar(this); + + m_titles.Add(title); + + return wxMenuBarBase::Append(menu, title); +} + +bool wxMenuBar::Insert(size_t pos, wxMenu *menu, const wxString& title) +{ + if ( !wxMenuBarBase::Insert(pos, menu, title) ) + return FALSE; + + wxFAIL_MSG(wxT("TODO")); + + return FALSE; +} + +wxMenu *wxMenuBar::Replace(size_t pos, wxMenu *menu, const wxString& title) +{ + if ( !wxMenuBarBase::Replace(pos, menu, title) ) + return FALSE; + + wxFAIL_MSG(wxT("TODO")); + + return NULL; +} + +wxMenu *wxMenuBar::Remove(size_t pos) +{ + wxMenu *menu = wxMenuBarBase::Remove(pos); + if ( !menu ) + return NULL; + + if ( m_menuBarFrame ) + menu->DestroyMenu(TRUE); + + menu->SetMenuBar(NULL); + + m_titles.Remove(pos); + + return menu; +} + +// Find the menu menuString, item itemString, and return the item id. +// Returns -1 if none found. +int wxMenuBar::FindMenuItem (const wxString& menuString, const wxString& itemString) const +{ + char buf1[200]; + char buf2[200]; + wxStripMenuCodes ((char *)(const char *)menuString, buf1); + + size_t menuCount = GetMenuCount(); + for (size_t i = 0; i < menuCount; i++) + { + wxStripMenuCodes ((char *)(const char *)m_titles[i], buf2); + if (strcmp (buf1, buf2) == 0) + return m_menus[i]->FindItem (itemString); + } + return -1; +} + +wxMenuItem *wxMenuBar::FindItem(int id, wxMenu ** itemMenu) const +{ + if (itemMenu) + *itemMenu = NULL; + + wxMenuItem *item = NULL; + size_t menuCount = GetMenuCount(); + for (size_t i = 0; i < menuCount; i++) + if ((item = m_menus[i]->FindItem(id, itemMenu))) + return item; + return NULL; +} + +// Create menubar +bool wxMenuBar::CreateMenuBar(wxFrame* parent) +{ + if (m_mainWidget) + { + XtVaSetValues((Widget) parent->GetMainWidget(), XmNmenuBar, (Widget) m_mainWidget, NULL); + /* + if (!XtIsManaged((Widget) m_mainWidget)) + XtManageChild((Widget) m_mainWidget); + */ + XtMapWidget((Widget) m_mainWidget); + return TRUE; + } + + Widget menuBarW = XmCreateMenuBar ((Widget) parent->GetMainWidget(), "MenuBar", NULL, 0); + m_mainWidget = (WXWidget) menuBarW; + + size_t menuCount = GetMenuCount(); + for (size_t i = 0; i < menuCount; i++) + { + wxMenu *menu = GetMenu(i); + wxString title(m_titles[i]); + menu->SetButtonWidget(menu->CreateMenu (this, menuBarW, menu, title, TRUE)); + + if (strcmp (wxStripMenuCodes(title), "Help") == 0) + XtVaSetValues ((Widget) menuBarW, XmNmenuHelpWidget, (Widget) menu->GetButtonWidget(), NULL); + + // tear off menu support +#if (XmVersion >= 1002) + if ( menu->IsTearOff() ) + { + XtVaSetValues(GetWidget(menu), + XmNtearOffModel, XmTEAR_OFF_ENABLED, + NULL); + Widget tearOff = XmGetTearOffControl(GetWidget(menu)); + wxDoChangeForegroundColour((Widget) tearOff, m_foregroundColour); + wxDoChangeBackgroundColour((Widget) tearOff, m_backgroundColour, TRUE); +#endif + } + } + + SetBackgroundColour(m_backgroundColour); + SetForegroundColour(m_foregroundColour); + SetFont(m_font); + + XtVaSetValues((Widget) parent->GetMainWidget(), XmNmenuBar, (Widget) m_mainWidget, NULL); + XtRealizeWidget ((Widget) menuBarW); + XtManageChild ((Widget) menuBarW); + SetMenuBarFrame(parent); + + return TRUE; +} + +// Destroy menubar, but keep data structures intact so we can recreate it. +bool wxMenuBar::DestroyMenuBar() +{ + if (!m_mainWidget) + { + SetMenuBarFrame((wxFrame*) NULL); + return FALSE; + } + + XtUnmanageChild ((Widget) m_mainWidget); + XtUnrealizeWidget ((Widget) m_mainWidget); + + size_t menuCount = GetMenuCount(); + for (size_t i = 0; i < menuCount; i++) + { + wxMenu *menu = GetMenu(i); + menu->DestroyMenu(TRUE); + + } + XtDestroyWidget((Widget) m_mainWidget); + m_mainWidget = (WXWidget) 0; + + SetMenuBarFrame((wxFrame*) NULL); + + return TRUE; +} + +//// Motif-specific +static XtWorkProcId WorkProcMenuId; + +/* Since PopupMenu under Motif stills grab right mouse button events +* after it was closed, we need to delete the associated widgets to +* allow next PopUpMenu to appear... +*/ + +int PostDeletionOfMenu( XtPointer* clientData ) +{ + XtRemoveWorkProc(WorkProcMenuId); + wxMenu *menu = (wxMenu *)clientData; + + if (menu->GetMainWidget()) + { + wxMenu *menuParent = menu->GetParent(); + if ( menuParent ) + { + wxMenuItemList::Node *node = menuParent->GetMenuItems().GetFirst(); + while ( node ) + { + if ( node->GetData()->GetSubMenu() == menu ) + { + menuParent->GetMenuItems().DeleteNode(node); + + break; + } + + node = node->GetNext(); + } + } + + menu->DestroyMenu(TRUE); + } + + // Mark as no longer popped up + menu->m_menuId = -1; + + return TRUE; +} + +void +wxMenuPopdownCallback(Widget WXUNUSED(w), XtPointer clientData, + XtPointer WXUNUSED(ptr)) +{ + wxMenu *menu = (wxMenu *)clientData; + + // Added by JOREL Jean-Charles + /* Since Callbacks of MenuItems are not yet processed, we put a + * background job which will be done when system will be idle. + * What awful hack!! :( + */ + + WorkProcMenuId = XtAppAddWorkProc( + (XtAppContext) wxTheApp->GetAppContext(), + (XtWorkProc) PostDeletionOfMenu, + (XtPointer) menu ); + // Apparently not found in Motif headers + // XtVaSetValues( w, XmNpopupEnabled, XmPOPUP_DISABLED, NULL ); +} + +/* +* Create a popup or pulldown menu. +* Submenus of a popup will be pulldown. +* +*/ + +WXWidget wxMenu::CreateMenu (wxMenuBar * menuBar, WXWidget parent, wxMenu * topMenu, const wxString& title, bool pullDown) +{ + Widget menu = (Widget) 0; + Widget buttonWidget = (Widget) 0; + Arg args[5]; + XtSetArg (args[0], XmNnumColumns, m_numColumns); + XtSetArg (args[1], XmNpacking, XmPACK_COLUMN); + + if (!pullDown) + { + menu = XmCreatePopupMenu ((Widget) parent, "popup", args, 2); + XtAddCallback(menu, + XmNunmapCallback, + (XtCallbackProc)wxMenuPopdownCallback, + (XtPointer)this); + } + else + { + char mnem = wxFindMnemonic (title); + wxStripMenuCodes ((char*) (const char*) title, wxBuffer); + + menu = XmCreatePulldownMenu ((Widget) parent, "pulldown", args, 2); + + wxString title2(wxStripMenuCodes(title)); + wxXmString label_str(title2); + buttonWidget = XtVaCreateManagedWidget(title2, +#if wxUSE_GADGETS + xmCascadeButtonGadgetClass, (Widget) parent, +#else + xmCascadeButtonWidgetClass, (Widget) parent, +#endif + XmNlabelString, label_str(), + XmNsubMenuId, menu, + NULL); + + if (mnem != 0) + XtVaSetValues (buttonWidget, XmNmnemonic, mnem, NULL); + } + + m_menuWidget = (WXWidget) menu; + + m_menuBar = menuBar; + m_topLevelMenu = topMenu; + + for ( wxMenuItemList::Node *node = GetMenuItems().GetFirst(); + node; + node = node->GetNext() ) + { + wxMenuItem *item = node->GetData(); + + item->CreateItem(menu, menuBar, topMenu); + } + + SetBackgroundColour(m_backgroundColour); + SetForegroundColour(m_foregroundColour); + SetFont(m_font); + + return buttonWidget; +} + +// Destroys the Motif implementation of the menu, +// but maintains the wxWindows data structures so we can +// do a CreateMenu again. +void wxMenu::DestroyMenu (bool full) +{ + for ( wxMenuItemList::Node *node = GetMenuItems().GetFirst(); + node; + node = node->GetNext() ) + { + wxMenuItem *item = node->GetData(); + item->SetMenuBar((wxMenuBar*) NULL); + + item->DestroyItem(full); + } + + if (m_buttonWidget) + { + if (full) + { + XtVaSetValues((Widget) m_buttonWidget, XmNsubMenuId, NULL, NULL); + XtDestroyWidget ((Widget) m_buttonWidget); + m_buttonWidget = (WXWidget) 0; + } + } + if (m_menuWidget && full) + { + XtDestroyWidget((Widget) m_menuWidget); + m_menuWidget = (WXWidget) NULL; + } +} + +WXWidget wxMenu::FindMenuItem (int id, wxMenuItem ** it) const +{ + if (id == m_menuId) + { + if (it) + *it = (wxMenuItem*) NULL; + return m_buttonWidget; + } + + for ( wxMenuItemList::Node *node = GetMenuItems().GetFirst(); + node; + node = node->GetNext() ) + { + wxMenuItem *item = node->GetData (); + if (item->GetId() == id) + { + if (it) + *it = item; + return item->GetButtonWidget(); + } + + if (item->GetSubMenu()) + { + WXWidget w = item->GetSubMenu()->FindMenuItem (id, it); + if (w) + { + return w; + } + } + } + + if (it) + *it = (wxMenuItem*) NULL; + return (WXWidget) NULL; +} + +void wxMenu::SetBackgroundColour(const wxColour& col) +{ + m_backgroundColour = col; + if (m_menuWidget) + wxDoChangeBackgroundColour(m_menuWidget, (wxColour&) col); + if (m_buttonWidget) + wxDoChangeBackgroundColour(m_buttonWidget, (wxColour&) col, TRUE); + + for ( wxMenuItemList::Node *node = GetMenuItems().GetFirst(); + node; + node = node->GetNext() ) + { + wxMenuItem* item = node->GetData(); + if (item->GetButtonWidget()) + { + // This crashes because it uses gadgets + // wxDoChangeBackgroundColour(item->GetButtonWidget(), (wxColour&) col, TRUE); + } + if (item->GetSubMenu()) + item->GetSubMenu()->SetBackgroundColour((wxColour&) col); + } +} + +void wxMenu::SetForegroundColour(const wxColour& col) +{ + m_foregroundColour = col; + if (m_menuWidget) + wxDoChangeForegroundColour(m_menuWidget, (wxColour&) col); + if (m_buttonWidget) + wxDoChangeForegroundColour(m_buttonWidget, (wxColour&) col); + + for ( wxMenuItemList::Node *node = GetMenuItems().GetFirst(); + node; + node = node->GetNext() ) + { + wxMenuItem* item = node->GetData(); + if (item->GetButtonWidget()) + { + // This crashes because it uses gadgets + // wxDoChangeForegroundColour(item->GetButtonWidget(), (wxColour&) col); + } + if (item->GetSubMenu()) + item->GetSubMenu()->SetForegroundColour((wxColour&) col); + } +} + +void wxMenu::ChangeFont(bool keepOriginalSize) +{ + // lesstif 0.87 hangs when setting XmNfontList +#ifndef LESSTIF_VERSION + if (!m_font.Ok() || !m_menuWidget) + return; + + XmFontList fontList = (XmFontList) m_font.GetFontList(1.0, XtDisplay((Widget) m_menuWidget)); + + XtVaSetValues ((Widget) m_menuWidget, + XmNfontList, fontList, + NULL); + if (m_buttonWidget) + { + XtVaSetValues ((Widget) m_buttonWidget, + XmNfontList, fontList, + NULL); + } + + for ( wxMenuItemList::Node *node = GetMenuItems().GetFirst(); + node; + node = node->GetNext() ) + { + wxMenuItem* item = node->GetData(); + if (m_menuWidget && item->GetButtonWidget() && m_font.Ok()) + { + XtVaSetValues ((Widget) item->GetButtonWidget(), + XmNfontList, fontList, + NULL); + } + if (item->GetSubMenu()) + item->GetSubMenu()->ChangeFont(keepOriginalSize); + } +#endif +} + +void wxMenu::SetFont(const wxFont& font) +{ + m_font = font; + ChangeFont(); +} + +bool wxMenuBar::SetBackgroundColour(const wxColour& col) +{ + m_backgroundColour = col; + if (m_mainWidget) + wxDoChangeBackgroundColour(m_mainWidget, (wxColour&) col); + + size_t menuCount = GetMenuCount(); + for (size_t i = 0; i < menuCount; i++) + m_menus[i]->SetBackgroundColour((wxColour&) col); + + return TRUE; +} + +bool wxMenuBar::SetForegroundColour(const wxColour& col) +{ + m_foregroundColour = col; + if (m_mainWidget) + wxDoChangeForegroundColour(m_mainWidget, (wxColour&) col); + + size_t menuCount = GetMenuCount(); + for (size_t i = 0; i < menuCount; i++) + m_menus[i]->SetForegroundColour((wxColour&) col); + + return TRUE; +} + +void wxMenuBar::ChangeFont(bool WXUNUSED(keepOriginalSize)) +{ + // Nothing to do for menubar, fonts are kept in wxMenus +} + +bool wxMenuBar::SetFont(const wxFont& font) +{ + m_font = font; + ChangeFont(); + + size_t menuCount = GetMenuCount(); + for (size_t i = 0; i < menuCount; i++) + m_menus[i]->SetFont(font); + + return TRUE; +} + diff --git a/src/x11/minifram.cpp b/src/x11/minifram.cpp new file mode 100644 index 0000000000..1161e3de57 --- /dev/null +++ b/src/x11/minifram.cpp @@ -0,0 +1,20 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: minifram.cpp +// Purpose: wxMiniFrame. Optional; identical to wxFrame if not supported. +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "minifram.h" +#endif + +#include "wx/minifram.h" + +IMPLEMENT_DYNAMIC_CLASS(wxMiniFrame, wxFrame) + + diff --git a/src/x11/palette.cpp b/src/x11/palette.cpp new file mode 100644 index 0000000000..ef2b2597a6 --- /dev/null +++ b/src/x11/palette.cpp @@ -0,0 +1,356 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: palette.cpp +// Purpose: wxPalette +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +/* + * Colour map + * + * When constructed with the default constructor, we start from + * the wxApp::GetMainColormap, allocating additional read-only cells + * in Create(). The cells are freed on the next call to Create() + * or when the destructor is called. + */ + +/* Wolfram Gloger +I have implemented basic colormap support for the X11 versions of +wxWindows, notably wxPalette::Create(). The way I did it is to +allocate additional read-only color cells in the default colormap. In +general you will get arbitrary pixel values assigned to these new +cells and therefore I added a method wxColourMap::TransferBitmap() +which maps the pixel values 0..n to the real ones obtained with +Create(). This is only implemented for the popular case of 8-bit +depth. + +Allocating read-write color cells would involve installing a private +X11 colormap for a particular window, and AFAIK this is not +recommended; only the window manager should do this... Also, it is +not the functionality that wxPalette::Create() aims to provide. + */ + +#ifdef __GNUG__ +#pragma implementation "palette.h" +#endif + +#include "wx/palette.h" +#include "wx/window.h" +#include "wx/app.h" +#include "wx/utils.h" + +#ifdef __VMS__ +#pragma message disable nosimpint +#endif +#include +#ifdef __VMS__ +#pragma message enable nosimpint +#endif +#include "wx/motif/private.h" + +IMPLEMENT_DYNAMIC_CLASS(wxPalette, wxGDIObject) +IMPLEMENT_DYNAMIC_CLASS(wxXPalette, wxObject) + +/* +* Palette +* +*/ + +wxXPalette::wxXPalette() +{ + m_cmap = (WXColormap) 0; + m_pix_array_n = 0; + m_pix_array = (unsigned long*) 0; + m_display = (WXDisplay*) 0; + m_destroyable = FALSE; +} + +wxPaletteRefData::wxPaletteRefData() +{ +} + +wxPaletteRefData::~wxPaletteRefData() +{ + Display *display = (Display*) NULL; + + wxNode *node, *next; + + for (node = m_palettes.First(); node; node = next) { + wxXPalette *c = (wxXPalette *)node->Data(); + unsigned long *pix_array = c->m_pix_array; + Colormap cmap = (Colormap) c->m_cmap; + bool destroyable = c->m_destroyable; + int pix_array_n = c->m_pix_array_n; + display = (Display*) c->m_display; + + if (pix_array_n > 0) + { + // XFreeColors(display, cmap, pix_array, pix_array_n, 0); + // Be careful not to free '0' pixels... + int i, j; + for(i=j=0; i i) XFreeColors(display, cmap, &pix_array[i], j-i, 0); + while(jNext(); + m_palettes.DeleteNode(node); + delete c; + } +} + +wxPalette::wxPalette() +{ +} + +wxPalette::wxPalette(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue) +{ + Create(n, red, green, blue); +} + +wxPalette::~wxPalette() +{ +} + +bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue) +{ + UnRef(); + + if (!n) { + return FALSE; + } + + m_refData = new wxPaletteRefData; + + XColor xcol; + Display* display = (Display*) wxGetDisplay(); + + unsigned long *pix_array; + Colormap cmap; + int pix_array_n; + + cmap = (Colormap) wxTheApp->GetMainColormap(display); + + pix_array = new unsigned long[n]; + if (!pix_array) + return FALSE; + + pix_array_n = n; + xcol.flags = DoRed | DoGreen | DoBlue; + for(int i = 0; i < n; i++) { + xcol.red = (unsigned short)red[i] << 8; + xcol.green = (unsigned short)green[i] << 8; + xcol.blue = (unsigned short)blue[i] << 8; + pix_array[i] = (XAllocColor(display, cmap, &xcol) == 0) ? 0 : xcol.pixel; + } + + wxXPalette *c = new wxXPalette; + + c->m_pix_array_n = pix_array_n; + c->m_pix_array = pix_array; + c->m_cmap = (WXColormap) cmap; + c->m_display = (WXDisplay*) display; + c->m_destroyable = FALSE; + M_PALETTEDATA->m_palettes.Append(c); + + return TRUE; +} + +int wxPalette::GetPixel(const unsigned char red, const unsigned char green, const unsigned char blue) const +{ + if ( !m_refData ) + return FALSE; + + // TODO + return FALSE; +} + +bool wxPalette::GetRGB(int index, unsigned char *WXUNUSED(red), unsigned char *WXUNUSED(green), unsigned char *WXUNUSED(blue)) const +{ + if ( !m_refData ) + return FALSE; + + if (index < 0 || index > 255) + return FALSE; + + // TODO + return FALSE; +} + +WXColormap wxPalette::GetXColormap(WXDisplay* display) const +{ + if (!M_PALETTEDATA || (M_PALETTEDATA->m_palettes.Number() == 0)) + return wxTheApp->GetMainColormap(display); + + wxNode* node = M_PALETTEDATA->m_palettes.First(); + if (!display && node) + { + wxXPalette* p = (wxXPalette*) node->Data(); + return p->m_cmap; + } + while (node) + { + wxXPalette* p = (wxXPalette*) node->Data(); + if (p->m_display == display) + return p->m_cmap; + + node = node->Next(); + } + + /* Make a new one: */ + wxXPalette *c = new wxXPalette; + wxXPalette *first = (wxXPalette *)M_PALETTEDATA->m_palettes.First()->Data(); + XColor xcol; + int pix_array_n = first->m_pix_array_n; + + c->m_pix_array_n = pix_array_n; + c->m_pix_array = new unsigned long[pix_array_n]; + c->m_display = display; + c->m_cmap = wxTheApp->GetMainColormap(display); + c->m_destroyable = FALSE; + + xcol.flags = DoRed | DoGreen | DoBlue; + int i; + for (i = 0; i < pix_array_n; i++) + { + xcol.pixel = first->m_pix_array[i]; + XQueryColor((Display*) first->m_display, (Colormap) first->m_cmap, &xcol); + c->m_pix_array[i] = + (XAllocColor((Display*) display, (Colormap) c->m_cmap, &xcol) == 0) ? 0 : xcol.pixel; + } + + // wxPalette* nonConstThis = (wxPalette*) this; + + M_PALETTEDATA->m_palettes.Append(c); + + return c->m_cmap; +} + +bool wxPalette::TransferBitmap(void *data, int depth, int size) +{ + switch(depth) { + case 8: + { + unsigned char *uptr = (unsigned char *)data; + int pix_array_n; + unsigned long *pix_array = GetXPixArray((Display*) wxGetDisplay(), &pix_array_n); + while(size-- > 0) + { + if((int)*uptr < pix_array_n) + *uptr = (unsigned char)pix_array[*uptr]; + uptr++; + } + + return TRUE; + } + default: + return FALSE; + } +} + +bool wxPalette::TransferBitmap8(unsigned char *data, unsigned long sz, + void *dest, unsigned int bpp) +{ + int pix_array_n; + unsigned long *pix_array = GetXPixArray((Display*) wxGetDisplay(), &pix_array_n); + switch(bpp) { + case 8: { + unsigned char *dptr = (unsigned char *)dest; + while(sz-- > 0) { + if((int)*data < pix_array_n) + *dptr = (unsigned char)pix_array[*data]; + data++; + dptr++; + } + break; + } + case 16: { + unsigned short *dptr = (unsigned short *)dest; + while(sz-- > 0) { + if((int)*data < pix_array_n) + *dptr = (unsigned short)pix_array[*data]; + data++; + dptr++; + } + break; + } + case 24: { + struct rgb24 { unsigned char r, g, b; } *dptr = (struct rgb24 *)dest; + while(sz-- > 0) { + if((int)*data < pix_array_n) { + dptr->r = pix_array[*data] & 0xFF; + dptr->g = (pix_array[*data] >> 8) & 0xFF; + dptr->b = (pix_array[*data] >> 16) & 0xFF; + } + data++; + dptr++; + } + break; + } + case 32: { + unsigned long *dptr = (unsigned long *)dest; + while(sz-- > 0) { + if((int)*data < pix_array_n) + *dptr = pix_array[*data]; + data++; + dptr++; + } + break; + } + default: + return FALSE; + } + return TRUE; +} + +unsigned long *wxPalette::GetXPixArray(WXDisplay *display, int *n) +{ + if (!M_PALETTEDATA) + return (unsigned long*) 0; + wxNode *node; + + for (node = M_PALETTEDATA->m_palettes.First(); node; node = node->Next()) + { + wxXPalette *c = (wxXPalette *)node->Data(); + if (c->m_display == display) + { + if (n) + *n = c->m_pix_array_n; + return c->m_pix_array; + } + } + + /* Not found; call GetXColormap, which will create it, then this again */ + if (GetXColormap(display)) + return GetXPixArray(display, n); + else + return (unsigned long*) 0; +} + +void wxPalette::PutXColormap(WXDisplay* display, WXColormap cm, bool dp) +{ + UnRef(); + + m_refData = new wxPaletteRefData; + + wxXPalette *c = new wxXPalette; + + c->m_pix_array_n = 0; + c->m_pix_array = (unsigned long*) NULL; + c->m_display = display; + c->m_cmap = cm; + c->m_destroyable = dp; + + M_PALETTEDATA->m_palettes.Append(c); +} + diff --git a/src/x11/pen.cpp b/src/x11/pen.cpp new file mode 100644 index 0000000000..4bc2b0bd89 --- /dev/null +++ b/src/x11/pen.cpp @@ -0,0 +1,182 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: src/motif/pen.cpp +// Purpose: wxPen +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "pen.h" +#endif + +#include "wx/setup.h" +#include "wx/utils.h" +#include "wx/pen.h" + +IMPLEMENT_DYNAMIC_CLASS(wxPen, wxGDIObject) + +wxPenRefData::wxPenRefData() +{ + m_style = wxSOLID; + m_width = 1; + m_join = wxJOIN_ROUND ; + m_cap = wxCAP_ROUND ; + m_nbDash = 0 ; + m_dash = (wxMOTIFDash*)NULL; +} + +wxPenRefData::wxPenRefData(const wxPenRefData& data) +{ + m_style = data.m_style; + m_width = data.m_width; + m_join = data.m_join; + m_cap = data.m_cap; + m_nbDash = data.m_nbDash; + m_dash = data.m_dash; + m_colour = data.m_colour; +} + +wxPenRefData::~wxPenRefData() +{ +} + +// Pens + +wxPen::wxPen() +{ +} + +wxPen::~wxPen() +{ +} + +// Should implement Create +wxPen::wxPen(const wxColour& col, int Width, int Style) +{ + m_refData = new wxPenRefData; + + M_PENDATA->m_colour = col; + M_PENDATA->m_width = Width; + M_PENDATA->m_style = Style; + M_PENDATA->m_join = wxJOIN_ROUND ; + M_PENDATA->m_cap = wxCAP_ROUND ; + M_PENDATA->m_nbDash = 0 ; + M_PENDATA->m_dash = (wxMOTIFDash*)NULL; + + RealizeResource(); +} + +wxPen::wxPen(const wxBitmap& stipple, int Width) +{ + m_refData = new wxPenRefData; + + M_PENDATA->m_stipple = stipple; + M_PENDATA->m_width = Width; + M_PENDATA->m_style = wxSTIPPLE; + M_PENDATA->m_join = wxJOIN_ROUND ; + M_PENDATA->m_cap = wxCAP_ROUND ; + M_PENDATA->m_nbDash = 0 ; + M_PENDATA->m_dash = (wxMOTIFDash*)NULL; + + RealizeResource(); +} + +void wxPen::Unshare() +{ + // Don't change shared data + if (!m_refData) + { + m_refData = new wxPenRefData(); + } + else + { + wxPenRefData* ref = new wxPenRefData(*(wxPenRefData*)m_refData); + UnRef(); + m_refData = ref; + } +} + +void wxPen::SetColour(const wxColour& col) +{ + Unshare(); + + M_PENDATA->m_colour = col; + + RealizeResource(); +} + +void wxPen::SetColour(unsigned char r, unsigned char g, unsigned char b) +{ + Unshare(); + + M_PENDATA->m_colour.Set(r, g, b); + + RealizeResource(); +} + +void wxPen::SetWidth(int Width) +{ + Unshare(); + + M_PENDATA->m_width = Width; + + RealizeResource(); +} + +void wxPen::SetStyle(int Style) +{ + Unshare(); + + M_PENDATA->m_style = Style; + + RealizeResource(); +} + +void wxPen::SetStipple(const wxBitmap& Stipple) +{ + Unshare(); + + M_PENDATA->m_stipple = Stipple; + M_PENDATA->m_style = wxSTIPPLE; + + RealizeResource(); +} + +void wxPen::SetDashes(int nb_dashes, const wxDash *Dash) +{ + Unshare(); + + M_PENDATA->m_nbDash = nb_dashes; + M_PENDATA->m_dash = (wxMOTIFDash *)Dash; + + RealizeResource(); +} + +void wxPen::SetJoin(int Join) +{ + Unshare(); + + M_PENDATA->m_join = Join; + + RealizeResource(); +} + +void wxPen::SetCap(int Cap) +{ + Unshare(); + + M_PENDATA->m_cap = Cap; + + RealizeResource(); +} + +bool wxPen::RealizeResource() +{ + // Nothing more to do + return TRUE; +} + diff --git a/src/x11/region.cpp b/src/x11/region.cpp new file mode 100644 index 0000000000..fb3b1e3db2 --- /dev/null +++ b/src/x11/region.cpp @@ -0,0 +1,536 @@ +///////////////////////////////////////////////////////////////////////////// +// File: region.cpp +// Purpose: Region class +// Author: Markus Holzem/Julian Smart +// Created: Fri Oct 24 10:46:34 MET 1997 +// RCS-ID: $Id$ +// Copyright: (c) 1997 Markus Holzem/Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "region.h" +#endif + +#include "wx/region.h" +#include "wx/gdicmn.h" + +#ifdef __VMS__ +#pragma message disable nosimpint +#endif +#include +#ifdef __VMS__ +#pragma message enable nosimpint +#endif +// #include "wx/motif/private.h" + + IMPLEMENT_DYNAMIC_CLASS(wxRegion, wxGDIObject) + IMPLEMENT_DYNAMIC_CLASS(wxRegionIterator, wxObject) + +// ---------------------------------------------------------------------------- +// list types +// ---------------------------------------------------------------------------- + +#include "wx/listimpl.cpp" + +WX_DEFINE_LIST(wxRectList); + +//----------------------------------------------------------------------------- +// wxRegionRefData implementation +//----------------------------------------------------------------------------- + +class WXDLLEXPORT wxRegionRefData : public wxGDIRefData { +public: + wxRegionRefData() + { + m_region = XCreateRegion(); + m_usingRects = FALSE; + m_rects = (wxRect*) NULL; + m_rectCount = 0; + } + + wxRegionRefData(const wxRegionRefData& data) + { + m_region = XCreateRegion(); + m_rects = (wxRect*) NULL; + m_rectCount = 0; + XUnionRegion(m_region, data.m_region, m_region); + + SetRects(data.m_rectCount, data.m_rects); + } + + ~wxRegionRefData() + { + XDestroyRegion(m_region); + DeleteRects(); + } + + wxRect* GetRects() { return m_rects; }; + void SetRects(const wxRectList& rectList); + void SetRects(int count, const wxRect* rects); + bool UsingRects() const { return m_usingRects; } + int GetRectCount() const { return m_rectCount; } + + void DeleteRects(); + + Region m_region; + wxRect* m_rects; + int m_rectCount; + bool m_usingRects; // TRUE if we're using the above. +}; + +void wxRegionRefData::SetRects(const wxRectList& rectList) +{ + DeleteRects(); + m_usingRects = (rectList.Number() > 0); + if (m_usingRects) + { + m_rectCount = rectList.Number(); + m_rects = new wxRect[m_rectCount]; + } + + wxRectList::Node* node = rectList.GetFirst(); + int i = 0; + while (node) { + wxRect* rect = node->GetData(); + m_rects[i] = * rect; + node = node->GetNext(); + i ++; + } +} + +void wxRegionRefData::SetRects(int count, const wxRect* rects) +{ + DeleteRects(); + m_usingRects = (count > 0); + if (m_usingRects) + { + m_rectCount = count; + m_rects = new wxRect[m_rectCount]; + int i; + for (i = 0; i < m_rectCount; i++) + m_rects[i] = rects[i]; + } +} + +void wxRegionRefData::DeleteRects() +{ + if (m_rects) + { + delete[] m_rects; + m_rects = (wxRect*) NULL; + } + m_rectCount = 0; + m_usingRects = FALSE; + } + +#define M_REGION (((wxRegionRefData*)m_refData)->m_region) + +//----------------------------------------------------------------------------- +// wxRegion +//----------------------------------------------------------------------------- + +/*! + * Create an empty region. + */ +wxRegion::wxRegion() +{ +} + +wxRegion::wxRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h) +{ + m_refData = new wxRegionRefData; + + XRectangle rect; + rect.x = x; + rect.y = y; + rect.width = w; + rect.height = h; + XUnionRectWithRegion(&rect, M_REGION, M_REGION); +} + +wxRegion::wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight) +{ + m_refData = new wxRegionRefData; + + XRectangle rect; + rect.x = topLeft.x; + rect.y = topLeft.y; + rect.width = bottomRight.x - topLeft.x; + rect.height = bottomRight.y - topLeft.y; + XUnionRectWithRegion(&rect, M_REGION, M_REGION); +} + +wxRegion::wxRegion(const wxRect& rect) +{ + m_refData = new wxRegionRefData; + + XRectangle rect1; + rect1.x = rect.x; + rect1.y = rect.y; + rect1.width = rect.width; + rect1.height = rect.height; + XUnionRectWithRegion(&rect1, M_REGION, M_REGION); +} + +/*! + * Destroy the region. + */ +wxRegion::~wxRegion() +{ + // m_refData unrefed in ~wxObject +} + +// Get the internal region handle +WXRegion wxRegion::GetXRegion() const +{ + wxASSERT( m_refData !=NULL ); + + return (WXRegion) ((wxRegionRefData*)m_refData)->m_region; +} + +//----------------------------------------------------------------------------- +//# Modify region +//----------------------------------------------------------------------------- + +//! Clear current region +void wxRegion::Clear() +{ + UnRef(); +} + +//! Combine rectangle (x, y, w, h) with this. +bool wxRegion::Combine(wxCoord x, wxCoord y, wxCoord width, wxCoord height, wxRegionOp op) +{ + // Don't change shared data + if (!m_refData) { + m_refData = new wxRegionRefData(); + } else if (m_refData->GetRefCount() > 1) { + wxRegionRefData* ref = (wxRegionRefData*)m_refData; + UnRef(); + m_refData = new wxRegionRefData(*ref); + } + // If ref count is 1, that means it's 'ours' anyway so no action. + + Region rectRegion = XCreateRegion(); + + XRectangle rect; + rect.x = x; + rect.y = y; + rect.width = width; + rect.height = height; + XUnionRectWithRegion(&rect, rectRegion, rectRegion); + + switch (op) + { + case wxRGN_AND: + XIntersectRegion(M_REGION, rectRegion, M_REGION); + break ; + case wxRGN_OR: + XUnionRegion(M_REGION, rectRegion, M_REGION); + break ; + case wxRGN_XOR: + // TODO + break ; + case wxRGN_DIFF: + // TODO + break ; + case wxRGN_COPY: // Don't have to do this one + default: + // TODO + break ; + } + + return FALSE; +} + +//! Union /e region with this. +bool wxRegion::Combine(const wxRegion& region, wxRegionOp op) +{ + if (region.Empty()) + return FALSE; + + // Don't change shared data + if (!m_refData) { + m_refData = new wxRegionRefData(); + } else if (m_refData->GetRefCount() > 1) { + wxRegionRefData* ref = (wxRegionRefData*)m_refData; + UnRef(); + m_refData = new wxRegionRefData(*ref); + } + + switch (op) + { + case wxRGN_AND: + XIntersectRegion(M_REGION, ((wxRegionRefData*)region.m_refData)->m_region, + M_REGION); + break ; + case wxRGN_OR: + XUnionRegion(M_REGION, ((wxRegionRefData*)region.m_refData)->m_region, + M_REGION); + break ; + case wxRGN_XOR: + // TODO + break ; + case wxRGN_DIFF: + // TODO + break ; + case wxRGN_COPY: // Don't have to do this one + default: + // TODO + break ; + } + + return FALSE; +} + +bool wxRegion::Combine(const wxRect& rect, wxRegionOp op) +{ + return Combine(rect.GetLeft(), rect.GetTop(), rect.GetWidth(), rect.GetHeight(), op); +} + +//----------------------------------------------------------------------------- +//# Information on region +//----------------------------------------------------------------------------- + +// Outer bounds of region +void wxRegion::GetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const +{ + if (m_refData) { + XRectangle rect; + XClipBox(M_REGION, &rect); + x = rect.x; + y = rect.y; + w = rect.width; + h = rect.height; + } else { + x = y = w = h = 0; + } +} + +wxRect wxRegion::GetBox() const +{ + wxCoord x, y, w, h; + GetBox(x, y, w, h); + return wxRect(x, y, w, h); +} + +// Is region empty? +bool wxRegion::Empty() const +{ + return m_refData ? XEmptyRegion(M_REGION) : TRUE; +} + +//----------------------------------------------------------------------------- +//# Tests +//----------------------------------------------------------------------------- + +// Does the region contain the point (x,y)? +wxRegionContain wxRegion::Contains(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y)) const +{ + if (!m_refData) + return wxOutRegion; + + // TODO. Return wxInRegion if within region. + if (0) + return wxInRegion; + return wxOutRegion; +} + +// Does the region contain the point pt? +wxRegionContain wxRegion::Contains(const wxPoint& pt) const +{ + if (!m_refData) + return wxOutRegion; + + return XPointInRegion(M_REGION, pt.x, pt.y) ? wxInRegion : wxOutRegion; +} + +// Does the region contain the rectangle (x, y, w, h)? +wxRegionContain wxRegion::Contains(wxCoord x, wxCoord y, wxCoord w, wxCoord h) const +{ + if (!m_refData) + return wxOutRegion; + + switch (XRectInRegion(M_REGION, x, y, w, h)) { + case RectangleIn: return wxInRegion; + case RectanglePart: return wxPartRegion; + } + return wxOutRegion; +} + +// Does the region contain the rectangle rect +wxRegionContain wxRegion::Contains(const wxRect& rect) const +{ + if (!m_refData) + return wxOutRegion; + + wxCoord x, y, w, h; + x = rect.x; + y = rect.y; + w = rect.GetWidth(); + h = rect.GetHeight(); + return Contains(x, y, w, h); +} + +bool wxRegion::UsingRects() const +{ + return ((wxRegionRefData*)m_refData)->UsingRects(); +} + +/* +wxRectList& wxRegion::GetRectList() +{ + return ((wxRegionRefData*)m_refData)->GetRectList(); +} +*/ + +wxRect* wxRegion::GetRects() +{ + return ((wxRegionRefData*)m_refData)->GetRects(); +} + +int wxRegion::GetRectCount() const +{ + return ((wxRegionRefData*)m_refData)->GetRectCount(); +} + +void wxRegion::SetRects(const wxRectList& rectList) +{ + ((wxRegionRefData*)m_refData)->SetRects(rectList); +} + +void wxRegion::SetRects(int count, const wxRect* rects) +{ + ((wxRegionRefData*)m_refData)->SetRects(count, rects); +} + +/////////////////////////////////////////////////////////////////////////////// +// // +// wxRegionIterator // +// // +/////////////////////////////////////////////////////////////////////////////// + +/*! + * Initialize empty iterator + */ +wxRegionIterator::wxRegionIterator() : m_current(0), m_numRects(0), m_rects(NULL) +{ +} + +wxRegionIterator::~wxRegionIterator() +{ + if (m_rects) + delete[] m_rects; +} + +/*! + * Initialize iterator for region + */ +wxRegionIterator::wxRegionIterator(const wxRegion& region) +{ + m_rects = NULL; + + Reset(region); +} + +/*! + * Reset iterator for a new /e region. + */ +void wxRegionIterator::Reset(const wxRegion& region) +{ + m_current = 0; + m_region = region; + + if (m_rects) + delete[] m_rects; + + m_rects = NULL; + + if (m_region.Empty()) + m_numRects = 0; + else + { + // Create m_rects and fill with rectangles for this region. + // Since we can't find the rectangles in a region, we cheat + // by retrieving the rectangles explicitly set in wxPaintDC::wxPaintDC + // (dcclient.cpp). + if (m_region.UsingRects()) + { + wxRect* rects = m_region.GetRects(); + int count = m_region.GetRectCount(); + m_numRects = count; + m_rects = new wxRect[m_numRects]; + + for (size_t i = 0; i < m_numRects; i++) + m_rects[i] = rects[i]; + + /* + int i = 0; + wxRectList::Node* node = rectList.GetFirst(); + while (node) { + wxRect* rect = node->GetData(); + m_rects[i] = * rect; + node = node->GetNext(); + i ++; + } + */ + } + else + { + // For now, fudge by getting the whole bounding box. + m_rects = new wxRect[1]; + m_numRects = 1; + m_rects[0] = m_region.GetBox(); + } + } +} + +/*! + * Increment iterator. The rectangle returned is the one after the + * incrementation. + */ +void wxRegionIterator::operator ++ () +{ + if (m_current < m_numRects) + ++m_current; +} + +/*! + * Increment iterator. The rectangle returned is the one before the + * incrementation. + */ +void wxRegionIterator::operator ++ (int) +{ + if (m_current < m_numRects) + ++m_current; +} + +wxCoord wxRegionIterator::GetX() const +{ + if (m_current < m_numRects) + return m_rects[m_current].x; + return 0; +} + +wxCoord wxRegionIterator::GetY() const +{ + if (m_current < m_numRects) + return m_rects[m_current].y; + return 0; +} + +wxCoord wxRegionIterator::GetW() const +{ + if (m_current < m_numRects) + return m_rects[m_current].width ; + return 0; +} + +wxCoord wxRegionIterator::GetH() const +{ + if (m_current < m_numRects) + return m_rects[m_current].height; + return 0; +} + diff --git a/src/x11/settings.cpp b/src/x11/settings.cpp new file mode 100644 index 0000000000..5d64ffcd06 --- /dev/null +++ b/src/x11/settings.cpp @@ -0,0 +1,246 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: settings.cpp +// Purpose: wxSettings +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +// TODO: these settings should probably be configurable from some central or +// per-user file, which can be edited using a Windows-control-panel clone. +// Also they should be documented better. Some are very MS Windows-ish. + +#ifdef __GNUG__ +#pragma implementation "settings.h" +#endif + +#include "wx/settings.h" +#include "wx/gdicmn.h" + +wxColour wxSystemSettingsNative::GetColour(wxSystemColour index) +{ + switch (index) + { + case wxSYS_COLOUR_WINDOW: + { + return *wxWHITE; + } + case wxSYS_COLOUR_SCROLLBAR: + // case wxSYS_COLOUR_DESKTOP: // Same as wxSYS_COLOUR_BACKGROUND + case wxSYS_COLOUR_BACKGROUND: + case wxSYS_COLOUR_ACTIVECAPTION: + case wxSYS_COLOUR_INACTIVECAPTION: + case wxSYS_COLOUR_MENU: + case wxSYS_COLOUR_WINDOWFRAME: + case wxSYS_COLOUR_ACTIVEBORDER: + case wxSYS_COLOUR_INACTIVEBORDER: + case wxSYS_COLOUR_BTNFACE: + // case wxSYS_COLOUR_3DFACE: // Same as wxSYS_COLOUR_BTNFACE + case wxSYS_COLOUR_GRAYTEXT: + { + return wxColour("LIGHT GREY"); + } + case wxSYS_COLOUR_BTNSHADOW: + // case wxSYS_COLOUR_3DSHADOW: // Same as wxSYS_COLOUR_BTNSHADOW + { + return wxColour("GREY"); + } + case wxSYS_COLOUR_3DDKSHADOW: + { + return *wxBLACK; + } + case wxSYS_COLOUR_HIGHLIGHT: + { + return *wxBLUE; + } + case wxSYS_COLOUR_BTNHIGHLIGHT: + case wxSYS_COLOUR_LISTBOX: + // case wxSYS_COLOUR_3DHIGHLIGHT: // Same as wxSYS_COLOUR_BTNHIGHLIGHT + { + return *wxWHITE; + } + case wxSYS_COLOUR_3DLIGHT: + { + return wxColour("LIGHT GREY"); + } + case wxSYS_COLOUR_MENUTEXT: + case wxSYS_COLOUR_WINDOWTEXT: + case wxSYS_COLOUR_CAPTIONTEXT: + case wxSYS_COLOUR_INACTIVECAPTIONTEXT: + case wxSYS_COLOUR_BTNTEXT: + case wxSYS_COLOUR_INFOTEXT: + { + return *wxBLACK; + } + case wxSYS_COLOUR_HIGHLIGHTTEXT: + { + return *wxWHITE; + } + case wxSYS_COLOUR_INFOBK: + case wxSYS_COLOUR_APPWORKSPACE: + { + return wxColour("LIGHT GREY"); + // return *wxWHITE; + } + } + return *wxWHITE; +} + +wxFont wxSystemSettingsNative::GetFont(wxSystemFont index) +{ + switch (index) + { + case wxSYS_SYSTEM_FIXED_FONT: + { + return wxFont(12, wxMODERN, wxNORMAL, wxNORMAL, FALSE); + break; + } + case wxSYS_DEVICE_DEFAULT_FONT: + case wxSYS_SYSTEM_FONT: + case wxSYS_DEFAULT_GUI_FONT: + default: + { + return wxFont(12, wxSWISS, wxNORMAL, wxNORMAL, FALSE); + break; + } + } + + return wxFont(); +} + +// Get a system metric, e.g. scrollbar size +int wxSystemSettingsNative::GetMetric(wxSystemMetric index) +{ + switch ( index) + { + case wxSYS_MOUSE_BUTTONS: + // TODO + return 0; + case wxSYS_BORDER_X: + // TODO + return 0; + case wxSYS_BORDER_Y: + // TODO + return 0; + case wxSYS_CURSOR_X: + // TODO + return 0; + case wxSYS_CURSOR_Y: + // TODO + return 0; + case wxSYS_DCLICK_X: + // TODO + return 0; + case wxSYS_DCLICK_Y: + // TODO + return 0; + case wxSYS_DRAG_X: + // TODO + return 0; + case wxSYS_DRAG_Y: + // TODO + return 0; + case wxSYS_EDGE_X: + // TODO + return 0; + case wxSYS_EDGE_Y: + // TODO + return 0; + case wxSYS_HSCROLL_ARROW_X: + // TODO + return 0; + case wxSYS_HSCROLL_ARROW_Y: + // TODO + return 0; + case wxSYS_HTHUMB_X: + // TODO + return 0; + case wxSYS_ICON_X: + // TODO + return 0; + case wxSYS_ICON_Y: + // TODO + return 0; + case wxSYS_ICONSPACING_X: + // TODO + return 0; + case wxSYS_ICONSPACING_Y: + // TODO + return 0; + case wxSYS_WINDOWMIN_X: + // TODO + return 0; + case wxSYS_WINDOWMIN_Y: + // TODO + return 0; + case wxSYS_SCREEN_X: + // TODO + return 0; + case wxSYS_SCREEN_Y: + // TODO + return 0; + case wxSYS_FRAMESIZE_X: + // TODO + return 0; + case wxSYS_FRAMESIZE_Y: + // TODO + return 0; + case wxSYS_SMALLICON_X: + // TODO + return 0; + case wxSYS_SMALLICON_Y: + // TODO + return 0; + case wxSYS_HSCROLL_Y: + // TODO + return 0; + case wxSYS_VSCROLL_X: + // TODO + return 0; + case wxSYS_VSCROLL_ARROW_X: + // TODO + return 0; + case wxSYS_VSCROLL_ARROW_Y: + // TODO + return 0; + case wxSYS_VTHUMB_Y: + // TODO + return 0; + case wxSYS_CAPTION_Y: + // TODO + return 0; + case wxSYS_MENU_Y: + // TODO + return 0; + case wxSYS_NETWORK_PRESENT: + // TODO + return 0; + case wxSYS_PENWINDOWS_PRESENT: + // TODO + return 0; + case wxSYS_SHOW_SOUNDS: + // TODO + return 0; + case wxSYS_SWAP_BUTTONS: + // TODO + return 0; + default: + return 0; + } +} + +bool wxSystemSettingsNative::HasFeature(wxSystemFeature index) +{ + switch (index) + { + case wxSYS_CAN_ICONIZE_FRAME: + case wxSYS_CAN_DRAW_FRAME_DECORATIONS: + return TRUE; + + default: + return FALSE; + } +} diff --git a/src/x11/timer.cpp b/src/x11/timer.cpp new file mode 100644 index 0000000000..570e4186f9 --- /dev/null +++ b/src/x11/timer.cpp @@ -0,0 +1,92 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: timer.cpp +// Purpose: wxTimer implementation +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "timer.h" +#endif + +#include "wx/timer.h" +#include "wx/app.h" +#include "wx/list.h" + +#ifdef __VMS__ +#pragma message disable nosimpint +#endif +#include +#ifdef __VMS__ +#pragma message enable nosimpint +#endif + +#include "wx/motif/private.h" + +IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxObject) + +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(); +} + +void wxTimer::Init() +{ + m_id = 0; + m_milli = 1000; +} + +wxTimer::~wxTimer() +{ + wxTimer::Stop(); + wxTimerList.DeleteObject(this); +} + +bool wxTimer::Start(int milliseconds, bool mode) +{ + Stop(); + + (void)wxTimerBase::Start(milliseconds, mode); + + if (!wxTimerList.Find((long)this)) + wxTimerList.Append((long)this, this); + + m_id = XtAppAddTimeOut((XtAppContext) wxTheApp->GetAppContext(), + m_milli, + (XtTimerCallbackProc) wxTimerCallback, + (XtPointer) this); + return TRUE; +} + +void wxTimer::Stop() +{ + if (m_id > 0) + { + XtRemoveTimeOut (m_id); + m_id = 0; + } + m_milli = 0 ; +} + + diff --git a/src/x11/toolbar.cpp b/src/x11/toolbar.cpp new file mode 100644 index 0000000000..a7faa4d42a --- /dev/null +++ b/src/x11/toolbar.cpp @@ -0,0 +1,666 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: motif/toolbar.cpp +// Purpose: wxToolBar +// Author: Julian Smart +// Modified by: 13.12.99 by VZ during toolbar classes reorganization +// Created: 04/01/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +// ============================================================================ +// declarations +// ============================================================================ + +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- + +#ifdef __GNUG__ + #pragma implementation "toolbar.h" +#endif + +#ifdef __VMS +#define XtDisplay XTDISPLAY +#endif + +#include "wx/wx.h" +#include "wx/app.h" +#include "wx/timer.h" +#include "wx/toolbar.h" + +#ifdef __VMS__ +#pragma message disable nosimpint +#endif +#include +#include +#include +#include +#include +#include +#include +#ifdef __VMS__ +#pragma message enable nosimpint +#endif + +#include "wx/motif/private.h" + +// ---------------------------------------------------------------------------- +// wxWin macros +// ---------------------------------------------------------------------------- + +#if !USE_SHARED_LIBRARY +IMPLEMENT_DYNAMIC_CLASS(wxToolBar, wxToolBarBase) +#endif + +// ---------------------------------------------------------------------------- +// private functions +// ---------------------------------------------------------------------------- + +static void wxToolButtonCallback (Widget w, XtPointer clientData, + XtPointer ptr); +static void wxToolButtonPopupCallback (Widget w, XtPointer client_data, + XEvent *event, Boolean *continue_to_dispatch); + +// ---------------------------------------------------------------------------- +// private classes +// ---------------------------------------------------------------------------- + +class wxToolBarTimer : public wxTimer +{ +public: + virtual void Notify(); + + static Widget help_popup; + static Widget buttonWidget; + static wxString helpString; +}; + +class wxToolBarTool : public wxToolBarToolBase +{ +public: + wxToolBarTool(wxToolBar *tbar, + int id, + const wxBitmap& bitmap1, + const wxBitmap& bitmap2, + bool toggle, + wxObject *clientData, + const wxString& shortHelpString, + const wxString& longHelpString) + : wxToolBarToolBase(tbar, id, bitmap1, bitmap2, toggle, + clientData, shortHelpString, longHelpString) + { + Init(); + } + + wxToolBarTool(wxToolBar *tbar, wxControl *control) + : wxToolBarToolBase(tbar, control) + { + Init(); + } + + virtual ~wxToolBarTool(); + + // accessors + void SetWidget(Widget widget) { m_widget = widget; } + Widget GetButtonWidget() const { return m_widget; } + + void SetPixmap(Pixmap pixmap) { m_pixmap = pixmap; } + Pixmap GetPixmap() const { return m_pixmap; } + +protected: + void Init(); + + Widget m_widget; + Pixmap m_pixmap; +}; + +// ---------------------------------------------------------------------------- +// globals +// ---------------------------------------------------------------------------- + +static wxToolBarTimer* wxTheToolBarTimer = (wxToolBarTimer*) NULL; + +Widget wxToolBarTimer::help_popup = (Widget) 0; +Widget wxToolBarTimer::buttonWidget = (Widget) 0; +wxString wxToolBarTimer::helpString; + +// ============================================================================ +// implementation +// ============================================================================ + +// ---------------------------------------------------------------------------- +// wxToolBarTool +// ---------------------------------------------------------------------------- + +wxToolBarToolBase *wxToolBar::CreateTool(int id, + const wxBitmap& bitmap1, + const wxBitmap& bitmap2, + bool toggle, + wxObject *clientData, + const wxString& shortHelpString, + const wxString& longHelpString) +{ + return new wxToolBarTool(this, id, bitmap1, bitmap2, toggle, + clientData, shortHelpString, longHelpString); +} + +wxToolBarToolBase *wxToolBar::CreateTool(wxControl *control) +{ + return new wxToolBarTool(this, control); +} + +void wxToolBarTool::Init() +{ + m_widget = (Widget)0; + m_pixmap = (Pixmap)0; +} + +wxToolBarTool::~wxToolBarTool() +{ + if ( m_widget ) + XtDestroyWidget(m_widget); + if ( m_pixmap ) + XmDestroyPixmap(DefaultScreenOfDisplay((Display*)wxGetDisplay()), + m_pixmap); +} + +// ---------------------------------------------------------------------------- +// wxToolBar construction +// ---------------------------------------------------------------------------- + +void wxToolBar::Init() +{ + m_maxWidth = -1; + m_maxHeight = -1; + m_defaultWidth = 24; + m_defaultHeight = 22; + m_toolPacking = 2; + m_toolSeparation = 8; + m_xMargin = 2; + m_yMargin = 2; + m_maxRows = 100; + m_maxCols = 100; +} + +bool wxToolBar::Create(wxWindow *parent, + wxWindowID id, + const wxPoint& pos, + const wxSize& size, + long style, + const wxString& name) +{ + Init(); + + m_windowId = id; + + SetName(name); + m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); + m_foregroundColour = parent->GetForegroundColour(); + m_windowStyle = style; + + SetParent(parent); + + if (parent) parent->AddChild(this); + + Widget parentWidget = (Widget) parent->GetClientWidget(); + + Widget toolbar = XtVaCreateManagedWidget("toolbar", + xmBulletinBoardWidgetClass, (Widget) parentWidget, + XmNmarginWidth, 0, + XmNmarginHeight, 0, + XmNresizePolicy, XmRESIZE_NONE, + NULL); +/* + Widget toolbar = XtVaCreateManagedWidget("toolbar", + xmFormWidgetClass, (Widget) m_clientWidget, + XmNtraversalOn, False, + XmNhorizontalSpacing, 0, + XmNverticalSpacing, 0, + XmNleftOffset, 0, + XmNrightOffset, 0, + XmNmarginWidth, 0, + XmNmarginHeight, 0, + NULL); +*/ + + m_mainWidget = (WXWidget) toolbar; + + m_font = parent->GetFont(); + ChangeFont(FALSE); + + SetCanAddEventHandler(TRUE); + AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y); + + ChangeBackgroundColour(); + + return TRUE; +} + +wxToolBar::~wxToolBar() +{ + delete wxTheToolBarTimer; + wxTheToolBarTimer = NULL; +} + +bool wxToolBar::Realize() +{ + if ( m_tools.GetCount() == 0 ) + { + // nothing to do + return TRUE; + } + + // Separator spacing + const int separatorSize = GetToolSeparation(); // 8; + wxSize margins = GetToolMargins(); + int packing = GetToolPacking(); + int marginX = margins.x; + int marginY = margins.y; + + int currentX = marginX; + int currentY = marginY; + + int buttonHeight = 0; + + int currentSpacing = 0; + + Widget button; + Pixmap pixmap, insensPixmap; + wxBitmap bmp; + + wxToolBarToolsList::Node *node = m_tools.GetFirst(); + while ( node ) + { + wxToolBarTool *tool = (wxToolBarTool *)node->GetData(); + + switch ( tool->GetStyle() ) + { + case wxTOOL_STYLE_CONTROL: + { + wxControl* control = tool->GetControl(); + wxSize sz = control->GetSize(); + wxPoint pos = control->GetPosition(); + control->Move(currentX, pos.y); + currentX += sz.x + packing; + + break; + } + case wxTOOL_STYLE_SEPARATOR: + currentX += separatorSize; + break; + + case wxTOOL_STYLE_BUTTON: + button = (Widget) 0; + + if ( tool->CanBeToggled() ) + { + button = XtVaCreateWidget("toggleButton", + xmToggleButtonWidgetClass, (Widget) m_mainWidget, + XmNx, currentX, XmNy, currentY, + XmNindicatorOn, False, + XmNshadowThickness, 2, + XmNborderWidth, 0, + XmNspacing, 0, + XmNmarginWidth, 0, + XmNmarginHeight, 0, + XmNmultiClick, XmMULTICLICK_KEEP, + XmNlabelType, XmPIXMAP, + NULL); + XtAddCallback ((Widget) button, XmNvalueChangedCallback, (XtCallbackProc) wxToolButtonCallback, + (XtPointer) this); + + XtVaSetValues ((Widget) button, + XmNselectColor, m_backgroundColour.AllocColour(XtDisplay((Widget) button)), + NULL); + } + else + { + button = XtVaCreateWidget("button", + xmPushButtonWidgetClass, (Widget) m_mainWidget, + XmNx, currentX, XmNy, currentY, + XmNpushButtonEnabled, True, + XmNmultiClick, XmMULTICLICK_KEEP, + XmNlabelType, XmPIXMAP, + NULL); + XtAddCallback (button, + XmNactivateCallback, (XtCallbackProc) wxToolButtonCallback, + (XtPointer) this); + } + + DoChangeBackgroundColour((WXWidget) button, m_backgroundColour, TRUE); + + tool->SetWidget(button); + + // 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. + bmp = tool->GetBitmap1(); + if ( bmp.GetMask() ) + { + int backgroundPixel; + XtVaGetValues(button, XmNbackground, &backgroundPixel, + NULL); + + wxColour col; + col.SetPixel(backgroundPixel); + + bmp = wxCreateMaskedBitmap(bmp, col); + + tool->SetBitmap1(bmp); + } + + // Create a selected/toggled bitmap. If there isn't a 2nd + // bitmap, we need to create it (with a darker, selected + // background) + int backgroundPixel; + if ( tool->CanBeToggled() ) + XtVaGetValues(button, XmNselectColor, &backgroundPixel, + NULL); + else + XtVaGetValues(button, XmNarmColor, &backgroundPixel, + NULL); + + wxColour col; + col.SetPixel(backgroundPixel); + + if (tool->GetBitmap2().Ok() && tool->GetBitmap2().GetMask()) + { + // Use what's there + wxBitmap newBitmap = wxCreateMaskedBitmap(tool->GetBitmap2(), col); + tool->SetBitmap2(newBitmap); + } + else + { + // Use unselected bitmap + if ( bmp.GetMask() ) + { + wxBitmap newBitmap = wxCreateMaskedBitmap(bmp, col); + tool->SetBitmap2(newBitmap); + } + else + tool->SetBitmap2(bmp); + } + + pixmap = (Pixmap) bmp.GetPixmap(); + insensPixmap = (Pixmap) bmp.GetInsensPixmap(); + + if (tool->CanBeToggled()) + { + // Toggle button + Pixmap pixmap2 = (Pixmap) 0; + Pixmap insensPixmap2 = (Pixmap) 0; + + // If there's a bitmap for the toggled state, use it, + // otherwise generate one. + if (tool->GetBitmap2().Ok()) + { + wxBitmap bmp2 = tool->GetBitmap2(); + pixmap2 = (Pixmap) bmp2.GetPixmap(); + insensPixmap2 = (Pixmap) bmp2.GetInsensPixmap(); + } + else + { + pixmap2 = (Pixmap) bmp.GetArmPixmap(button); + insensPixmap2 = XCreateInsensitivePixmap((Display*) wxGetDisplay(), pixmap2); + } + + tool->SetPixmap(pixmap2); + + XtVaSetValues (button, + XmNfillOnSelect, True, + XmNlabelPixmap, pixmap, + XmNselectPixmap, pixmap2, + XmNlabelInsensitivePixmap, insensPixmap, + XmNselectInsensitivePixmap, insensPixmap2, + XmNlabelType, XmPIXMAP, + NULL); + } + else + { + Pixmap pixmap2 = (Pixmap) 0; + + // If there's a bitmap for the armed state, use it, + // otherwise generate one. + if (tool->GetBitmap2().Ok()) + { + pixmap2 = (Pixmap) tool->GetBitmap2().GetPixmap(); + } + else + { + pixmap2 = (Pixmap) bmp.GetArmPixmap(button); + + } + + tool->SetPixmap(pixmap2); + + // Normal button + XtVaSetValues(button, + XmNlabelPixmap, pixmap, + XmNlabelInsensitivePixmap, insensPixmap, + XmNarmPixmap, pixmap2, + NULL); + } + + XtManageChild(button); + + { + Dimension width, height; + XtVaGetValues(button, + XmNwidth, &width, + XmNheight, & height, + NULL); + currentX += width + packing; + buttonHeight = wxMax(buttonHeight, height); + } + + XtAddEventHandler (button, EnterWindowMask | LeaveWindowMask, + False, wxToolButtonPopupCallback, (XtPointer) this); + + currentSpacing = 0; + break; + } + + node = node->GetNext(); + } + + SetSize(-1, -1, currentX, buttonHeight + 2*marginY); + + return TRUE; +} + +wxToolBarToolBase *wxToolBar::FindToolForPosition(wxCoord WXUNUSED(x), + wxCoord WXUNUSED(y)) const +{ + wxFAIL_MSG( _T("TODO") ); + + return (wxToolBarToolBase *)NULL; +} + +bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos), wxToolBarToolBase *tool) +{ + tool->Attach(this); + + return TRUE; +} + +bool wxToolBar::DoDeleteTool(size_t WXUNUSED(pos), wxToolBarToolBase *tool) +{ + tool->Detach(); + + return TRUE; +} + +void wxToolBar::DoEnableTool(wxToolBarToolBase *toolBase, bool enable) +{ + wxToolBarTool *tool = (wxToolBarTool *)toolBase; + + XtSetSensitive(tool->GetButtonWidget(), (Boolean) enable); +} + +void wxToolBar::DoToggleTool(wxToolBarToolBase *toolBase, bool toggle) +{ + wxToolBarTool *tool = (wxToolBarTool *)toolBase; + + XmToggleButtonSetState(tool->GetButtonWidget(), (Boolean) toggle, False); +} + +void wxToolBar::DoSetToggle(wxToolBarToolBase * WXUNUSED(tool), + bool WXUNUSED(toggle)) +{ + // nothing to do +} + +// ---------------------------------------------------------------------------- +// Motif callbacks +// ---------------------------------------------------------------------------- + +wxToolBarToolBase *wxToolBar::FindToolByWidget(WXWidget w) const +{ + wxToolBarToolsList::Node* node = m_tools.GetFirst(); + while ( node ) + { + wxToolBarTool *tool = (wxToolBarTool *)node->GetData(); + if ( tool->GetButtonWidget() == w) + { + return tool; + } + + node = node->GetNext(); + } + + return (wxToolBarToolBase *)NULL; +} + +static void wxToolButtonCallback(Widget w, + XtPointer clientData, + XtPointer WXUNUSED(ptr)) +{ + wxToolBar *toolBar = (wxToolBar *) clientData; + wxToolBarToolBase *tool = toolBar->FindToolByWidget((WXWidget) w); + if ( !tool ) + return; + + if ( tool->CanBeToggled() ) + tool->Toggle(); + + if ( !toolBar->OnLeftClick(tool->GetId(), tool->IsToggled()) ) + { + // revert + tool->Toggle(); + } +} + + +static void wxToolButtonPopupCallback(Widget w, + XtPointer client_data, + XEvent *event, + Boolean *WXUNUSED(continue_to_dispatch)) +{ + // TODO: retrieve delay before popping up tooltip from wxSystemSettings. + static const int delayMilli = 800; + + wxToolBar* toolBar = (wxToolBar*) client_data; + wxToolBarToolBase *tool = toolBar->FindToolByWidget((WXWidget) w); + + if ( !tool ) + return; + + wxString tooltip = tool->GetShortHelp(); + if ( !tooltip ) + return; + + if (!wxTheToolBarTimer) + wxTheToolBarTimer = new wxToolBarTimer; + + wxToolBarTimer::buttonWidget = w; + wxToolBarTimer::helpString = tooltip; + + /************************************************************/ + /* Popup help label */ + /************************************************************/ + if (event->type == EnterNotify) + { + if (wxToolBarTimer::help_popup != (Widget) 0) + { + XtDestroyWidget (wxToolBarTimer::help_popup); + XtPopdown (wxToolBarTimer::help_popup); + } + wxToolBarTimer::help_popup = (Widget) 0; + + // One shot + wxTheToolBarTimer->Start(delayMilli, TRUE); + + } + /************************************************************/ + /* Popdown help label */ + /************************************************************/ + else if (event->type == LeaveNotify) + { + if (wxTheToolBarTimer) + wxTheToolBarTimer->Stop(); + if (wxToolBarTimer::help_popup != (Widget) 0) + { + XtDestroyWidget (wxToolBarTimer::help_popup); + XtPopdown (wxToolBarTimer::help_popup); + } + wxToolBarTimer::help_popup = (Widget) 0; + } +} + +void wxToolBarTimer::Notify() +{ + Position x, y; + + /************************************************************/ + /* Create shell without window decorations */ + /************************************************************/ + help_popup = XtVaCreatePopupShell ("shell", + overrideShellWidgetClass, (Widget) wxTheApp->GetTopLevelWidget(), + NULL); + + /************************************************************/ + /* Get absolute position on display of toolbar button */ + /************************************************************/ + XtTranslateCoords (buttonWidget, + (Position) 0, + (Position) 0, + &x, &y); + + // Move the tooltip more or less above the button + int yOffset = 20; // TODO: What should be really? + y -= yOffset; + if (y < yOffset) y = 0; + + /************************************************************/ + /* Set the position of the help popup */ + /************************************************************/ + XtVaSetValues (help_popup, + XmNx, (Position) x, + XmNy, (Position) y, + NULL); + + /************************************************************/ + /* Create help label */ + /************************************************************/ + XmString text = XmStringCreateSimple ((char*) (const char*) helpString); + XtVaCreateManagedWidget ("help_label", + xmLabelWidgetClass, help_popup, + XmNlabelString, text, + XtVaTypedArg, + XmNforeground, XtRString, "black", + strlen("black")+1, + XtVaTypedArg, + XmNbackground, XtRString, "LightGoldenrod", + strlen("LightGoldenrod")+1, + NULL); + XmStringFree (text); + + /************************************************************/ + /* Popup help label */ + /************************************************************/ + XtPopup (help_popup, XtGrabNone); +} + diff --git a/src/x11/toplevel.cpp b/src/x11/toplevel.cpp new file mode 100644 index 0000000000..14b660afe3 --- /dev/null +++ b/src/x11/toplevel.cpp @@ -0,0 +1,930 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: motif/frame.cpp +// Purpose: wxFrame +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +// ============================================================================ +// declarations +// ============================================================================ + +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- + +#ifdef __GNUG__ + #pragma implementation "frame.h" +#endif + + +#ifdef __VMS +#define XtDisplay XTDISPLAY +#define XtWindow XTWINDOW +#define XtScreen XTSCREEN +#endif + +# include "wx/frame.h" +#include "wx/statusbr.h" +#include "wx/toolbar.h" +#include "wx/menuitem.h" +#include "wx/menu.h" +#include "wx/dcclient.h" +#include "wx/dialog.h" +#include "wx/settings.h" +#include "wx/app.h" +#include "wx/utils.h" +#include "wx/log.h" + +#ifdef __VMS__ + #pragma message disable nosimpint +#endif + +#if defined(__ultrix) || defined(__sgi) + #include +#endif + +#include +#include +#if XmVersion >= 1002 + #include +#else + #include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if XmVersion > 1000 + #include +#endif + +#ifdef __VMS__ + #pragma message enable nosimpint +#endif + +#include "wx/motif/private.h" + +// ---------------------------------------------------------------------------- +// private functions +// ---------------------------------------------------------------------------- + +static void wxFrameEventHandler(Widget wid, + XtPointer WXUNUSED(client_data), + XEvent* event, + Boolean* continueToDispatch); +static void wxCloseFrameCallback(Widget, XtPointer, XmAnyCallbackStruct *cbs); +static void wxFrameFocusProc(Widget workArea, XtPointer clientData, + XmAnyCallbackStruct *cbs); +static void wxFrameMapProc(Widget frameShell, XtPointer clientData, + XCrossingEvent * event); + +// ---------------------------------------------------------------------------- +// globals +// ---------------------------------------------------------------------------- + +extern wxList wxModelessWindows; +extern wxList wxPendingDelete; + +// TODO: this should be tidied so that any frame can be the +// top frame +static bool wxTopLevelUsed = FALSE; + +// ---------------------------------------------------------------------------- +// wxWin macros +// ---------------------------------------------------------------------------- + +BEGIN_EVENT_TABLE(wxFrame, wxFrameBase) + EVT_ACTIVATE(wxFrame::OnActivate) + EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged) +END_EVENT_TABLE() + +IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxWindow) + +// ============================================================================ +// implementation +// ============================================================================ + +// ---------------------------------------------------------------------------- +// frame construction +// ---------------------------------------------------------------------------- + +void wxFrame::Init() +{ + m_iconized = FALSE; + + //// Motif-specific + m_frameShell = (WXWidget) NULL; + m_frameWidget = (WXWidget) NULL;; + m_workArea = (WXWidget) NULL;; + m_clientArea = (WXWidget) NULL;; + m_visibleStatus = TRUE; +} + +bool wxFrame::Create(wxWindow *parent, + wxWindowID id, + const wxString& title, + const wxPoint& pos, + const wxSize& size, + long style, + const wxString& name) +{ + if ( parent ) + parent->AddChild(this); + else + wxTopLevelWindows.Append(this); + + wxModelessWindows.Append(this); + + SetName(name); + + m_windowStyle = style; + + m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE); + m_foregroundColour = *wxBLACK; + m_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); + + if ( id > -1 ) + m_windowId = id; + else + m_windowId = (int)NewControlId(); + + int x = pos.x, y = pos.y; + int width = size.x, height = size.y; + + // Set reasonable values for position and size if defaults have been + // requested + // + // MB TODO: something better than these arbitrary values ? + // VZ should use X resources for this... + if ( width == -1 ) + width = 400; + if ( height == -1 ) + height = 400; + + int displayW, displayH; + wxDisplaySize( &displayW, &displayH ); + + if ( x == -1 ) + { + x = (displayW - width) / 2; + if (x < 10) x = 10; + } + if ( y == -1 ) + { + y = (displayH - height) / 2; + if (y < 10) y = 10; + } + + // VZ: what does this do?? + if (wxTopLevelUsed) + { + // Change suggested by Matthew Flatt + m_frameShell = (WXWidget)XtAppCreateShell + ( + name, + wxTheApp->GetClassName(), + topLevelShellWidgetClass, + (Display*) wxGetDisplay(), + NULL, + 0 + ); + } + else + { + m_frameShell = wxTheApp->GetTopLevelWidget(); + wxTopLevelUsed = TRUE; + } + + XtVaSetValues((Widget) m_frameShell, + // Allows menu to resize + XmNallowShellResize, True, + XmNdeleteResponse, XmDO_NOTHING, + XmNmappedWhenManaged, False, + XmNiconic, (style & wxICONIZE) ? TRUE : FALSE, + NULL); + + if (!title.IsEmpty()) + XtVaSetValues((Widget) m_frameShell, + XmNtitle, title.c_str(), + NULL); + + m_frameWidget = (WXWidget) XtVaCreateManagedWidget("main_window", + xmMainWindowWidgetClass, (Widget) m_frameShell, + XmNresizePolicy, XmRESIZE_NONE, + NULL); + + m_workArea = (WXWidget) XtVaCreateWidget("form", + xmFormWidgetClass, (Widget) m_frameWidget, + XmNresizePolicy, XmRESIZE_NONE, + NULL); + + m_clientArea = (WXWidget) XtVaCreateWidget("client", + xmBulletinBoardWidgetClass, (Widget) m_workArea, + XmNmarginWidth, 0, + XmNmarginHeight, 0, + XmNrightAttachment, XmATTACH_FORM, + XmNleftAttachment, XmATTACH_FORM, + XmNtopAttachment, XmATTACH_FORM, + XmNbottomAttachment, XmATTACH_FORM, + // XmNresizePolicy, XmRESIZE_ANY, + NULL); + + wxLogTrace(wxTRACE_Messages, + "Created frame (0x%08x) with work area 0x%08x and client " + "area 0x%08x", m_frameWidget, m_workArea, m_clientArea); + + XtAddEventHandler((Widget) m_clientArea, ExposureMask,FALSE, + wxUniversalRepaintProc, (XtPointer) this); + + XtAddEventHandler((Widget) m_clientArea, + ButtonPressMask | ButtonReleaseMask | PointerMotionMask | KeyPressMask, + FALSE, + wxFrameEventHandler, + (XtPointer)this); + + XtVaSetValues((Widget) m_frameWidget, + XmNworkWindow, (Widget) m_workArea, + NULL); + + XtManageChild((Widget) m_clientArea); + XtManageChild((Widget) m_workArea); + + wxAddWindowToTable((Widget) m_workArea, this); + wxAddWindowToTable((Widget) m_clientArea, this); + + XtTranslations ptr; + + XtOverrideTranslations((Widget) m_workArea, + ptr = XtParseTranslationTable(": resize()")); + + XtFree((char *)ptr); + + XtAddCallback((Widget) m_workArea, XmNfocusCallback, + (XtCallbackProc)wxFrameFocusProc, (XtPointer)this); + + /* Part of show-&-hide fix */ + XtAddEventHandler((Widget) m_frameShell, StructureNotifyMask, + False, (XtEventHandler)wxFrameMapProc, + (XtPointer)m_workArea); + + if (x > -1) + XtVaSetValues((Widget) m_frameShell, XmNx, x, NULL); + if (y > -1) + XtVaSetValues((Widget) m_frameShell, XmNy, y, NULL); + if (width > -1) + XtVaSetValues((Widget) m_frameShell, XmNwidth, width, NULL); + if (height > -1) + XtVaSetValues((Widget) m_frameShell, XmNheight, height, NULL); + + m_mainWidget = m_frameWidget; + + ChangeFont(FALSE); + + // This patch comes from Torsten Liermann lier@lier1.muc.de + if (XmIsMotifWMRunning( (Widget) m_frameShell )) + { + int decor = 0; + if (style & wxRESIZE_BORDER) + decor |= MWM_DECOR_RESIZEH; + if (style & wxSYSTEM_MENU) + decor |= MWM_DECOR_MENU; + if ((style & wxCAPTION) || + (style & wxTINY_CAPTION_HORIZ) || + (style & wxTINY_CAPTION_VERT)) + decor |= MWM_DECOR_TITLE; + if (style & wxTHICK_FRAME) + decor |= MWM_DECOR_BORDER; + if (style & wxTHICK_FRAME) + decor |= MWM_DECOR_BORDER; + if (style & wxMINIMIZE_BOX) + decor |= MWM_DECOR_MINIMIZE; + if (style & wxMAXIMIZE_BOX) + decor |= MWM_DECOR_MAXIMIZE; + XtVaSetValues((Widget) m_frameShell,XmNmwmDecorations,decor,NULL); + } + // This allows non-Motif window managers to support at least the + // no-decorations case. + else + { + if (style == 0) + XtVaSetValues((Widget) m_frameShell,XmNoverrideRedirect,TRUE,NULL); + } + XtRealizeWidget((Widget) m_frameShell); + + // Intercept CLOSE messages from the window manager + Atom WM_DELETE_WINDOW = XmInternAtom(XtDisplay((Widget) m_frameShell), "WM_DELETE_WINDOW", False); +#if (XmREVISION > 1 || XmVERSION > 1) + XmAddWMProtocolCallback((Widget) m_frameShell, WM_DELETE_WINDOW, (XtCallbackProc) wxCloseFrameCallback, (XtPointer)this); +#else +#if XmREVISION == 1 + XmAddWMProtocolCallback((Widget) m_frameShell, WM_DELETE_WINDOW, (XtCallbackProc) wxCloseFrameCallback, (caddr_t)this); +#else + XmAddWMProtocolCallback((Widget) m_frameShell, WM_DELETE_WINDOW, (void (*)())wxCloseFrameCallback, (caddr_t)this); +#endif +#endif + + ChangeBackgroundColour(); + + PreResize(); + + wxSizeEvent sizeEvent(wxSize(width, height), GetId()); + sizeEvent.SetEventObject(this); + + GetEventHandler()->ProcessEvent(sizeEvent); + + return TRUE; +} + +wxFrame::~wxFrame() +{ + m_isBeingDeleted = TRUE; + + if (m_clientArea) + { + XtRemoveEventHandler((Widget) m_clientArea, ExposureMask, FALSE, + wxUniversalRepaintProc, (XtPointer) this); + XtRemoveEventHandler((Widget) m_clientArea, ButtonPressMask | ButtonReleaseMask | PointerMotionMask | KeyPressMask, + FALSE, + wxFrameEventHandler, (XtPointer) this); + wxDeleteWindowFromTable((Widget) m_clientArea); + } + + if (GetMainWidget()) + Show(FALSE); + + if (m_frameMenuBar) + { + m_frameMenuBar->DestroyMenuBar(); + + // Hack to stop core dump on Ultrix, OSF, for some strange reason. +#if MOTIF_MENUBAR_DELETE_FIX + GetMenuBar()->SetMainWidget((WXWidget) NULL); +#endif + delete m_frameMenuBar; + m_frameMenuBar = NULL; + } + + wxTopLevelWindows.DeleteObject(this); + wxModelessWindows.DeleteObject(this); + + if (m_frameStatusBar) + { + delete m_frameStatusBar; + m_frameStatusBar = NULL; + } + + DestroyChildren(); + + if (m_workArea) + { + wxDeleteWindowFromTable((Widget) m_workArea); + + XtDestroyWidget ((Widget) m_workArea); + } + + if (m_frameWidget) + { + wxDeleteWindowFromTable((Widget) m_frameWidget); + XtDestroyWidget ((Widget) m_frameWidget); + } + + if (m_frameShell) + XtDestroyWidget ((Widget) m_frameShell); + + SetMainWidget((WXWidget) NULL); + + /* Check if it's the last top-level window */ + + if (wxTheApp && (wxTopLevelWindows.Number() == 0)) + { + wxTheApp->SetTopWindow(NULL); + + if (wxTheApp->GetExitOnFrameDelete()) + { + // Signal to the app that we're going to close + wxTheApp->ExitMainLoop(); + } + } +} + +// Get size *available for subwindows* i.e. excluding menu bar, toolbar etc. +void wxFrame::DoGetClientSize(int *x, int *y) const +{ + Dimension xx, yy; + XtVaGetValues((Widget) m_workArea, XmNwidth, &xx, XmNheight, &yy, NULL); + + if (m_frameStatusBar) + { + int sbw, sbh; + m_frameStatusBar->GetSize(& sbw, & sbh); + yy -= sbh; + } +#if wxUSE_TOOLBAR + if (m_frameToolBar) + { + int tbw, tbh; + m_frameToolBar->GetSize(& tbw, & tbh); + if (m_frameToolBar->GetWindowStyleFlag() & wxTB_VERTICAL) + xx -= tbw; + else + yy -= tbh; + } +#endif // wxUSE_TOOLBAR + /* + if (GetMenuBar() != (wxMenuBar*) NULL) + { + // it seems that if a frame holds a panel, the menu bar size + // gets automatically taken care of --- grano@cs.helsinki.fi 4.4.95 + bool hasSubPanel = FALSE; + for(wxNode* node = GetChildren().First(); node; node = node->Next()) + { + wxWindow *win = (wxWindow *)node->Data(); + hasSubPanel = (win->IsKindOf(CLASSINFO(wxPanel)) && !win->IsKindOf(CLASSINFO(wxDialog))); + + if (hasSubPanel) + break; + } + if (! hasSubPanel) { + Dimension ys; + XtVaGetValues((Widget) GetMenuBarWidget(), XmNheight, &ys, NULL); + yy -= ys; + } + } + */ + + *x = xx; *y = yy; +} + +// Set the client size (i.e. leave the calculation of borders etc. +// to wxWindows) +void wxFrame::DoSetClientSize(int width, int height) +{ + // Calculate how large the new main window should be + // by finding the difference between the client area and the + // main window area, and adding on to the new client area + if (width > -1) + XtVaSetValues((Widget) m_workArea, XmNwidth, width, NULL); + + if (height > -1) + { + if (m_frameStatusBar) + { + int sbw, sbh; + m_frameStatusBar->GetSize(& sbw, & sbh); + height += sbh; + } +#if wxUSE_TOOLBAR + if (m_frameToolBar) + { + int tbw, tbh; + m_frameToolBar->GetSize(& tbw, & tbh); + if (m_frameToolBar->GetWindowStyleFlag() & wxTB_VERTICAL) + width += tbw; + else + height += tbh; + } +#endif // wxUSE_TOOLBAR + + XtVaSetValues((Widget) m_workArea, XmNheight, height, NULL); + } + PreResize(); + + wxSizeEvent sizeEvent(wxSize(width, height), GetId()); + sizeEvent.SetEventObject(this); + + GetEventHandler()->ProcessEvent(sizeEvent); + +} + +void wxFrame::DoGetSize(int *width, int *height) const +{ + Dimension xx, yy; + XtVaGetValues((Widget) m_frameShell, XmNwidth, &xx, XmNheight, &yy, NULL); + *width = xx; *height = yy; +} + +void wxFrame::DoGetPosition(int *x, int *y) const +{ + Window parent_window = XtWindow((Widget) m_frameShell), + next_parent = XtWindow((Widget) m_frameShell), + root = RootWindowOfScreen(XtScreen((Widget) m_frameShell)); + + // search for the parent that is child of ROOT, because the WM may + // reparent twice and notify only the next parent (like FVWM) + while (next_parent != root) { + Window *theChildren; unsigned int n; + parent_window = next_parent; + XQueryTree(XtDisplay((Widget) m_frameShell), parent_window, &root, + &next_parent, &theChildren, &n); + XFree(theChildren); // not needed + } + int xx, yy; unsigned int dummy; + XGetGeometry(XtDisplay((Widget) m_frameShell), parent_window, &root, + &xx, &yy, &dummy, &dummy, &dummy, &dummy); + if (x) *x = xx; + if (y) *y = yy; +} + +void wxFrame::DoSetSize(int x, int y, int width, int height, int WXUNUSED(sizeFlags)) +{ + if (x > -1) + XtVaSetValues((Widget) m_frameShell, XmNx, x, NULL); + if (y > -1) + XtVaSetValues((Widget) m_frameShell, XmNy, y, NULL); + if (width > -1) + XtVaSetValues((Widget) m_frameWidget, XmNwidth, width, NULL); + if (height > -1) + XtVaSetValues((Widget) m_frameWidget, XmNheight, height, NULL); + + if (!(height == -1 && width == -1)) + { + PreResize(); + + wxSizeEvent sizeEvent(wxSize(width, height), GetId()); + sizeEvent.SetEventObject(this); + + GetEventHandler()->ProcessEvent(sizeEvent); + } +} + +bool wxFrame::Show(bool show) +{ + if (!m_frameShell) + return wxWindow::Show(show); + + m_visibleStatus = show; /* show-&-hide fix */ + + m_isShown = show; + if (show) { + XtMapWidget((Widget) m_frameShell); + XRaiseWindow(XtDisplay((Widget) m_frameShell), XtWindow((Widget) m_frameShell)); + } else { + XtUnmapWidget((Widget) m_frameShell); + // XmUpdateDisplay(wxTheApp->topLevel); // Experimental: may be responsible for crashes + } + return TRUE; +} + +void wxFrame::Iconize(bool iconize) +{ + if (!iconize) + Show(TRUE); + + if (m_frameShell) + XtVaSetValues((Widget) m_frameShell, XmNiconic, (Boolean)iconize, NULL); +} + +void wxFrame::Restore() +{ + if ( m_frameShell ) + XtVaSetValues((Widget) m_frameShell, XmNiconic, FALSE, NULL); +} + +void wxFrame::Maximize(bool maximize) +{ + Show(TRUE); + + if ( maximize ) + Restore(); +} + +bool wxFrame::IsIconized() const +{ + if (!m_frameShell) + return FALSE; + + Boolean iconic; + XtVaGetValues((Widget) m_frameShell, XmNiconic, &iconic, NULL); + return iconic; +} + +// Is it maximized? +bool wxFrame::IsMaximized() const +{ + // No maximizing in Motif (?) + return FALSE; +} + +void wxFrame::SetTitle(const wxString& title) +{ + if (title == m_title) + return; + + m_title = title; + + if (!title.IsNull()) + XtVaSetValues((Widget) m_frameShell, + XmNtitle, title.c_str(), + XmNiconName, title.c_str(), + NULL); +} + +void wxFrame::SetIcon(const wxIcon& icon) +{ + m_icon = icon; + + if (!m_frameShell) + return; + + if (!icon.Ok() || !icon.GetPixmap()) + return; + + XtVaSetValues((Widget) m_frameShell, XtNiconPixmap, icon.GetPixmap(), NULL); +} + +void wxFrame::PositionStatusBar() +{ + if (!m_frameStatusBar) + return; + + int w, h; + GetClientSize(&w, &h); + int sw, sh; + m_frameStatusBar->GetSize(&sw, &sh); + + // Since we wish the status bar to be directly under the client area, + // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS. + m_frameStatusBar->SetSize(0, h, w, sh); +} + +WXWidget wxFrame::GetMenuBarWidget() const +{ + if (GetMenuBar()) + return GetMenuBar()->GetMainWidget(); + else + return (WXWidget) NULL; +} + +void wxFrame::SetMenuBar(wxMenuBar *menuBar) +{ + if (!menuBar) + { + m_frameMenuBar = NULL; + return; + } + + // Currently can't set it twice + // wxASSERT_MSG( (m_frameMenuBar == (wxMenuBar*) NULL), "Cannot set the menubar more than once"); + + if (m_frameMenuBar) + { + m_frameMenuBar->DestroyMenuBar(); + delete m_frameMenuBar; + } + + m_frameMenuBar = menuBar; + m_frameMenuBar->CreateMenuBar(this); +} + +// Responds to colour changes, and passes event on to children. +void wxFrame::OnSysColourChanged(wxSysColourChangedEvent& event) +{ + SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE)); + Refresh(); + + if ( m_frameStatusBar ) + { + wxSysColourChangedEvent event2; + event2.SetEventObject( m_frameStatusBar ); + m_frameStatusBar->ProcessEvent(event2); + } + + // Propagate the event to the non-top-level children + wxWindow::OnSysColourChanged(event); +} + +// Default activation behaviour - set the focus for the first child +// subwindow found. +void wxFrame::OnActivate(wxActivateEvent& event) +{ + if (!event.GetActive()) + return; + + for(wxNode *node = GetChildren().First(); node; node = node->Next()) + { + // Find a child that's a subwindow, but not a dialog box. + wxWindow *child = (wxWindow *)node->Data(); + if (!child->IsKindOf(CLASSINFO(wxFrame)) && + !child->IsKindOf(CLASSINFO(wxDialog))) + { + child->SetFocus(); + return; + } + } +} + +#if wxUSE_TOOLBAR + +wxToolBar* wxFrame::CreateToolBar(long style, + wxWindowID id, + const wxString& name) +{ + if ( wxFrameBase::CreateToolBar(style, id, name) ) + { + PositionToolBar(); + } + + return m_frameToolBar; +} + +void wxFrame::PositionToolBar() +{ + if (GetToolBar()) + { + int cw, ch; + GetClientSize(& cw, &ch); + + int tw, th; + GetToolBar()->GetSize(& tw, & th); + + if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL) + { + // 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 + th, wxSIZE_NO_ADJUSTMENTS); + } + else + { + // Use the 'real' position + GetToolBar()->SetSize(0, 0, cw, th, wxSIZE_NO_ADJUSTMENTS); + } + } +} +#endif // wxUSE_TOOLBAR + +void wxFrame::Raise() +{ + Window parent_window = XtWindow((Widget) m_frameShell), + next_parent = XtWindow((Widget) m_frameShell), + root = RootWindowOfScreen(XtScreen((Widget) m_frameShell)); + // search for the parent that is child of ROOT, because the WM may + // reparent twice and notify only the next parent (like FVWM) + while (next_parent != root) { + Window *theChildren; unsigned int n; + parent_window = next_parent; + XQueryTree(XtDisplay((Widget) m_frameShell), parent_window, &root, + &next_parent, &theChildren, &n); + XFree(theChildren); // not needed + } + XRaiseWindow(XtDisplay((Widget) m_frameShell), parent_window); +} + +void wxFrame::Lower() +{ + Window parent_window = XtWindow((Widget) m_frameShell), + next_parent = XtWindow((Widget) m_frameShell), + root = RootWindowOfScreen(XtScreen((Widget) m_frameShell)); + // search for the parent that is child of ROOT, because the WM may + // reparent twice and notify only the next parent (like FVWM) + while (next_parent != root) { + Window *theChildren; unsigned int n; + parent_window = next_parent; + XQueryTree(XtDisplay((Widget) m_frameShell), parent_window, &root, + &next_parent, &theChildren, &n); + XFree(theChildren); // not needed + } + XLowerWindow(XtDisplay((Widget) m_frameShell), parent_window); +} + +void wxFrameFocusProc(Widget WXUNUSED(workArea), XtPointer WXUNUSED(clientData), + XmAnyCallbackStruct *WXUNUSED(cbs)) +{ + // wxDebugMsg("focus proc from frame %ld\n",(long)frame); + // TODO + // wxFrame *frame = (wxFrame *)clientData; + // frame->GetEventHandler()->OnSetFocus(); +} + +/* MATTEW: Used to insure that hide-&-show within an event cycle works */ +static void wxFrameMapProc(Widget frameShell, XtPointer clientData, + XCrossingEvent * event) +{ + wxFrame *frame = (wxFrame *)wxGetWindowFromTable((Widget)clientData); + + if (frame) { + XEvent *e = (XEvent *)event; + + if (e->xany.type == MapNotify) + { + // Iconize fix + XtVaSetValues(frameShell, XmNiconic, (Boolean)False, NULL); + if (!frame->GetVisibleStatus()) + { + /* We really wanted this to be hidden! */ + XtUnmapWidget((Widget) frame->GetShellWidget()); + } + } + else if (e->xany.type == UnmapNotify) + // Iconize fix + XtVaSetValues(frameShell, XmNiconic, (Boolean)True, NULL); + } +} + +//// Motif-specific +bool wxFrame::PreResize() +{ +#if wxUSE_TOOLBAR + PositionToolBar(); +#endif // wxUSE_TOOLBAR + +#if wxUSE_STATUSBAR + PositionStatusBar(); +#endif // wxUSE_STATUSBAR + + return TRUE; +} + +WXWidget wxFrame::GetClientWidget() const +{ + return m_clientArea; +} + +void wxFrame::ChangeFont(bool WXUNUSED(keepOriginalSize)) +{ + // TODO +} + +void wxFrame::ChangeBackgroundColour() +{ + if (GetClientWidget()) + DoChangeBackgroundColour(GetClientWidget(), m_backgroundColour); +} + +void wxFrame::ChangeForegroundColour() +{ + if (GetClientWidget()) + DoChangeForegroundColour(GetClientWidget(), m_foregroundColour); +} + +void wxCloseFrameCallback(Widget WXUNUSED(widget), XtPointer client_data, XmAnyCallbackStruct *WXUNUSED(cbs)) +{ + wxFrame *frame = (wxFrame *)client_data; + + wxCloseEvent closeEvent(wxEVT_CLOSE_WINDOW, frame->GetId()); + closeEvent.SetEventObject(frame); + + // May delete the frame (with delayed deletion) + frame->GetEventHandler()->ProcessEvent(closeEvent); +} + +static void wxFrameEventHandler(Widget wid, + XtPointer WXUNUSED(client_data), + XEvent* event, + Boolean* continueToDispatch) +{ + wxFrame *frame = (wxFrame *)wxGetWindowFromTable(wid); + if (frame) + { + wxMouseEvent wxevent(wxEVT_NULL); + if (wxTranslateMouseEvent(wxevent, frame, wid, event)) + { + wxevent.SetEventObject(frame); + wxevent.SetId(frame->GetId()); + frame->GetEventHandler()->ProcessEvent(wxevent); + } + else + { + // An attempt to implement OnCharHook by calling OnCharHook first; + // if this returns TRUE, set continueToDispatch to False + // (don't continue processing). + // Otherwise set it to True and call OnChar. + wxKeyEvent keyEvent(wxEVT_CHAR); + if (wxTranslateKeyEvent(keyEvent, frame, wid, event)) + { + keyEvent.SetEventObject(frame); + keyEvent.SetId(frame->GetId()); + keyEvent.SetEventType(wxEVT_CHAR_HOOK); + if (frame->GetEventHandler()->ProcessEvent(keyEvent)) + { + *continueToDispatch = False; + return; + } + else + { + // For simplicity, OnKeyDown is the same as OnChar + // TODO: filter modifier key presses from OnChar + keyEvent.SetEventType(wxEVT_KEY_DOWN); + + // Only process OnChar if OnKeyDown didn't swallow it + if (!frame->GetEventHandler()->ProcessEvent (keyEvent)) + { + keyEvent.SetEventType(wxEVT_CHAR); + frame->GetEventHandler()->ProcessEvent(keyEvent); + } + } + } + } + } + *continueToDispatch = True; +} diff --git a/src/x11/utils.cpp b/src/x11/utils.cpp new file mode 100644 index 0000000000..9f6ed67e35 --- /dev/null +++ b/src/x11/utils.cpp @@ -0,0 +1,1233 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: utils.cpp +// Purpose: Various utilities +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +// ============================================================================ +// declarations +// ============================================================================ + +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- + +#ifdef __VMS +#define XtDisplay XTDISPLAY +#endif + +#include "wx/setup.h" +#include "wx/utils.h" +#include "wx/app.h" +#include "wx/msgdlg.h" +#include "wx/cursor.h" +#include "wx/window.h" // for wxTopLevelWindows + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if (defined(__SUNCC__) || defined(__CLCC__)) + #include +#endif + +#ifdef __VMS__ +#pragma message disable nosimpint +#endif +#include +#ifdef __VMS__ +#pragma message enable nosimpint +#endif + +#include "wx/unix/execute.h" + +#include "wx/motif/private.h" + +// ---------------------------------------------------------------------------- +// private functions +// ---------------------------------------------------------------------------- + +// 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); + +// ============================================================================ +// implementation +// ============================================================================ + +// ---------------------------------------------------------------------------- +// async event processing +// ---------------------------------------------------------------------------- + +// Consume all events until no more left +void wxFlushEvents() +{ + Display *display = (Display*) wxGetDisplay(); + + XSync (display, FALSE); + + // 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); + } +} + +// Check whether this window wants to process messages, e.g. Stop button +// in long calculations. +bool wxCheckForInterrupt(wxWindow *wnd) +{ + wxCHECK_MSG( wnd, FALSE, "NULL window in wxCheckForInterrupt" ); + + Display *dpy=(Display*) wnd->GetXDisplay(); + Window win=(Window) wnd->GetXWindow(); + XEvent event; + XFlush(dpy); + if (wnd->GetMainWidget()) + { + XmUpdateDisplay((Widget)(wnd->GetMainWidget())); + } + + bool hadEvents = FALSE; + while( XCheckMaskEvent(dpy, + ButtonPressMask|ButtonReleaseMask|ButtonMotionMask| + PointerMotionMask|KeyPressMask|KeyReleaseMask, + &event) ) + { + if ( event.xany.window == win ) + { + hadEvents = TRUE; + + XtDispatchEvent(&event); + } + } + + return hadEvents; +} + +// ---------------------------------------------------------------------------- +// wxExecute stuff +// ---------------------------------------------------------------------------- + +static void xt_notify_end_process(XtPointer data, int *WXUNUSED(fid), + XtInputId *id) +{ + wxEndProcessData *proc_data = (wxEndProcessData *)data; + + wxHandleProcessTermination(proc_data); + + // VZ: I think they should be the same... + wxASSERT( (int)*id == proc_data->tag ); + + XtRemoveInput(*id); +} + +int wxAddProcessCallback(wxEndProcessData *proc_data, int fd) +{ + XtInputId id = XtAppAddInput((XtAppContext) wxTheApp->GetAppContext(), + fd, + (XtPointer *) XtInputReadMask, + (XtInputCallbackProc) xt_notify_end_process, + (XtPointer) proc_data); + + return (int)id; +} + +// ---------------------------------------------------------------------------- +// misc +// ---------------------------------------------------------------------------- + +// Emit a beeeeeep +void wxBell() +{ + // Use current setting for the bell + XBell ((Display*) wxGetDisplay(), 0); +} + +int wxGetOsVersion(int *majorVsn, int *minorVsn) +{ + // FIXME TODO + // This code is WRONG!! Does NOT return the + // Motif version of the libs but the X protocol + // version! + 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) +// ---------------------------------------------------------------------------- + +// 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; +} + +#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) + { + const char *file = node->GetKeyString(); + // 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) +{ + 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) +{ + char buf[50]; + sprintf(buf, "%.4f", value); + return wxWriteResource(section, entry, buf, file); +} + +bool wxWriteResource(const wxString& section, const wxString& entry, long value, const wxString& file) +{ + char buf[50]; + sprintf(buf, "%ld", value); + return wxWriteResource(section, entry, buf, file); +} + +bool wxWriteResource(const wxString& section, const wxString& entry, int value, const wxString& file) +{ + char buf[50]; + sprintf(buf, "%d", value); + return wxWriteResource(section, entry, buf, file); +} + +bool wxGetResource(const wxString& section, const wxString& entry, char **value, const wxString& file) +{ + 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) +{ + char *s = NULL; + bool succ = wxGetResource(section, entry, (char **)&s, file); + if (succ) + { + *value = (float)strtod(s, NULL); + delete[] s; + return TRUE; + } + else return FALSE; +} + +bool wxGetResource(const wxString& section, const wxString& entry, long *value, const wxString& file) +{ + char *s = NULL; + bool succ = wxGetResource(section, entry, (char **)&s, file); + if (succ) + { + *value = strtol(s, NULL, 10); + delete[] s; + return TRUE; + } + else return FALSE; +} + +bool wxGetResource(const wxString& section, const wxString& entry, int *value, const wxString& file) +{ + char *s = NULL; + bool succ = wxGetResource(section, entry, (char **)&s, file); + if (succ) + { + // 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; +} + +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); + wxString hostname = wxGetHostName(); + if ( !!hostname ) + strncat(environment, hostname, 1024 - len); + } + 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 + +// ---------------------------------------------------------------------------- +// busy cursor stuff +// ---------------------------------------------------------------------------- + +static int wxBusyCursorCount = 0; + +// Helper function +static void +wxXSetBusyCursor (wxWindow * win, wxCursor * cursor) +{ + Display *display = (Display*) win->GetXDisplay(); + + Window xwin = (Window) win->GetXWindow(); + if (!xwin) + return; + + 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++; + if (wxBusyCursorCount == 1) + { + for(wxNode *node = wxTopLevelWindows.First (); node; node = node->Next()) + { + wxWindow *win = (wxWindow *) node->Data (); + wxXSetBusyCursor (win, cursor); + } + } +} + +// Restore cursor to normal +void wxEndBusyCursor() +{ + if (wxBusyCursorCount == 0) + return; + + wxBusyCursorCount--; + if (wxBusyCursorCount == 0) + { + for(wxNode *node = wxTopLevelWindows.First (); node; node = node->Next()) + { + wxWindow *win = (wxWindow *) node->Data (); + wxXSetBusyCursor (win, NULL); + } + } +} + +// TRUE if we're between the above two calls +bool wxIsBusy() +{ + return (wxBusyCursorCount > 0); +} + +// ---------------------------------------------------------------------------- +// display info +// ---------------------------------------------------------------------------- + +void wxGetMousePosition( int* x, int* y ) +{ + 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 +bool wxColourDisplay() +{ + return wxDisplayDepth() > 1; +} + +// Returns depth of screen +int wxDisplayDepth() +{ + Display *dpy = (Display*) wxGetDisplay(); + + return DefaultDepth (dpy, DefaultScreen (dpy)); +} + +// Get size of display +void wxDisplaySize(int *width, int *height) +{ + Display *dpy = (Display*) wxGetDisplay(); + + if ( width ) + *width = DisplayWidth (dpy, DefaultScreen (dpy)); + if ( height ) + *height = DisplayHeight (dpy, DefaultScreen (dpy)); +} + +void wxDisplaySizeMM(int *width, int *height) +{ + Display *dpy = (Display*) wxGetDisplay(); + + if ( width ) + *width = DisplayWidthMM(dpy, DefaultScreen (dpy)); + if ( height ) + *height = DisplayHeightMM(dpy, DefaultScreen (dpy)); +} + +void wxClientDisplayRect(int *x, int *y, int *width, int *height) +{ + // This is supposed to return desktop dimensions minus any window + // manager panels, menus, taskbars, etc. If there is a way to do that + // for this platform please fix this function, otherwise it defaults + // to the entire desktop. + if (x) *x = 0; + if (y) *y = 0; + wxDisplaySize(width, height); +} + + +// Configurable display in Motif +static WXDisplay *gs_currentDisplay = NULL; +static wxString gs_displayName; + +WXDisplay *wxGetDisplay() +{ + if (gs_currentDisplay) + return gs_currentDisplay; + + if (wxTheApp && wxTheApp->GetTopLevelWidget()) + return XtDisplay ((Widget) wxTheApp->GetTopLevelWidget()); + else if (wxTheApp) + return wxTheApp->GetInitialDisplay(); + else + return (WXDisplay*) NULL; +} + +bool wxSetDisplay(const wxString& display_name) +{ + gs_displayName = display_name; + + if ( !display_name ) + { + gs_currentDisplay = NULL; + + return TRUE; + } + else + { + Cardinal argc = 0; + + Display *display = XtOpenDisplay((XtAppContext) wxTheApp->GetAppContext(), + (const char*) display_name, + (const char*) wxTheApp->GetAppName(), + (const char*) wxTheApp->GetClassName(), + NULL, +#if XtSpecificationRelease < 5 + 0, &argc, +#else + 0, (int *)&argc, +#endif + NULL); + + if (display) + { + gs_currentDisplay = (WXDisplay*) display; + return TRUE; + } + else + return FALSE; + } +} + +wxString wxGetDisplayName() +{ + return gs_displayName; +} + +wxWindow* wxFindWindowAtPoint(const wxPoint& pt) +{ + return wxGenericFindWindowAtPoint(pt); +} + +// ---------------------------------------------------------------------------- +// accelerators +// ---------------------------------------------------------------------------- + +// Find the letter corresponding to the mnemonic, for Motif +char wxFindMnemonic (const char *s) +{ + char mnem = 0; + int len = strlen (s); + int i; + for (i = 0; i < len; i++) + { + if (s[i] == '&') + { + // Carefully handle && + if ((i + 1) <= len && s[i + 1] == '&') + i++; + else + { + mnem = s[i + 1]; + break; + } + } + } + return mnem; +} + +char * wxFindAccelerator (const char *s) +{ + // VZ: this function returns incorrect keysym which completely breaks kbd + // handling + return NULL; + +#if 0 + // The accelerator text is after the \t char. + while (*s && *s != '\t') + s++; + if (*s == '\0') + return (NULL); + s++; + /* + Now we need to format it as X standard: + + input output + + F7 --> F7 + Ctrl+N --> CtrlN + Alt+k --> Metak + Ctrl+Shift+A --> Ctrl ShiftA + + */ + + wxBuffer[0] = '\0'; + char *tmp = copystring (s); + s = tmp; + char *p = tmp; + + while (1) + { + while (*p && *p != '+') + p++; + if (*p) + { + *p = '\0'; + if (wxBuffer[0]) + strcat (wxBuffer, " "); + if (strcmp (s, "Alt")) + strcat (wxBuffer, s); + else + strcat (wxBuffer, "Meta"); + s = p++; + } + else + { + strcat (wxBuffer, ""); + strcat (wxBuffer, s); + break; + } + } + delete[]tmp; + return wxBuffer; +#endif +} + +XmString wxFindAcceleratorText (const char *s) +{ + // VZ: this function returns incorrect keysym which completely breaks kbd + // handling + return NULL; + +#if 0 + // The accelerator text is after the \t char. + while (*s && *s != '\t') + s++; + if (*s == '\0') + return (NULL); + s++; + XmString text = XmStringCreateSimple ((char *)s); + return text; +#endif +} + +// ---------------------------------------------------------------------------- +// keycode translations +// ---------------------------------------------------------------------------- + +#include + +// FIXME what about tables?? + +int wxCharCodeXToWX(KeySym keySym) +{ + int id; + switch (keySym) + { + case XK_Shift_L: + case XK_Shift_R: + id = WXK_SHIFT; break; + case XK_Control_L: + case XK_Control_R: + id = WXK_CONTROL; break; + case XK_BackSpace: + id = WXK_BACK; break; + case XK_Delete: + id = WXK_DELETE; break; + case XK_Clear: + id = WXK_CLEAR; break; + case XK_Tab: + id = WXK_TAB; break; + case XK_numbersign: + id = '#'; break; + case XK_Return: + id = WXK_RETURN; break; + case XK_Escape: + id = WXK_ESCAPE; break; + case XK_Pause: + case XK_Break: + id = WXK_PAUSE; break; + case XK_Num_Lock: + id = WXK_NUMLOCK; break; + case XK_Scroll_Lock: + id = WXK_SCROLL; break; + + case XK_Home: + id = WXK_HOME; break; + case XK_End: + id = WXK_END; break; + case XK_Left: + id = WXK_LEFT; break; + case XK_Right: + id = WXK_RIGHT; break; + case XK_Up: + id = WXK_UP; break; + case XK_Down: + id = WXK_DOWN; break; + case XK_Next: + id = WXK_NEXT; break; + case XK_Prior: + id = WXK_PRIOR; break; + case XK_Menu: + id = WXK_MENU; break; + case XK_Select: + id = WXK_SELECT; break; + case XK_Cancel: + id = WXK_CANCEL; break; + case XK_Print: + id = WXK_PRINT; break; + case XK_Execute: + id = WXK_EXECUTE; break; + case XK_Insert: + id = WXK_INSERT; break; + case XK_Help: + id = WXK_HELP; break; + + case XK_KP_Multiply: + id = WXK_MULTIPLY; break; + case XK_KP_Add: + id = WXK_ADD; break; + case XK_KP_Subtract: + id = WXK_SUBTRACT; break; + case XK_KP_Divide: + id = WXK_DIVIDE; break; + case XK_KP_Decimal: + id = WXK_DECIMAL; break; + case XK_KP_Equal: + id = '='; break; + case XK_KP_Space: + id = ' '; break; + case XK_KP_Tab: + id = WXK_TAB; break; + case XK_KP_Enter: + id = WXK_RETURN; break; + case XK_KP_0: + id = WXK_NUMPAD0; break; + case XK_KP_1: + id = WXK_NUMPAD1; break; + case XK_KP_2: + id = WXK_NUMPAD2; break; + case XK_KP_3: + id = WXK_NUMPAD3; break; + case XK_KP_4: + id = WXK_NUMPAD4; break; + case XK_KP_5: + id = WXK_NUMPAD5; break; + case XK_KP_6: + id = WXK_NUMPAD6; break; + case XK_KP_7: + id = WXK_NUMPAD7; break; + case XK_KP_8: + id = WXK_NUMPAD8; break; + case XK_KP_9: + id = WXK_NUMPAD9; break; + case XK_F1: + id = WXK_F1; break; + case XK_F2: + id = WXK_F2; break; + case XK_F3: + id = WXK_F3; break; + case XK_F4: + id = WXK_F4; break; + case XK_F5: + id = WXK_F5; break; + case XK_F6: + id = WXK_F6; break; + case XK_F7: + id = WXK_F7; break; + case XK_F8: + id = WXK_F8; break; + case XK_F9: + id = WXK_F9; break; + case XK_F10: + id = WXK_F10; break; + case XK_F11: + id = WXK_F11; break; + case XK_F12: + id = WXK_F12; break; + case XK_F13: + id = WXK_F13; break; + case XK_F14: + id = WXK_F14; break; + case XK_F15: + id = WXK_F15; break; + case XK_F16: + id = WXK_F16; break; + case XK_F17: + id = WXK_F17; break; + case XK_F18: + id = WXK_F18; break; + case XK_F19: + id = WXK_F19; break; + case XK_F20: + id = WXK_F20; break; + case XK_F21: + id = WXK_F21; break; + case XK_F22: + id = WXK_F22; break; + case XK_F23: + id = WXK_F23; break; + case XK_F24: + id = WXK_F24; break; + default: + id = (keySym <= 255) ? (int)keySym : -1; + } + + return id; +} + +KeySym wxCharCodeWXToX(int id) +{ + KeySym keySym; + + switch (id) + { + case WXK_CANCEL: keySym = XK_Cancel; break; + case WXK_BACK: keySym = XK_BackSpace; break; + case WXK_TAB: keySym = XK_Tab; break; + case WXK_CLEAR: keySym = XK_Clear; break; + case WXK_RETURN: keySym = XK_Return; break; + case WXK_SHIFT: keySym = XK_Shift_L; break; + case WXK_CONTROL: keySym = XK_Control_L; break; + case WXK_MENU : keySym = XK_Menu; break; + case WXK_PAUSE: keySym = XK_Pause; break; + case WXK_ESCAPE: keySym = XK_Escape; break; + case WXK_SPACE: keySym = ' '; break; + case WXK_PRIOR: keySym = XK_Prior; break; + case WXK_NEXT : keySym = XK_Next; break; + case WXK_END: keySym = XK_End; break; + case WXK_HOME : keySym = XK_Home; break; + case WXK_LEFT : keySym = XK_Left; break; + case WXK_UP: keySym = XK_Up; break; + case WXK_RIGHT: keySym = XK_Right; break; + case WXK_DOWN : keySym = XK_Down; break; + case WXK_SELECT: keySym = XK_Select; break; + case WXK_PRINT: keySym = XK_Print; break; + case WXK_EXECUTE: keySym = XK_Execute; break; + case WXK_INSERT: keySym = XK_Insert; break; + case WXK_DELETE: keySym = XK_Delete; break; + case WXK_HELP : keySym = XK_Help; break; + case WXK_NUMPAD0: keySym = XK_KP_0; break; + case WXK_NUMPAD1: keySym = XK_KP_1; break; + case WXK_NUMPAD2: keySym = XK_KP_2; break; + case WXK_NUMPAD3: keySym = XK_KP_3; break; + case WXK_NUMPAD4: keySym = XK_KP_4; break; + case WXK_NUMPAD5: keySym = XK_KP_5; break; + case WXK_NUMPAD6: keySym = XK_KP_6; break; + case WXK_NUMPAD7: keySym = XK_KP_7; break; + case WXK_NUMPAD8: keySym = XK_KP_8; break; + case WXK_NUMPAD9: keySym = XK_KP_9; break; + case WXK_MULTIPLY: keySym = XK_KP_Multiply; break; + case WXK_ADD: keySym = XK_KP_Add; break; + case WXK_SUBTRACT: keySym = XK_KP_Subtract; break; + case WXK_DECIMAL: keySym = XK_KP_Decimal; break; + case WXK_DIVIDE: keySym = XK_KP_Divide; break; + case WXK_F1: keySym = XK_F1; break; + case WXK_F2: keySym = XK_F2; break; + case WXK_F3: keySym = XK_F3; break; + case WXK_F4: keySym = XK_F4; break; + case WXK_F5: keySym = XK_F5; break; + case WXK_F6: keySym = XK_F6; break; + case WXK_F7: keySym = XK_F7; break; + case WXK_F8: keySym = XK_F8; break; + case WXK_F9: keySym = XK_F9; break; + case WXK_F10: keySym = XK_F10; break; + case WXK_F11: keySym = XK_F11; break; + case WXK_F12: keySym = XK_F12; break; + case WXK_F13: keySym = XK_F13; break; + case WXK_F14: keySym = XK_F14; break; + case WXK_F15: keySym = XK_F15; break; + case WXK_F16: keySym = XK_F16; break; + case WXK_F17: keySym = XK_F17; break; + case WXK_F18: keySym = XK_F18; break; + case WXK_F19: keySym = XK_F19; break; + case WXK_F20: keySym = XK_F20; break; + case WXK_F21: keySym = XK_F21; break; + case WXK_F22: keySym = XK_F22; break; + case WXK_F23: keySym = XK_F23; break; + case WXK_F24: keySym = XK_F24; break; + case WXK_NUMLOCK: keySym = XK_Num_Lock; break; + case WXK_SCROLL: keySym = XK_Scroll_Lock; break; + default: keySym = id <= 255 ? (KeySym)id : 0; + } + + return keySym; +} + +// ---------------------------------------------------------------------------- +// Some colour manipulation routines +// ---------------------------------------------------------------------------- + +void wxHSVToXColor(wxHSV *hsv,XColor *rgb) +{ + int h = hsv->h; + int s = hsv->s; + int v = hsv->v; + int r = 0, g = 0, b = 0; + 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 = 0, 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 = 0; + 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 = 0, 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; + +/* FIXME, TODO + 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); + } +} + + +// These functions duplicate those in wxWindow, but are needed +// for use outside of wxWindow (e.g. wxMenu, wxMenuBar). + +// Change a widget's foreground and background colours. + +void wxDoChangeForegroundColour(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. + + XtVaSetValues ((Widget) widget, + XmNforeground, foregroundColour.AllocColour(XtDisplay((Widget) widget)), + NULL); +} + +void wxDoChangeBackgroundColour(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); + + if (changeArmColour) + XtVaSetValues ((Widget) widget, + XmNarmColor, g_itemColors[wxSELE_INDEX].pixel, + NULL); +} + diff --git a/src/x11/window.cpp b/src/x11/window.cpp new file mode 100644 index 0000000000..d0a7035d95 --- /dev/null +++ b/src/x11/window.cpp @@ -0,0 +1,3024 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: windows.cpp +// Purpose: wxWindow +// Author: Julian Smart +// Modified by: +// Created: 17/09/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +// ============================================================================ +// declarations +// ============================================================================ + +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- + +#ifdef __GNUG__ + #pragma implementation "window.h" +#endif + +#ifdef __VMS +#define XtDisplay XTDISPLAY +#define XtWindow XTWINDOW +#define XtScreen XTSCREEN +#endif + +#include "wx/setup.h" +#include "wx/menu.h" +#include "wx/dc.h" +#include "wx/dcclient.h" +#include "wx/utils.h" +#include "wx/app.h" +#include "wx/panel.h" +#include "wx/layout.h" +#include "wx/dialog.h" +#include "wx/listbox.h" +#include "wx/button.h" +#include "wx/settings.h" +#include "wx/msgdlg.h" +#include "wx/frame.h" +#include "wx/scrolwin.h" +#include "wx/module.h" +#include "wx/menuitem.h" +#include "wx/log.h" + +#if wxUSE_DRAG_AND_DROP + #include "wx/dnd.h" +#endif + +#ifdef __VMS__ +#pragma message disable nosimpint +#endif +#include + +#include +#include +#include +#include +#include +#include // for XmMenuPosition +#ifdef __VMS__ +#pragma message enable nosimpint +#endif + +#include "wx/motif/private.h" + +#include + +// ---------------------------------------------------------------------------- +// constants +// ---------------------------------------------------------------------------- + +static const int SCROLL_MARGIN = 4; + +// ---------------------------------------------------------------------------- +// global variables for this module +// ---------------------------------------------------------------------------- + +extern wxHashTable *wxWidgetHashTable; +static wxWindow* g_captureWindow = NULL; + + +// ---------------------------------------------------------------------------- +// private functions +// ---------------------------------------------------------------------------- + +static void wxCanvasRepaintProc(Widget, XtPointer, XmDrawingAreaCallbackStruct * cbs); +static void wxCanvasInputEvent(Widget drawingArea, XtPointer data, XmDrawingAreaCallbackStruct * cbs); +static void wxCanvasMotionEvent(Widget, XButtonEvent * event); +static void wxCanvasEnterLeave(Widget drawingArea, XtPointer clientData, XCrossingEvent * event); +static void wxScrollBarCallback(Widget widget, XtPointer clientData, + XmScrollBarCallbackStruct *cbs); +static void wxPanelItemEventHandler(Widget wid, + XtPointer client_data, + XEvent* event, + Boolean *continueToDispatch); + +// unused for now +#if 0 + +// Helper function for 16-bit fonts +static int str16len(const char *s) +{ + int count = 0; + + while (s[0] && s[1]) { + count++; + s += 2; + } + + return count; +} + +#endif // 0 + +// ---------------------------------------------------------------------------- +// macros +// ---------------------------------------------------------------------------- + +#define event_left_is_down(x) ((x)->xbutton.state & Button1Mask) +#define event_middle_is_down(x) ((x)->xbutton.state & Button2Mask) +#define event_right_is_down(x) ((x)->xbutton.state & Button3Mask) + +// ---------------------------------------------------------------------------- +// event tables +// ---------------------------------------------------------------------------- + + IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowBase) + + BEGIN_EVENT_TABLE(wxWindow, wxWindowBase) + EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged) + EVT_IDLE(wxWindow::OnIdle) + END_EVENT_TABLE() + +// ============================================================================ +// implementation +// ============================================================================ + +// ---------------------------------------------------------------------------- +// helper functions +// ---------------------------------------------------------------------------- + +void wxWindow::UnmanageAndDestroy(WXWidget widget) +{ + Widget w = (Widget)widget; + if ( w ) + { + XtUnmanageChild(w); + XtDestroyWidget(w); + } +} + +bool wxWindow::MapOrUnmap(WXWidget widget, bool map) +{ + Widget w = (Widget)widget; + if ( !w ) + return FALSE; + + if ( map ) + XtMapWidget(w); + else + XtUnmapWidget(w); + + return TRUE; +} + +// ---------------------------------------------------------------------------- +// constructors +// ---------------------------------------------------------------------------- + +void wxWindow::Init() +{ + // generic initializations first + InitBase(); + + // Motif-specific + m_needsRefresh = TRUE; + m_mainWidget = (WXWidget) 0; + + m_button1Pressed = + m_button2Pressed = + m_button3Pressed = FALSE; + + m_winCaptured = FALSE; + + m_isShown = TRUE; + m_isBeingDeleted = FALSE; + + m_hScrollBar = + m_vScrollBar = + m_borderWidget = + m_scrolledWindow = + m_drawingArea = (WXWidget) 0; + + m_hScroll = + m_vScroll = FALSE; + + m_scrollPosX = + m_scrollPosY = 0; + + m_backingPixmap = (WXPixmap) 0; + m_pixmapWidth = + m_pixmapHeight = 0; + + m_pixmapOffsetX = + m_pixmapOffsetY = 0; + + m_lastTS = 0; + m_lastButton = 0; + m_canAddEventHandler = FALSE; +} + +// real construction (Init() must have been called before!) +bool wxWindow::Create(wxWindow *parent, wxWindowID id, + const wxPoint& pos, + const wxSize& size, + long style, + const wxString& name) +{ + wxCHECK_MSG( parent, FALSE, "can't create wxWindow without parent" ); + + CreateBase(parent, id, pos, size, style, wxDefaultValidator, name); + + parent->AddChild(this); + + m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); + m_foregroundColour = *wxBLACK; + + //// TODO: we should probably optimize by only creating a + //// a drawing area if we have one or more scrollbars (wxVSCROLL/wxHSCROLL). + //// But for now, let's simplify things by always creating the + //// drawing area, since otherwise the translations are different. + + // New translations for getting mouse motion feedback + static const String translations = +": wxCanvasMotionEvent() DrawingAreaInput() ManagerGadgetButtonMotion()\n\ +: wxCanvasMotionEvent() DrawingAreaInput() ManagerGadgetButtonMotion()\n\ +: wxCanvasMotionEvent() DrawingAreaInput() ManagerGadgetButtonMotion()\n\ +: wxCanvasMotionEvent() DrawingAreaInput() ManagerGadgetButtonMotion()\n\ +: DrawingAreaInput() ManagerGadgetArm()\n\ +: DrawingAreaInput() ManagerGadgetArm()\n\ +: DrawingAreaInput() ManagerGadgetArm()\n\ +: DrawingAreaInput() ManagerGadgetActivate()\n\ +: DrawingAreaInput() ManagerGadgetActivate()\n\ +: DrawingAreaInput() ManagerGadgetActivate()\n\ +: wxCanvasMotionEvent() DrawingAreaInput()\n\ +: wxCanvasMotionEvent() DrawingAreaInput()\n\ +: wxCanvasMotionEvent() DrawingAreaInput()\n\ +: DrawingAreaInput()"; + + XtActionsRec actions[1]; + actions[0].string = "wxCanvasMotionEvent"; + actions[0].proc = (XtActionProc) wxCanvasMotionEvent; + XtAppAddActions ((XtAppContext) wxTheApp->GetAppContext(), actions, 1); + + Widget parentWidget = (Widget) parent->GetClientWidget(); + + if (style & wxSIMPLE_BORDER) + { + m_borderWidget = (WXWidget)XtVaCreateManagedWidget + ( + "canvasBorder", + xmFrameWidgetClass, parentWidget, + XmNshadowType, XmSHADOW_IN, + XmNshadowThickness, 1, + NULL + ); + } else if (style & wxSUNKEN_BORDER) + { + m_borderWidget = (WXWidget)XtVaCreateManagedWidget + ( + "canvasBorder", + xmFrameWidgetClass, parentWidget, + XmNshadowType, XmSHADOW_IN, + NULL + ); + } else if (style & wxRAISED_BORDER) + { + m_borderWidget = (WXWidget)XtVaCreateManagedWidget + ( + "canvasBorder", + xmFrameWidgetClass, parentWidget, + XmNshadowType, XmSHADOW_OUT, + NULL + ); + } + + m_scrolledWindow = (WXWidget)XtVaCreateManagedWidget + ( + "scrolledWindow", + xmScrolledWindowWidgetClass, + m_borderWidget ? (Widget) m_borderWidget + : parentWidget, + XmNresizePolicy, XmRESIZE_NONE, + XmNspacing, 0, + XmNscrollingPolicy, XmAPPLICATION_DEFINED, + //XmNscrollBarDisplayPolicy, XmAS_NEEDED, + NULL + ); + + XtTranslations ptr = XtParseTranslationTable(translations); + m_drawingArea = (WXWidget)XtVaCreateWidget + ( + name, + xmDrawingAreaWidgetClass, (Widget) m_scrolledWindow, + XmNunitType, XmPIXELS, + // XmNresizePolicy, XmRESIZE_ANY, + XmNresizePolicy, XmRESIZE_NONE, + XmNmarginHeight, 0, + XmNmarginWidth, 0, + XmNtranslations, ptr, + NULL + ); + XtFree((char *) ptr); + +#if 0 + if (GetWindowStyleFlag() & wxOVERRIDE_KEY_TRANSLATIONS) + { + ptr = XtParseTranslationTable (": DrawingAreaInput()"); + XtOverrideTranslations ((Widget) m_drawingArea, ptr); + XtFree ((char *) ptr); + } +#endif // 0 + + wxAddWindowToTable((Widget) m_drawingArea, this); + wxAddWindowToTable((Widget) m_scrolledWindow, this); + + // This order is very important in Motif 1.2.1 + XtRealizeWidget ((Widget) m_scrolledWindow); + XtRealizeWidget ((Widget) m_drawingArea); + XtManageChild ((Widget) m_drawingArea); + + ptr = XtParseTranslationTable(": resize()"); + XtOverrideTranslations((Widget) m_drawingArea, ptr); + XtFree ((char *) ptr); + + XtAddCallback ((Widget) m_drawingArea, XmNexposeCallback, (XtCallbackProc) wxCanvasRepaintProc, (XtPointer) this); + XtAddCallback ((Widget) m_drawingArea, XmNinputCallback, (XtCallbackProc) wxCanvasInputEvent, (XtPointer) this); + + // TODO? +#if 0 + display = XtDisplay (scrolledWindow); + xwindow = XtWindow (drawingArea); +#endif // 0 + + XtAddEventHandler( + (Widget)m_drawingArea, + PointerMotionHintMask | EnterWindowMask | + LeaveWindowMask | FocusChangeMask, + False, + (XtEventHandler) wxCanvasEnterLeave, + (XtPointer) this + ); + + // Scrolled widget needs to have its colour changed or we get a little blue + // square where the scrollbars abutt + wxColour backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); + DoChangeBackgroundColour(m_scrolledWindow, backgroundColour, TRUE); + DoChangeBackgroundColour(m_drawingArea, backgroundColour, TRUE); + + XmScrolledWindowSetAreas( + (Widget)m_scrolledWindow, + (Widget) 0, (Widget) 0, + (Widget) m_drawingArea); + +#if 0 + if (m_hScrollBar) + XtRealizeWidget ((Widget) m_hScrollBar); + if (m_vScrollBar) + XtRealizeWidget ((Widget) m_vScrollBar); +#endif // 0 + + // Without this, the cursor may not be restored properly (e.g. in splitter + // sample). + SetCursor(*wxSTANDARD_CURSOR); + SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); + SetSize(pos.x, pos.y, size.x, size.y); + + return TRUE; +} + +// Destructor +wxWindow::~wxWindow() +{ + if (g_captureWindow == this) + g_captureWindow = NULL; + + m_isBeingDeleted = TRUE; + + // Motif-specific actions first + WXWidget wMain = GetMainWidget(); + if ( wMain ) + { + // Removes event handlers + DetachWidget(wMain); + } + + ClearUpdateRects(); + + if ( m_parent ) + m_parent->RemoveChild( this ); + + // If m_drawingArea, we're a fully-fledged window with drawing area, + // scrollbars etc. (what wxCanvas used to be) + if ( m_drawingArea ) + { + // Destroy children before destroying self + DestroyChildren(); + + if (m_backingPixmap) + XFreePixmap (XtDisplay ((Widget) GetMainWidget()), (Pixmap) m_backingPixmap); + + Widget w = (Widget) m_drawingArea; + wxDeleteWindowFromTable(w); + + if (w) + { + XtDestroyWidget(w); + m_drawingArea = (WXWidget) 0; + } + + // Only if we're _really_ a canvas (not a dialog box/panel) + if (m_scrolledWindow) + { + wxDeleteWindowFromTable((Widget) m_scrolledWindow); + } + + if (m_hScrollBar) + { + wxDeleteWindowFromTable((Widget) m_hScrollBar); + XtUnmanageChild((Widget) m_hScrollBar); + } + if (m_vScrollBar) + { + wxDeleteWindowFromTable((Widget) m_vScrollBar); + XtUnmanageChild((Widget) m_vScrollBar); + } + + if (m_hScrollBar) + XtDestroyWidget((Widget) m_hScrollBar); + if (m_vScrollBar) + XtDestroyWidget((Widget) m_vScrollBar); + + UnmanageAndDestroy(m_scrolledWindow); + + if (m_borderWidget) + { + XtDestroyWidget ((Widget) m_borderWidget); + m_borderWidget = (WXWidget) 0; + } + } + else // Why wasn't this here before? JACS 8/3/2000 + DestroyChildren(); + + + // Destroy the window + if (GetMainWidget()) + { + // If this line (XtDestroyWidget) causes a crash, you may comment it out. + // Child widgets will get destroyed automatically when a frame + // or dialog is destroyed, but before that you may get some memory + // leaks and potential layout problems if you delete and then add + // child windows. + + // GRG, Feb/2000: commented this out when adding support for + // wxSCROLL[WIN]_THUMBRELEASE events. Also it was reported + // that this call crashed wxMotif under OS/2, so it seems + // that leaving it out is the right thing to do. + // SN, Feb/2000: newgrid/griddemo shows why it is needed :-( + XtDestroyWidget((Widget) GetMainWidget()); + SetMainWidget((WXWidget) NULL); + } +} + +// ---------------------------------------------------------------------------- +// scrollbar management +// ---------------------------------------------------------------------------- + +// Helper function +void wxWindow::CreateScrollbar(wxOrientation orientation) +{ + wxCHECK_RET( m_drawingArea, "this window can't have scrollbars" ); + + XtVaSetValues((Widget) m_scrolledWindow, XmNresizePolicy, XmRESIZE_NONE, NULL); + + // Add scrollbars if required + if (orientation == wxHORIZONTAL) + { + Widget hScrollBar = XtVaCreateManagedWidget ("hsb", + xmScrollBarWidgetClass, (Widget) m_scrolledWindow, + XmNorientation, XmHORIZONTAL, + NULL); + XtAddCallback (hScrollBar, XmNvalueChangedCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL); + XtAddCallback (hScrollBar, XmNdragCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL); + XtAddCallback (hScrollBar, XmNincrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL); + XtAddCallback (hScrollBar, XmNdecrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL); + XtAddCallback (hScrollBar, XmNpageIncrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL); + XtAddCallback (hScrollBar, XmNpageDecrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL); + XtAddCallback (hScrollBar, XmNtoTopCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL); + XtAddCallback (hScrollBar, XmNtoBottomCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL); + + XtVaSetValues (hScrollBar, + XmNincrement, 1, + XmNvalue, 0, + NULL); + + m_hScrollBar = (WXWidget) hScrollBar; + + wxColour backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); + DoChangeBackgroundColour(m_hScrollBar, backgroundColour, TRUE); + + XtRealizeWidget(hScrollBar); + + XtVaSetValues((Widget) m_scrolledWindow, + XmNhorizontalScrollBar, (Widget) m_hScrollBar, + NULL); + + m_hScroll = TRUE; + + wxAddWindowToTable( hScrollBar, this ); + } + + if (orientation == wxVERTICAL) + { + Widget vScrollBar = XtVaCreateManagedWidget ("vsb", + xmScrollBarWidgetClass, (Widget) m_scrolledWindow, + XmNorientation, XmVERTICAL, + NULL); + XtAddCallback (vScrollBar, XmNvalueChangedCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL); + XtAddCallback (vScrollBar, XmNdragCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL); + XtAddCallback (vScrollBar, XmNincrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL); + XtAddCallback (vScrollBar, XmNdecrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL); + XtAddCallback (vScrollBar, XmNpageIncrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL); + XtAddCallback (vScrollBar, XmNpageDecrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL); + XtAddCallback (vScrollBar, XmNtoTopCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL); + XtAddCallback (vScrollBar, XmNtoBottomCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL); + + XtVaSetValues (vScrollBar, + XmNincrement, 1, + XmNvalue, 0, + NULL); + + m_vScrollBar = (WXWidget) vScrollBar; + wxColour backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); + DoChangeBackgroundColour(m_vScrollBar, backgroundColour, TRUE); + + XtRealizeWidget(vScrollBar); + + XtVaSetValues((Widget) m_scrolledWindow, + XmNverticalScrollBar, (Widget) m_vScrollBar, + NULL); + + m_vScroll = TRUE; + + wxAddWindowToTable( vScrollBar, this ); + } + + XtVaSetValues((Widget) m_scrolledWindow, XmNresizePolicy, XmRESIZE_ANY, NULL); +} + +void wxWindow::DestroyScrollbar(wxOrientation orientation) +{ + wxCHECK_RET( m_drawingArea, "this window can't have scrollbars" ); + + XtVaSetValues((Widget) m_scrolledWindow, XmNresizePolicy, XmRESIZE_NONE, NULL); + // Add scrollbars if required + if (orientation == wxHORIZONTAL) + { + if (m_hScrollBar) + { + wxDeleteWindowFromTable((Widget)m_hScrollBar); + XtDestroyWidget((Widget) m_hScrollBar); + } + m_hScrollBar = (WXWidget) 0; + m_hScroll = FALSE; + + XtVaSetValues((Widget) m_scrolledWindow, + XmNhorizontalScrollBar, (Widget) 0, + NULL); + + } + + if (orientation == wxVERTICAL) + { + if (m_vScrollBar) + { + wxDeleteWindowFromTable((Widget)m_vScrollBar); + XtDestroyWidget((Widget) m_vScrollBar); + } + m_vScrollBar = (WXWidget) 0; + m_vScroll = FALSE; + + XtVaSetValues((Widget) m_scrolledWindow, + XmNverticalScrollBar, (Widget) 0, + NULL); + + } + XtVaSetValues((Widget) m_scrolledWindow, XmNresizePolicy, XmRESIZE_ANY, NULL); +} + +// --------------------------------------------------------------------------- +// basic operations +// --------------------------------------------------------------------------- + +void wxWindow::SetFocus() +{ + Widget wMain = (Widget) GetMainWidget(); + XmProcessTraversal(wMain, XmTRAVERSE_CURRENT); + XmProcessTraversal((Widget) GetMainWidget(), XmTRAVERSE_CURRENT); +} + +// Get the window with the focus +wxWindow *wxWindowBase::FindFocus() +{ + // TODO Problems: + // (1) Can there be multiple focussed widgets in an application? + // In which case we need to find the top-level window that's + // currently active. + // (2) The widget with the focus may not be in the widget table + // depending on which widgets I put in the table + wxWindow *winFocus = (wxWindow *)NULL; + for ( wxWindowList::Node *node = wxTopLevelWindows.GetFirst(); + node; + node = node->GetNext() ) + { + wxWindow *win = node->GetData(); + + Widget w = XmGetFocusWidget ((Widget) win->GetTopWidget()); + + if (w != (Widget) NULL) + { + winFocus = wxGetWindowFromTable(w); + if ( winFocus ) + break; + } + } + + return winFocus; +} + +bool wxWindow::Enable(bool enable) +{ + if ( !wxWindowBase::Enable(enable) ) + return FALSE; + + Widget wMain = (Widget)GetMainWidget(); + if ( wMain ) + { + XtSetSensitive(wMain, enable); + XmUpdateDisplay(wMain); + } + + return TRUE; +} + +bool wxWindow::Show(bool show) +{ + if ( !wxWindowBase::Show(show) ) + return FALSE; + + if (m_borderWidget || m_scrolledWindow) + { + MapOrUnmap(m_drawingArea, show); + MapOrUnmap(m_borderWidget ? m_borderWidget : m_scrolledWindow, show); + } + else + { + if ( !MapOrUnmap(GetTopWidget(), show) ) + MapOrUnmap(GetMainWidget(), show); + } + +#if 0 + Window xwin = (Window) GetXWindow(); + Display *xdisp = (Display*) GetXDisplay(); + if (show) + XMapWindow(xdisp, xwin); + else + XUnmapWindow(xdisp, xwin); +#endif + + return TRUE; +} + +// Raise the window to the top of the Z order +void wxWindow::Raise() +{ + Widget wTop = (Widget) GetTopWidget(); + Window window = XtWindow(wTop); + XRaiseWindow(XtDisplay(wTop), window); +} + +// Lower the window to the bottom of the Z order +void wxWindow::Lower() +{ + Widget wTop = (Widget) GetTopWidget(); + Window window = XtWindow(wTop); + XLowerWindow(XtDisplay(wTop), window); +} + +void wxWindow::SetTitle(const wxString& title) +{ + XtVaSetValues((Widget)GetMainWidget(), XmNtitle, title.c_str(), NULL); +} + +wxString wxWindow::GetTitle() const +{ + char *title; + XtVaGetValues((Widget)GetMainWidget(), XmNtitle, &title, NULL); + + return wxString(title); +} + +void wxWindow::DoCaptureMouse() +{ + g_captureWindow = this; + if ( m_winCaptured ) + return; + + Widget wMain = (Widget)GetMainWidget(); + if ( wMain ) + XtAddGrab(wMain, TRUE, FALSE); + + m_winCaptured = TRUE; +} + +void wxWindow::DoReleaseMouse() +{ + g_captureWindow = NULL; + if ( !m_winCaptured ) + return; + + Widget wMain = (Widget)GetMainWidget(); + if ( wMain ) + XtRemoveGrab(wMain); + + m_winCaptured = FALSE; +} + +bool wxWindow::SetFont(const wxFont& font) +{ + if ( !wxWindowBase::SetFont(font) ) + { + // nothing to do + return FALSE; + } + + ChangeFont(); + + return TRUE; +} + +bool wxWindow::SetCursor(const wxCursor& cursor) +{ + if ( !wxWindowBase::SetCursor(cursor) ) + { + // no change + return FALSE; + } + + // wxASSERT_MSG( m_cursor.Ok(), + // wxT("cursor must be valid after call to the base version")); + wxCursor* cursor2 = NULL; + if (m_cursor.Ok()) + cursor2 = & m_cursor; + else + cursor2 = wxSTANDARD_CURSOR; + + WXDisplay *dpy = GetXDisplay(); + WXCursor x_cursor = cursor2->GetXCursor(dpy); + + Widget w = (Widget) GetMainWidget(); + Window win = XtWindow(w); + XDefineCursor((Display*) dpy, win, (Cursor) x_cursor); + + return TRUE; +} + +// Coordinates relative to the window +void wxWindow::WarpPointer (int x, int y) +{ + Widget wClient = (Widget)GetClientWidget(); + + XWarpPointer(XtDisplay(wClient), None, XtWindow(wClient), 0, 0, 0, 0, x, y); +} + +// --------------------------------------------------------------------------- +// scrolling stuff +// --------------------------------------------------------------------------- + +int wxWindow::GetScrollPos(int orient) const +{ + if (orient == wxHORIZONTAL) + return m_scrollPosX; + else + return m_scrollPosY; + +#if 0 + Widget scrollBar = (Widget) ((orient == wxHORIZONTAL) ? m_hScrollBar : m_vScrollBar); + if (scrollBar) + { + int pos; + XtVaGetValues(scrollBar, XmNvalue, &pos, NULL); + return pos; + } + else + return 0; +#endif // 0 +} + +// This now returns the whole range, not just the number of positions that we +// can scroll. +int wxWindow::GetScrollRange(int orient) const +{ + Widget scrollBar = (Widget)GetScrollbar((wxOrientation)orient); + wxCHECK_MSG( scrollBar, 0, "no such scrollbar" ); + + int range; + XtVaGetValues(scrollBar, XmNmaximum, &range, NULL); + return range; +} + +int wxWindow::GetScrollThumb(int orient) const +{ + Widget scrollBar = (Widget)GetScrollbar((wxOrientation)orient); + wxCHECK_MSG( scrollBar, 0, "no such scrollbar" ); + + int thumb; + XtVaGetValues(scrollBar, XmNsliderSize, &thumb, NULL); + return thumb; +} + +void wxWindow::SetScrollPos(int orient, int pos, bool WXUNUSED(refresh)) +{ + Widget scrollBar = (Widget)GetScrollbar((wxOrientation)orient); + + if ( scrollBar ) + { + XtVaSetValues (scrollBar, XmNvalue, pos, NULL); + } + + SetInternalScrollPos((wxOrientation)orient, pos); +} + +// New function that will replace some of the above. +void wxWindow::SetScrollbar(int orient, int pos, int thumbVisible, + int range, bool WXUNUSED(refresh)) +{ + int oldW, oldH; + GetSize(& oldW, & oldH); + + if (range == 0) + range = 1; + if (thumbVisible == 0) + thumbVisible = 1; + + if (thumbVisible > range) + thumbVisible = range; + + // Save the old state to see if it changed + WXWidget oldScrollBar = GetScrollbar((wxOrientation)orient); + + if (orient == wxHORIZONTAL) + { + if (thumbVisible == range) + { + if (m_hScrollBar) + DestroyScrollbar(wxHORIZONTAL); + } + else + { + if (!m_hScrollBar) + CreateScrollbar(wxHORIZONTAL); + } + } + if (orient == wxVERTICAL) + { + if (thumbVisible == range) + { + if (m_vScrollBar) + DestroyScrollbar(wxVERTICAL); + } + else + { + if (!m_vScrollBar) + CreateScrollbar(wxVERTICAL); + } + } + WXWidget newScrollBar = GetScrollbar((wxOrientation)orient); + + if (oldScrollBar != newScrollBar) + { + // This is important! Without it, scrollbars misbehave badly. + XtUnrealizeWidget((Widget) m_scrolledWindow); + XmScrolledWindowSetAreas ((Widget) m_scrolledWindow, (Widget) m_hScrollBar, (Widget) m_vScrollBar, (Widget) m_drawingArea); + XtRealizeWidget((Widget) m_scrolledWindow); + XtManageChild((Widget) m_scrolledWindow); + } + + if (newScrollBar) + { + XtVaSetValues((Widget) newScrollBar, + XmNvalue, pos, + XmNminimum, 0, + XmNmaximum, range, + XmNsliderSize, thumbVisible, + NULL); + } + + SetInternalScrollPos((wxOrientation)orient, pos); + + int newW, newH; + GetSize(& newW, & newH); + + // Adjusting scrollbars can resize the canvas accidentally + if (newW != oldW || newH != oldH) + SetSize(-1, -1, oldW, oldH); +} + +// Does a physical scroll +void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect) +{ + int x, y, w, h; + if (rect) + { + // Use specified rectangle + x = rect->x; y = rect->y; w = rect->width; h = rect->height; + } + else + { + // Use whole client area + x = 0; y = 0; + GetClientSize(& w, & h); + } + + wxNode *cnode = m_children.First(); + while (cnode) + { + wxWindow *child = (wxWindow*) cnode->Data(); + int sx = 0; + int sy = 0; + child->GetSize( &sx, &sy ); + wxPoint pos( child->GetPosition() ); + child->SetSize( pos.x + dx, pos.y + dy, sx, sy, wxSIZE_ALLOW_MINUS_ONE ); + cnode = cnode->Next(); + } + + int x1 = (dx >= 0) ? x : x - dx; + int y1 = (dy >= 0) ? y : y - dy; + int w1 = w - abs(dx); + int h1 = h - abs(dy); + int x2 = (dx >= 0) ? x + dx : x; + int y2 = (dy >= 0) ? y + dy : y; + + wxClientDC dc(this); + + dc.SetLogicalFunction (wxCOPY); + + Widget widget = (Widget) GetMainWidget(); + Window window = XtWindow(widget); + Display* display = XtDisplay(widget); + + XCopyArea(display, window, window, (GC) dc.GetGC(), + x1, y1, w1, h1, x2, y2); + + dc.SetAutoSetting(TRUE); + wxBrush brush(GetBackgroundColour(), wxSOLID); + dc.SetBrush(brush); // FIXME: needed? + + // We'll add rectangles to the list of update rectangles according to which + // bits we've exposed. + wxList updateRects; + + if (dx > 0) + { + wxRect *rect = new wxRect; + rect->x = x; + rect->y = y; + rect->width = dx; + rect->height = h; + + XFillRectangle(display, window, + (GC) dc.GetGC(), rect->x, rect->y, rect->width, rect->height); + + rect->x = rect->x; + rect->y = rect->y; + rect->width = rect->width; + rect->height = rect->height; + + updateRects.Append((wxObject*) rect); + } + else if (dx < 0) + { + wxRect *rect = new wxRect; + + rect->x = x + w + dx; + rect->y = y; + rect->width = -dx; + rect->height = h; + + XFillRectangle(display, window, + (GC) dc.GetGC(), rect->x, rect->y, rect->width, + rect->height); + + rect->x = rect->x; + rect->y = rect->y; + rect->width = rect->width; + rect->height = rect->height; + + updateRects.Append((wxObject*) rect); + } + if (dy > 0) + { + wxRect *rect = new wxRect; + + rect->x = x; + rect->y = y; + rect->width = w; + rect->height = dy; + + XFillRectangle(display, window, + (GC) dc.GetGC(), rect->x, rect->y, rect->width, rect->height); + + rect->x = rect->x; + rect->y = rect->y; + rect->width = rect->width; + rect->height = rect->height; + + updateRects.Append((wxObject*) rect); + } + else if (dy < 0) + { + wxRect *rect = new wxRect; + + rect->x = x; + rect->y = y + h + dy; + rect->width = w; + rect->height = -dy; + + XFillRectangle(display, window, + (GC) dc.GetGC(), rect->x, rect->y, rect->width, rect->height); + + rect->x = rect->x; + rect->y = rect->y; + rect->width = rect->width; + rect->height = rect->height; + + updateRects.Append((wxObject*) rect); + } + dc.SetBrush(wxNullBrush); + + // Now send expose events + + wxNode* node = updateRects.First(); + while (node) + { + wxRect* rect = (wxRect*) node->Data(); + XExposeEvent event; + + event.type = Expose; + event.display = display; + event.send_event = True; + event.window = window; + + event.x = rect->x; + event.y = rect->y; + event.width = rect->width; + event.height = rect->height; + + event.count = 0; + + XSendEvent(display, window, False, ExposureMask, (XEvent *)&event); + + node = node->Next(); + + } + + // Delete the update rects + node = updateRects.First(); + while (node) + { + wxRect* rect = (wxRect*) node->Data(); + delete rect; + node = node->Next(); + } + + XmUpdateDisplay((Widget) GetMainWidget()); +} + +// --------------------------------------------------------------------------- +// drag and drop +// --------------------------------------------------------------------------- + +#if wxUSE_DRAG_AND_DROP + +void wxWindow::SetDropTarget(wxDropTarget * WXUNUSED(pDropTarget)) +{ + // TODO +} + +#endif + +// Old style file-manager drag&drop +void wxWindow::DragAcceptFiles(bool WXUNUSED(accept)) +{ + // TODO +} + +// ---------------------------------------------------------------------------- +// tooltips +// ---------------------------------------------------------------------------- + +#if wxUSE_TOOLTIPS + +void wxWindow::DoSetToolTip(wxToolTip * WXUNUSED(tooltip)) +{ + // TODO +} + +#endif // wxUSE_TOOLTIPS + +// ---------------------------------------------------------------------------- +// popup menus +// ---------------------------------------------------------------------------- + +bool wxWindow::DoPopupMenu(wxMenu *menu, int x, int y) +{ + Widget widget = (Widget) GetMainWidget(); + + /* The menuId field seems to be usused, so we'll use it to + indicate whether a menu is popped up or not: + 0: Not currently created as a popup + -1: Created as a popup, but not active + 1: Active popup. + */ + + if (menu->GetParent() && (menu->GetId() != -1)) + return FALSE; + + if (menu->GetMainWidget()) { + menu->DestroyMenu(TRUE); + } + + menu->SetId(1); /* Mark as popped-up */ + menu->CreateMenu(NULL, widget, menu); + menu->SetInvokingWindow(this); + + menu->UpdateUI(); + + // menu->SetParent(parent); + // parent->children->Append(menu); // Store menu for later deletion + + Widget menuWidget = (Widget) menu->GetMainWidget(); + + int rootX = 0; + int rootY = 0; + + int deviceX = x; + int deviceY = y; + /* + if (this->IsKindOf(CLASSINFO(wxCanvas))) + { + wxCanvas *canvas = (wxCanvas *) this; + deviceX = canvas->GetDC ()->LogicalToDeviceX (x); + deviceY = canvas->GetDC ()->LogicalToDeviceY (y); + } + */ + + Display *display = XtDisplay (widget); + Window rootWindow = RootWindowOfScreen (XtScreen((Widget)widget)); + Window thisWindow = XtWindow (widget); + Window childWindow; + XTranslateCoordinates (display, thisWindow, rootWindow, (int) deviceX, (int) deviceY, + &rootX, &rootY, &childWindow); + + XButtonPressedEvent event; + event.type = ButtonPress; + event.button = 1; + + event.x = deviceX; + event.y = deviceY; + + event.x_root = rootX; + event.y_root = rootY; + + XmMenuPosition (menuWidget, &event); + XtManageChild (menuWidget); + + return TRUE; +} + +// --------------------------------------------------------------------------- +// moving and resizing +// --------------------------------------------------------------------------- + +bool wxWindow::PreResize() +{ + return TRUE; +} + +// Get total size +void wxWindow::DoGetSize(int *x, int *y) const +{ + if (m_drawingArea) + { + CanvasGetSize(x, y); + return; + } + + Widget widget = (Widget) GetTopWidget(); + Dimension xx, yy; + XtVaGetValues(widget, XmNwidth, &xx, XmNheight, &yy, NULL); + if(x) *x = xx; if(y) *y = yy; +} + +void wxWindow::DoGetPosition(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); + + // 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; + } + + if(x) *x = xx; if(y) *y = yy; +} + +void wxWindow::DoScreenToClient(int *x, int *y) const +{ + Widget widget = (Widget) GetClientWidget(); + Display *display = XtDisplay((Widget) GetMainWidget()); + Window rootWindow = RootWindowOfScreen(XtScreen(widget)); + Window thisWindow = XtWindow(widget); + + Window childWindow; + int xx = *x; + int yy = *y; + XTranslateCoordinates(display, rootWindow, thisWindow, xx, yy, x, y, &childWindow); +} + +void wxWindow::DoClientToScreen(int *x, int *y) const +{ + Widget widget = (Widget) GetClientWidget(); + Display *display = XtDisplay(widget); + Window rootWindow = RootWindowOfScreen(XtScreen(widget)); + Window thisWindow = XtWindow(widget); + + Window childWindow; + int xx = *x; + int yy = *y; + XTranslateCoordinates(display, thisWindow, rootWindow, xx, yy, x, y, &childWindow); +} + + +// Get size *available for subwindows* i.e. excluding menu bar etc. +void wxWindow::DoGetClientSize(int *x, int *y) const +{ + Widget widget = (Widget) GetClientWidget(); + Dimension xx, yy; + XtVaGetValues(widget, XmNwidth, &xx, XmNheight, &yy, NULL); + if(x) *x = xx; if(y) *y = yy; +} + +void wxWindow::DoSetSize(int x, int y, int width, int height, int sizeFlags) +{ + // A bit of optimization to help sort out the flickers. + int oldX, oldY, oldW, oldH; + GetSize(& oldW, & oldH); + GetPosition(& oldX, & oldY); + + if ( !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) ) + { + if ( x == -1 ) + x = oldX; + if ( y == -1 ) + y = oldY; + } + + if ( width == -1 ) + width = oldW; + if ( height == -1 ) + height = oldH; + + bool nothingChanged = (x == oldX) && (y == oldY) && + (width == oldW) && (height == oldH); + + if (!wxNoOptimize::CanOptimize()) + { + nothingChanged = FALSE; + } + + if ( !nothingChanged ) + { + if (m_drawingArea) + { + CanvasSetSize(x, y, width, height, sizeFlags); + return; + } + + Widget widget = (Widget) GetTopWidget(); + if (!widget) + return; + + bool managed = XtIsManaged( widget ); + if (managed) + XtUnmanageChild(widget); + + int xx = x; + int yy = y; + AdjustForParentClientOrigin(xx, yy, sizeFlags); + + DoMoveWindow(xx, yy, width, height); + + if (managed) + XtManageChild(widget); + + // How about this bit. Maybe we don't need to generate size events + // all the time -- they'll be generated when the window is sized anyway. +#if 0 + wxSizeEvent sizeEvent(wxSize(width, height), GetId()); + sizeEvent.SetEventObject(this); + + GetEventHandler()->ProcessEvent(sizeEvent); +#endif // 0 + } +} + +void wxWindow::DoSetClientSize(int width, int height) +{ + if (m_drawingArea) + { + CanvasSetClientSize(width, height); + return; + } + + Widget widget = (Widget) GetTopWidget(); + + if (width > -1) + XtVaSetValues(widget, XmNwidth, width, NULL); + if (height > -1) + XtVaSetValues(widget, XmNheight, height, NULL); + + wxSizeEvent sizeEvent(wxSize(width, height), GetId()); + sizeEvent.SetEventObject(this); + + GetEventHandler()->ProcessEvent(sizeEvent); +} + +// For implementation purposes - sometimes decorations make the client area +// smaller +wxPoint wxWindow::GetClientAreaOrigin() const +{ + return wxPoint(0, 0); +} + +// Makes an adjustment to the window position (for example, a frame that has +// a toolbar that it manages itself). +void wxWindow::AdjustForParentClientOrigin(int& x, int& y, int sizeFlags) +{ + if (((sizeFlags & wxSIZE_NO_ADJUSTMENTS) == 0) && GetParent()) + { + wxPoint pt(GetParent()->GetClientAreaOrigin()); + x += pt.x; y += pt.y; + } +} + +void wxWindow::SetSizeHints(int minW, int minH, int maxW, int maxH, int incW, int incH) +{ + m_minWidth = minW; + m_minHeight = minH; + m_maxWidth = maxW; + m_maxHeight = maxH; + + wxFrame *frame = wxDynamicCast(this, wxFrame); + if ( !frame ) + { + // TODO what about dialogs? + return; + } + + Widget widget = (Widget) frame->GetShellWidget(); + + if (minW > -1) + XtVaSetValues(widget, XmNminWidth, minW, NULL); + if (minH > -1) + XtVaSetValues(widget, XmNminHeight, minH, NULL); + if (maxW > -1) + XtVaSetValues(widget, XmNmaxWidth, maxW, NULL); + if (maxH > -1) + XtVaSetValues(widget, XmNmaxHeight, maxH, NULL); + if (incW > -1) + XtVaSetValues(widget, XmNwidthInc, incW, NULL); + if (incH > -1) + XtVaSetValues(widget, XmNheightInc, incH, NULL); +} + +void wxWindow::DoMoveWindow(int x, int y, int width, int height) +{ + XtVaSetValues((Widget)GetTopWidget(), + XmNx, x, + XmNy, y, + XmNwidth, width, + XmNheight, height, + NULL); +} + +// --------------------------------------------------------------------------- +// text metrics +// --------------------------------------------------------------------------- + +int wxWindow::GetCharHeight() const +{ + wxCHECK_MSG( m_font.Ok(), 0, "valid window font needed" ); + + WXFontStructPtr pFontStruct = m_font.GetFontStruct(1.0, GetXDisplay()); + + int direction, ascent, descent; + XCharStruct overall; + XTextExtents ((XFontStruct*) pFontStruct, "x", 1, &direction, &ascent, + &descent, &overall); + + // return (overall.ascent + overall.descent); + return (ascent + descent); +} + +int wxWindow::GetCharWidth() const +{ + wxCHECK_MSG( m_font.Ok(), 0, "valid window font needed" ); + + WXFontStructPtr pFontStruct = m_font.GetFontStruct(1.0, GetXDisplay()); + + int direction, ascent, descent; + XCharStruct overall; + XTextExtents ((XFontStruct*) pFontStruct, "x", 1, &direction, &ascent, + &descent, &overall); + + return overall.width; +} + +void wxWindow::GetTextExtent(const wxString& string, + int *x, int *y, + int *descent, int *externalLeading, + const wxFont *theFont) const +{ + wxFont *fontToUse = (wxFont *)theFont; + if (!fontToUse) + fontToUse = (wxFont *) & m_font; + + wxCHECK_RET( fontToUse->Ok(), "valid window font needed" ); + + WXFontStructPtr pFontStruct = theFont->GetFontStruct(1.0, GetXDisplay()); + + int direction, ascent, descent2; + XCharStruct overall; + int slen = string.Len(); + +#if 0 + if (use16) + XTextExtents16((XFontStruct*) pFontStruct, (XChar2b *) (char*) (const char*) string, slen, &direction, + &ascent, &descent2, &overall); +#endif + + XTextExtents((XFontStruct*) pFontStruct, string, slen, + &direction, &ascent, &descent2, &overall); + + if ( x ) + *x = (overall.width); + if ( y ) + *y = (ascent + descent2); + if (descent) + *descent = descent2; + if (externalLeading) + *externalLeading = 0; + +} + +// ---------------------------------------------------------------------------- +// painting +// ---------------------------------------------------------------------------- + +void wxWindow::Refresh(bool eraseBack, const wxRect *rect) +{ + m_needsRefresh = TRUE; + Display *display = XtDisplay((Widget) GetMainWidget()); + Window thisWindow = XtWindow((Widget) GetMainWidget()); + + XExposeEvent dummyEvent; + int width, height; + GetSize(&width, &height); + + dummyEvent.type = Expose; + dummyEvent.display = display; + dummyEvent.send_event = True; + dummyEvent.window = thisWindow; + if (rect) + { + dummyEvent.x = rect->x; + dummyEvent.y = rect->y; + dummyEvent.width = rect->width; + dummyEvent.height = rect->height; + } + else + { + dummyEvent.x = 0; + dummyEvent.y = 0; + dummyEvent.width = width; + dummyEvent.height = height; + } + dummyEvent.count = 0; + + if (eraseBack) + { + wxClientDC dc(this); + wxBrush backgroundBrush(GetBackgroundColour(), wxSOLID); + dc.SetBackground(backgroundBrush); + if (rect) + dc.Clear(*rect); + else + dc.Clear(); + } + + XSendEvent(display, thisWindow, False, ExposureMask, (XEvent *)&dummyEvent); +} + +void wxWindow::Clear() +{ + wxClientDC dc(this); + wxBrush brush(GetBackgroundColour(), wxSOLID); + dc.SetBackground(brush); + dc.Clear(); +} + +void wxWindow::ClearUpdateRects() +{ + wxRectList::Node* node = m_updateRects.GetFirst(); + while (node) + { + wxRect* rect = node->GetData(); + delete rect; + node = node->GetNext(); + } + + m_updateRects.Clear(); +} + +void wxWindow::DoPaint() +{ + //TODO : make a temporary gc so we can do the XCopyArea below + if (m_backingPixmap && !m_needsRefresh) + { + wxPaintDC dc(this); + + GC tempGC = (GC) dc.GetBackingGC(); + + Widget widget = (Widget) GetMainWidget(); + + int scrollPosX = 0; + int scrollPosY = 0; + + // We have to test whether it's a wxScrolledWindow (hack!) because + // otherwise we don't know how many pixels have been scrolled. We might + // solve this in the future by defining virtual wxWindow functions to get + // the scroll position in pixels. Or, each kind of scrolled window has to + // implement backing stores itself, using generic wxWindows code. + wxScrolledWindow* scrolledWindow = wxDynamicCast(this, wxScrolledWindow); + if ( scrolledWindow ) + { + int x, y; + scrolledWindow->CalcScrolledPosition(0, 0, &x, &y); + + scrollPosX = - x; + scrollPosY = - y; + } + + // TODO: This could be optimized further by only copying the areas in the + // current update region. + + // Only blit the part visible in the client area. The backing pixmap + // always starts at 0, 0 but we may be looking at only a portion of it. + wxSize clientArea = GetClientSize(); + int toBlitX = m_pixmapWidth - scrollPosX; + int toBlitY = m_pixmapHeight - scrollPosY; + + // Copy whichever is samller, the amount of pixmap we have to copy, + // or the size of the client area. + toBlitX = wxMin(toBlitX, clientArea.x); + toBlitY = wxMin(toBlitY, clientArea.y); + + // Make sure we're not negative + toBlitX = wxMax(0, toBlitX); + toBlitY = wxMax(0, toBlitY); + + XCopyArea + ( + XtDisplay(widget), + (Pixmap) m_backingPixmap, + XtWindow (widget), + tempGC, + scrollPosX, scrollPosY, // Start at the scroll position + toBlitX, toBlitY, // How much of the pixmap to copy + 0, 0 // Destination + ); + } + else + { + // Set an erase event first + wxEraseEvent eraseEvent(GetId()); + eraseEvent.SetEventObject(this); + GetEventHandler()->ProcessEvent(eraseEvent); + + wxPaintEvent event(GetId()); + event.SetEventObject(this); + GetEventHandler()->ProcessEvent(event); + + m_needsRefresh = FALSE; + } +} + +// ---------------------------------------------------------------------------- +// event handlers +// ---------------------------------------------------------------------------- + +// Responds to colour changes: passes event on to children. +void wxWindow::OnSysColourChanged(wxSysColourChangedEvent& event) +{ + wxWindowList::Node *node = GetChildren().GetFirst(); + while ( node ) + { + // Only propagate to non-top-level windows + wxWindow *win = node->GetData(); + if ( win->GetParent() ) + { + wxSysColourChangedEvent event2; + event.m_eventObject = win; + win->GetEventHandler()->ProcessEvent(event2); + } + + node = node->GetNext(); + } +} + +void wxWindow::OnIdle(wxIdleEvent& WXUNUSED(event)) +{ + // This calls the UI-update mechanism (querying windows for + // menu/toolbar/control state information) + UpdateWindowUI(); +} + +// ---------------------------------------------------------------------------- +// accelerators +// ---------------------------------------------------------------------------- + +bool wxWindow::ProcessAccelerator(wxKeyEvent& event) +{ + if (!m_acceleratorTable.Ok()) + return FALSE; + + int count = m_acceleratorTable.GetCount(); + wxAcceleratorEntry* entries = m_acceleratorTable.GetEntries(); + int i; + for (i = 0; i < count; i++) + { + wxAcceleratorEntry* entry = & (entries[i]); + if (entry->MatchesEvent(event)) + { + // Bingo, we have a match. Now find a control that matches the + // entry command id. + + // Need to go up to the top of the window hierarchy, since it might + // be e.g. a menu item + wxWindow* parent = this; + while ( parent && !parent->IsTopLevel() ) + parent = parent->GetParent(); + + if (!parent) + return FALSE; + + wxFrame* frame = wxDynamicCast(parent, wxFrame); + if ( frame ) + { + // Try for a menu command + if (frame->GetMenuBar()) + { + wxMenuItem* item = frame->GetMenuBar()->FindItem(entry->GetCommand()); + if (item) + { + wxCommandEvent commandEvent(wxEVT_COMMAND_MENU_SELECTED, entry->GetCommand()); + commandEvent.SetEventObject(frame); + + // If ProcessEvent returns TRUE (it was handled), then + // the calling code will skip the event handling. + return frame->GetEventHandler()->ProcessEvent(commandEvent); + } + } + } + + // Find a child matching the command id + wxWindow* child = parent->FindWindow(entry->GetCommand()); + + // No such child + if (!child) + return FALSE; + + // Now we process those kinds of windows that we can. + // For now, only buttons. + if ( wxDynamicCast(child, wxButton) ) + { + wxCommandEvent commandEvent (wxEVT_COMMAND_BUTTON_CLICKED, child->GetId()); + commandEvent.SetEventObject(child); + return child->GetEventHandler()->ProcessEvent(commandEvent); + } + + return FALSE; + } // matches event + }// for + + // We didn't match the key event against an accelerator. + return FALSE; +} + +// ============================================================================ +// Motif-specific stuff from here on +// ============================================================================ + +// ---------------------------------------------------------------------------- +// function which maintain the global hash table mapping Widgets to wxWindows +// ---------------------------------------------------------------------------- + +bool wxAddWindowToTable(Widget w, wxWindow *win) +{ + wxWindow *oldItem = NULL; + if ((oldItem = (wxWindow *)wxWidgetHashTable->Get ((long) w))) + { + wxLogDebug("Widget table clash: new widget is %ld, %s", + (long)w, win->GetClassInfo()->GetClassName()); + return FALSE; + } + + wxWidgetHashTable->Put((long) w, win); + + wxLogTrace("widget", "Widget 0x%08x <-> window %p (%s)", + w, win, win->GetClassInfo()->GetClassName()); + + return TRUE; +} + +wxWindow *wxGetWindowFromTable(Widget w) +{ + return (wxWindow *)wxWidgetHashTable->Get((long) w); +} + +void wxDeleteWindowFromTable(Widget w) +{ + wxWidgetHashTable->Delete((long)w); +} + +// ---------------------------------------------------------------------------- +// add/remove window from the table +// ---------------------------------------------------------------------------- + +// Add to hash table, add event handler +bool wxWindow::AttachWidget (wxWindow* WXUNUSED(parent), WXWidget mainWidget, + WXWidget formWidget, int x, int y, int width, int height) +{ + wxAddWindowToTable((Widget) mainWidget, this); + if (CanAddEventHandler()) + { + XtAddEventHandler((Widget) mainWidget, + ButtonPressMask | ButtonReleaseMask | PointerMotionMask, // | KeyPressMask, + False, + wxPanelItemEventHandler, + (XtPointer) this); + } + + if (!formWidget) + { + XtTranslations ptr; + XtOverrideTranslations ((Widget) mainWidget, + ptr = XtParseTranslationTable (": resize()")); + XtFree ((char *) ptr); + } + + // Some widgets have a parent form widget, e.g. wxRadioBox + if (formWidget) + { + if (!wxAddWindowToTable((Widget) formWidget, this)) + return FALSE; + + XtTranslations ptr; + XtOverrideTranslations ((Widget) formWidget, + ptr = XtParseTranslationTable (": resize()")); + XtFree ((char *) ptr); + } + + if (x == -1) + x = 0; + if (y == -1) + y = 0; + SetSize (x, y, width, height); + + return TRUE; +} + +// Remove event handler, remove from hash table +bool wxWindow::DetachWidget(WXWidget widget) +{ + if (CanAddEventHandler()) + { + XtRemoveEventHandler((Widget) widget, + ButtonPressMask | ButtonReleaseMask | PointerMotionMask, // | KeyPressMask, + False, + wxPanelItemEventHandler, + (XtPointer)this); + } + + wxDeleteWindowFromTable((Widget) widget); + return TRUE; +} + +// ---------------------------------------------------------------------------- +// Motif-specific accessors +// ---------------------------------------------------------------------------- + +// Get the underlying X window +WXWindow wxWindow::GetXWindow() const +{ + Widget wMain = (Widget)GetMainWidget(); + if ( wMain ) + return (WXWindow) XtWindow(wMain); + else + return (WXWindow) 0; +} + +// Get the underlying X display +WXDisplay *wxWindow::GetXDisplay() const +{ + Widget wMain = (Widget)GetMainWidget(); + if ( wMain ) + return (WXDisplay*) XtDisplay(wMain); + else + return (WXDisplay*) NULL; +} + +WXWidget wxWindow::GetMainWidget() const +{ + if (m_drawingArea) + return m_drawingArea; + else + return m_mainWidget; +} + +WXWidget wxWindow::GetClientWidget() const +{ + if (m_drawingArea != (WXWidget) 0) + return m_drawingArea; + else + return GetMainWidget(); +} + +WXWidget wxWindow::GetTopWidget() const +{ + return GetMainWidget(); +} + +WXWidget wxWindow::GetLabelWidget() const +{ + return GetMainWidget(); +} + +// ---------------------------------------------------------------------------- +// Motif callbacks +// ---------------------------------------------------------------------------- + +// All widgets should have this as their resize proc. +// OnSize sent to wxWindow via client data. +void wxWidgetResizeProc(Widget w, XConfigureEvent *WXUNUSED(event), String WXUNUSED(args)[], int *WXUNUSED(num_args)) +{ + wxWindow *win = wxGetWindowFromTable(w); + if (!win) + return; + + if (win->PreResize()) + { + int width, height; + win->GetSize(&width, &height); + wxSizeEvent sizeEvent(wxSize(width, height), win->GetId()); + sizeEvent.SetEventObject(win); + win->GetEventHandler()->ProcessEvent(sizeEvent); + } +} + +static void wxCanvasRepaintProc(Widget drawingArea, + XtPointer clientData, + XmDrawingAreaCallbackStruct * cbs) +{ + if (!wxGetWindowFromTable(drawingArea)) + return; + + XEvent * event = cbs->event; + wxWindow * win = (wxWindow *) clientData; + + switch (event->type) + { + case Expose: + { + win->AddUpdateRect(event->xexpose.x, event->xexpose.y, + event->xexpose.width, event->xexpose.height); + + if (event -> xexpose.count == 0) + { + win->DoPaint(); + win->ClearUpdateRects(); + } + break; + } + } +} + +// Unable to deal with Enter/Leave without a separate EventHandler (Motif 1.1.4) +static void wxCanvasEnterLeave(Widget drawingArea, + XtPointer WXUNUSED(clientData), + XCrossingEvent * event) +{ + XmDrawingAreaCallbackStruct cbs; + XEvent ev; + + ((XCrossingEvent &) ev) = *event; + + cbs.reason = XmCR_INPUT; + cbs.event = &ev; + + wxCanvasInputEvent(drawingArea, (XtPointer) NULL, &cbs); +} + +// Fix to make it work under Motif 1.0 (!) +static void wxCanvasMotionEvent (Widget WXUNUSED(drawingArea), XButtonEvent * WXUNUSED(event)) +{ +#if XmVersion <= 1000 + XmDrawingAreaCallbackStruct cbs; + XEvent ev; + + ev = *((XEvent *) event); + cbs.reason = XmCR_INPUT; + cbs.event = &ev; + + wxCanvasInputEvent (drawingArea, (XtPointer) NULL, &cbs); +#endif // XmVersion <= 1000 +} + +static void wxCanvasInputEvent(Widget drawingArea, + XtPointer WXUNUSED(data), + XmDrawingAreaCallbackStruct * cbs) +{ + wxWindow *canvas = wxGetWindowFromTable(drawingArea); + XEvent local_event; + + if (canvas==NULL) + return; + + if (cbs->reason != XmCR_INPUT) + return; + + local_event = *(cbs->event); // We must keep a copy! + + switch (local_event.xany.type) + { + case EnterNotify: + case LeaveNotify: + case ButtonPress: + case ButtonRelease: + case MotionNotify: + { + // FIXME: most of this mouse event code is more or less + // duplicated in wxTranslateMouseEvent + // + wxEventType eventType = wxEVT_NULL; + + if (local_event.xany.type == EnterNotify) + { + //if (local_event.xcrossing.mode!=NotifyNormal) + // return ; // Ignore grab events + eventType = wxEVT_ENTER_WINDOW; + // canvas->GetEventHandler()->OnSetFocus(); + } + else if (local_event.xany.type == LeaveNotify) + { + //if (local_event.xcrossingr.mode!=NotifyNormal) + // return ; // Ignore grab events + eventType = wxEVT_LEAVE_WINDOW; + // canvas->GetEventHandler()->OnKillFocus(); + } + else if (local_event.xany.type == MotionNotify) + { + eventType = wxEVT_MOTION; + } + + else if (local_event.xany.type == ButtonPress) + { + if (local_event.xbutton.button == Button1) + { + eventType = wxEVT_LEFT_DOWN; + canvas->SetButton1(TRUE); + } + else if (local_event.xbutton.button == Button2) + { + eventType = wxEVT_MIDDLE_DOWN; + canvas->SetButton2(TRUE); + } + else if (local_event.xbutton.button == Button3) + { + eventType = wxEVT_RIGHT_DOWN; + canvas->SetButton3(TRUE); + } + } + else if (local_event.xany.type == ButtonRelease) + { + if (local_event.xbutton.button == Button1) + { + eventType = wxEVT_LEFT_UP; + canvas->SetButton1(FALSE); + } + else if (local_event.xbutton.button == Button2) + { + eventType = wxEVT_MIDDLE_UP; + canvas->SetButton2(FALSE); + } + else if (local_event.xbutton.button == Button3) + { + eventType = wxEVT_RIGHT_UP; + canvas->SetButton3(FALSE); + } + } + + wxMouseEvent wxevent (eventType); + + wxevent.m_leftDown = ((eventType == wxEVT_LEFT_DOWN) + || (event_left_is_down (&local_event) + && (eventType != wxEVT_LEFT_UP))); + wxevent.m_middleDown = ((eventType == wxEVT_MIDDLE_DOWN) + || (event_middle_is_down (&local_event) + && (eventType != wxEVT_MIDDLE_UP))); + wxevent.m_rightDown = ((eventType == wxEVT_RIGHT_DOWN) + || (event_right_is_down (&local_event) + && (eventType != wxEVT_RIGHT_UP))); + + wxevent.m_shiftDown = local_event.xbutton.state & ShiftMask; + wxevent.m_controlDown = local_event.xbutton.state & ControlMask; + wxevent.m_altDown = local_event.xbutton.state & Mod3Mask; + wxevent.m_metaDown = local_event.xbutton.state & Mod1Mask; + wxevent.SetTimestamp(local_event.xbutton.time); + + if ( eventType == wxEVT_MOTION ) + { + if (local_event.xmotion.is_hint == NotifyHint) + { + Window root, child; + Display *dpy = XtDisplay (drawingArea); + + XQueryPointer (dpy, XtWindow (drawingArea), + &root, &child, + &local_event.xmotion.x_root, + &local_event.xmotion.y_root, + &local_event.xmotion.x, + &local_event.xmotion.y, + &local_event.xmotion.state); + } + else + { + } + } + + // Now check if we need to translate this event into a double click + if (TRUE) // canvas->doubleClickAllowed) + { + if (wxevent.ButtonDown()) + { + long dclickTime = XtGetMultiClickTime((Display*) wxGetDisplay()); + + // get button and time-stamp + int button = 0; + if (wxevent.LeftDown()) + button = 1; + else if (wxevent.MiddleDown()) + button = 2; + else if (wxevent.RightDown()) + button = 3; + long ts = wxevent.GetTimestamp(); + + // check, if single or double click + int buttonLast = canvas->GetLastClickedButton(); + long lastTS = canvas->GetLastClickTime(); + if ( buttonLast && buttonLast == button && (ts - lastTS) < dclickTime ) + { + // I have a dclick + canvas->SetLastClick(0, ts); + + wxEventType typeDouble; + if ( eventType == wxEVT_LEFT_DOWN ) + typeDouble = wxEVT_LEFT_DCLICK; + else if ( eventType == wxEVT_MIDDLE_DOWN ) + typeDouble = wxEVT_MIDDLE_DCLICK; + else if ( eventType == wxEVT_RIGHT_DOWN ) + typeDouble = wxEVT_RIGHT_DCLICK; + else + typeDouble = wxEVT_NULL; + + if ( typeDouble != wxEVT_NULL ) + { + wxevent.SetEventType(typeDouble); + } + } + else + { + // not fast enough or different button + canvas->SetLastClick(button, ts); + } + } + } + + wxevent.SetId(canvas->GetId()); + wxevent.SetEventObject(canvas); + wxevent.m_x = local_event.xbutton.x; + wxevent.m_y = local_event.xbutton.y; + canvas->GetEventHandler()->ProcessEvent (wxevent); +#if 0 + if (eventType == wxEVT_ENTER_WINDOW || + eventType == wxEVT_LEAVE_WINDOW || + eventType == wxEVT_MOTION + ) + return; +#endif // 0 + break; + } + case KeyPress: + { + KeySym keySym; +#if 0 + XComposeStatus compose; + (void) XLookupString ((XKeyEvent *) & local_event, wxBuffer, 20, &keySym, &compose); +#endif // 0 + + (void) XLookupString ((XKeyEvent *) & local_event, wxBuffer, 20, &keySym, NULL); + int id = wxCharCodeXToWX (keySym); + + wxEventType eventType = wxEVT_CHAR; + + wxKeyEvent event (eventType); + + if (local_event.xkey.state & ShiftMask) + event.m_shiftDown = TRUE; + if (local_event.xkey.state & ControlMask) + event.m_controlDown = TRUE; + if (local_event.xkey.state & Mod3Mask) + event.m_altDown = TRUE; + if (local_event.xkey.state & Mod1Mask) + event.m_metaDown = TRUE; + event.SetEventObject(canvas); + event.m_keyCode = id; + event.SetTimestamp(local_event.xkey.time); + + if (id > -1) + { + // Implement wxFrame::OnCharHook by checking ancestor. + wxWindow *parent = canvas->GetParent(); + while (parent && !parent->IsKindOf(CLASSINFO(wxFrame))) + parent = parent->GetParent(); + + if (parent) + { + event.SetEventType(wxEVT_CHAR_HOOK); + if (parent->GetEventHandler()->ProcessEvent(event)) + return; + } + + // For simplicity, OnKeyDown is the same as OnChar + // TODO: filter modifier key presses from OnChar + event.SetEventType(wxEVT_KEY_DOWN); + + // Only process OnChar if OnKeyDown didn't swallow it + if (!canvas->GetEventHandler()->ProcessEvent (event)) + { + event.SetEventType(wxEVT_CHAR); + canvas->GetEventHandler()->ProcessEvent (event); + } + } + break; + } + case KeyRelease: + { + KeySym keySym; + (void) XLookupString ((XKeyEvent *) & local_event, wxBuffer, 20, &keySym, NULL); + int id = wxCharCodeXToWX (keySym); + + wxKeyEvent event (wxEVT_KEY_UP); + + if (local_event.xkey.state & ShiftMask) + event.m_shiftDown = TRUE; + if (local_event.xkey.state & ControlMask) + event.m_controlDown = TRUE; + if (local_event.xkey.state & Mod3Mask) + event.m_altDown = TRUE; + if (local_event.xkey.state & Mod1Mask) + event.m_metaDown = TRUE; + event.SetEventObject(canvas); + event.m_keyCode = id; + event.SetTimestamp(local_event.xkey.time); + + if (id > -1) + { + canvas->GetEventHandler()->ProcessEvent (event); + } + break; + } + case FocusIn: + { + if (local_event.xfocus.detail != NotifyPointer) + { + wxFocusEvent event(wxEVT_SET_FOCUS, canvas->GetId()); + event.SetEventObject(canvas); + canvas->GetEventHandler()->ProcessEvent(event); + } + break; + } + case FocusOut: + { + if (local_event.xfocus.detail != NotifyPointer) + { + wxFocusEvent event(wxEVT_KILL_FOCUS, canvas->GetId()); + event.SetEventObject(canvas); + canvas->GetEventHandler()->ProcessEvent(event); + } + break; + } + default: + break; + } +} + +static void wxPanelItemEventHandler(Widget wid, + XtPointer WXUNUSED(client_data), + XEvent* event, + Boolean *continueToDispatch) +{ + // Widget can be a label or the actual widget. + + wxWindow *window = wxGetWindowFromTable(wid); + if (window) + { + wxMouseEvent wxevent(0); + if (wxTranslateMouseEvent(wxevent, window, wid, event)) + { + window->GetEventHandler()->ProcessEvent(wxevent); + } + } + + // TODO: probably the key to allowing default behaviour to happen. Say we + // set a m_doDefault flag to FALSE at the start of this function. Then in + // e.g. wxWindow::OnMouseEvent we can call Default() which sets this flag to + // TRUE, indicating that default processing can happen. Thus, behaviour can + // appear to be overridden just by adding an event handler and not calling + // wxWindow::OnWhatever. ALSO, maybe we can use this instead of the current + // way of handling drawing area events, to simplify things. + *continueToDispatch = True; +} + +static void wxScrollBarCallback(Widget scrollbar, + XtPointer clientData, + XmScrollBarCallbackStruct *cbs) +{ + wxWindow *win = wxGetWindowFromTable(scrollbar); + int orientation = (int) clientData; + + wxEventType eventType = wxEVT_NULL; + switch (cbs->reason) + { + case XmCR_INCREMENT: + { + eventType = wxEVT_SCROLLWIN_LINEDOWN; + break; + } + case XmCR_DECREMENT: + { + eventType = wxEVT_SCROLLWIN_LINEUP; + break; + } + case XmCR_DRAG: + { + eventType = wxEVT_SCROLLWIN_THUMBTRACK; + break; + } + case XmCR_VALUE_CHANGED: + { + eventType = wxEVT_SCROLLWIN_THUMBRELEASE; + break; + } + case XmCR_PAGE_INCREMENT: + { + eventType = wxEVT_SCROLLWIN_PAGEDOWN; + break; + } + case XmCR_PAGE_DECREMENT: + { + eventType = wxEVT_SCROLLWIN_PAGEUP; + break; + } + case XmCR_TO_TOP: + { + eventType = wxEVT_SCROLLWIN_TOP; + break; + } + case XmCR_TO_BOTTOM: + { + eventType = wxEVT_SCROLLWIN_BOTTOM; + break; + } + default: + { + // Should never get here + wxFAIL_MSG("Unknown scroll event."); + break; + } + } + + wxScrollWinEvent event(eventType, + cbs->value, + ((orientation == XmHORIZONTAL) ? + wxHORIZONTAL : wxVERTICAL)); + event.SetEventObject( win ); + win->GetEventHandler()->ProcessEvent(event); +} + +// For repainting arbitrary windows +void wxUniversalRepaintProc(Widget w, XtPointer WXUNUSED(c_data), XEvent *event, char *) +{ + Window window; + Display *display; + + wxWindow* win = wxGetWindowFromTable(w); + if (!win) + return; + + switch(event -> type) + { + case Expose: + { + window = (Window) win -> GetXWindow(); + display = (Display *) win -> GetXDisplay(); + + if (event -> xexpose.count == 0) + { + win->DoPaint(); + + win->ClearUpdateRects(); + } + else + { + win->AddUpdateRect(event->xexpose.x, event->xexpose.y, + event->xexpose.width, event->xexpose.height); + } + + break; + } + } +} + +// ---------------------------------------------------------------------------- +// CanvaseXXXSize() functions +// ---------------------------------------------------------------------------- + +// SetSize, but as per old wxCanvas (with drawing widget etc.) +void wxWindow::CanvasSetSize (int x, int y, int w, int h, int sizeFlags) +{ + // A bit of optimization to help sort out the flickers. + int oldX, oldY, oldW, oldH; + GetSize(& oldW, & oldH); + GetPosition(& oldX, & oldY); + + bool useOldPos = FALSE; + bool useOldSize = FALSE; + + if ((x == -1) && (x == -1) && ((sizeFlags & wxSIZE_ALLOW_MINUS_ONE) == 0)) + useOldPos = TRUE; + else if (x == oldX && y == oldY) + useOldPos = TRUE; + + if ((w == -1) && (h == -1)) + useOldSize = TRUE; + else if (w == oldW && h == oldH) + useOldSize = TRUE; + + if (!wxNoOptimize::CanOptimize()) + { + useOldSize = FALSE; useOldPos = FALSE; + } + + if (useOldPos && useOldSize) + return; + + Widget drawingArea = (Widget) m_drawingArea; + bool managed = XtIsManaged(m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow); + + if (managed) + XtUnmanageChild (m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow); + XtVaSetValues(drawingArea, XmNresizePolicy, XmRESIZE_ANY, NULL); + + int xx = x; int yy = y; + AdjustForParentClientOrigin(xx, yy, sizeFlags); + + if (!useOldPos) + { + if (x > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) + { + XtVaSetValues (m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow, + XmNx, xx, NULL); + } + + if (y > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) + { + XtVaSetValues (m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow, + XmNy, yy, NULL); + } + } + + if (!useOldSize) + { + + if (w > -1) + { + if (m_borderWidget) + { + XtVaSetValues ((Widget) m_borderWidget, XmNwidth, w, NULL); + short thick, margin; + XtVaGetValues ((Widget) m_borderWidget, + XmNshadowThickness, &thick, + XmNmarginWidth, &margin, + NULL); + w -= 2 * (thick + margin); + } + + XtVaSetValues ((Widget) m_scrolledWindow, XmNwidth, w, NULL); + + Dimension spacing; + Widget sbar; + XtVaGetValues ((Widget) m_scrolledWindow, + XmNspacing, &spacing, + XmNverticalScrollBar, &sbar, + NULL); + Dimension wsbar; + if (sbar) + XtVaGetValues (sbar, XmNwidth, &wsbar, NULL); + else + wsbar = 0; + + w -= (spacing + wsbar); + +#if 0 + XtVaSetValues(drawingArea, XmNwidth, w, NULL); +#endif // 0 + } + if (h > -1) + { + if (m_borderWidget) + { + XtVaSetValues ((Widget) m_borderWidget, XmNheight, h, NULL); + short thick, margin; + XtVaGetValues ((Widget) m_borderWidget, + XmNshadowThickness, &thick, + XmNmarginHeight, &margin, + NULL); + h -= 2 * (thick + margin); + } + + XtVaSetValues ((Widget) m_scrolledWindow, XmNheight, h, NULL); + + Dimension spacing; + Widget sbar; + XtVaGetValues ((Widget) m_scrolledWindow, + XmNspacing, &spacing, + XmNhorizontalScrollBar, &sbar, + NULL); + Dimension wsbar; + if (sbar) + XtVaGetValues (sbar, XmNheight, &wsbar, NULL); + else + wsbar = 0; + + h -= (spacing + wsbar); + +#if 0 + XtVaSetValues(drawingArea, XmNheight, h, NULL); +#endif // 0 + } + } + + if (managed) + XtManageChild (m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow); + XtVaSetValues(drawingArea, XmNresizePolicy, XmRESIZE_NONE, NULL); + +#if 0 + int ww, hh; + GetClientSize (&ww, &hh); + wxSizeEvent sizeEvent(wxSize(ww, hh), GetId()); + sizeEvent.SetEventObject(this); + + GetEventHandler()->ProcessEvent(sizeEvent); +#endif // 0 +} + +void wxWindow::CanvasSetClientSize (int w, int h) +{ + Widget drawingArea = (Widget) m_drawingArea; + + XtVaSetValues(drawingArea, XmNresizePolicy, XmRESIZE_ANY, NULL); + + if (w > -1) + XtVaSetValues(drawingArea, XmNwidth, w, NULL); + if (h > -1) + XtVaSetValues(drawingArea, XmNheight, h, NULL); + +#if 0 + // TODO: is this necessary? + allowRepainting = FALSE; + + XSync (XtDisplay (drawingArea), FALSE); + XEvent event; + while (XtAppPending (wxTheApp->appContext)) + { + XFlush (XtDisplay (drawingArea)); + XtAppNextEvent (wxTheApp->appContext, &event); + XtDispatchEvent (&event); + } +#endif // 0 + + XtVaSetValues(drawingArea, XmNresizePolicy, XmRESIZE_NONE, NULL); + +#if 0 + allowRepainting = TRUE; + DoRefresh (); + + wxSizeEvent sizeEvent(wxSize(w, h), GetId()); + sizeEvent.SetEventObject(this); + + GetEventHandler()->ProcessEvent(sizeEvent); +#endif // 0 +} + +void wxWindow::CanvasGetClientSize (int *w, int *h) const +{ + // Must return the same thing that was set via SetClientSize + Dimension xx, yy; + XtVaGetValues ((Widget) m_drawingArea, XmNwidth, &xx, XmNheight, &yy, NULL); + *w = xx; + *h = yy; +} + +void wxWindow::CanvasGetSize (int *w, int *h) const +{ + Dimension xx, yy; + if ((Widget) m_borderWidget) + XtVaGetValues ((Widget) m_borderWidget, XmNwidth, &xx, XmNheight, &yy, NULL); + else if ((Widget) m_scrolledWindow) + XtVaGetValues ((Widget) m_scrolledWindow, XmNwidth, &xx, XmNheight, &yy, NULL); + else + XtVaGetValues ((Widget) m_drawingArea, XmNwidth, &xx, XmNheight, &yy, NULL); + + *w = xx; + *h = yy; +} + +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); + + // 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; +} + +// ---------------------------------------------------------------------------- +// TranslateXXXEvent() functions +// ---------------------------------------------------------------------------- + +bool wxTranslateMouseEvent(wxMouseEvent& wxevent, wxWindow *win, Widget widget, XEvent *xevent) +{ + switch (xevent->xany.type) + { + case EnterNotify: // never received here - yes ? MB + case LeaveNotify: // never received here - yes ? MB + case ButtonPress: + case ButtonRelease: + case MotionNotify: + { + wxEventType eventType = wxEVT_NULL; + + // FIXME: this is never true I think - MB + // + if (xevent->xany.type == LeaveNotify) + { + win->SetButton1(FALSE); + win->SetButton2(FALSE); + win->SetButton3(FALSE); + return FALSE; + } + else if (xevent->xany.type == MotionNotify) + { + eventType = wxEVT_MOTION; + } + else if (xevent->xany.type == ButtonPress) + { + wxevent.SetTimestamp(xevent->xbutton.time); + int button = 0; + if (xevent->xbutton.button == Button1) + { + eventType = wxEVT_LEFT_DOWN; + win->SetButton1(TRUE); + button = 1; + } + else if (xevent->xbutton.button == Button2) + { + eventType = wxEVT_MIDDLE_DOWN; + win->SetButton2(TRUE); + button = 2; + } + else if (xevent->xbutton.button == Button3) + { + eventType = wxEVT_RIGHT_DOWN; + win->SetButton3(TRUE); + button = 3; + } + + // check for a double click + // + long dclickTime = XtGetMultiClickTime((Display*) wxGetDisplay()); + long ts = wxevent.GetTimestamp(); + + int buttonLast = win->GetLastClickedButton(); + long lastTS = win->GetLastClickTime(); + if ( buttonLast && buttonLast == button && (ts - lastTS) < dclickTime ) + { + // I have a dclick + win->SetLastClick(0, ts); + if ( eventType == wxEVT_LEFT_DOWN ) + eventType = wxEVT_LEFT_DCLICK; + else if ( eventType == wxEVT_MIDDLE_DOWN ) + eventType = wxEVT_MIDDLE_DCLICK; + else if ( eventType == wxEVT_RIGHT_DOWN ) + eventType = wxEVT_RIGHT_DCLICK; + } + else + { + // not fast enough or different button + win->SetLastClick(button, ts); + } + } + else if (xevent->xany.type == ButtonRelease) + { + if (xevent->xbutton.button == Button1) + { + eventType = wxEVT_LEFT_UP; + win->SetButton1(FALSE); + } + else if (xevent->xbutton.button == Button2) + { + eventType = wxEVT_MIDDLE_UP; + win->SetButton2(FALSE); + } + else if (xevent->xbutton.button == Button3) + { + eventType = wxEVT_RIGHT_UP; + win->SetButton3(FALSE); + } + else return FALSE; + } + else + { + return FALSE; + } + + wxevent.SetEventType(eventType); + + Position x1, y1; + XtVaGetValues(widget, XmNx, &x1, XmNy, &y1, NULL); + + int x2, y2; + win->GetPosition(&x2, &y2); + + // The button x/y must be translated to wxWindows + // window space - the widget might be a label or button, + // within a form. + int dx = 0; + int dy = 0; + if (widget != (Widget)win->GetMainWidget()) + { + dx = x1; + dy = y1; + } + + wxevent.m_x = xevent->xbutton.x + dx; + wxevent.m_y = xevent->xbutton.y + dy; + + wxevent.m_leftDown = ((eventType == wxEVT_LEFT_DOWN) + || (event_left_is_down (xevent) + && (eventType != wxEVT_LEFT_UP))); + wxevent.m_middleDown = ((eventType == wxEVT_MIDDLE_DOWN) + || (event_middle_is_down (xevent) + && (eventType != wxEVT_MIDDLE_UP))); + wxevent.m_rightDown = ((eventType == wxEVT_RIGHT_DOWN) + || (event_right_is_down (xevent) + && (eventType != wxEVT_RIGHT_UP))); + + wxevent.m_shiftDown = xevent->xbutton.state & ShiftMask; + wxevent.m_controlDown = xevent->xbutton.state & ControlMask; + wxevent.m_altDown = xevent->xbutton.state & Mod3Mask; + wxevent.m_metaDown = xevent->xbutton.state & Mod1Mask; + + wxevent.SetId(win->GetId()); + wxevent.SetEventObject(win); + + return TRUE; + } + } + return FALSE; +} + +bool wxTranslateKeyEvent(wxKeyEvent& wxevent, wxWindow *win, Widget WXUNUSED(widget), XEvent *xevent) +{ + switch (xevent->xany.type) + { + case KeyPress: + case KeyRelease: + { + char buf[20]; + + KeySym keySym; +#if 0 + XComposeStatus compose; + (void) XLookupString ((XKeyEvent *) xevent, buf, 20, &keySym, &compose); +#endif // 0 + (void) XLookupString ((XKeyEvent *) xevent, buf, 20, &keySym, NULL); + int id = wxCharCodeXToWX (keySym); + + if (xevent->xkey.state & ShiftMask) + wxevent.m_shiftDown = TRUE; + if (xevent->xkey.state & ControlMask) + wxevent.m_controlDown = TRUE; + if (xevent->xkey.state & Mod3Mask) + wxevent.m_altDown = TRUE; + if (xevent->xkey.state & Mod1Mask) + wxevent.m_metaDown = TRUE; + wxevent.SetEventObject(win); + wxevent.m_keyCode = id; + wxevent.SetTimestamp(xevent->xkey.time); + + wxevent.m_x = xevent->xbutton.x; + wxevent.m_y = xevent->xbutton.y; + + if (id > -1) + return TRUE; + else + return FALSE; + break; + } + default: + break; + } + return FALSE; +} + +// ---------------------------------------------------------------------------- +// Colour stuff +// ---------------------------------------------------------------------------- + +#define YAllocColor XAllocColor +XColor g_itemColors[5]; +int wxComputeColours (Display *display, wxColour * back, wxColour * fore) +{ + int result; + static XmColorProc colorProc; + + result = wxNO_COLORS; + + if (back) + { + 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 + colorProc = XmSetColorCalculation ((XmColorProc) NULL); + // And set it back to motif. + XmSetColorCalculation (colorProc); + } + (*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) + { + 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; + } + + Display *dpy = display; + Colormap cmap = (Colormap) wxTheApp->GetMainColormap((WXDisplay*) dpy); + + if (back) + { + /* 5 Colours to allocate */ + for (int i = 0; i < 5; i++) + if (!YAllocColor (dpy, cmap, &g_itemColors[i])) + result = wxNO_COLORS; + } + else if (fore) + { + /* Only 1 colour to allocate */ + if (!YAllocColor (dpy, cmap, &g_itemColors[wxFORE_INDEX])) + result = wxNO_COLORS; + } + + return (result); + +} + +// 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() +{ + WXWidget mainWidget = GetMainWidget(); + if ( mainWidget ) + DoChangeBackgroundColour(mainWidget, m_backgroundColour); + + // This not necessary +#if 0 + + if (m_scrolledWindow && (GetMainWidget() != m_scrolledWindow)) + { + DoChangeBackgroundColour(m_scrolledWindow, m_backgroundColour); + // Have to set the scrollbar colours back since + // the scrolled window seemed to change them + wxColour backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); + + if (m_hScrollBar) + DoChangeBackgroundColour(m_hScrollBar, backgroundColour); + if (m_vScrollBar) + DoChangeBackgroundColour(m_vScrollBar, backgroundColour); + } +#endif +} + +void wxWindow::ChangeForegroundColour() +{ + WXWidget mainWidget = GetMainWidget(); + if ( mainWidget ) + DoChangeForegroundColour(mainWidget, m_foregroundColour); + if ( m_scrolledWindow && mainWidget != m_scrolledWindow ) + DoChangeForegroundColour(m_scrolledWindow, m_foregroundColour); +} + +// Change a widget's foreground and background colours. +void wxWindow::DoChangeForegroundColour(WXWidget widget, wxColour& foregroundColour) +{ + // 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. + + Widget w = (Widget)widget; + XtVaSetValues( + w, + XmNforeground, foregroundColour.AllocColour(XtDisplay(w)), + NULL + ); +} + +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); + + if (changeArmColour) + XtVaSetValues ((Widget) widget, + XmNarmColor, g_itemColors[wxSELE_INDEX].pixel, + NULL); +} + +bool wxWindow::SetBackgroundColour(const wxColour& col) +{ + if ( !wxWindowBase::SetBackgroundColour(col) ) + return FALSE; + + ChangeBackgroundColour(); + + return TRUE; +} + +bool wxWindow::SetForegroundColour(const wxColour& col) +{ + if ( !wxWindowBase::SetForegroundColour(col) ) + return FALSE; + + ChangeForegroundColour(); + + return TRUE; +} + +void wxWindow::ChangeFont(bool keepOriginalSize) +{ + // 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_font.Ok()) + { + int width, height, width1, height1; + GetSize(& width, & height); + + // lesstif 0.87 hangs here +#ifndef LESSTIF_VERSION + XtVaSetValues (w, + XmNfontList, (XmFontList) m_font.GetFontList(1.0, XtDisplay(w)), + NULL); +#endif + + GetSize(& width1, & height1); + if (keepOriginalSize && (width != width1 || height != height1)) + { + SetSize(-1, -1, width, height); + } + } +} + +// ---------------------------------------------------------------------------- +// global functions +// ---------------------------------------------------------------------------- + +wxWindow *wxGetActiveWindow() +{ + // TODO + wxFAIL_MSG("Not implemented"); + return NULL; +} + +/* static */ +wxWindow *wxWindowBase::GetCapture() +{ + return (wxWindow *)g_captureWindow; +} + + +// Find the wxWindow at the current mouse position, returning the mouse +// position. +wxWindow* wxFindWindowAtPointer(wxPoint& pt) +{ + return wxFindWindowAtPoint(wxGetMousePosition()); +} + +// Get the current mouse position. +wxPoint wxGetMousePosition() +{ + Display *display = (Display*) wxGetDisplay(); + Window rootWindow = RootWindowOfScreen (DefaultScreenOfDisplay(display)); + Window rootReturn, childReturn; + int rootX, rootY, winX, winY; + unsigned int maskReturn; + + XQueryPointer (display, + rootWindow, + &rootReturn, + &childReturn, + &rootX, &rootY, &winX, &winY, &maskReturn); + return wxPoint(rootX, rootY); +} + + +// ---------------------------------------------------------------------------- +// wxNoOptimize: switch off size optimization +// ---------------------------------------------------------------------------- + +int wxNoOptimize::ms_count = 0; + -- 2.45.2