#ifndef _WX_CONTROL_H_BASE_
#define _WX_CONTROL_H_BASE_
+// all classes derived from wxControl need the validators
+#include "wx/validate.h"
+
#if defined(__WXMSW__)
#include "wx/msw/control.h"
#elif defined(__WXMOTIF__)
typedef int (*WXFARPROC)();
#endif
-#endif
+typedef WXHWND WXWidget;
+#endif // MSW
#ifdef __WXMOTIF__
/* Stand-ins for X/Xt/Motif types */
typedef void* WXImage;
typedef void* WXCursor;
typedef void* WXFontList;
-#endif
+#endif // Motif
#ifdef __WXGTK__
/* Stand-ins for GLIB types */
typedef struct _GtkItemFactory GtkItemFactory;
typedef struct _GtkSelectionData GtkSelectionData;
-#endif
+typedef GtkWidget *WXWidget;
+#endif // GTK
// This is required because of clashing macros in windows.h, which may be
// included before or after wxWindows classes, and therefore must be
// Created: 01/02/97
// RCS-ID: $Id$
// Copyright: (c)
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GDICMNH__
#define _WX_GDICMNH__
+// ---------------------------------------------------------------------------
+// headers
+// ---------------------------------------------------------------------------
+
#ifdef __GNUG__
-#pragma interface "gdicmn.h"
+ #pragma interface "gdicmn.h"
#endif
#include "wx/object.h"
#include "wx/setup.h"
#include "wx/colour.h"
+// ---------------------------------------------------------------------------
+// forward declarations
+// ---------------------------------------------------------------------------
+
+class WXDLLEXPORT wxBitmap;
+class WXDLLEXPORT wxBrush;
+class WXDLLEXPORT wxColour;
+class WXDLLEXPORT wxCursor;
+class WXDLLEXPORT wxFont;
+class WXDLLEXPORT wxIcon;
+class WXDLLEXPORT wxPalette;
+class WXDLLEXPORT wxPen;
+class WXDLLEXPORT wxRegion;
+class WXDLLEXPORT wxString;
+
+// ---------------------------------------------------------------------------
+// constants
+// ---------------------------------------------------------------------------
+
+// Bitmap flags
+enum
+{
+ wxBITMAP_TYPE_BMP = 1,
+ wxBITMAP_TYPE_BMP_RESOURCE,
+ wxBITMAP_TYPE_RESOURCE = wxBITMAP_TYPE_BMP_RESOURCE,
+ wxBITMAP_TYPE_ICO,
+ wxBITMAP_TYPE_ICO_RESOURCE,
+ wxBITMAP_TYPE_CUR,
+ wxBITMAP_TYPE_CUR_RESOURCE,
+ wxBITMAP_TYPE_XBM,
+ wxBITMAP_TYPE_XBM_DATA,
+ wxBITMAP_TYPE_XPM,
+ wxBITMAP_TYPE_XPM_DATA,
+ wxBITMAP_TYPE_TIF,
+ wxBITMAP_TYPE_TIF_RESOURCE,
+ wxBITMAP_TYPE_GIF,
+ wxBITMAP_TYPE_GIF_RESOURCE,
+ wxBITMAP_TYPE_PNG,
+ wxBITMAP_TYPE_PNG_RESOURCE,
+ wxBITMAP_TYPE_JPEG,
+ wxBITMAP_TYPE_JPEG_RESOURCE,
+ wxBITMAP_TYPE_ANY = 50
+};
+
// Standard cursors
-typedef enum {
- wxCURSOR_NONE = 0,
- wxCURSOR_ARROW = 1,
- wxCURSOR_BULLSEYE,
- wxCURSOR_CHAR,
- wxCURSOR_CROSS,
- wxCURSOR_HAND,
- wxCURSOR_IBEAM,
- wxCURSOR_LEFT_BUTTON,
- wxCURSOR_MAGNIFIER,
- wxCURSOR_MIDDLE_BUTTON,
- wxCURSOR_NO_ENTRY,
- wxCURSOR_PAINT_BRUSH,
- wxCURSOR_PENCIL,
- wxCURSOR_POINT_LEFT,
- wxCURSOR_POINT_RIGHT,
- wxCURSOR_QUESTION_ARROW,
- wxCURSOR_RIGHT_BUTTON,
- wxCURSOR_SIZENESW,
- wxCURSOR_SIZENS,
- wxCURSOR_SIZENWSE,
- wxCURSOR_SIZEWE,
- wxCURSOR_SIZING,
- wxCURSOR_SPRAYCAN,
- wxCURSOR_WAIT,
- wxCURSOR_WATCH,
- wxCURSOR_BLANK
+enum wxStockCursor
+{
+ wxCURSOR_NONE, // should be 0
+ wxCURSOR_ARROW,
+ wxCURSOR_BULLSEYE,
+ wxCURSOR_CHAR,
+ wxCURSOR_CROSS,
+ wxCURSOR_HAND,
+ wxCURSOR_IBEAM,
+ wxCURSOR_LEFT_BUTTON,
+ wxCURSOR_MAGNIFIER,
+ wxCURSOR_MIDDLE_BUTTON,
+ wxCURSOR_NO_ENTRY,
+ wxCURSOR_PAINT_BRUSH,
+ wxCURSOR_PENCIL,
+ wxCURSOR_POINT_LEFT,
+ wxCURSOR_POINT_RIGHT,
+ wxCURSOR_QUESTION_ARROW,
+ wxCURSOR_RIGHT_BUTTON,
+ wxCURSOR_SIZENESW,
+ wxCURSOR_SIZENS,
+ wxCURSOR_SIZENWSE,
+ wxCURSOR_SIZEWE,
+ wxCURSOR_SIZING,
+ wxCURSOR_SPRAYCAN,
+ wxCURSOR_WAIT,
+ wxCURSOR_WATCH,
+ wxCURSOR_BLANK,
#ifdef __X__
- /* Not yet implemented for Windows */
- , wxCURSOR_CROSS_REVERSE,
- wxCURSOR_DOUBLE_ARROW,
- wxCURSOR_BASED_ARROW_UP,
- wxCURSOR_BASED_ARROW_DOWN
-#endif
-} wxStockCursor;
+ // Not yet implemented for Windows
+ wxCURSOR_CROSS_REVERSE,
+ wxCURSOR_DOUBLE_ARROW,
+ wxCURSOR_BASED_ARROW_UP,
+ wxCURSOR_BASED_ARROW_DOWN
+#endif // X11
+
+ wxCURSOR_MAX
+};
+
+// ---------------------------------------------------------------------------
+// macros
+// ---------------------------------------------------------------------------
+
+/* Useful macro for creating icons portably, for example:
+
+ wxIcon *icon = new wxICON(mondrian);
+
+ expands into:
+
+ wxIcon *icon = new wxIcon("mondrian"); // On wxMSW
+ wxIcon *icon = new wxIcon(mondrian_xpm); // On wxGTK
+ */
+
+#ifdef __WXMSW__
+ // Load from a resource
+ #define wxICON(X) wxIcon("" #X "")
+#elif defined(__WXGTK__)
+ // Initialize from an included XPM
+ #define wxICON(X) wxIcon( (const char**) X##_xpm )
+#elif defined(__WXMOTIF__)
+ // 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 "")
+#endif // platform
+
+// ===========================================================================
+// classes
+// ===========================================================================
+// ---------------------------------------------------------------------------
+// wxSize
+// ---------------------------------------------------------------------------
class WXDLLEXPORT wxSize
{
public:
- long x;
- long y;
- inline wxSize() { x = 0; y = 0; }
- inline wxSize(long xx, long yy) { x = xx; y = yy; }
- inline wxSize(const wxSize& sz) { x = sz.x; y = sz.y; }
- inline void operator = (const wxSize& sz) { x = sz.x; y = sz.y; }
- inline bool operator == (const wxSize& sz) const { return (x == sz.x && y == sz.y); }
- inline wxSize operator + (const wxSize& sz) { return wxSize(x + sz.x, y + sz.y); }
- inline wxSize operator - (const wxSize& sz) { return wxSize(x - sz.x, y - sz.y); }
- inline void Set(long xx, long yy) { x = xx; y = yy; }
- inline long GetX() const { return x; }
- inline long GetY() const { return y; }
+ // members are public for compatibility
+ long x;
+ long y;
+
+ // constructors
+ wxSize() { x = y = 0; }
+ wxSize(long xx, long yy) { Set(xx, yy); }
+
+ // no copy ctor or assignment operator - the defaults are ok
+
+ bool operator==(const wxSize& sz) const { return x == sz.x && y == sz.y; }
+
+ // FIXME are these really useful? If they're, we should have += &c as well
+ 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); }
+
+ void Set(long xx, long yy) { x = xx; y = yy; }
+
+ long GetX() const { return x; }
+ long GetY() const { return y; }
};
-// Point
+// ---------------------------------------------------------------------------
+// Point classes: with real or integer coordinates
+// ---------------------------------------------------------------------------
class WXDLLEXPORT wxRealPoint
{
- public:
- double x;
- double y;
- inline wxRealPoint() { x = 0.0; y = 0.0; };
- inline wxRealPoint(double _x, double _y) { x = _x; y = _y; };
- inline wxRealPoint operator + (const wxRealPoint& pt) { return wxRealPoint(x + pt.x, y + pt.y); }
- inline wxRealPoint operator - (const wxRealPoint& pt) { return wxRealPoint(x - pt.x, y - pt.y); }
-
- inline void operator = (const wxRealPoint& pt) { x = pt.x; y = pt.y; }
- inline bool operator == (const wxRealPoint& pt) const { return (x == pt.x && y == pt.y); }
+public:
+ double x;
+ double y;
+
+ wxRealPoint() { x = y = 0.0; };
+ wxRealPoint(double xx, double yy) { x = xx; y = yy; };
+
+ wxRealPoint operator+(const wxRealPoint& pt) { return wxRealPoint(x + pt.x, y + pt.y); }
+ wxRealPoint operator-(const wxRealPoint& pt) { return wxRealPoint(x - pt.x, y - pt.y); }
+
+ bool operator==(const wxRealPoint& pt) const { return x == pt.x && y == pt.y; }
};
class WXDLLEXPORT wxPoint
{
- public:
+public:
#if defined(__WXMSW__) && !defined(__WIN32__)
- int x;
- int y;
+ int x;
+ int y;
#else
- long x;
- long y;
+ long x;
+ long y;
#endif
- inline wxPoint() { x = 0; y = 0; };
- wxPoint(long the_x, long the_y) { x = the_x; y = the_y; };
- wxPoint(const wxPoint& pt) { x = pt.x; y = pt.y; };
+ wxPoint() { x = y = 0; };
+ wxPoint(long xx, long yy) { x = xx; y = yy; };
+
+ // no copy ctor or assignment operator - the defaults are ok
- inline void operator = (const wxPoint& pt) { x = pt.x; y = pt.y; }
- inline bool operator == (const wxPoint& pt) const { return (x == pt.x && y == pt.y); }
- inline wxPoint operator + (const wxPoint& pt) { return wxPoint(x + pt.x, y + pt.y); }
- inline wxPoint operator - (const wxPoint& pt) { return wxPoint(x - pt.x, y - pt.y); }
+ bool operator==(const wxPoint& pt) const { return x == pt.x && y == pt.y; }
+
+ wxPoint operator + (const wxPoint& pt) { return wxPoint(x + pt.x, y + pt.y); }
+ wxPoint operator - (const wxPoint& pt) { return wxPoint(x - pt.x, y - pt.y); }
};
#if WXWIN_COMPATIBILITY
-#define wxIntPoint wxPoint
-#define wxRectangle wxRect
-#endif
+ #define wxIntPoint wxPoint
+ #define wxRectangle wxRect
+#endif // WXWIN_COMPATIBILITY
+
+// ---------------------------------------------------------------------------
+// wxRect
+// ---------------------------------------------------------------------------
class WXDLLEXPORT wxRect
{
public:
- wxRect() ;
- wxRect(long x, long y, long w, long h);
- wxRect(const wxPoint& topLeft, const wxPoint& bottomRight);
- wxRect(const wxPoint& pos, const wxSize& size);
- wxRect(const wxRect& rect);
-
- inline long GetX() const { return x; }
- inline void SetX(long X) { x = X; }
- inline long GetY() const { return y; }
- inline void SetY(long Y) { y = Y; }
- inline long GetWidth() const { return width; }
- inline void SetWidth(long w) { width = w; }
- inline long GetHeight() const { return height; }
- inline void SetHeight(long h) { height = h; }
-
- inline wxPoint GetPosition() { return wxPoint(x, y); }
- inline wxSize GetSize() { return wxSize(width, height); }
-
- inline long GetLeft() const { return x; }
- inline long GetTop() const { return y; }
- inline long GetBottom() const { return y + height; }
- inline long GetRight() const { return x + width; }
-
- wxRect& operator = (const wxRect& rect);
- bool operator == (const wxRect& rect);
- bool operator != (const wxRect& rect);
-public:
- long x, y, width, height;
-};
+ wxRect();
+ wxRect(long x, long y, long w, long h);
+ wxRect(const wxPoint& topLeft, const wxPoint& bottomRight);
+ wxRect(const wxPoint& pos, const wxSize& size);
+ wxRect(const wxRect& rect);
-class WXDLLEXPORT wxBrush;
-class WXDLLEXPORT wxPen;
-class WXDLLEXPORT wxBitmap;
-class WXDLLEXPORT wxIcon;
-class WXDLLEXPORT wxCursor;
-class WXDLLEXPORT wxFont;
-class WXDLLEXPORT wxPalette;
-class WXDLLEXPORT wxPalette;
-class WXDLLEXPORT wxRegion;
+ long GetX() const { return x; }
+ void SetX(long xx) { x = xx; }
-/*
- * Bitmap flags
- */
+ long GetY() const { return y; }
+ void SetY(long yy) { y = yy; }
-// Hint to indicate filetype
-#define wxBITMAP_TYPE_BMP 1
-#define wxBITMAP_TYPE_BMP_RESOURCE 2
-#define wxBITMAP_TYPE_ICO 3
-#define wxBITMAP_TYPE_ICO_RESOURCE 4
-#define wxBITMAP_TYPE_CUR 5
-#define wxBITMAP_TYPE_CUR_RESOURCE 6
-#define wxBITMAP_TYPE_XBM 7
-#define wxBITMAP_TYPE_XBM_DATA 8
-#define wxBITMAP_TYPE_XPM 9
-#define wxBITMAP_TYPE_XPM_DATA 10
-#define wxBITMAP_TYPE_TIF 11
-#define wxBITMAP_TYPE_TIF_RESOURCE 12
-#define wxBITMAP_TYPE_GIF 13
-#define wxBITMAP_TYPE_GIF_RESOURCE 14
-#define wxBITMAP_TYPE_PNG 15
-#define wxBITMAP_TYPE_PNG_RESOURCE 16
-#define wxBITMAP_TYPE_JPEG 17
-#define wxBITMAP_TYPE_JPEG_RESOURCE 18
-#define wxBITMAP_TYPE_ANY 50
-
-#define wxBITMAP_TYPE_RESOURCE wxBITMAP_TYPE_BMP_RESOURCE
+ long GetWidth() const { return width; }
+ void SetWidth(long w) { width = w; }
-class WXDLLEXPORT wxBitmap;
-class WXDLLEXPORT wxCursor;
-class WXDLLEXPORT wxIcon;
-class WXDLLEXPORT wxColour;
-class WXDLLEXPORT wxString;
+ long GetHeight() const { return height; }
+ void SetHeight(long h) { height = h; }
+
+ wxPoint GetPosition() { return wxPoint(x, y); }
+ wxSize GetSize() { return wxSize(width, height); }
+
+ long GetLeft() const { return x; }
+ long GetTop() const { return y; }
+ long GetBottom() const { return y + height; }
+ long GetRight() const { return x + width; }
+
+ wxRect& operator = (const wxRect& rect);
+ bool operator == (const wxRect& rect);
+ bool operator != (const wxRect& rect);
+
+public:
+ long x, y, width, height;
+};
+// ---------------------------------------------------------------------------
// Management of pens, brushes and fonts
-class WXDLLEXPORT wxPenList: public wxList
+// ---------------------------------------------------------------------------
+
+class WXDLLEXPORT wxPenList : public wxList
{
- DECLARE_DYNAMIC_CLASS(wxPenList)
- public:
- inline wxPenList()
- { }
- ~wxPenList();
- void AddPen(wxPen *pen);
- void RemovePen(wxPen *pen);
- wxPen *FindOrCreatePen(const wxColour& colour, int width, int style);
+ DECLARE_DYNAMIC_CLASS(wxPenList)
+
+public:
+ wxPenList() { }
+ ~wxPenList();
+
+ void AddPen(wxPen *pen);
+ void RemovePen(wxPen *pen);
+ wxPen *FindOrCreatePen(const wxColour& colour, int width, int style);
};
-class WXDLLEXPORT wxBrushList: public wxList
+class WXDLLEXPORT wxBrushList : public wxList
{
- DECLARE_DYNAMIC_CLASS(wxBrushList)
- public:
- inline wxBrushList()
- { }
- ~wxBrushList();
- void AddBrush(wxBrush *brush);
- void RemoveBrush(wxBrush *brush);
- wxBrush *FindOrCreateBrush(const wxColour& colour, int style);
+ DECLARE_DYNAMIC_CLASS(wxBrushList)
+
+public:
+ wxBrushList() { }
+ ~wxBrushList();
+
+ void AddBrush(wxBrush *brush);
+ void RemoveBrush(wxBrush *brush);
+ wxBrush *FindOrCreateBrush(const wxColour& colour, int style);
};
WXDLLEXPORT_DATA(extern const wxChar*) wxEmptyString;
-class WXDLLEXPORT wxFontList: public wxList
+class WXDLLEXPORT wxFontList : public wxList
{
- DECLARE_DYNAMIC_CLASS(wxFontList)
- public:
- inline wxFontList()
- { }
- ~wxFontList();
- void AddFont(wxFont *font);
- void RemoveFont(wxFont *font);
- wxFont *FindOrCreateFont(int pointSize, int family, int style, int weight,
- bool underline = FALSE, const wxString& face = wxEmptyString);
+ DECLARE_DYNAMIC_CLASS(wxFontList)
+
+public:
+ wxFontList() { }
+ ~wxFontList();
+
+ void AddFont(wxFont *font);
+ void RemoveFont(wxFont *font);
+ wxFont *FindOrCreateFont(int pointSize, int family, int style, int weight,
+ bool underline = FALSE,
+ const wxString& face = wxEmptyString);
};
-class WXDLLEXPORT wxColourDatabase: public wxList
+class WXDLLEXPORT wxColourDatabase : public wxList
{
- DECLARE_CLASS(wxColourDatabase)
- public:
- wxColourDatabase(int type);
- ~wxColourDatabase() ;
- // Not const because it may add a name to the database
- wxColour *FindColour(const wxString& colour) ;
- wxString FindName(const wxColour& colour) const;
- void Initialize();
+ DECLARE_CLASS(wxColourDatabase)
+
+public:
+ wxColourDatabase(int type);
+ ~wxColourDatabase() ;
+
+ // Not const because it may add a name to the database
+ wxColour *FindColour(const wxString& colour) ;
+ wxString FindName(const wxColour& colour) const;
+ void Initialize();
};
-class WXDLLEXPORT wxBitmapList: public wxList
+class WXDLLEXPORT wxBitmapList : public wxList
{
- DECLARE_DYNAMIC_CLASS(wxBitmapList)
- public:
- wxBitmapList();
- ~wxBitmapList();
+ DECLARE_DYNAMIC_CLASS(wxBitmapList)
- void AddBitmap(wxBitmap *bitmap);
- void RemoveBitmap(wxBitmap *bitmap);
+public:
+ wxBitmapList();
+ ~wxBitmapList();
+
+ void AddBitmap(wxBitmap *bitmap);
+ void RemoveBitmap(wxBitmap *bitmap);
};
+class WXDLLEXPORT wxResourceCache: public wxList
+{
+public:
+ wxResourceCache() { }
+ wxResourceCache(const unsigned int keyType) : wxList(keyType) { }
+ ~wxResourceCache();
+
+private:
+ DECLARE_DYNAMIC_CLASS(wxResourceCache)
+};
+
+// ---------------------------------------------------------------------------
+// global variables
+// ---------------------------------------------------------------------------
+
// Lists of GDI objects
-WXDLLEXPORT_DATA(extern wxPenList*) wxThePenList;
-WXDLLEXPORT_DATA(extern wxBrushList*) wxTheBrushList;
-WXDLLEXPORT_DATA(extern wxFontList*) wxTheFontList;
-WXDLLEXPORT_DATA(extern wxBitmapList*) wxTheBitmapList;
+WXDLLEXPORT_DATA(extern wxPenList*) wxThePenList;
+WXDLLEXPORT_DATA(extern wxBrushList*) wxTheBrushList;
+WXDLLEXPORT_DATA(extern wxFontList*) wxTheFontList;
+WXDLLEXPORT_DATA(extern wxBitmapList*) wxTheBitmapList;
// Stock objects
-WXDLLEXPORT_DATA(extern wxFont*) wxNORMAL_FONT;
-WXDLLEXPORT_DATA(extern wxFont*) wxSMALL_FONT;
-WXDLLEXPORT_DATA(extern wxFont*) wxITALIC_FONT;
-WXDLLEXPORT_DATA(extern wxFont*) wxSWISS_FONT;
-
-WXDLLEXPORT_DATA(extern wxPen*) wxRED_PEN;
-WXDLLEXPORT_DATA(extern wxPen*) wxCYAN_PEN;
-WXDLLEXPORT_DATA(extern wxPen*) wxGREEN_PEN;
-WXDLLEXPORT_DATA(extern wxPen*) wxBLACK_PEN;
-WXDLLEXPORT_DATA(extern wxPen*) wxWHITE_PEN;
-WXDLLEXPORT_DATA(extern wxPen*) wxTRANSPARENT_PEN;
-WXDLLEXPORT_DATA(extern wxPen*) wxBLACK_DASHED_PEN;
-WXDLLEXPORT_DATA(extern wxPen*) wxGREY_PEN;
-WXDLLEXPORT_DATA(extern wxPen*) wxMEDIUM_GREY_PEN;
-WXDLLEXPORT_DATA(extern wxPen*) wxLIGHT_GREY_PEN;
-
-WXDLLEXPORT_DATA(extern wxBrush*) wxBLUE_BRUSH;
-WXDLLEXPORT_DATA(extern wxBrush*) wxGREEN_BRUSH;
-WXDLLEXPORT_DATA(extern wxBrush*) wxWHITE_BRUSH;
-WXDLLEXPORT_DATA(extern wxBrush*) wxBLACK_BRUSH;
-WXDLLEXPORT_DATA(extern wxBrush*) wxGREY_BRUSH;
-WXDLLEXPORT_DATA(extern wxBrush*) wxMEDIUM_GREY_BRUSH;
-WXDLLEXPORT_DATA(extern wxBrush*) wxLIGHT_GREY_BRUSH;
-WXDLLEXPORT_DATA(extern wxBrush*) wxTRANSPARENT_BRUSH;
-WXDLLEXPORT_DATA(extern wxBrush*) wxCYAN_BRUSH;
-WXDLLEXPORT_DATA(extern wxBrush*) wxRED_BRUSH;
-
-WXDLLEXPORT_DATA(extern wxColour*) wxBLACK;
-WXDLLEXPORT_DATA(extern wxColour*) wxWHITE;
-WXDLLEXPORT_DATA(extern wxColour*) wxRED;
-WXDLLEXPORT_DATA(extern wxColour*) wxBLUE;
-WXDLLEXPORT_DATA(extern wxColour*) wxGREEN;
-WXDLLEXPORT_DATA(extern wxColour*) wxCYAN;
-WXDLLEXPORT_DATA(extern wxColour*) wxLIGHT_GREY;
+WXDLLEXPORT_DATA(extern wxFont*) wxNORMAL_FONT;
+WXDLLEXPORT_DATA(extern wxFont*) wxSMALL_FONT;
+WXDLLEXPORT_DATA(extern wxFont*) wxITALIC_FONT;
+WXDLLEXPORT_DATA(extern wxFont*) wxSWISS_FONT;
+
+WXDLLEXPORT_DATA(extern wxPen*) wxRED_PEN;
+WXDLLEXPORT_DATA(extern wxPen*) wxCYAN_PEN;
+WXDLLEXPORT_DATA(extern wxPen*) wxGREEN_PEN;
+WXDLLEXPORT_DATA(extern wxPen*) wxBLACK_PEN;
+WXDLLEXPORT_DATA(extern wxPen*) wxWHITE_PEN;
+WXDLLEXPORT_DATA(extern wxPen*) wxTRANSPARENT_PEN;
+WXDLLEXPORT_DATA(extern wxPen*) wxBLACK_DASHED_PEN;
+WXDLLEXPORT_DATA(extern wxPen*) wxGREY_PEN;
+WXDLLEXPORT_DATA(extern wxPen*) wxMEDIUM_GREY_PEN;
+WXDLLEXPORT_DATA(extern wxPen*) wxLIGHT_GREY_PEN;
+
+WXDLLEXPORT_DATA(extern wxBrush*) wxBLUE_BRUSH;
+WXDLLEXPORT_DATA(extern wxBrush*) wxGREEN_BRUSH;
+WXDLLEXPORT_DATA(extern wxBrush*) wxWHITE_BRUSH;
+WXDLLEXPORT_DATA(extern wxBrush*) wxBLACK_BRUSH;
+WXDLLEXPORT_DATA(extern wxBrush*) wxGREY_BRUSH;
+WXDLLEXPORT_DATA(extern wxBrush*) wxMEDIUM_GREY_BRUSH;
+WXDLLEXPORT_DATA(extern wxBrush*) wxLIGHT_GREY_BRUSH;
+WXDLLEXPORT_DATA(extern wxBrush*) wxTRANSPARENT_BRUSH;
+WXDLLEXPORT_DATA(extern wxBrush*) wxCYAN_BRUSH;
+WXDLLEXPORT_DATA(extern wxBrush*) wxRED_BRUSH;
+
+WXDLLEXPORT_DATA(extern wxColour*) wxBLACK;
+WXDLLEXPORT_DATA(extern wxColour*) wxWHITE;
+WXDLLEXPORT_DATA(extern wxColour*) wxRED;
+WXDLLEXPORT_DATA(extern wxColour*) wxBLUE;
+WXDLLEXPORT_DATA(extern wxColour*) wxGREEN;
+WXDLLEXPORT_DATA(extern wxColour*) wxCYAN;
+WXDLLEXPORT_DATA(extern wxColour*) wxLIGHT_GREY;
// 'Null' objects
-WXDLLEXPORT_DATA(extern wxBitmap) wxNullBitmap;
-WXDLLEXPORT_DATA(extern wxIcon) wxNullIcon;
-WXDLLEXPORT_DATA(extern wxCursor) wxNullCursor;
-WXDLLEXPORT_DATA(extern wxPen) wxNullPen;
-WXDLLEXPORT_DATA(extern wxBrush) wxNullBrush;
-WXDLLEXPORT_DATA(extern wxPalette) wxNullPalette;
-WXDLLEXPORT_DATA(extern wxFont) wxNullFont;
-WXDLLEXPORT_DATA(extern wxColour) wxNullColour;
+WXDLLEXPORT_DATA(extern wxBitmap) wxNullBitmap;
+WXDLLEXPORT_DATA(extern wxIcon) wxNullIcon;
+WXDLLEXPORT_DATA(extern wxCursor) wxNullCursor;
+WXDLLEXPORT_DATA(extern wxPen) wxNullPen;
+WXDLLEXPORT_DATA(extern wxBrush) wxNullBrush;
+WXDLLEXPORT_DATA(extern wxPalette) wxNullPalette;
+WXDLLEXPORT_DATA(extern wxFont) wxNullFont;
+WXDLLEXPORT_DATA(extern wxColour) wxNullColour;
// Stock cursors types
-WXDLLEXPORT_DATA(extern wxCursor*) wxSTANDARD_CURSOR;
-WXDLLEXPORT_DATA(extern wxCursor*) wxHOURGLASS_CURSOR;
-WXDLLEXPORT_DATA(extern wxCursor*) wxCROSS_CURSOR;
+WXDLLEXPORT_DATA(extern wxCursor*) wxSTANDARD_CURSOR;
+WXDLLEXPORT_DATA(extern wxCursor*) wxHOURGLASS_CURSOR;
+WXDLLEXPORT_DATA(extern wxCursor*) wxCROSS_CURSOR;
+
+WXDLLEXPORT_DATA(extern wxColourDatabase*) wxTheColourDatabase;
+
+WXDLLEXPORT_DATA(extern const wxChar*) wxPanelNameStr;
-WXDLLEXPORT_DATA(extern wxColourDatabase*) wxTheColourDatabase;
+WXDLLEXPORT_DATA(extern const wxSize) wxDefaultSize;
+WXDLLEXPORT_DATA(extern const wxPoint) wxDefaultPosition;
+
+// The list of objects which should be deleted
+WXDLLEXPORT_DATA(extern wxList) wxPendingDelete;
+
+// ---------------------------------------------------------------------------
+// global functions
+// ---------------------------------------------------------------------------
+
+// resource management
extern void WXDLLEXPORT wxInitializeStockObjects();
extern void WXDLLEXPORT wxInitializeStockLists();
extern void WXDLLEXPORT wxDeleteStockObjects();
extern void WXDLLEXPORT wxDeleteStockLists();
+// is the display colour (or monochrome)?
extern bool WXDLLEXPORT wxColourDisplay();
// Returns depth of screen
extern int WXDLLEXPORT wxDisplayDepth();
#define wxGetDisplayDepth wxDisplayDepth
+// get the diaplay size
extern void WXDLLEXPORT wxDisplaySize(int *width, int *height);
extern wxSize WXDLLEXPORT wxGetDisplaySize();
+// set global cursor
extern void WXDLLEXPORT wxSetCursor(const wxCursor& cursor);
-// Useful macro for creating icons portably
-
-#ifdef __WXMSW__
-// Load from a resource
-# define wxICON(X) wxIcon("" #X "")
-
-#elif defined(__WXGTK__)
-// Initialize from an included XPM
-# define wxICON(X) wxIcon( (const char**) X##_xpm )
-#elif defined(__WXMOTIF__)
-// 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 "")
-#endif
-
-/*
- Example:
- wxIcon *icon = new wxICON(mondrian);
- expands into:
- wxIcon *icon = new wxIcon("mondrian"); // On wxMSW
- wxIcon *icon = new wxIcon(mondrian_xpm); // On wxGTK
- */
-
-class WXDLLEXPORT wxResourceCache: public wxList
-{
-public:
- wxResourceCache() { }
- wxResourceCache(const unsigned int keyType) : wxList(keyType) { }
- ~wxResourceCache();
-
-private:
- DECLARE_DYNAMIC_CLASS(wxResourceCache)
-};
-
#endif
// _WX_GDICMNH__
// We have to hand down a few functions
- void SetBackgroundColour( const wxColour &colour );
- void SetForegroundColour( const wxColour &colour );
- void SetFont( const wxFont &font );
+ bool SetBackgroundColour( const wxColour &colour );
+ bool SetForegroundColour( const wxColour &colour );
+ bool SetFont( const wxFont &font );
#if wxUSE_DRAG_AND_DROP
void SetDropTarget( wxDropTarget *dropTarget )
{ return m_mainWin->GetDropTarget(); }
#endif
- void SetCursor( const wxCursor &cursor )
- { if (m_mainWin) m_mainWin->wxWindow::SetCursor( cursor); }
+ bool SetCursor( const wxCursor &cursor )
+ { return m_mainWin ? m_mainWin->wxWindow::SetCursor(cursor) : FALSE; }
wxColour GetBackgroundColour() const
- { if (m_mainWin) return m_mainWin->GetBackgroundColour();
- else return wxColour(); }
+ { return m_mainWin ? m_mainWin->GetBackgroundColour() : wxColour(); }
wxColour GetForegroundColour() const
- { if (m_mainWin) return m_mainWin->GetForegroundColour();
- else return wxColour(); }
+ { return m_mainWin ? m_mainWin->GetForegroundColour() : wxColour(); }
bool PopupMenu( wxMenu *menu, int x, int y )
{ return m_mainWin->PopupMenu( menu, x, y ); }
void SetFocus()
wxString GetTabText(int id) const;
// Layout tabs (optional, e.g. if resizing window)
- void Layout(void);
+ void LayoutTabs();
// Draw all tabs
virtual void Draw(wxDC& dc);
void SetBitmapLabel( const wxBitmap& bitmap );
void SetBitmapSelected( const wxBitmap& bitmap );
- virtual void Enable(const bool);
+ virtual bool Enable(const bool);
// implementation
const wxString& name = wxButtonNameStr);
void SetDefault();
void SetLabel( const wxString &label );
- void Enable( bool enable );
+ bool Enable( bool enable );
// implementation
bool GetValue() const;
void SetLabel( const wxString& label );
- void Enable( bool enable );
+ bool Enable( bool enable );
// implementation
void ApplyWidgetStyle();
virtual void Maximize() { }
virtual void Restore() { }
+ void SetReturnCode(int returnCode) { m_returnCode = returnCode; }
+ int GetReturnCode() const { return m_returnCode; }
+
// implementation
virtual void GtkOnSize( int x, int y, int width, int height );
int sizeFlags = wxSIZE_AUTO);
private:
+ int m_returnCode;
+
DECLARE_EVENT_TABLE()
};
wxFont( const wxFont& font );
~wxFont();
wxFont& operator = ( const wxFont& font );
- bool operator == ( const wxFont& font );
- bool operator != ( const wxFont& font );
+ bool operator == ( const wxFont& font ) const;
+ bool operator != ( const wxFont& font ) const;
bool Ok() const;
int GetPointSize() const;
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
int n = 0, const wxString choices[] = (const wxString *) NULL,
int majorDim = 1, long style = wxRA_HORIZONTAL,
const wxValidator& val = wxDefaultValidator,
- const wxString& name = wxRadioBoxNameStr )
+ const wxString& name = wxRadioBoxNameStr )
{
Create( parent, id, title, pos, size, n, choices, majorDim, style, val, name );
}
int n = 0, const wxString choices[] = (const wxString *) NULL,
int majorDim = 0, long style = wxRA_HORIZONTAL,
const wxValidator& val = wxDefaultValidator,
- const wxString& name = wxRadioBoxNameStr );
+ const wxString& name = wxRadioBoxNameStr );
int FindString( const wxString& s) const;
void SetSelection( int n );
int GetSelection(void) const;
void SetLabel( int item, wxBitmap *bitmap );
wxString GetLabel( int item ) const;
bool Show( bool show );
- void Enable( bool enable );
+ bool Enable( bool enable );
void Enable( int item, bool enable );
void Show( int item, bool show );
virtual wxString GetStringSelection(void) const;
virtual void SetLabel(const wxString& label);
virtual void SetValue(bool val);
virtual bool GetValue(void) const;
- void Enable( bool enable );
+ bool Enable( bool enable );
// implementation
wxTextCtrl& operator<<(const char c);
#endif
- void SetFont( const wxFont &font );
- void SetForegroundColour(const wxColour &colour);
- void SetBackgroundColour(const wxColour &colour);
+ bool SetFont( const wxFont &font );
+ bool SetForegroundColour(const wxColour &colour);
+ bool SetBackgroundColour(const wxColour &colour);
// implementation
#pragma interface
#endif
-#include "wx/defs.h"
-#include "wx/object.h"
-#include "wx/list.h"
-#include "wx/event.h"
-#include "wx/validate.h"
-#include "wx/cursor.h"
-#include "wx/font.h"
-#include "wx/region.h"
-#include "wx/accel.h"
-
-//-----------------------------------------------------------------------------
-// global data
-//-----------------------------------------------------------------------------
-
-extern const wxChar *wxFrameNameStr;
-extern wxWindowList wxTopLevelWindows;
-
-//-----------------------------------------------------------------------------
-// global function
-//-----------------------------------------------------------------------------
-
-extern wxWindow* wxGetActiveWindow();
-
-//-----------------------------------------------------------------------------
-// classes
-//-----------------------------------------------------------------------------
-
-class wxLayoutConstraints;
-class wxSizer;
-class wxDC;
-class wxClientData;
-class wxVoidClientData;
-class wxWindow;
-#if wxUSE_WX_RESOURCES
- class wxResourceTable;
- class wxItemResource;
-#endif
-#if wxUSE_DRAG_AND_DROP
- class wxDropTarget;
-#endif
-class wxToolTip;
-
//-----------------------------------------------------------------------------
// callback definition for inserting a window (internal)
//-----------------------------------------------------------------------------
typedef void (*wxInsertChildFunction)( wxWindow*, wxWindow* );
-//-----------------------------------------------------------------------------
-// global data
-//-----------------------------------------------------------------------------
-
-extern const wxChar *wxPanelNameStr;
-extern const wxSize wxDefaultSize;
-extern const wxPoint wxDefaultPosition;
-
-//-----------------------------------------------------------------------------
-// wxClientData
-//-----------------------------------------------------------------------------
-
-class wxClientData
-{
-public:
- wxClientData() { }
- virtual ~wxClientData() { }
-};
-
-//-----------------------------------------------------------------------------
-// wxStringClientData
-//-----------------------------------------------------------------------------
-
-class wxStringClientData : public wxClientData
-{
-public:
- wxStringClientData() { }
- wxStringClientData( wxString &data ) { m_data = data; }
- void SetData( wxString &data ) { m_data = data; }
- wxString GetData() const { return m_data; }
-
-private:
- wxString m_data;
-};
-
//-----------------------------------------------------------------------------
// wxWindow
//-----------------------------------------------------------------------------
-class wxWindow : public wxEvtHandler
+class wxWindow : public wxWindowBase
{
DECLARE_DYNAMIC_CLASS(wxWindow)
// creating the window
// -------------------
wxWindow();
- wxWindow(wxWindow *parent, wxWindowID id,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = 0,
- const wxString& name = wxPanelNameStr);
- bool Create(wxWindow *parent, wxWindowID id,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = 0,
- const wxString& name = wxPanelNameStr);
+ wxWindow(wxWindow *parent,
+ wxWindowID id,
+ const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize,
+ long style = 0,
+ const wxString& name = wxPanelNameStr);
+ bool Create(wxWindow *parent,
+ wxWindowID id,
+ const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize,
+ long style = 0,
+ const wxString& name = wxPanelNameStr);
virtual ~wxWindow();
-#if wxUSE_WX_RESOURCES
- virtual bool LoadFromResource(wxWindow *parent,
- const wxString& resourceName,
- const wxResourceTable *table = (const wxResourceTable *) NULL);
- virtual wxControl *CreateItem(const wxItemResource* childResource,
- const wxItemResource* parentResource,
- const wxResourceTable *table = (const wxResourceTable *) NULL);
-#endif // wxUSE_WX_RESOURCES
-
- // closing the window
- // ------------------
- bool Close( bool force = FALSE );
+ // implement base class (pure) virtual methods
+ // -------------------------------------------
virtual bool Destroy();
- virtual bool DestroyChildren();
-
- bool IsBeingDeleted();
-
- // moving/resizing
- // ---------------
-
- // set the window size and/or position
- void SetSize( int x, int y, int width, int height,
- int sizeFlags = wxSIZE_AUTO )
- { DoSetSize(x, y, width, height, sizeFlags); }
-
- void SetSize( int width, int height )
- { DoSetSize( -1, -1, width, height, wxSIZE_USE_EXISTING ); }
-
- void SetSize( const wxSize& size )
- { SetSize( size.x, size.y); }
-
- void SetSize(const wxRect& rect, int sizeFlags = wxSIZE_AUTO)
- { DoSetSize(rect.x, rect.y, rect.width, rect.height, sizeFlags); }
-
- void Move( int x, int y )
- { DoSetSize( x, y, -1, -1, wxSIZE_USE_EXISTING ); }
-
- void Move(const wxPoint& pt)
- { Move(pt.x, pt.y); }
-
- // client size is the size of area available for subwindows
- void SetClientSize( int width, int height )
- { DoSetClientSize(width, height); }
-
- void SetClientSize( const wxSize& size )
- { DoSetClientSize(size.x, size.y); }
-
- void SetClientSize(const wxRect& rect)
- { SetClientSize( rect.width, rect.height ); }
-
- // get the window position and/or size
- virtual void GetPosition( int *x, int *y ) const;
- wxPoint GetPosition() const
- {
- int w, h;
- GetPosition(& w, & h);
-
- return wxPoint(w, h);
- }
-
- virtual void GetSize( int *width, int *height ) const;
-
- wxSize GetSize() const
- {
- int w, h;
- GetSize(& w, & h);
- return wxSize(w, h);
- }
-
- wxRect GetRect() const
- {
- int x, y, w, h;
- GetPosition(& x, & y);
- GetSize(& w, & h);
- return wxRect(x, y, w, h);
- }
-
- virtual void GetClientSize( int *width, int *height ) const;
- wxSize GetClientSize() const
- {
- int w, h;
- GetClientSize(& w, & h);
- return wxSize(w, h);
- }
-
- // position with respect to the the parent window
- virtual void Centre( int direction = wxHORIZONTAL );
- void Center(int direction = wxHORIZONTAL) { Centre(direction); }
- virtual void Fit();
-
- // set min/max size of the window
- virtual void SetSizeHints( int minW, int minH,
- int maxW = -1, int maxH = -1,
- int incW = -1, int incH = -1 );
-
- // Dialog units translations. Implemented in wincmn.cpp.
- // -----------------------------------------------------
-
- wxPoint ConvertPixelsToDialog( const wxPoint& pt );
- wxPoint ConvertDialogToPixels( const wxPoint& pt );
- wxSize ConvertPixelsToDialog( const wxSize& sz )
- {
- wxPoint pt(ConvertPixelsToDialog(wxPoint(sz.x, sz.y)));
-
- return wxSize(pt.x, pt.y);
- }
-
- wxSize ConvertDialogToPixels( const wxSize& sz )
- {
- wxPoint pt(ConvertDialogToPixels(wxPoint(sz.x, sz.y)));
-
- return wxSize(pt.x, pt.y);
- }
-
- void OnSize( wxSizeEvent &event );
+ virtual void Raise();
+ virtual void Lower();
- // window state
- // ------------
+ virtual bool Show( bool show = TRUE );
+ virtual bool Enable( bool enable = TRUE );
- virtual bool Show( bool show );
- virtual void Enable( bool enable );
- virtual void MakeModal( bool modal );
- virtual bool IsEnabled() const { return m_isEnabled; }
- inline bool Enabled() const { return IsEnabled(); }
+ virtual bool IsRetained() const;
virtual void SetFocus();
- static wxWindow *FindFocus();
-
- void SetReturnCode( int retCode );
- int GetReturnCode();
-
- // parent/children relations
- // -------------------------
-
- virtual void AddChild( wxWindow *child );
- wxList& GetChildren() { return m_children; }
-
- virtual void RemoveChild( wxWindow *child );
-
- wxWindow *GetParent() const
- { return m_parent; }
- wxWindow *GetGrandParent() const
- { return (m_parent ? m_parent->m_parent : (wxWindow*)NULL); }
- void SetParent( wxWindow *parent )
- { m_parent = parent; }
- virtual wxWindow *ReParent( wxWindow *newParent );
-
- // event handler stuff
- // -------------------
-
- wxEvtHandler *GetEventHandler() const;
- void SetEventHandler( wxEvtHandler *handler );
- void PushEventHandler( wxEvtHandler *handler );
- wxEvtHandler *PopEventHandler( bool deleteHandler = FALSE );
-
- // validators and client data
- // --------------------------
-
- virtual void SetValidator( const wxValidator &validator );
- virtual wxValidator *GetValidator();
-
- virtual void SetClientObject( wxClientData *data );
- virtual wxClientData *GetClientObject();
-
- virtual void SetClientData( void *data );
- virtual void *GetClientData();
-
- // accelerators
- // ------------
- virtual void SetAcceleratorTable( const wxAcceleratorTable& accel );
- virtual wxAcceleratorTable *GetAcceleratorTable() { return &m_acceleratorTable; }
-
- void SetId( wxWindowID id );
- wxWindowID GetId() const;
-
- void SetCursor( const wxCursor &cursor );
-
- virtual void PrepareDC( wxDC &dc );
+ virtual bool AcceptsFocus() const;
- void WarpPointer(int x, int y);
+ virtual bool Reparent( wxWindow *newParent );
-#if wxUSE_TOOLTIPS
- void SetToolTip( const wxString &tip );
- virtual void SetToolTip( wxToolTip *tip );
- wxToolTip* GetToolTip() const { return m_toolTip; }
-#endif // wxUSE_TOOLTIPS
+ virtual void WarpPointer(int x, int y);
+ virtual void CaptureMouse();
+ virtual void ReleaseMouse();
- virtual void Refresh( bool eraseBackground = TRUE, const wxRect *rect = (const wxRect *) NULL );
+ virtual void Refresh( bool eraseBackground = TRUE,
+ const wxRect *rect = (const wxRect *) NULL );
virtual void Clear();
- virtual wxRegion GetUpdateRegion() const;
- virtual bool IsExposed( int x, int y ) const;
- virtual bool IsExposed( int x, int y, int w, int h ) const;
- virtual bool IsExposed( const wxPoint& pt ) const;
- virtual bool IsExposed( const wxRect& rect ) const;
-
- // colours
- // -------
-
- virtual wxColour GetBackgroundColour() const;
- virtual void SetBackgroundColour( const wxColour &colour );
- virtual wxColour GetForegroundColour() const;
- virtual void SetForegroundColour( const wxColour &colour );
-
- // fonts
- // -----
+ 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, bool use16 = FALSE) 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 SetFont( const wxFont &font );
- virtual wxFont& GetFont() { return m_font; }
+ virtual void ClientToScreen( int *x, int *y ) const;
+ virtual void ScreenToClient( int *x, int *y ) const;
- // For backward compatibility
- virtual void SetButtonFont(const wxFont& font) { SetFont(font); }
- virtual void SetLabelFont(const wxFont& font) { SetFont(font); }
- virtual wxFont& GetLabelFont() { return GetFont(); };
- virtual wxFont& GetButtonFont() { return GetFont(); };
+ virtual bool PopupMenu( wxMenu *menu, int x, int y );
- virtual void SetWindowStyleFlag( long flag );
- virtual long GetWindowStyleFlag() 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 CaptureMouse();
- virtual void ReleaseMouse();
+#if wxUSE_DRAG_AND_DROP
+ virtual void SetDropTarget( wxDropTarget *dropTarget );
+#endif // wxUSE_DRAG_AND_DROP
- virtual void SetTitle( const wxString &title );
- virtual wxString GetTitle() const;
- virtual void SetName( const wxString &name );
- virtual wxString GetName() const;
- virtual wxString GetLabel() const;
+ // implementation
+ // --------------
- void OnSysColourChanged( wxSysColourChangedEvent &WXUNUSED(event) ) { }
+ // wxWindows callbacks
void OnKeyDown( wxKeyEvent &event );
- virtual bool IsShown() const;
+ // simple accessors
+ bool HasVMT() const { return m_hasVMT; }
- virtual void Raise();
- virtual void Lower();
+ int GetX() const { return m_x; }
+ int GetY() const { return m_y; }
+ int GetWidth() const { return m_width; }
+ int GetHeight() const { return m_height; }
- virtual bool IsRetained();
- virtual wxWindow *FindWindow( long id );
- virtual wxWindow *FindWindow( const wxString& name );
+ GtkWidget *GetWxWindow() const { return m_wxwindow; }
+ GtkWidget *GetWidget() const { return GetHandle(); }
- void AllowDoubleClick( bool WXUNUSED(allow) ) { }
- void SetDoubleClick( bool WXUNUSED(allow) ) { }
+ GtkAdjustment *GetHAdjust() const { return m_hAdjust; }
+ GtkAdjustment *GetVAdjust() const { return m_vAdjust; }
- virtual void ClientToScreen( int *x, int *y );
- virtual void ScreenToClient( int *x, int *y );
+ float GetOldHorizontalPos() const { return m_oldHorizontalPos; }
+ float GetOldVerticalPos() const { return m_oldVerticalPos; }
- virtual bool Validate();
- virtual bool TransferDataToWindow();
- virtual bool TransferDataFromWindow();
- void OnInitDialog( wxInitDialogEvent &event );
- virtual void InitDialog();
+ void SetOldHorizontalPos(float fpos) { m_oldHorizontalPos = fpos; }
+ void SetOldVerticalPos(float fpos) { m_oldVerticalPos = fpos; }
- virtual bool PopupMenu( wxMenu *menu, int x, int y );
+ bool IsSizeSet() const { return m_sizeSet; }
-#if wxUSE_DRAG_AND_DROP
- virtual void SetDropTarget( wxDropTarget *dropTarget );
- virtual wxDropTarget *GetDropTarget() const;
-#endif
-
- 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 bool AcceptsFocus() const;
+ // also sets the global flag
+ void SetScrolling(bool scroll);
- void UpdateWindowUI();
-
- // implementation
-
- bool HasVMT();
+ bool HasScrolling() const { return m_hasScrolling; }
+ bool IsScrolling() const { return m_isScrolling; }
+ bool IsStaticBox() const { return m_isStaticBox; }
/* I don't want users to override what's done in idle so everything that
has to be done in idle time in order for wxGTK to work is done in
const wxSize &size, long style, const wxString &name );
void PostCreation();
+ void InsertChild(wxWindow *child) { (*m_insertCallback)(this, child); }
+ void DoAddChild(wxWindow *child) { AddChild(child); InsertChild(child); }
+
/* the methods below are required because many native widgets
are composed of several subwidgets and setting a style for
the widget means setting it for all subwidgets as well.
virtual void ApplyToolTip( GtkTooltips *tips, const wxChar *tip );
#endif // wxUSE_TOOLTIPS
- /* private member variables */
-
- wxWindow *m_parent;
- wxList m_children;
- int m_x,m_y;
- int m_width,m_height;
- int m_minWidth,m_minHeight;
- int m_maxWidth,m_maxHeight;
- int m_retCode;
- wxEvtHandler *m_eventHandler;
- wxValidator *m_windowValidator;
-#if wxUSE_DRAG_AND_DROP
- wxDropTarget *m_dropTarget;
-#endif
- wxWindowID m_windowId;
- wxCursor m_cursor;
- wxFont m_font;
- wxColour m_backgroundColour;
- wxColour m_foregroundColour;
- wxRegion m_updateRegion;
- long m_windowStyle;
- bool m_isShown;
- bool m_isEnabled;
- wxString m_windowName;
- wxAcceleratorTable m_acceleratorTable;
- wxClientData *m_clientObject;
- void *m_clientData;
+ // called from GTK signales handlers
+ void UpdateSize() { m_sizeSet = FALSE; }
+ void InternalSetPosition(int x, int y) { m_x = x; m_y = y; }
+ void InternalSetSize(int w, int h)
+ { m_width = w; m_height = h; UpdateSize(); }
-#if wxUSE_TOOLTIPS
- wxToolTip *m_toolTip;
-#endif // wxUSE_TOOLTIPS
+protected:
+ // position and size of the window
+ int m_x, m_y;
+ int m_width, m_height;
- GtkWidget *m_widget;
+ // see the docs in src/gtk/window.cpp
GtkWidget *m_wxwindow;
+
+ // scrolling stuff
GtkAdjustment *m_hAdjust,*m_vAdjust;
- float m_oldHorizontalPos;
- float m_oldVerticalPos;
- bool m_needParent; /* ! wxFrame, wxDialog, wxNotebookPage ? */
- bool m_hasScrolling;
- bool m_isScrolling;
- bool m_hasVMT;
- bool m_sizeSet;
- bool m_resizing;
+ float m_oldHorizontalPos,
+ m_oldVerticalPos;
GdkGC *m_scrollGC;
- GtkStyle *m_widgetStyle;
- bool m_isStaticBox; /* faster than IS_KIND_OF */
- bool m_isFrame; /* faster than IS_KIND_OF */
- bool m_acceptsFocus; /* ! wxStaticBox etc. */
-
- wxInsertChildFunction m_insertCallback;
-public:
+ // extra (wxGTK-specific) flags
+ bool m_needParent:1; /* ! wxFrame, wxDialog, wxNotebookPage ? */
+ bool m_hasScrolling:1;
+ bool m_isScrolling:1;
+ bool m_hasVMT:1;
+ bool m_sizeSet:1;
+ bool m_resizing:1;
+ bool m_isStaticBox:1; /* faster than IS_KIND_OF */
+ bool m_isFrame:1; /* faster than IS_KIND_OF */
+ bool m_acceptsFocus:1; /* ! wxStaticBox etc. */
- wxLayoutConstraints *m_constraints;
- wxList *m_constraintsInvolvedIn;
- wxSizer *m_windowSizer;
- wxWindow *m_sizerParent;
- bool m_autoLayout;
-
- wxLayoutConstraints *GetConstraints() const;
- void SetConstraints( wxLayoutConstraints *constraints );
- void SetAutoLayout( bool autoLayout );
- bool GetAutoLayout() const;
- bool Layout();
- void SetSizer( wxSizer *sizer );
- wxSizer *GetSizer() const;
- void SetSizerParent( wxWindow *win );
- wxWindow *GetSizerParent() const;
- void UnsetConstraints(wxLayoutConstraints *c);
- inline wxList *GetConstraintsInvolvedIn() const ;
- void AddConstraintReference(wxWindow *otherWin);
- void RemoveConstraintReference(wxWindow *otherWin);
- void DeleteRelatedConstraints();
- virtual void ResetConstraints();
- virtual void SetConstraintSizes(bool recurse = TRUE);
- virtual bool LayoutPhase1(int *noChanges);
- virtual bool LayoutPhase2(int *noChanges);
- virtual bool DoPhase(int);
- virtual void TransformSizerToActual(int *x, int *y) const ;
- virtual void SizerSetSize(int x, int y, int w, int h);
- virtual void SizerMove(int x, int y);
- virtual void SetSizeConstraint(int x, int y, int w, int h);
- virtual void MoveConstraint(int x, int y);
- virtual void GetSizeConstraint(int *w, int *h) const ;
- virtual void GetClientSizeConstraint(int *w, int *h) const ;
- virtual void GetPositionConstraint(int *x, int *y) const ;
+ GtkStyle *m_widgetStyle;
-protected:
- // common part of all ctors
- void Init();
+ wxInsertChildFunction m_insertCallback;
- // this is the virtual function to be overriden in any derived class which
- // wants to change how SetSize() or Move() works - it is called by all
- // versions of these functions in the base class
+ // implement the base class pure virtuals
+ 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);
-
- // same as DoSetSize() for the client size
virtual void DoSetClientSize(int width, int height);
+#if wxUSE_TOOLTIPS
+ virtual void DoSetToolTip( wxToolTip *tip );
+#endif // wxUSE_TOOLTIPS
+
+ // common part of all ctors (can't be virtual because called from ctor)
+ void Init();
+
private:
DECLARE_EVENT_TABLE()
};
void SetBitmapLabel( const wxBitmap& bitmap );
void SetBitmapSelected( const wxBitmap& bitmap );
- virtual void Enable(const bool);
+ virtual bool Enable(const bool);
// implementation
const wxString& name = wxButtonNameStr);
void SetDefault();
void SetLabel( const wxString &label );
- void Enable( bool enable );
+ bool Enable( bool enable );
// implementation
bool GetValue() const;
void SetLabel( const wxString& label );
- void Enable( bool enable );
+ bool Enable( bool enable );
// implementation
void ApplyWidgetStyle();
virtual void Maximize() { }
virtual void Restore() { }
+ void SetReturnCode(int returnCode) { m_returnCode = returnCode; }
+ int GetReturnCode() const { return m_returnCode; }
+
// implementation
virtual void GtkOnSize( int x, int y, int width, int height );
int sizeFlags = wxSIZE_AUTO);
private:
+ int m_returnCode;
+
DECLARE_EVENT_TABLE()
};
wxFont( const wxFont& font );
~wxFont();
wxFont& operator = ( const wxFont& font );
- bool operator == ( const wxFont& font );
- bool operator != ( const wxFont& font );
+ bool operator == ( const wxFont& font ) const;
+ bool operator != ( const wxFont& font ) const;
bool Ok() const;
int GetPointSize() const;
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
int n = 0, const wxString choices[] = (const wxString *) NULL,
int majorDim = 1, long style = wxRA_HORIZONTAL,
const wxValidator& val = wxDefaultValidator,
- const wxString& name = wxRadioBoxNameStr )
+ const wxString& name = wxRadioBoxNameStr )
{
Create( parent, id, title, pos, size, n, choices, majorDim, style, val, name );
}
int n = 0, const wxString choices[] = (const wxString *) NULL,
int majorDim = 0, long style = wxRA_HORIZONTAL,
const wxValidator& val = wxDefaultValidator,
- const wxString& name = wxRadioBoxNameStr );
+ const wxString& name = wxRadioBoxNameStr );
int FindString( const wxString& s) const;
void SetSelection( int n );
int GetSelection(void) const;
void SetLabel( int item, wxBitmap *bitmap );
wxString GetLabel( int item ) const;
bool Show( bool show );
- void Enable( bool enable );
+ bool Enable( bool enable );
void Enable( int item, bool enable );
void Show( int item, bool show );
virtual wxString GetStringSelection(void) const;
virtual void SetLabel(const wxString& label);
virtual void SetValue(bool val);
virtual bool GetValue(void) const;
- void Enable( bool enable );
+ bool Enable( bool enable );
// implementation
wxTextCtrl& operator<<(const char c);
#endif
- void SetFont( const wxFont &font );
- void SetForegroundColour(const wxColour &colour);
- void SetBackgroundColour(const wxColour &colour);
+ bool SetFont( const wxFont &font );
+ bool SetForegroundColour(const wxColour &colour);
+ bool SetBackgroundColour(const wxColour &colour);
// implementation
#pragma interface
#endif
-#include "wx/defs.h"
-#include "wx/object.h"
-#include "wx/list.h"
-#include "wx/event.h"
-#include "wx/validate.h"
-#include "wx/cursor.h"
-#include "wx/font.h"
-#include "wx/region.h"
-#include "wx/accel.h"
-
-//-----------------------------------------------------------------------------
-// global data
-//-----------------------------------------------------------------------------
-
-extern const wxChar *wxFrameNameStr;
-extern wxWindowList wxTopLevelWindows;
-
-//-----------------------------------------------------------------------------
-// global function
-//-----------------------------------------------------------------------------
-
-extern wxWindow* wxGetActiveWindow();
-
-//-----------------------------------------------------------------------------
-// classes
-//-----------------------------------------------------------------------------
-
-class wxLayoutConstraints;
-class wxSizer;
-class wxDC;
-class wxClientData;
-class wxVoidClientData;
-class wxWindow;
-#if wxUSE_WX_RESOURCES
- class wxResourceTable;
- class wxItemResource;
-#endif
-#if wxUSE_DRAG_AND_DROP
- class wxDropTarget;
-#endif
-class wxToolTip;
-
//-----------------------------------------------------------------------------
// callback definition for inserting a window (internal)
//-----------------------------------------------------------------------------
typedef void (*wxInsertChildFunction)( wxWindow*, wxWindow* );
-//-----------------------------------------------------------------------------
-// global data
-//-----------------------------------------------------------------------------
-
-extern const wxChar *wxPanelNameStr;
-extern const wxSize wxDefaultSize;
-extern const wxPoint wxDefaultPosition;
-
-//-----------------------------------------------------------------------------
-// wxClientData
-//-----------------------------------------------------------------------------
-
-class wxClientData
-{
-public:
- wxClientData() { }
- virtual ~wxClientData() { }
-};
-
-//-----------------------------------------------------------------------------
-// wxStringClientData
-//-----------------------------------------------------------------------------
-
-class wxStringClientData : public wxClientData
-{
-public:
- wxStringClientData() { }
- wxStringClientData( wxString &data ) { m_data = data; }
- void SetData( wxString &data ) { m_data = data; }
- wxString GetData() const { return m_data; }
-
-private:
- wxString m_data;
-};
-
//-----------------------------------------------------------------------------
// wxWindow
//-----------------------------------------------------------------------------
-class wxWindow : public wxEvtHandler
+class wxWindow : public wxWindowBase
{
DECLARE_DYNAMIC_CLASS(wxWindow)
// creating the window
// -------------------
wxWindow();
- wxWindow(wxWindow *parent, wxWindowID id,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = 0,
- const wxString& name = wxPanelNameStr);
- bool Create(wxWindow *parent, wxWindowID id,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = 0,
- const wxString& name = wxPanelNameStr);
+ wxWindow(wxWindow *parent,
+ wxWindowID id,
+ const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize,
+ long style = 0,
+ const wxString& name = wxPanelNameStr);
+ bool Create(wxWindow *parent,
+ wxWindowID id,
+ const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize,
+ long style = 0,
+ const wxString& name = wxPanelNameStr);
virtual ~wxWindow();
-#if wxUSE_WX_RESOURCES
- virtual bool LoadFromResource(wxWindow *parent,
- const wxString& resourceName,
- const wxResourceTable *table = (const wxResourceTable *) NULL);
- virtual wxControl *CreateItem(const wxItemResource* childResource,
- const wxItemResource* parentResource,
- const wxResourceTable *table = (const wxResourceTable *) NULL);
-#endif // wxUSE_WX_RESOURCES
-
- // closing the window
- // ------------------
- bool Close( bool force = FALSE );
+ // implement base class (pure) virtual methods
+ // -------------------------------------------
virtual bool Destroy();
- virtual bool DestroyChildren();
-
- bool IsBeingDeleted();
-
- // moving/resizing
- // ---------------
-
- // set the window size and/or position
- void SetSize( int x, int y, int width, int height,
- int sizeFlags = wxSIZE_AUTO )
- { DoSetSize(x, y, width, height, sizeFlags); }
-
- void SetSize( int width, int height )
- { DoSetSize( -1, -1, width, height, wxSIZE_USE_EXISTING ); }
-
- void SetSize( const wxSize& size )
- { SetSize( size.x, size.y); }
-
- void SetSize(const wxRect& rect, int sizeFlags = wxSIZE_AUTO)
- { DoSetSize(rect.x, rect.y, rect.width, rect.height, sizeFlags); }
-
- void Move( int x, int y )
- { DoSetSize( x, y, -1, -1, wxSIZE_USE_EXISTING ); }
-
- void Move(const wxPoint& pt)
- { Move(pt.x, pt.y); }
-
- // client size is the size of area available for subwindows
- void SetClientSize( int width, int height )
- { DoSetClientSize(width, height); }
-
- void SetClientSize( const wxSize& size )
- { DoSetClientSize(size.x, size.y); }
-
- void SetClientSize(const wxRect& rect)
- { SetClientSize( rect.width, rect.height ); }
-
- // get the window position and/or size
- virtual void GetPosition( int *x, int *y ) const;
- wxPoint GetPosition() const
- {
- int w, h;
- GetPosition(& w, & h);
-
- return wxPoint(w, h);
- }
-
- virtual void GetSize( int *width, int *height ) const;
-
- wxSize GetSize() const
- {
- int w, h;
- GetSize(& w, & h);
- return wxSize(w, h);
- }
-
- wxRect GetRect() const
- {
- int x, y, w, h;
- GetPosition(& x, & y);
- GetSize(& w, & h);
- return wxRect(x, y, w, h);
- }
-
- virtual void GetClientSize( int *width, int *height ) const;
- wxSize GetClientSize() const
- {
- int w, h;
- GetClientSize(& w, & h);
- return wxSize(w, h);
- }
-
- // position with respect to the the parent window
- virtual void Centre( int direction = wxHORIZONTAL );
- void Center(int direction = wxHORIZONTAL) { Centre(direction); }
- virtual void Fit();
-
- // set min/max size of the window
- virtual void SetSizeHints( int minW, int minH,
- int maxW = -1, int maxH = -1,
- int incW = -1, int incH = -1 );
-
- // Dialog units translations. Implemented in wincmn.cpp.
- // -----------------------------------------------------
-
- wxPoint ConvertPixelsToDialog( const wxPoint& pt );
- wxPoint ConvertDialogToPixels( const wxPoint& pt );
- wxSize ConvertPixelsToDialog( const wxSize& sz )
- {
- wxPoint pt(ConvertPixelsToDialog(wxPoint(sz.x, sz.y)));
-
- return wxSize(pt.x, pt.y);
- }
-
- wxSize ConvertDialogToPixels( const wxSize& sz )
- {
- wxPoint pt(ConvertDialogToPixels(wxPoint(sz.x, sz.y)));
-
- return wxSize(pt.x, pt.y);
- }
-
- void OnSize( wxSizeEvent &event );
+ virtual void Raise();
+ virtual void Lower();
- // window state
- // ------------
+ virtual bool Show( bool show = TRUE );
+ virtual bool Enable( bool enable = TRUE );
- virtual bool Show( bool show );
- virtual void Enable( bool enable );
- virtual void MakeModal( bool modal );
- virtual bool IsEnabled() const { return m_isEnabled; }
- inline bool Enabled() const { return IsEnabled(); }
+ virtual bool IsRetained() const;
virtual void SetFocus();
- static wxWindow *FindFocus();
-
- void SetReturnCode( int retCode );
- int GetReturnCode();
-
- // parent/children relations
- // -------------------------
-
- virtual void AddChild( wxWindow *child );
- wxList& GetChildren() { return m_children; }
-
- virtual void RemoveChild( wxWindow *child );
-
- wxWindow *GetParent() const
- { return m_parent; }
- wxWindow *GetGrandParent() const
- { return (m_parent ? m_parent->m_parent : (wxWindow*)NULL); }
- void SetParent( wxWindow *parent )
- { m_parent = parent; }
- virtual wxWindow *ReParent( wxWindow *newParent );
-
- // event handler stuff
- // -------------------
-
- wxEvtHandler *GetEventHandler() const;
- void SetEventHandler( wxEvtHandler *handler );
- void PushEventHandler( wxEvtHandler *handler );
- wxEvtHandler *PopEventHandler( bool deleteHandler = FALSE );
-
- // validators and client data
- // --------------------------
-
- virtual void SetValidator( const wxValidator &validator );
- virtual wxValidator *GetValidator();
-
- virtual void SetClientObject( wxClientData *data );
- virtual wxClientData *GetClientObject();
-
- virtual void SetClientData( void *data );
- virtual void *GetClientData();
-
- // accelerators
- // ------------
- virtual void SetAcceleratorTable( const wxAcceleratorTable& accel );
- virtual wxAcceleratorTable *GetAcceleratorTable() { return &m_acceleratorTable; }
-
- void SetId( wxWindowID id );
- wxWindowID GetId() const;
-
- void SetCursor( const wxCursor &cursor );
-
- virtual void PrepareDC( wxDC &dc );
+ virtual bool AcceptsFocus() const;
- void WarpPointer(int x, int y);
+ virtual bool Reparent( wxWindow *newParent );
-#if wxUSE_TOOLTIPS
- void SetToolTip( const wxString &tip );
- virtual void SetToolTip( wxToolTip *tip );
- wxToolTip* GetToolTip() const { return m_toolTip; }
-#endif // wxUSE_TOOLTIPS
+ virtual void WarpPointer(int x, int y);
+ virtual void CaptureMouse();
+ virtual void ReleaseMouse();
- virtual void Refresh( bool eraseBackground = TRUE, const wxRect *rect = (const wxRect *) NULL );
+ virtual void Refresh( bool eraseBackground = TRUE,
+ const wxRect *rect = (const wxRect *) NULL );
virtual void Clear();
- virtual wxRegion GetUpdateRegion() const;
- virtual bool IsExposed( int x, int y ) const;
- virtual bool IsExposed( int x, int y, int w, int h ) const;
- virtual bool IsExposed( const wxPoint& pt ) const;
- virtual bool IsExposed( const wxRect& rect ) const;
-
- // colours
- // -------
-
- virtual wxColour GetBackgroundColour() const;
- virtual void SetBackgroundColour( const wxColour &colour );
- virtual wxColour GetForegroundColour() const;
- virtual void SetForegroundColour( const wxColour &colour );
-
- // fonts
- // -----
+ 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, bool use16 = FALSE) 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 SetFont( const wxFont &font );
- virtual wxFont& GetFont() { return m_font; }
+ virtual void ClientToScreen( int *x, int *y ) const;
+ virtual void ScreenToClient( int *x, int *y ) const;
- // For backward compatibility
- virtual void SetButtonFont(const wxFont& font) { SetFont(font); }
- virtual void SetLabelFont(const wxFont& font) { SetFont(font); }
- virtual wxFont& GetLabelFont() { return GetFont(); };
- virtual wxFont& GetButtonFont() { return GetFont(); };
+ virtual bool PopupMenu( wxMenu *menu, int x, int y );
- virtual void SetWindowStyleFlag( long flag );
- virtual long GetWindowStyleFlag() 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 CaptureMouse();
- virtual void ReleaseMouse();
+#if wxUSE_DRAG_AND_DROP
+ virtual void SetDropTarget( wxDropTarget *dropTarget );
+#endif // wxUSE_DRAG_AND_DROP
- virtual void SetTitle( const wxString &title );
- virtual wxString GetTitle() const;
- virtual void SetName( const wxString &name );
- virtual wxString GetName() const;
- virtual wxString GetLabel() const;
+ // implementation
+ // --------------
- void OnSysColourChanged( wxSysColourChangedEvent &WXUNUSED(event) ) { }
+ // wxWindows callbacks
void OnKeyDown( wxKeyEvent &event );
- virtual bool IsShown() const;
+ // simple accessors
+ bool HasVMT() const { return m_hasVMT; }
- virtual void Raise();
- virtual void Lower();
+ int GetX() const { return m_x; }
+ int GetY() const { return m_y; }
+ int GetWidth() const { return m_width; }
+ int GetHeight() const { return m_height; }
- virtual bool IsRetained();
- virtual wxWindow *FindWindow( long id );
- virtual wxWindow *FindWindow( const wxString& name );
+ GtkWidget *GetWxWindow() const { return m_wxwindow; }
+ GtkWidget *GetWidget() const { return GetHandle(); }
- void AllowDoubleClick( bool WXUNUSED(allow) ) { }
- void SetDoubleClick( bool WXUNUSED(allow) ) { }
+ GtkAdjustment *GetHAdjust() const { return m_hAdjust; }
+ GtkAdjustment *GetVAdjust() const { return m_vAdjust; }
- virtual void ClientToScreen( int *x, int *y );
- virtual void ScreenToClient( int *x, int *y );
+ float GetOldHorizontalPos() const { return m_oldHorizontalPos; }
+ float GetOldVerticalPos() const { return m_oldVerticalPos; }
- virtual bool Validate();
- virtual bool TransferDataToWindow();
- virtual bool TransferDataFromWindow();
- void OnInitDialog( wxInitDialogEvent &event );
- virtual void InitDialog();
+ void SetOldHorizontalPos(float fpos) { m_oldHorizontalPos = fpos; }
+ void SetOldVerticalPos(float fpos) { m_oldVerticalPos = fpos; }
- virtual bool PopupMenu( wxMenu *menu, int x, int y );
+ bool IsSizeSet() const { return m_sizeSet; }
-#if wxUSE_DRAG_AND_DROP
- virtual void SetDropTarget( wxDropTarget *dropTarget );
- virtual wxDropTarget *GetDropTarget() const;
-#endif
-
- 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 bool AcceptsFocus() const;
+ // also sets the global flag
+ void SetScrolling(bool scroll);
- void UpdateWindowUI();
-
- // implementation
-
- bool HasVMT();
+ bool HasScrolling() const { return m_hasScrolling; }
+ bool IsScrolling() const { return m_isScrolling; }
+ bool IsStaticBox() const { return m_isStaticBox; }
/* I don't want users to override what's done in idle so everything that
has to be done in idle time in order for wxGTK to work is done in
const wxSize &size, long style, const wxString &name );
void PostCreation();
+ void InsertChild(wxWindow *child) { (*m_insertCallback)(this, child); }
+ void DoAddChild(wxWindow *child) { AddChild(child); InsertChild(child); }
+
/* the methods below are required because many native widgets
are composed of several subwidgets and setting a style for
the widget means setting it for all subwidgets as well.
virtual void ApplyToolTip( GtkTooltips *tips, const wxChar *tip );
#endif // wxUSE_TOOLTIPS
- /* private member variables */
-
- wxWindow *m_parent;
- wxList m_children;
- int m_x,m_y;
- int m_width,m_height;
- int m_minWidth,m_minHeight;
- int m_maxWidth,m_maxHeight;
- int m_retCode;
- wxEvtHandler *m_eventHandler;
- wxValidator *m_windowValidator;
-#if wxUSE_DRAG_AND_DROP
- wxDropTarget *m_dropTarget;
-#endif
- wxWindowID m_windowId;
- wxCursor m_cursor;
- wxFont m_font;
- wxColour m_backgroundColour;
- wxColour m_foregroundColour;
- wxRegion m_updateRegion;
- long m_windowStyle;
- bool m_isShown;
- bool m_isEnabled;
- wxString m_windowName;
- wxAcceleratorTable m_acceleratorTable;
- wxClientData *m_clientObject;
- void *m_clientData;
+ // called from GTK signales handlers
+ void UpdateSize() { m_sizeSet = FALSE; }
+ void InternalSetPosition(int x, int y) { m_x = x; m_y = y; }
+ void InternalSetSize(int w, int h)
+ { m_width = w; m_height = h; UpdateSize(); }
-#if wxUSE_TOOLTIPS
- wxToolTip *m_toolTip;
-#endif // wxUSE_TOOLTIPS
+protected:
+ // position and size of the window
+ int m_x, m_y;
+ int m_width, m_height;
- GtkWidget *m_widget;
+ // see the docs in src/gtk/window.cpp
GtkWidget *m_wxwindow;
+
+ // scrolling stuff
GtkAdjustment *m_hAdjust,*m_vAdjust;
- float m_oldHorizontalPos;
- float m_oldVerticalPos;
- bool m_needParent; /* ! wxFrame, wxDialog, wxNotebookPage ? */
- bool m_hasScrolling;
- bool m_isScrolling;
- bool m_hasVMT;
- bool m_sizeSet;
- bool m_resizing;
+ float m_oldHorizontalPos,
+ m_oldVerticalPos;
GdkGC *m_scrollGC;
- GtkStyle *m_widgetStyle;
- bool m_isStaticBox; /* faster than IS_KIND_OF */
- bool m_isFrame; /* faster than IS_KIND_OF */
- bool m_acceptsFocus; /* ! wxStaticBox etc. */
-
- wxInsertChildFunction m_insertCallback;
-public:
+ // extra (wxGTK-specific) flags
+ bool m_needParent:1; /* ! wxFrame, wxDialog, wxNotebookPage ? */
+ bool m_hasScrolling:1;
+ bool m_isScrolling:1;
+ bool m_hasVMT:1;
+ bool m_sizeSet:1;
+ bool m_resizing:1;
+ bool m_isStaticBox:1; /* faster than IS_KIND_OF */
+ bool m_isFrame:1; /* faster than IS_KIND_OF */
+ bool m_acceptsFocus:1; /* ! wxStaticBox etc. */
- wxLayoutConstraints *m_constraints;
- wxList *m_constraintsInvolvedIn;
- wxSizer *m_windowSizer;
- wxWindow *m_sizerParent;
- bool m_autoLayout;
-
- wxLayoutConstraints *GetConstraints() const;
- void SetConstraints( wxLayoutConstraints *constraints );
- void SetAutoLayout( bool autoLayout );
- bool GetAutoLayout() const;
- bool Layout();
- void SetSizer( wxSizer *sizer );
- wxSizer *GetSizer() const;
- void SetSizerParent( wxWindow *win );
- wxWindow *GetSizerParent() const;
- void UnsetConstraints(wxLayoutConstraints *c);
- inline wxList *GetConstraintsInvolvedIn() const ;
- void AddConstraintReference(wxWindow *otherWin);
- void RemoveConstraintReference(wxWindow *otherWin);
- void DeleteRelatedConstraints();
- virtual void ResetConstraints();
- virtual void SetConstraintSizes(bool recurse = TRUE);
- virtual bool LayoutPhase1(int *noChanges);
- virtual bool LayoutPhase2(int *noChanges);
- virtual bool DoPhase(int);
- virtual void TransformSizerToActual(int *x, int *y) const ;
- virtual void SizerSetSize(int x, int y, int w, int h);
- virtual void SizerMove(int x, int y);
- virtual void SetSizeConstraint(int x, int y, int w, int h);
- virtual void MoveConstraint(int x, int y);
- virtual void GetSizeConstraint(int *w, int *h) const ;
- virtual void GetClientSizeConstraint(int *w, int *h) const ;
- virtual void GetPositionConstraint(int *x, int *y) const ;
+ GtkStyle *m_widgetStyle;
-protected:
- // common part of all ctors
- void Init();
+ wxInsertChildFunction m_insertCallback;
- // this is the virtual function to be overriden in any derived class which
- // wants to change how SetSize() or Move() works - it is called by all
- // versions of these functions in the base class
+ // implement the base class pure virtuals
+ 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);
-
- // same as DoSetSize() for the client size
virtual void DoSetClientSize(int width, int height);
+#if wxUSE_TOOLTIPS
+ virtual void DoSetToolTip( wxToolTip *tip );
+#endif // wxUSE_TOOLTIPS
+
+ // common part of all ctors (can't be virtual because called from ctor)
+ void Init();
+
private:
DECLARE_EVENT_TABLE()
};
#ifndef _WX_LAYOUTH__
#define _WX_LAYOUTH__
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
#ifdef __GNUG__
-#pragma interface "layout.h"
+ #pragma interface "layout.h"
#endif
#include "wx/defs.h"
-class WXDLLEXPORT wxWindow;
-
// X stupidly defines these in X.h
#ifdef Above
-#undef Above
+ #undef Above
#endif
#ifdef Below
-#undef Below
+ #undef Below
#endif
+// ----------------------------------------------------------------------------
+// forward declrations
+// ----------------------------------------------------------------------------
+
+class WXDLLEXPORT wxWindowBase;
+class WXDLLEXPORT wxLayoutConstraints;
+
+// ----------------------------------------------------------------------------
+// constants
+// ----------------------------------------------------------------------------
+
#define wxLAYOUT_DEFAULT_MARGIN 0
-enum wxEdge { wxLeft, wxTop, wxRight, wxBottom, wxWidth, wxHeight,
- wxCentre, wxCenter = wxCentre, wxCentreX, wxCentreY };
-enum wxRelationship { wxUnconstrained = 0,
- wxAsIs,
- wxPercentOf,
- wxAbove,
- wxBelow,
- wxLeftOf,
- wxRightOf,
- wxSameAs,
- wxAbsolute };
+enum wxEdge
+{
+ wxLeft, wxTop, wxRight, wxBottom, wxWidth, wxHeight,
+ wxCentre, wxCenter = wxCentre, wxCentreX, wxCentreY
+};
-class WXDLLEXPORT wxLayoutConstraints;
-class WXDLLEXPORT wxIndividualLayoutConstraint: public wxObject
+enum wxRelationship
{
- DECLARE_DYNAMIC_CLASS(wxIndividualLayoutConstraint)
-
- protected:
- // To be allowed to modify the internal variables
- friend class wxIndividualLayoutConstraint_Serialize;
-
- // 'This' window is the parent or sibling of otherWin
- wxWindow *otherWin;
-
- wxEdge myEdge;
- wxRelationship relationship;
- int margin;
- int value;
- int percent;
- wxEdge otherEdge;
- bool done;
-
- public:
- wxIndividualLayoutConstraint();
- ~wxIndividualLayoutConstraint();
-
- void Set(wxRelationship rel, wxWindow *otherW, wxEdge otherE, int val = 0, int marg = wxLAYOUT_DEFAULT_MARGIN);
-
- //
- // Sibling relationships
- //
- void LeftOf(wxWindow *sibling, int marg = wxLAYOUT_DEFAULT_MARGIN);
- void RightOf(wxWindow *sibling, int marg = wxLAYOUT_DEFAULT_MARGIN);
- void Above(wxWindow *sibling, int marg = wxLAYOUT_DEFAULT_MARGIN);
- void Below(wxWindow *sibling, int marg = wxLAYOUT_DEFAULT_MARGIN);
-
- //
- // 'Same edge' alignment
- //
- void SameAs(wxWindow *otherW, wxEdge edge, int marg = wxLAYOUT_DEFAULT_MARGIN);
-
- // The edge is a percentage of the other window's edge
- void PercentOf(wxWindow *otherW, wxEdge wh, int per);
-
- //
- // Edge has absolute value
- //
- void Absolute(int val);
-
- //
- // Dimension is unconstrained
- //
- inline void Unconstrained() { relationship = wxUnconstrained; }
-
- //
- // Dimension is 'as is' (use current size settings)
- //
- inline void AsIs() { relationship = wxAsIs; }
-
- //
- // Accessors
- //
- inline wxWindow *GetOtherWindow() { return otherWin; }
- inline wxEdge GetMyEdge() const { return myEdge; }
- inline void SetEdge(wxEdge which) { myEdge = which; }
- inline void SetValue(int v) { value = v; }
- inline int GetMargin() { return margin; }
- inline void SetMargin(int m) { margin = m; }
- inline int GetValue() const { return value; }
- inline int GetPercent() const { return percent; }
- inline int GetOtherEdge() const { return otherEdge; }
- inline bool GetDone() const { return done; }
- inline void SetDone(bool d) { done = d; }
- inline wxRelationship GetRelationship() { return relationship; }
- inline void SetRelationship(wxRelationship r) { relationship = r; }
-
- // Reset constraint if it mentions otherWin
- bool ResetIfWin(wxWindow *otherW);
-
- // Try to satisfy constraint
- bool SatisfyConstraint(wxLayoutConstraints *constraints, wxWindow *win);
-
- // Get the value of this edge or dimension, or if this
- // is not determinable, -1.
- int GetEdge(wxEdge which, wxWindow *thisWin, wxWindow *other) const;
+ wxUnconstrained = 0,
+ wxAsIs,
+ wxPercentOf,
+ wxAbove,
+ wxBelow,
+ wxLeftOf,
+ wxRightOf,
+ wxSameAs,
+ wxAbsolute
};
-class WXDLLEXPORT wxLayoutConstraints: public wxObject
+enum wxSizerBehaviour
{
- DECLARE_DYNAMIC_CLASS(wxLayoutConstraints)
-
- public:
- // Edge constraints
- wxIndividualLayoutConstraint left;
- wxIndividualLayoutConstraint top;
- wxIndividualLayoutConstraint right;
- wxIndividualLayoutConstraint bottom;
- // Size constraints
- wxIndividualLayoutConstraint width;
- wxIndividualLayoutConstraint height;
- // Centre constraints
- wxIndividualLayoutConstraint centreX;
- wxIndividualLayoutConstraint centreY;
-
- wxLayoutConstraints();
- ~wxLayoutConstraints();
-
- bool SatisfyConstraints(wxWindow *win, int *noChanges);
- bool AreSatisfied() const
- {
- return left.GetDone() && top.GetDone() && right.GetDone() &&
- bottom.GetDone() && centreX.GetDone() && centreY.GetDone();
- }
+ wxSizerShrink,
+ wxSizerExpand,
+ wxSizerNone
};
-bool WXDLLEXPORT wxOldDoLayout(wxWindow *win);
+#define wxTYPE_SIZER 90
+
+// =============================================================================
+// classes
+// =============================================================================
+
+// ----------------------------------------------------------------------------
+// wxIndividualLayoutConstraint: a constraint on window position
+// ----------------------------------------------------------------------------
+
+class WXDLLEXPORT wxIndividualLayoutConstraint : public wxObject
+{
+ DECLARE_DYNAMIC_CLASS(wxIndividualLayoutConstraint)
+
+protected:
+ // To be allowed to modify the internal variables
+ friend class wxIndividualLayoutConstraint_Serialize;
+
+ // 'This' window is the parent or sibling of otherWin
+ wxWindowBase *otherWin;
+
+ wxEdge myEdge;
+ wxRelationship relationship;
+ int margin;
+ int value;
+ int percent;
+ wxEdge otherEdge;
+ bool done;
+
+public:
+ wxIndividualLayoutConstraint();
+ ~wxIndividualLayoutConstraint();
+
+ void Set(wxRelationship rel, wxWindowBase *otherW, wxEdge otherE, int val = 0, int marg = wxLAYOUT_DEFAULT_MARGIN);
+
+ //
+ // Sibling relationships
+ //
+ void LeftOf(wxWindowBase *sibling, int marg = wxLAYOUT_DEFAULT_MARGIN);
+ void RightOf(wxWindowBase *sibling, int marg = wxLAYOUT_DEFAULT_MARGIN);
+ void Above(wxWindowBase *sibling, int marg = wxLAYOUT_DEFAULT_MARGIN);
+ void Below(wxWindowBase *sibling, int marg = wxLAYOUT_DEFAULT_MARGIN);
+
+ //
+ // 'Same edge' alignment
+ //
+ void SameAs(wxWindowBase *otherW, wxEdge edge, int marg = wxLAYOUT_DEFAULT_MARGIN);
+
+ // The edge is a percentage of the other window's edge
+ void PercentOf(wxWindowBase *otherW, wxEdge wh, int per);
+
+ //
+ // Edge has absolute value
+ //
+ void Absolute(int val);
+
+ //
+ // Dimension is unconstrained
+ //
+ void Unconstrained() { relationship = wxUnconstrained; }
+
+ //
+ // Dimension is 'as is' (use current size settings)
+ //
+ void AsIs() { relationship = wxAsIs; }
+
+ //
+ // Accessors
+ //
+ wxWindowBase *GetOtherWindow() { return otherWin; }
+ wxEdge GetMyEdge() const { return myEdge; }
+ void SetEdge(wxEdge which) { myEdge = which; }
+ void SetValue(int v) { value = v; }
+ int GetMargin() { return margin; }
+ void SetMargin(int m) { margin = m; }
+ int GetValue() const { return value; }
+ int GetPercent() const { return percent; }
+ int GetOtherEdge() const { return otherEdge; }
+ bool GetDone() const { return done; }
+ void SetDone(bool d) { done = d; }
+ wxRelationship GetRelationship() { return relationship; }
+ void SetRelationship(wxRelationship r) { relationship = r; }
+
+ // Reset constraint if it mentions otherWin
+ bool ResetIfWin(wxWindowBase *otherW);
+
+ // Try to satisfy constraint
+ bool SatisfyConstraint(wxLayoutConstraints *constraints, wxWindowBase *win);
+
+ // Get the value of this edge or dimension, or if this
+ // is not determinable, -1.
+ int GetEdge(wxEdge which, wxWindowBase *thisWin, wxWindowBase *other) const;
+};
+
+// ----------------------------------------------------------------------------
+// wxLayoutConstraints: the complete set of constraints for a window
+// ----------------------------------------------------------------------------
+
+class WXDLLEXPORT wxLayoutConstraints : public wxObject
+{
+ DECLARE_DYNAMIC_CLASS(wxLayoutConstraints)
+
+public:
+ // Edge constraints
+ wxIndividualLayoutConstraint left;
+ wxIndividualLayoutConstraint top;
+ wxIndividualLayoutConstraint right;
+ wxIndividualLayoutConstraint bottom;
+ // Size constraints
+ wxIndividualLayoutConstraint width;
+ wxIndividualLayoutConstraint height;
+ // Centre constraints
+ wxIndividualLayoutConstraint centreX;
+ wxIndividualLayoutConstraint centreY;
+
+ wxLayoutConstraints();
+ ~wxLayoutConstraints();
+
+ bool SatisfyConstraints(wxWindowBase *win, int *noChanges);
+ bool AreSatisfied() const
+ {
+ return left.GetDone() && top.GetDone() && right.GetDone() &&
+ bottom.GetDone() && centreX.GetDone() && centreY.GetDone();
+ }
+};
+
+// ----------------------------------------------------------------------------
+// sizers
+// ----------------------------------------------------------------------------
/*
*/
-enum wxSizerBehaviour
-{
- wxSizerShrink,
- wxSizerExpand,
- wxSizerNone
-};
-
-#define wxTYPE_SIZER 90
-
class WXDLLEXPORT wxSizer : public wxWindow
{
-DECLARE_DYNAMIC_CLASS(wxSizer)
+ DECLARE_DYNAMIC_CLASS(wxSizer)
protected:
wxSizerBehaviour sizerBehaviour;
public:
wxSizer();
- wxSizer(wxWindow *parent, wxSizerBehaviour behav = wxSizerNone);
+ wxSizer(wxWindowBase *parent, wxSizerBehaviour behav = wxSizerNone);
~wxSizer();
- bool Create(wxWindow *parent, wxSizerBehaviour behav = wxSizerNone);
+ bool Create(wxWindowBase *parent, wxSizerBehaviour behav = wxSizerNone);
virtual void GetSize(int *w, int *h) const;
int GetBorderX() { return borderX ; }
int GetBorderY() { return borderY ; }
- virtual void AddSizerChild(wxWindow *child);
- virtual void RemoveSizerChild(wxWindow *child);
+ virtual void AddSizerChild(wxWindowBase *child);
+ virtual void RemoveSizerChild(wxWindowBase *child);
virtual void SetBehaviour(wxSizerBehaviour b) { sizerBehaviour = b; }
virtual wxSizerBehaviour GetBehaviour() { return sizerBehaviour; }
class WXDLLEXPORT wxRowColSizer : public wxSizer
{
-DECLARE_DYNAMIC_CLASS(wxRowColSizer)
+ DECLARE_DYNAMIC_CLASS(wxRowColSizer)
protected:
bool rowOrCol;
public:
// rowOrCol = TRUE to be laid out in rows, otherwise in columns.
wxRowColSizer();
- wxRowColSizer(wxWindow *parent, bool rowOrCol = wxSIZER_ROWS,
+ wxRowColSizer(wxWindowBase *parent, bool rowOrCol = wxSIZER_ROWS,
int rowsOrColSize = 20, wxSizerBehaviour = wxSizerShrink);
~wxRowColSizer();
- bool Create(wxWindow *parent, bool rowOrCol = wxSIZER_ROWS,
+ bool Create(wxWindowBase *parent, bool rowOrCol = wxSIZER_ROWS,
int rowsOrColSize = 20, wxSizerBehaviour = wxSizerShrink);
virtual void SetRowOrCol(bool rc) { rowOrCol = rc; }
class WXDLLEXPORT wxSpacingSizer : public wxSizer
{
-DECLARE_DYNAMIC_CLASS(wxSpacingSizer)
+ DECLARE_DYNAMIC_CLASS(wxSpacingSizer)
public:
wxSpacingSizer();
- wxSpacingSizer(wxWindow *parent, wxRelationship rel, wxWindow *other, int spacing);
- wxSpacingSizer(wxWindow *parent);
+ wxSpacingSizer(wxWindowBase *parent, wxRelationship rel, wxWindowBase *other, int spacing);
+ wxSpacingSizer(wxWindowBase *parent);
~wxSpacingSizer();
- bool Create(wxWindow *parent, wxRelationship rel, wxWindow *other, int sp);
- bool Create(wxWindow *parent);
+ bool Create(wxWindowBase *parent, wxRelationship rel, wxWindowBase *other, int sp);
+ bool Create(wxWindowBase *parent);
};
+// ----------------------------------------------------------------------------
+// global functions
+// ----------------------------------------------------------------------------
+
+#if WXWIN_COMPATIBILITY
+ extern bool WXDLLEXPORT wxOldDoLayout(wxWindowBase *win);
+#endif // WXWIN_COMPATIBILITY
+
#endif
// _WX_LAYOUTH__
virtual ~wxNodeBase();
- // @@ no check is done that the list is really keyed on strings
+ // FIXME no check is done that the list is really keyed on strings
const wxChar *GetKeyString() const { return m_key.string; }
long GetKeyInteger() const { return m_key.integer; }
// 2. We redefine all non-type-safe wxList functions with type-safe versions
// which don't take any space (everything is inline), but bring compile
// time error checking.
-
-#define WX_DECLARE_LIST_2(T, name, nodetype) \
+//
+// 3. The macro which is usually used (WX_DECLARE_LIST) is defined in terms of
+// a more generic WX_DECLARE_LIST_2 macro which, in turn, uses the most
+// generic WX_DECLARE_LIST_3 one. The last macro adds a sometimes
+// interesting capability to store polymorphic objects in the list and is
+// particularly useful with, for example, "wxWindow *" list where the
+// wxWindowBase pointers are put into the list, but wxWindow pointers are
+// retrieved from it.
+
+#define WX_DECLARE_LIST_3(T, Tbase, name, nodetype) \
typedef int (*wxSortFuncFor_##name)(const T *, const T *); \
\
class WXDLLEXPORT nodetype : public wxNodeBase \
return node ? (T*)(node->GetData()) : (T*)NULL; \
} \
\
- nodetype *Append(T *object) \
+ nodetype *Append(Tbase *object) \
{ return (nodetype *)wxListBase::Append(object); } \
- nodetype *Insert(T *object) \
+ nodetype *Insert(Tbase *object) \
{ return (nodetype *)Insert((nodetype*)NULL, object); } \
- nodetype *Insert(nodetype *prev, T *object) \
+ nodetype *Insert(nodetype *prev, Tbase *object) \
{ return (nodetype *)wxListBase::Insert(prev, object); } \
\
nodetype *Append(long key, void *object) \
{ return (nodetype *)wxListBase::DetachNode(node); } \
bool DeleteNode(nodetype *node) \
{ return wxListBase::DeleteNode(node); } \
- bool DeleteObject(T *object) \
+ bool DeleteObject(Tbase *object) \
{ return wxListBase::DeleteObject(object); } \
\
- nodetype *Find(T *object) const \
+ nodetype *Find(Tbase *object) const \
{ return (nodetype *)wxListBase::Find(object); } \
\
virtual nodetype *Find(const wxListKey& key) const \
{ return (nodetype *)wxListBase::Find(key); } \
\
- int IndexOf( T *object ) const \
+ int IndexOf(Tbase *object) const \
{ return wxListBase::IndexOf(object); } \
\
void Sort(wxSortFuncFor_##name func) \
} \
}
+#define WX_DECLARE_LIST_2(elementtype, listname, nodename) \
+ WX_DECLARE_LIST_3(elementtype, elementtype, listname, nodename)
+
#define WX_DECLARE_LIST(elementtype, listname) \
typedef elementtype _WX_LIST_ITEM_TYPE_##listname; \
WX_DECLARE_LIST_2(elementtype, listname, wx##listname##Node)
// =============================================================================
// ----------------------------------------------------------------------------
-// commonly used string classes
+// commonly used list classes
// ----------------------------------------------------------------------------
-class wxWindow;
-WX_DECLARE_LIST(wxWindow, wxWindowList);
-
#ifdef wxLIST_COMPATIBILITY
// -----------------------------------------------------------------------------
#endif
// Lay the tools out
- virtual void Layout(void);
+ virtual void LayoutTools();
// Add all the buttons: required for Win95.
virtual bool CreateTools(void) { return TRUE; }
virtual void SpringUpButton(int index);
- void Layout(void);
+ virtual void LayoutTools();
// The post-tool-addition call
- bool Realize() { Layout(); return TRUE; };
+ virtual bool Realize() { LayoutTools(); return TRUE; };
protected:
int m_currentRowsOrColumns;
#include "wx/event.h"
-class WXDLLEXPORT wxWindow;
+class WXDLLEXPORT wxWindowBase;
/*
A validator has up to three purposes:
{
public:
wxValidator();
- ~wxValidator();
+ virtual ~wxValidator();
// Make a clone of this validator (or return NULL) - currently necessary
// if you're passing a reference to a validator.
// Called when the value in the window must be validated.
// This function can pop up an error message.
- virtual bool Validate(wxWindow *WXUNUSED(parent)) { return FALSE; };
+ virtual bool Validate(wxWindowBase *WXUNUSED(parent)) { return FALSE; };
// Called to transfer data to the window
virtual bool TransferToWindow() { return FALSE; }
virtual bool TransferFromWindow() { return FALSE; };
// accessors
- wxWindow *GetWindow() const { return m_validatorWindow; }
- void SetWindow(wxWindow *win) { m_validatorWindow = win; }
+ wxWindowBase *GetWindow() const { return m_validatorWindow; }
+ void SetWindow(wxWindowBase *win) { m_validatorWindow = win; }
// validators beep by default if invalid key is pressed, these functions
// allow to change it
static void SetBellOnError(bool doIt = TRUE) { ms_isSilent = doIt; }
protected:
- wxWindow *m_validatorWindow;
+ wxWindowBase *m_validatorWindow;
private:
static bool ms_isSilent;
+///////////////////////////////////////////////////////////////////////////////
+// Name: window.h
+// Purpose: wxWindowBase class - the interface of wxWindowBase
+// Author: Vadim Zeitlin
+// Modified by:
+// Created: 01/02/97
+// RCS-ID: $Id$
+// Copyright: (c) wxWindows team
+// Licence: wxWindows licence
+///////////////////////////////////////////////////////////////////////////////
+
#ifndef _WX_WINDOW_H_BASE_
#define _WX_WINDOW_H_BASE_
+// ----------------------------------------------------------------------------
+// headers which we must include here
+// ----------------------------------------------------------------------------
+
+#include "wx/event.h" // the base class
+
+#include "wx/list.h" // defines wxWindowList
+
+#include "wx/cursor.h" // we have member variables of these classes
+#include "wx/font.h" // so we can't do without them
+#include "wx/colour.h"
+#include "wx/region.h"
+#include "wx/accel.h"
+
+// ----------------------------------------------------------------------------
+// forward declarations
+// ----------------------------------------------------------------------------
+
+class WXDLLEXPORT wxClientData;
+class WXDLLEXPORT wxControl;
+class WXDLLEXPORT wxCursor;
+class WXDLLEXPORT wxDc;
+class WXDLLEXPORT wxDropTarget;
+class WXDLLEXPORT wxItemResource;
+class WXDLLEXPORT wxLayoutConstraints;
+class WXDLLEXPORT wxResourceTable;
+class WXDLLEXPORT wxSizer;
+class WXDLLEXPORT wxToolTip;
+class WXDLLEXPORT wxValidator;
+class WXDLLEXPORT wxWindowBase;
+class WXDLLEXPORT wxWindow;
+
+// ----------------------------------------------------------------------------
+// (pseudo)template list classes
+// ----------------------------------------------------------------------------
+
+WX_DECLARE_LIST_3(wxWindow, wxWindowBase, wxWindowList, wxWindowListNode);
+
+// ----------------------------------------------------------------------------
+// global variables
+// ----------------------------------------------------------------------------
+
+WXDLLEXPORT_DATA(extern wxWindowList) wxTopLevelWindows;
+
+// ----------------------------------------------------------------------------
+// helper classes used by [SG]etClientObject/Data
+//
+// TODO move into a separate header?
+// ----------------------------------------------------------------------------
+
+class wxClientData
+{
+public:
+ wxClientData() { }
+ virtual ~wxClientData() { }
+};
+
+class wxStringClientData : public wxClientData
+{
+public:
+ wxStringClientData() { }
+ wxStringClientData( const wxString &data ) : m_data(data) { }
+ void SetData( const wxString &data ) { m_data = data; }
+ const wxString& GetData() const { return m_data; }
+
+private:
+ wxString m_data;
+};
+
+// ----------------------------------------------------------------------------
+// wxWindowBase is the base class for all GUI controls/widgets, this is the public
+// interface of this class.
+//
+// Event handler: windows have themselves as their event handlers by default,
+// but their event handlers could be set to another object entirely. This
+// separation can reduce the amount of derivation required, and allow
+// alteration of a window's functionality (e.g. by a resource editor that
+// temporarily switches event handlers).
+// ----------------------------------------------------------------------------
+
+class WXDLLEXPORT wxWindowBase : public wxEvtHandler
+{
+ DECLARE_ABSTRACT_CLASS(wxWindowBase);
+
+public:
+ // creating the window
+ // -------------------
+
+ // default ctor
+ wxWindowBase() { InitBase(); }
+
+ // pseudo ctor (can't be virtual, called from ctor)
+ bool CreateBase(wxWindowBase *parent,
+ wxWindowID id,
+ const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize,
+ long style = 0,
+ const wxString& name = wxPanelNameStr);
+
+ virtual ~wxWindowBase();
+
+#if wxUSE_WX_RESOURCES
+ // these functions are implemented in resource.cpp and resourc2.cpp
+ virtual bool LoadFromResource(wxWindow *parent,
+ const wxString& resourceName,
+ const wxResourceTable *table = (const wxResourceTable *) NULL);
+ virtual wxControl *CreateItem(const wxItemResource* childResource,
+ const wxItemResource* parentResource,
+ const wxResourceTable *table = (const wxResourceTable *) NULL);
+#endif // wxUSE_WX_RESOURCES
+
+ // deleting the window
+ // -------------------
+
+ // ask the window to close itself, return TRUE if the event handler
+ // honoured our request
+ bool Close( bool force = FALSE );
+
+ // the following functions delete the C++ objects (the window itself
+ // or its children) as well as the GUI windows and normally should
+ // never be used directly
+
+ // delete window unconditionally (dangerous!), returns TRUE if ok
+ virtual bool Destroy();
+ // delete all children of this window, returns TRUE if ok
+ bool DestroyChildren();
+
+ // is the window being deleted?
+ bool IsBeingDeleted() const { return m_isBeingDeleted; }
+
+ // window attributes
+ // -----------------
+
+ // the title (or label, see below) of the window: the text which the
+ // window shows
+ virtual void SetTitle( const wxString & WXUNUSED(title) ) { }
+ virtual wxString GetTitle() const { return ""; }
+
+ // label is just the same as the title (but for, e.g., buttons it
+ // makes more sense to speak about labels)
+ wxString GetLabel() const { return GetTitle(); }
+
+ // the window name is used for ressource setting in X, it is not the
+ // same as the window title/label
+ virtual void SetName( const wxString &name ) { m_windowName = name; }
+ virtual wxString GetName() const { return m_windowName; }
+
+ // window id uniquely identifies the window among its siblings unless
+ // it is -1 which means "don't care"
+ void SetId( wxWindowID id ) { m_windowId = id; }
+ wxWindowID GetId() const { return m_windowId; }
+
+ // generate a control id for the controls which were not given one by
+ // user
+ static int NewControlId() { return ++ms_lastControlId; }
+
+ // moving/resizing
+ // ---------------
+
+ // set the window size and/or position
+ void SetSize( int x, int y, int width, int height,
+ int sizeFlags = wxSIZE_AUTO )
+ { DoSetSize(x, y, width, height, sizeFlags); }
+
+ void SetSize( int width, int height )
+ { DoSetSize( -1, -1, width, height, wxSIZE_USE_EXISTING ); }
+
+ void SetSize( const wxSize& size )
+ { SetSize( size.x, size.y); }
+
+ void SetSize(const wxRect& rect, int sizeFlags = wxSIZE_AUTO)
+ { DoSetSize(rect.x, rect.y, rect.width, rect.height, sizeFlags); }
+
+ void Move( int x, int y )
+ { DoSetSize( x, y, -1, -1, wxSIZE_USE_EXISTING ); }
+
+ void Move(const wxPoint& pt)
+ { Move(pt.x, pt.y); }
+
+ // Z-order
+ virtual void Raise() = 0;
+ virtual void Lower() = 0;
+
+ // client size is the size of area available for subwindows
+ void SetClientSize( int width, int height )
+ { DoSetClientSize(width, height); }
+
+ void SetClientSize( const wxSize& size )
+ { DoSetClientSize(size.x, size.y); }
+
+ void SetClientSize(const wxRect& rect)
+ { SetClientSize( rect.width, rect.height ); }
+
+ // get the window position and/or size (pointers may be NULL)
+ void GetPosition( int *x, int *y ) const { DoGetPosition(x, y); }
+ wxPoint GetPosition() const
+ {
+ int w, h;
+ DoGetPosition(&w, &h);
+
+ return wxPoint(w, h);
+ }
+
+ void GetSize( int *w, int *h ) const { DoGetSize(w, h); }
+ wxSize GetSize() const
+ {
+ int w, h;
+ DoGetSize(& w, & h);
+ return wxSize(w, h);
+ }
+
+ wxRect GetRect() const
+ {
+ int x, y, w, h;
+ GetPosition(& x, & y);
+ GetSize(& w, & h);
+
+ return wxRect(x, y, w, h);
+ }
+
+ void GetClientSize( int *w, int *h ) const { DoGetClientSize(w, h); }
+ wxSize GetClientSize() const
+ {
+ int w, h;
+ DoGetClientSize(& w, & h);
+
+ return wxSize(w, h);
+ }
+
+ // centre with respect to the the parent window
+ void Centre( int direction = wxHORIZONTAL );
+ void Center( int direction = wxHORIZONTAL ) { Centre(direction); }
+
+ // set window size to wrap around its children
+ virtual void Fit();
+
+ // set min/max size of the window
+ virtual void SetSizeHints( int minW, int minH,
+ int maxW = -1, int maxH = -1,
+ int incW = -1, int incH = -1 );
+
+ // window state
+ // ------------
+
+ // returns TRUE if window was shown/hidden, FALSE if the nothing was
+ // done (window was already shown/hidden)
+ virtual bool Show( bool show = TRUE );
+ bool Hide() { return Show(FALSE); }
+
+ // returns TRUE if window was enabled/disabled, FALSE if nothing done
+ virtual bool Enable( bool enable = TRUE );
+ bool Disable() { return Enable(FALSE); }
+
+ bool IsShown() const { return m_isShown; }
+ bool IsEnabled() const { return m_isEnabled; }
+
+ // get/set window style (setting style won't update the window and so
+ // is only useful for internal usage)
+ virtual void SetWindowStyleFlag( long style ) { m_windowStyle = style; }
+ virtual long GetWindowStyleFlag() const { return m_windowStyle; }
+
+ // just some (somewhat shorter) synonims
+ void SetWindowStyle( long style ) { SetWindowStyleFlag(style); }
+ long GetWindowStyle() const { return GetWindowStyleFlag(); }
+
+ bool HasFlag(int flag) const { return (m_windowStyle & flag) != 0; }
+
+ virtual bool IsRetained() const
+ { return (m_windowStyle & wxRETAINED) != 0; }
+
+ // make the window modal (all other windows unresponsive)
+ virtual void MakeModal(bool modal = TRUE);
+
+ // focus handling
+ // --------------
+
+ // set focus to this window
+ virtual void SetFocus() = 0;
+
+ // return the window which currently has the focus or NULL
+ static wxWindow *FindFocus() /* = 0: implement in derived classes */;
+
+ // can this window have focus?
+ virtual bool AcceptsFocus() const { return IsShown() && IsEnabled(); }
+
+ // parent/children relations
+ // -------------------------
+
+ // get the list of children
+ const wxWindowList& GetChildren() const { return m_children; }
+ wxWindowList& GetChildren() { return m_children; }
+
+ // get the parent or the parent of the parent
+ wxWindow *GetParent() const { return m_parent; }
+ inline wxWindow *GetGrandParent() const;
+
+ // is this window a top level one?
+ bool IsTopLevel() const { return m_parent != 0; }
+
+ // it doesn't really change parent, use ReParent() instead
+ void SetParent( wxWindowBase *parent ) { m_parent = (wxWindow *)parent; }
+ // change the real parent of this window, return TRUE if the parent
+ // was changed, FALSE otherwise (error or newParent == oldParent)
+ virtual bool Reparent( wxWindowBase *newParent );
+
+ // find window among the descendants of this one either by id or by
+ // name (return NULL if not found)
+ wxWindow *FindWindow( long id );
+ wxWindow *FindWindow( const wxString& name );
+
+ // implementation mostly
+ virtual void AddChild( wxWindowBase *child );
+ virtual void RemoveChild( wxWindowBase *child );
+
+ // event handler stuff
+ // -------------------
+
+ // get the current event handler
+ wxEvtHandler *GetEventHandler() const { return m_eventHandler; }
+
+ // replace the event handler (allows to completely subclass the
+ // window)
+ void SetEventHandler( wxEvtHandler *handler ) { m_eventHandler = handler; }
+
+ // push/pop event handler: allows to chain a custom event handler to
+ // alreasy existing ones
+ void PushEventHandler( wxEvtHandler *handler );
+ wxEvtHandler *PopEventHandler( bool deleteHandler = FALSE );
+
+ // validators and client data
+ // --------------------------
+
+ // a window may have an associated validator which is used to control
+ // user input
+ virtual void SetValidator( const wxValidator &validator );
+ virtual wxValidator *GetValidator() { return m_windowValidator; }
+
+ // each window may have associated client data: either a pointer to
+ // wxClientData object in which case it is managed by the window (i.e.
+ // it will delete the data when it's destroyed) or an untyped pointer
+ // which won't be deleted by the window
+ virtual void SetClientObject( wxClientData *data )
+ {
+ if ( m_clientObject )
+ delete m_clientObject;
+
+ m_clientObject = data;
+ }
+ virtual wxClientData *GetClientObject() const { return m_clientObject; }
+
+ virtual void SetClientData( void *data ) { m_clientData = data; }
+ virtual void *GetClientData() const { return m_clientData; }
+
+ // dialog oriented functions
+ // -------------------------
+
+ // validate the correctness of input, return TRUE if ok
+ virtual bool Validate();
+
+ // transfer data between internal and GUI representations
+ virtual bool TransferDataToWindow();
+ virtual bool TransferDataFromWindow();
+
+ virtual void InitDialog();
+
+ // accelerators
+ // ------------
+ virtual void SetAcceleratorTable( const wxAcceleratorTable& accel )
+ { m_acceleratorTable = accel; }
+ wxAcceleratorTable *GetAcceleratorTable()
+ { return &m_acceleratorTable; }
+
+ // dialog units translations
+ // -------------------------
+
+ wxPoint ConvertPixelsToDialog( const wxPoint& pt );
+ wxPoint ConvertDialogToPixels( const wxPoint& pt );
+ wxSize ConvertPixelsToDialog( const wxSize& sz )
+ {
+ wxPoint pt(ConvertPixelsToDialog(wxPoint(sz.x, sz.y)));
+
+ return wxSize(pt.x, pt.y);
+ }
+
+ wxSize ConvertDialogToPixels( const wxSize& sz )
+ {
+ wxPoint pt(ConvertDialogToPixels(wxPoint(sz.x, sz.y)));
+
+ return wxSize(pt.x, pt.y);
+ }
+
+ // mouse functions
+ // ---------------
+
+ // move the mouse to the specified position
+ virtual void WarpPointer(int x, int y) = 0;
+
+ // start or end mouse capture
+ virtual void CaptureMouse() = 0;
+ virtual void ReleaseMouse() = 0;
+
+ // painting the window
+ // -------------------
+
+ // mark the specified rectangle (or the whole window) as "dirty" so it
+ // will be repainted
+ virtual void Refresh( bool eraseBackground = TRUE,
+ const wxRect *rect = (const wxRect *) NULL ) = 0;
+ // clear the window entirely
+ virtual void Clear() = 0;
+
+ // adjust DC for drawing on this window
+ virtual void PrepareDC( wxDC &dc ) { }
+
+ // the update region of the window contains the areas which must be
+ // repainted by the program
+ const wxRegion& GetUpdateRegion() const { return m_updateRegion; }
+ wxRegion& GetUpdateRegion() { return m_updateRegion; }
+
+ // these functions verify whether the given point/rectangle belongs to
+ // (or at least intersects with) the update region
+ bool IsExposed( int x, int y ) const;
+ bool IsExposed( int x, int y, int w, int h ) const;
+
+ bool IsExposed( const wxPoint& pt ) const
+ { return IsExposed(pt.x, pt.y); }
+ bool IsExposed( const wxRect& rect ) const
+ { return IsExposed(rect.x, rect.y, rect.width, rect.height); }
+
+ // colours, fonts and cursors
+ // --------------------------
+
+ // set/retrieve the window colours (system defaults are used by
+ // default): Set functions return TRUE if colour was changed
+ virtual bool SetBackgroundColour( const wxColour &colour );
+ virtual bool SetForegroundColour( const wxColour &colour );
+
+ wxColour GetBackgroundColour() const { return m_backgroundColour; }
+ wxColour GetForegroundColour() const { return m_foregroundColour; }
+
+ // set/retrieve the cursor for this window (SetCursor() returns TRUE
+ // if the cursor was really changed)
+ virtual bool SetCursor( const wxCursor &cursor );
+ const wxCursor& GetCursor() const { return m_cursor; }
+ wxCursor& GetCursor() { return m_cursor; }
+
+ // set/retrieve the font for the window (SetFont() returns TRUE if the
+ // font really changed)
+ virtual bool SetFont( const wxFont &font ) = 0;
+ const wxFont& GetFont() const { return m_font; }
+ wxFont& GetFont() { return m_font; }
+
+ // get the (average) character size for the current font
+ virtual int GetCharHeight() const = 0;
+ virtual int GetCharWidth() const = 0;
+
+ // get the width/height/... of the text using current or specified
+ // font
+ 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 = 0;
+
+ // translate to/from screen/client coordinates (pointers may be NULL)
+ virtual void ClientToScreen( int *x, int *y ) const = 0;
+ virtual void ScreenToClient( int *x, int *y ) const = 0;
+
+ // misc
+ // ----
+
+ void UpdateWindowUI();
+
+ virtual bool PopupMenu( wxMenu *menu, int x, int y ) = 0;
+
+ // scrollbars
+ // ----------
+
+ // configure the window scrollbars
+ virtual void SetScrollbar( int orient,
+ int pos,
+ int thumbVisible,
+ int range,
+ bool refresh = TRUE ) = 0;
+ virtual void SetScrollPos( int orient, int pos, bool refresh = TRUE ) = 0;
+ virtual int GetScrollPos( int orient ) const = 0;
+ virtual int GetScrollThumb( int orient ) const = 0;
+ virtual int GetScrollRange( int orient ) const = 0;
+
+ // scroll window to the specified position
+ virtual void ScrollWindow( int dx, int dy,
+ const wxRect* rect = (wxRect *) NULL ) = 0;
+
+ // tooltips
+ // --------
+#if wxUSE_TOOLTIPS
+ // the easiest way to set a tooltip for a window is to use this method
+ void SetToolTip( const wxString &tip );
+ // attach a tooltip to the window
+ void SetToolTip( wxToolTip *tip ) { DoSetToolTip(tip); }
+ // get the associated tooltip or NULL if none
+ wxToolTip* GetToolTip() const { return m_tooltip; }
+#endif // wxUSE_TOOLTIPS
+
+ // drag and drop
+ // -------------
+#if wxUSE_DRAG_AND_DROP
+ // set/retrieve the drop target associated with this window (may be
+ // NULL; it's owned by the window and will be deleted by it)
+ virtual void SetDropTarget( wxDropTarget *dropTarget ) = 0;
+ virtual wxDropTarget *GetDropTarget() const { return m_dropTarget; }
+#endif // wxUSE_DRAG_AND_DROP
+
+ // constraints and sizers
+ // ----------------------
+#if wxUSE_CONSTRAINTS
+ // set the constraints for this window or retrieve them (may be NULL)
+ void SetConstraints( wxLayoutConstraints *constraints );
+ wxLayoutConstraints *GetConstraints() const { return m_constraints; }
+
+ // when using constraints, it makes sense to update children positions
+ // automatically whenever the window is resized - this is done if
+ // autoLayout is on
+ void SetAutoLayout( bool autoLayout ) { m_autoLayout = autoLayout; }
+ bool GetAutoLayout() const { return m_autoLayout; }
+
+ // do layout the window and its children
+ virtual bool Layout();
+
+ // implementation only
+ void UnsetConstraints(wxLayoutConstraints *c);
+ wxWindowList *GetConstraintsInvolvedIn() const
+ { return m_constraintsInvolvedIn; }
+ void AddConstraintReference(wxWindowBase *otherWin);
+ void RemoveConstraintReference(wxWindowBase *otherWin);
+ void DeleteRelatedConstraints();
+ void ResetConstraints();
+
+ // these methods may be overriden for special layout algorithms
+ virtual void SetConstraintSizes(bool recurse = TRUE);
+ virtual bool LayoutPhase1(int *noChanges);
+ virtual bool LayoutPhase2(int *noChanges);
+ virtual bool DoPhase(int);
+
+ // these methods are virtual but normally won't be overridden
+ virtual void TransformSizerToActual(int *x, int *y) const ;
+ virtual void SetSizeConstraint(int x, int y, int w, int h);
+ virtual void MoveConstraint(int x, int y);
+ virtual void GetSizeConstraint(int *w, int *h) const ;
+ virtual void GetClientSizeConstraint(int *w, int *h) const ;
+ virtual void GetPositionConstraint(int *x, int *y) const ;
+
+ // sizers
+ // TODO: what are they and how do they work??
+ void SetSizer( wxSizer *sizer );
+ wxSizer *GetSizer() const { return m_windowSizer; }
+
+ void SetSizerParent( wxWindowBase *win ) { m_sizerParent = win; }
+ wxWindowBase *GetSizerParent() const { return m_sizerParent; }
+
+ virtual void SizerSetSize(int x, int y, int w, int h);
+ virtual void SizerMove(int x, int y);
+#endif // wxUSE_CONSTRAINTS
+
+ // backward compatibility
+ // ----------------------
+#if WXWIN_COMPATIBILITY
+ bool Enabled() const { return IsEnabled(); }
+
+ void SetButtonFont(const wxFont& font) { SetFont(font); }
+ void SetLabelFont(const wxFont& font) { SetFont(font); }
+ wxFont& GetLabelFont() { return GetFont(); };
+ wxFont& GetButtonFont() { return GetFont(); };
+#endif // WXWIN_COMPATIBILITY
+
+ // implementation
+ // --------------
+
+ // event handlers
+ void OnSysColourChanged( wxSysColourChangedEvent& event );
+ void OnInitDialog( wxInitDialogEvent &event );
+
+ // accessors
+ WXWidget GetHandle() const { return m_widget; }
+
+protected:
+ // the window handle (for the underlying windowing system) and the window
+ // id - a number which uniquely identifies a window among its siblings
+ // unless it is -1
+ WXWidget m_widget;
+ wxWindowID m_windowId;
+
+ // the parent window of this window (or NULL) and the list of the children
+ // of this window
+ wxWindow *m_parent;
+ wxWindowList m_children;
+
+ // the minimal allowed size for the window (no minimal size if variable(s)
+ // contain(s) -1)
+ int m_minWidth, m_minHeight, m_maxWidth, m_maxHeight;
+
+ // event handler for this window: usually is just 'this' but may be
+ // changed with SetEventHandler()
+ wxEvtHandler *m_eventHandler;
+
+ // associated validator or NULL if none
+ wxValidator *m_windowValidator;
+
+#if wxUSE_DRAG_AND_DROP
+ wxDropTarget *m_dropTarget;
+#endif // wxUSE_DRAG_AND_DROP
+
+ // visual window attributes
+ wxCursor m_cursor;
+ wxFont m_font;
+ wxColour m_backgroundColour, m_foregroundColour;
+
+ // the region which should be repainted in response to paint event
+ wxRegion m_updateRegion;
+
+ // the accelerator table for the window which translates key strokes into
+ // command events
+ wxAcceleratorTable m_acceleratorTable;
+
+ // user data associated with the window: either an object which will be
+ // deleted by the window when it's deleted or some raw pointer which we do
+ // nothing with
+ wxClientData *m_clientObject;
+ void *m_clientData;
+
+ // the tooltip for this window (may be NULL)
+#if wxUSE_TOOLTIPS
+ wxToolTip *m_tooltip;
+#endif // wxUSE_TOOLTIPS
+
+ // constraints and sizers
+#if wxUSE_CONSTRAINTS
+ // the constraints for this window or NULL
+ wxLayoutConstraints *m_constraints;
+
+ // constraints this window is involved in
+ wxWindowList *m_constraintsInvolvedIn;
+
+ // top level and the parent sizers
+ // TODO what's this and how does it work?)
+ wxSizer *m_windowSizer;
+ wxWindowBase *m_sizerParent;
+
+ // Layout() window automatically when its size changes?
+ bool m_autoLayout:1;
+#endif // wxUSE_CONSTRAINTS
+
+ // window state
+ bool m_isShown:1;
+ bool m_isEnabled:1;
+ bool m_isBeingDeleted:1;
+
+ // window attributes
+ long m_windowStyle;
+ wxString m_windowName;
+
+protected:
+ // common part of all ctors: it is not virtual because it is called from
+ // ctor
+ void InitBase();
+
+ // get the default size for the new window if no explicit size given
+ // FIXME why 20 and not 30, 10 or ...?
+ static int WidthDefault(int w) { return w == -1 ? 20 : w; }
+ static int HeightDefault(int h) { return h == -1 ? 20 : h; }
+
+ // more pure virtual functions
+ // ---------------------------
+
+ // NB: we must have DoSomething() function when Something() is an overloaded
+ // method: indeed, we can't just have "virtual Something()" in case when
+ // the function is overloaded because then we'd have to make virtual all
+ // the variants (otherwise only the virtual function may be called on a
+ // pointer to derived class according to C++ rules) which is, in
+ // general, absolutely not needed. So instead we implement all
+ // overloaded Something()s in terms of DoSomething() which will be the
+ // only one to be virtual.
+
+ // retrieve the position/size of the window
+ virtual void DoGetPosition( int *x, int *y ) const = 0;
+ virtual void DoGetSize( int *width, int *height ) const = 0;
+ virtual void DoGetClientSize( int *width, int *height ) const = 0;
+
+ // this is the virtual function to be overriden in any derived class which
+ // wants to change how SetSize() or Move() works - it is called by all
+ // versions of these functions in the base class
+ virtual void DoSetSize(int x, int y,
+ int width, int height,
+ int sizeFlags = wxSIZE_AUTO) = 0;
+
+ // same as DoSetSize() for the client size
+ virtual void DoSetClientSize(int width, int height) = 0;
+
+#if wxUSE_TOOLTIPS
+ virtual void DoSetToolTip( wxToolTip *tip );
+#endif // wxUSE_TOOLTIPS
+
+private:
+ // contains the last id generated by NewControlId
+ static int ms_lastControlId;
+
+ DECLARE_EVENT_TABLE()
+};
+
+// ----------------------------------------------------------------------------
+// now include the declaration of wxWindow class
+// ----------------------------------------------------------------------------
+
#if defined(__WXMSW__)
-#include "wx/msw/window.h"
+ #include "wx/msw/window.h"
#elif defined(__WXMOTIF__)
-#include "wx/motif/window.h"
+ #include "wx/motif/window.h"
#elif defined(__WXGTK__)
-#include "wx/gtk/window.h"
+ #include "wx/gtk/window.h"
#elif defined(__WXQT__)
-#include "wx/qt/window.h"
+ #include "wx/qt/window.h"
#elif defined(__WXMAC__)
-#include "wx/mac/window.h"
-#elif defined(__WXSTUBS__)
-#include "wx/stubs/window.h"
+ #include "wx/mac/window.h"
#endif
+// ----------------------------------------------------------------------------
+// inline functions which couldn't be declared in the class body because of
+// forward dependencies
+// ----------------------------------------------------------------------------
+
+wxWindow *wxWindowBase::GetGrandParent() const
+{
+ return m_parent ? m_parent->GetParent() : (wxWindow *)NULL;
+}
+
+// ----------------------------------------------------------------------------
+// global function
+// ----------------------------------------------------------------------------
+
+extern wxWindow* WXDLLEXPORT wxGetActiveWindow();
+
#endif
// _WX_WINDOW_H_BASE_
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
-// Licence: wxWindows license
+// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
+// =============================================================================
+// declarations
+// =============================================================================
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
#ifdef __GNUG__
-#pragma implementation "layout.h"
+ #pragma implementation "layout.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
-#pragma hdrstop
+ #pragma hdrstop
#endif
#include "wx/defs.h"
#ifndef WX_PRECOMP
-#include "wx/window.h"
-#include "wx/utils.h"
-#include "wx/dialog.h"
-#include "wx/msgdlg.h"
-#include <wx/intl.h>
+ #include "wx/window.h"
+ #include "wx/utils.h"
+ #include "wx/dialog.h"
+ #include "wx/msgdlg.h"
+ #include "wx/intl.h"
#endif
#include "wx/layout.h"
#if !USE_SHARED_LIBRARY
-IMPLEMENT_DYNAMIC_CLASS(wxIndividualLayoutConstraint, wxObject)
-IMPLEMENT_DYNAMIC_CLASS(wxLayoutConstraints, wxObject)
-IMPLEMENT_DYNAMIC_CLASS(wxSizer, wxObject)
-IMPLEMENT_DYNAMIC_CLASS(wxRowColSizer, wxSizer)
-IMPLEMENT_DYNAMIC_CLASS(wxSpacingSizer, wxSizer)
+ IMPLEMENT_DYNAMIC_CLASS(wxIndividualLayoutConstraint, wxObject)
+ IMPLEMENT_DYNAMIC_CLASS(wxLayoutConstraints, wxObject)
+ IMPLEMENT_DYNAMIC_CLASS(wxSizer, wxObject)
+ IMPLEMENT_DYNAMIC_CLASS(wxRowColSizer, wxSizer)
+ IMPLEMENT_DYNAMIC_CLASS(wxSpacingSizer, wxSizer)
#endif
/*
*/
// Find margin sizes if a sizer, or zero otherwise
-int wxSizerMarginX(wxWindow *win)
+int wxSizerMarginX(wxWindowBase *win)
{
- if ( win->IsKindOf(CLASSINFO(wxSizer)) )
- {
- wxSizer *sizer = (wxSizer *)win;
- return sizer->GetBorderX();
- }
- else
- return 0;
+ if ( win->IsKindOf(CLASSINFO(wxSizer)) )
+ {
+ wxSizer *sizer = (wxSizer *)win;
+ return sizer->GetBorderX();
+ }
+ else
+ return 0;
}
-int wxSizerMarginY(wxWindow *win)
+int wxSizerMarginY(wxWindowBase *win)
{
- if ( win->IsKindOf(CLASSINFO(wxSizer)) )
- {
- wxSizer *sizer = (wxSizer *)win;
- return sizer->GetBorderY();
- }
- else
- return 0;
+ if ( win->IsKindOf(CLASSINFO(wxSizer)) )
+ {
+ wxSizer *sizer = (wxSizer *)win;
+ return sizer->GetBorderY();
+ }
+ else
+ return 0;
}
wxIndividualLayoutConstraint::wxIndividualLayoutConstraint()
{
- myEdge = wxTop; relationship = wxUnconstrained; margin = 0; value = 0; percent = 0; otherEdge = wxTop;
- done = FALSE; otherWin = (wxWindow *) NULL;
+ myEdge = wxTop;
+ relationship = wxUnconstrained;
+ margin = 0;
+ value = 0;
+ percent = 0;
+ otherEdge = wxTop;
+ done = FALSE;
+ otherWin = (wxWindowBase *) NULL;
}
wxIndividualLayoutConstraint::~wxIndividualLayoutConstraint()
{
}
-void wxIndividualLayoutConstraint::Set(wxRelationship rel, wxWindow *otherW, wxEdge otherE, int val, int marg)
+void wxIndividualLayoutConstraint::Set(wxRelationship rel, wxWindowBase *otherW, wxEdge otherE, int val, int marg)
{
- relationship = rel; otherWin = otherW; otherEdge = otherE; value = val; margin = marg;
+ relationship = rel;
+ otherWin = otherW;
+ otherEdge = otherE;
+ value = val;
+ margin = marg;
}
-void wxIndividualLayoutConstraint::LeftOf(wxWindow *sibling, int marg)
-{ Set(wxLeftOf, sibling, wxLeft, 0, marg); }
+void wxIndividualLayoutConstraint::LeftOf(wxWindowBase *sibling, int marg)
+{
+ Set(wxLeftOf, sibling, wxLeft, 0, marg);
+}
-void wxIndividualLayoutConstraint::RightOf(wxWindow *sibling, int marg)
-{ Set(wxRightOf, sibling, wxRight, 0, marg); }
+void wxIndividualLayoutConstraint::RightOf(wxWindowBase *sibling, int marg)
+{
+ Set(wxRightOf, sibling, wxRight, 0, marg);
+}
-void wxIndividualLayoutConstraint::Above(wxWindow *sibling, int marg)
-{ Set(wxAbove, sibling, wxTop, 0, marg); }
+void wxIndividualLayoutConstraint::Above(wxWindowBase *sibling, int marg)
+{
+ Set(wxAbove, sibling, wxTop, 0, marg);
+}
-void wxIndividualLayoutConstraint::Below(wxWindow *sibling, int marg)
-{ Set(wxBelow, sibling, wxBottom, 0, marg); }
+void wxIndividualLayoutConstraint::Below(wxWindowBase *sibling, int marg)
+{
+ Set(wxBelow, sibling, wxBottom, 0, marg);
+}
//
// 'Same edge' alignment
//
-void wxIndividualLayoutConstraint::SameAs(wxWindow *otherW, wxEdge edge, int marg)
-{ Set(wxPercentOf, otherW, edge, 0, marg); percent = 100; }
+void wxIndividualLayoutConstraint::SameAs(wxWindowBase *otherW, wxEdge edge, int marg)
+{
+ Set(wxPercentOf, otherW, edge, 0, marg);
+ percent = 100;
+}
// The edge is a percentage of the other window's edge
-void wxIndividualLayoutConstraint::PercentOf(wxWindow *otherW, wxEdge wh, int per)
-{ otherWin = otherW; relationship = wxPercentOf; percent = per;
- otherEdge = wh;
+void wxIndividualLayoutConstraint::PercentOf(wxWindowBase *otherW, wxEdge wh, int per)
+{
+ otherWin = otherW;
+ relationship = wxPercentOf;
+ percent = per;
+
+ otherEdge = wh;
}
//
// Edge has absolute value
//
void wxIndividualLayoutConstraint::Absolute(int val)
-{ value = val; relationship = wxAbsolute; }
+{
+ value = val; relationship = wxAbsolute;
+}
// Reset constraint if it mentions otherWin
-bool wxIndividualLayoutConstraint::ResetIfWin(wxWindow *otherW)
+bool wxIndividualLayoutConstraint::ResetIfWin(wxWindowBase *otherW)
{
- if (otherW == otherWin)
- {
- myEdge = wxTop; relationship = wxAsIs; margin = 0; value = 0; percent = 0; otherEdge = wxTop;
- otherWin = (wxWindow *) NULL;
- return TRUE;
- }
- else
- return FALSE;
+ if (otherW == otherWin)
+ {
+ myEdge = wxTop;
+ relationship = wxAsIs;
+ margin = 0;
+ value = 0;
+ percent = 0;
+ otherEdge = wxTop;
+ otherWin = (wxWindowBase *) NULL;
+ return TRUE;
+ }
+ else
+ return FALSE;
}
// Try to satisfy constraint
-bool wxIndividualLayoutConstraint::SatisfyConstraint(wxLayoutConstraints *constraints, wxWindow *win)
+bool wxIndividualLayoutConstraint::SatisfyConstraint(wxLayoutConstraints *constraints, wxWindowBase *win)
{
- if (relationship == wxAbsolute)
- {
- done = TRUE;
- return TRUE;
- }
-
- switch (myEdge)
- {
- case wxLeft:
+ if (relationship == wxAbsolute)
{
- switch (relationship)
- {
- case wxLeftOf:
- {
- // We can know this edge if: otherWin is win's parent,
- // or otherWin has a satisfied constraint, or
- // otherWin has no constraint.
- int edgePos = GetEdge(otherEdge, win, otherWin);
- if (edgePos != -1)
- {
- value = edgePos - margin;
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
- }
- case wxRightOf:
- {
- int edgePos = GetEdge(otherEdge, win, otherWin);
- if (edgePos != -1)
- {
- value = edgePos + margin;
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
- }
- case wxPercentOf:
- {
- int edgePos = GetEdge(otherEdge, win, otherWin);
- if (edgePos != -1)
- {
- value = (int)(edgePos*(((float)percent)*0.01) + margin);
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
- }
- case wxUnconstrained:
- {
- // We know the left-hand edge position if we know
- // the right-hand edge and we know the width; OR if we know the centre and the width.
- if (constraints->right.GetDone() && constraints->width.GetDone())
- {
- value = (constraints->right.GetValue() - constraints->width.GetValue() + margin);
- done = TRUE;
- return TRUE;
- }
- else if (constraints->centreX.GetDone() && constraints->width.GetDone())
- {
- value = (int)(constraints->centreX.GetValue() - (constraints->width.GetValue()/2) + margin);
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
- }
- case wxAsIs:
- {
- int y;
- win->GetPosition(&value, &y);
- done = TRUE;
- return TRUE;
- }
- default:
- break;
- }
- break;
- }
- case wxRight:
- {
- switch (relationship)
- {
- case wxLeftOf:
- {
- // We can know this edge if: otherWin is win's parent,
- // or otherWin has a satisfied constraint, or
- // otherWin has no constraint.
- int edgePos = GetEdge(otherEdge, win, otherWin);
- if (edgePos != -1)
- {
- value = edgePos - margin;
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
- }
- case wxRightOf:
- {
- int edgePos = GetEdge(otherEdge, win, otherWin);
- if (edgePos != -1)
- {
- value = edgePos + margin;
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
- }
- case wxPercentOf:
- {
- int edgePos = GetEdge(otherEdge, win, otherWin);
- if (edgePos != -1)
- {
- value = (int)(edgePos*(((float)percent)*0.01) - margin);
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
- }
- case wxUnconstrained:
- {
- // We know the right-hand edge position if we know
- // the left-hand edge and we know the width, OR if we know the
- // centre edge and the width.
- if (constraints->left.GetDone() && constraints->width.GetDone())
- {
- value = (constraints->left.GetValue() + constraints->width.GetValue() - margin);
- done = TRUE;
- return TRUE;
- }
- else if (constraints->centreX.GetDone() && constraints->width.GetDone())
- {
- value = (int)(constraints->centreX.GetValue() + (constraints->width.GetValue()/2) - margin);
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
- }
- case wxAsIs:
- {
- int x, y;
- int w, h;
- win->GetSize(&w, &h);
- win->GetPosition(&x, &y);
- value = x + w;
- done = TRUE;
- return TRUE;
- }
- default:
- break;
- }
- break;
- }
- case wxTop:
- {
- switch (relationship)
- {
- case wxAbove:
- {
- // We can know this edge if: otherWin is win's parent,
- // or otherWin has a satisfied constraint, or
- // otherWin has no constraint.
- int edgePos = GetEdge(otherEdge, win, otherWin);
- if (edgePos != -1)
- {
- value = edgePos - margin;
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
- }
- case wxBelow:
- {
- int edgePos = GetEdge(otherEdge, win, otherWin);
- if (edgePos != -1)
- {
- value = edgePos + margin;
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
- }
- case wxPercentOf:
- {
- int edgePos = GetEdge(otherEdge, win, otherWin);
- if (edgePos != -1)
- {
- value = (int)(edgePos*(((float)percent)*0.01) + margin);
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
- }
- case wxUnconstrained:
- {
- // We know the top edge position if we know
- // the bottom edge and we know the height; OR if we know the centre
- // edge and the height.
- if (constraints->bottom.GetDone() && constraints->height.GetDone())
- {
- value = (constraints->bottom.GetValue() - constraints->height.GetValue() + margin);
- done = TRUE;
- return TRUE;
- }
- else if (constraints->centreY.GetDone() && constraints->height.GetDone())
- {
- value = (constraints->centreY.GetValue() - (constraints->height.GetValue()/2) + margin);
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
- }
- case wxAsIs:
- {
- int x;
- win->GetPosition(&x, &value);
- done = TRUE;
- return TRUE;
- }
- default:
- break;
- }
- break;
- }
- case wxBottom:
- {
- switch (relationship)
- {
- case wxAbove:
- {
- // We can know this edge if: otherWin is win's parent,
- // or otherWin has a satisfied constraint, or
- // otherWin has no constraint.
- int edgePos = GetEdge(otherEdge, win, otherWin);
- if (edgePos != -1)
- {
- value = edgePos + margin;
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
- }
- case wxBelow:
- {
- int edgePos = GetEdge(otherEdge, win, otherWin);
- if (edgePos != -1)
- {
- value = edgePos - margin;
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
- }
- case wxPercentOf:
- {
- int edgePos = GetEdge(otherEdge, win, otherWin);
- if (edgePos != -1)
- {
- value = (int)(edgePos*(((float)percent)*0.01) - margin);
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
- }
- case wxUnconstrained:
- {
- // We know the bottom edge position if we know
- // the top edge and we know the height; OR if we know the
- // centre edge and the height.
- if (constraints->top.GetDone() && constraints->height.GetDone())
- {
- value = (constraints->top.GetValue() + constraints->height.GetValue() - margin);
- done = TRUE;
- return TRUE;
- }
- else if (constraints->centreY.GetDone() && constraints->height.GetDone())
- {
- value = (constraints->centreY.GetValue() + (constraints->height.GetValue()/2) - margin);
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
- }
- case wxAsIs:
- {
- int x, y;
- int w, h;
- win->GetSize(&w, &h);
- win->GetPosition(&x, &y);
- value = h + y;
- done = TRUE;
- return TRUE;
- }
- default:
- break;
- }
- break;
- }
- case wxCentreX:
- {
- switch (relationship)
- {
- case wxLeftOf:
- {
- // We can know this edge if: otherWin is win's parent,
- // or otherWin has a satisfied constraint, or
- // otherWin has no constraint.
- int edgePos = GetEdge(otherEdge, win, otherWin);
- if (edgePos != -1)
- {
- value = edgePos - margin;
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
- }
- case wxRightOf:
- {
- int edgePos = GetEdge(otherEdge, win, otherWin);
- if (edgePos != -1)
- {
- value = edgePos + margin;
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
- }
- case wxPercentOf:
- {
- int edgePos = GetEdge(otherEdge, win, otherWin);
- if (edgePos != -1)
- {
- value = (int)(edgePos*(((float)percent)*0.01) + margin);
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
- }
- case wxUnconstrained:
- {
- // We know the centre position if we know
- // the left-hand edge and we know the width, OR
- // the right-hand edge and the width
- if (constraints->left.GetDone() && constraints->width.GetDone())
- {
- value = (int)(constraints->left.GetValue() + (constraints->width.GetValue()/2) + margin);
- done = TRUE;
- return TRUE;
- }
- else if (constraints->right.GetDone() && constraints->width.GetDone())
- {
- value = (int)(constraints->left.GetValue() - (constraints->width.GetValue()/2) + margin);
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
- }
- default:
- break;
- }
- break;
+ done = TRUE;
+ return TRUE;
}
- case wxCentreY:
+
+ switch (myEdge)
{
- switch (relationship)
- {
- case wxAbove:
- {
- // We can know this edge if: otherWin is win's parent,
- // or otherWin has a satisfied constraint, or
- // otherWin has no constraint.
- int edgePos = GetEdge(otherEdge, win, otherWin);
- if (edgePos != -1)
- {
- value = edgePos - margin;
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
- }
- case wxBelow:
+ case wxLeft:
{
- int edgePos = GetEdge(otherEdge, win, otherWin);
- if (edgePos != -1)
- {
- value = edgePos + margin;
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
+ switch (relationship)
+ {
+ case wxLeftOf:
+ {
+ // We can know this edge if: otherWin is win's
+ // parent, or otherWin has a satisfied constraint,
+ // or otherWin has no constraint.
+ int edgePos = GetEdge(otherEdge, win, otherWin);
+ if (edgePos != -1)
+ {
+ value = edgePos - margin;
+ done = TRUE;
+ return TRUE;
+ }
+ else
+ return FALSE;
+ }
+ case wxRightOf:
+ {
+ int edgePos = GetEdge(otherEdge, win, otherWin);
+ if (edgePos != -1)
+ {
+ value = edgePos + margin;
+ done = TRUE;
+ return TRUE;
+ }
+ else
+ return FALSE;
+ }
+ case wxPercentOf:
+ {
+ int edgePos = GetEdge(otherEdge, win, otherWin);
+ if (edgePos != -1)
+ {
+ value = (int)(edgePos*(((float)percent)*0.01) + margin);
+ done = TRUE;
+ return TRUE;
+ }
+ else
+ return FALSE;
+ }
+ case wxUnconstrained:
+ {
+ // We know the left-hand edge position if we know
+ // the right-hand edge and we know the width; OR if
+ // we know the centre and the width.
+ if (constraints->right.GetDone() && constraints->width.GetDone())
+ {
+ value = (constraints->right.GetValue() - constraints->width.GetValue() + margin);
+ done = TRUE;
+ return TRUE;
+ }
+ else if (constraints->centreX.GetDone() && constraints->width.GetDone())
+ {
+ value = (int)(constraints->centreX.GetValue() - (constraints->width.GetValue()/2) + margin);
+ done = TRUE;
+ return TRUE;
+ }
+ else
+ return FALSE;
+ }
+ case wxAsIs:
+ {
+ int y;
+ win->GetPosition(&value, &y);
+ done = TRUE;
+ return TRUE;
+ }
+ default:
+ break;
+ }
+ break;
}
- case wxPercentOf:
+ case wxRight:
{
- int edgePos = GetEdge(otherEdge, win, otherWin);
- if (edgePos != -1)
- {
- value = (int)(edgePos*(((float)percent)*0.01) + margin);
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
+ switch (relationship)
+ {
+ case wxLeftOf:
+ {
+ // We can know this edge if: otherWin is win's
+ // parent, or otherWin has a satisfied constraint,
+ // or otherWin has no constraint.
+ int edgePos = GetEdge(otherEdge, win, otherWin);
+ if (edgePos != -1)
+ {
+ value = edgePos - margin;
+ done = TRUE;
+ return TRUE;
+ }
+ else
+ return FALSE;
+ }
+ case wxRightOf:
+ {
+ int edgePos = GetEdge(otherEdge, win, otherWin);
+ if (edgePos != -1)
+ {
+ value = edgePos + margin;
+ done = TRUE;
+ return TRUE;
+ }
+ else
+ return FALSE;
+ }
+ case wxPercentOf:
+ {
+ int edgePos = GetEdge(otherEdge, win, otherWin);
+ if (edgePos != -1)
+ {
+ value = (int)(edgePos*(((float)percent)*0.01) - margin);
+ done = TRUE;
+ return TRUE;
+ }
+ else
+ return FALSE;
+ }
+ case wxUnconstrained:
+ {
+ // We know the right-hand edge position if we know the
+ // left-hand edge and we know the width, OR if we know the
+ // centre edge and the width.
+ if (constraints->left.GetDone() && constraints->width.GetDone())
+ {
+ value = (constraints->left.GetValue() + constraints->width.GetValue() - margin);
+ done = TRUE;
+ return TRUE;
+ }
+ else if (constraints->centreX.GetDone() && constraints->width.GetDone())
+ {
+ value = (int)(constraints->centreX.GetValue() + (constraints->width.GetValue()/2) - margin);
+ done = TRUE;
+ return TRUE;
+ }
+ else
+ return FALSE;
+ }
+ case wxAsIs:
+ {
+ int x, y;
+ int w, h;
+ win->GetSize(&w, &h);
+ win->GetPosition(&x, &y);
+ value = x + w;
+ done = TRUE;
+ return TRUE;
+ }
+ default:
+ break;
+ }
+ break;
}
- case wxUnconstrained:
- {
- // We know the centre position if we know
- // the top edge and we know the height, OR
- // the bottom edge and the height.
- if (constraints->bottom.GetDone() && constraints->height.GetDone())
- {
- value = (int)(constraints->bottom.GetValue() - (constraints->height.GetValue()/2) + margin);
- done = TRUE;
- return TRUE;
- }
- else if (constraints->top.GetDone() && constraints->height.GetDone())
- {
- value = (int)(constraints->top.GetValue() + (constraints->height.GetValue()/2) + margin);
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
- }
- default:
- break;
- }
- break;
- }
- case wxWidth:
- {
- switch (relationship)
- {
- case wxPercentOf:
+ case wxTop:
{
- int edgePos = GetEdge(otherEdge, win, otherWin);
- if (edgePos != -1)
- {
- value = (int)(edgePos*(((float)percent)*0.01));
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
+ switch (relationship)
+ {
+ case wxAbove:
+ {
+ // We can know this edge if: otherWin is win's
+ // parent, or otherWin has a satisfied constraint,
+ // or otherWin has no constraint.
+ int edgePos = GetEdge(otherEdge, win, otherWin);
+ if (edgePos != -1)
+ {
+ value = edgePos - margin;
+ done = TRUE;
+ return TRUE;
+ }
+ else
+ return FALSE;
+ }
+ case wxBelow:
+ {
+ int edgePos = GetEdge(otherEdge, win, otherWin);
+ if (edgePos != -1)
+ {
+ value = edgePos + margin;
+ done = TRUE;
+ return TRUE;
+ }
+ else
+ return FALSE;
+ }
+ case wxPercentOf:
+ {
+ int edgePos = GetEdge(otherEdge, win, otherWin);
+ if (edgePos != -1)
+ {
+ value = (int)(edgePos*(((float)percent)*0.01) + margin);
+ done = TRUE;
+ return TRUE;
+ }
+ else
+ return FALSE;
+ }
+ case wxUnconstrained:
+ {
+ // We know the top edge position if we know the bottom edge
+ // and we know the height; OR if we know the centre edge and
+ // the height.
+ if (constraints->bottom.GetDone() && constraints->height.GetDone())
+ {
+ value = (constraints->bottom.GetValue() - constraints->height.GetValue() + margin);
+ done = TRUE;
+ return TRUE;
+ }
+ else if (constraints->centreY.GetDone() && constraints->height.GetDone())
+ {
+ value = (constraints->centreY.GetValue() - (constraints->height.GetValue()/2) + margin);
+ done = TRUE;
+ return TRUE;
+ }
+ else
+ return FALSE;
+ }
+ case wxAsIs:
+ {
+ int x;
+ win->GetPosition(&x, &value);
+ done = TRUE;
+ return TRUE;
+ }
+ default:
+ break;
+ }
+ break;
}
- case wxAsIs:
+ case wxBottom:
{
- if (win)
- {
- int h;
- win->GetSize(&value, &h);
- done = TRUE;
- return TRUE;
- }
- else return FALSE;
+ switch (relationship)
+ {
+ case wxAbove:
+ {
+ // We can know this edge if: otherWin is win's parent,
+ // or otherWin has a satisfied constraint, or
+ // otherWin has no constraint.
+ int edgePos = GetEdge(otherEdge, win, otherWin);
+ if (edgePos != -1)
+ {
+ value = edgePos + margin;
+ done = TRUE;
+ return TRUE;
+ }
+ else
+ return FALSE;
+ }
+ case wxBelow:
+ {
+ int edgePos = GetEdge(otherEdge, win, otherWin);
+ if (edgePos != -1)
+ {
+ value = edgePos - margin;
+ done = TRUE;
+ return TRUE;
+ }
+ else
+ return FALSE;
+ }
+ case wxPercentOf:
+ {
+ int edgePos = GetEdge(otherEdge, win, otherWin);
+ if (edgePos != -1)
+ {
+ value = (int)(edgePos*(((float)percent)*0.01) - margin);
+ done = TRUE;
+ return TRUE;
+ }
+ else
+ return FALSE;
+ }
+ case wxUnconstrained:
+ {
+ // We know the bottom edge position if we know the top edge
+ // and we know the height; OR if we know the centre edge and
+ // the height.
+ if (constraints->top.GetDone() && constraints->height.GetDone())
+ {
+ value = (constraints->top.GetValue() + constraints->height.GetValue() - margin);
+ done = TRUE;
+ return TRUE;
+ }
+ else if (constraints->centreY.GetDone() && constraints->height.GetDone())
+ {
+ value = (constraints->centreY.GetValue() + (constraints->height.GetValue()/2) - margin);
+ done = TRUE;
+ return TRUE;
+ }
+ else
+ return FALSE;
+ }
+ case wxAsIs:
+ {
+ int x, y;
+ int w, h;
+ win->GetSize(&w, &h);
+ win->GetPosition(&x, &y);
+ value = h + y;
+ done = TRUE;
+ return TRUE;
+ }
+ default:
+ break;
+ }
+ break;
}
- case wxUnconstrained:
+ case wxCentreX:
{
- // We know the width if we know the left edge and the right edge, OR
- // if we know the left edge and the centre, OR
- // if we know the right edge and the centre
- if (constraints->left.GetDone() && constraints->right.GetDone())
- {
- value = constraints->right.GetValue() - constraints->left.GetValue();
- done = TRUE;
- return TRUE;
- }
- else if (constraints->centreX.GetDone() && constraints->left.GetDone())
- {
- value = (int)(2*(constraints->centreX.GetValue() - constraints->left.GetValue()));
- done = TRUE;
- return TRUE;
- }
- else if (constraints->centreX.GetDone() && constraints->right.GetDone())
- {
- value = (int)(2*(constraints->right.GetValue() - constraints->centreX.GetValue()));
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
+ switch (relationship)
+ {
+ case wxLeftOf:
+ {
+ // We can know this edge if: otherWin is win's parent, or
+ // otherWin has a satisfied constraint, or otherWin has no
+ // constraint.
+ int edgePos = GetEdge(otherEdge, win, otherWin);
+ if (edgePos != -1)
+ {
+ value = edgePos - margin;
+ done = TRUE;
+ return TRUE;
+ }
+ else
+ return FALSE;
+ }
+ case wxRightOf:
+ {
+ int edgePos = GetEdge(otherEdge, win, otherWin);
+ if (edgePos != -1)
+ {
+ value = edgePos + margin;
+ done = TRUE;
+ return TRUE;
+ }
+ else
+ return FALSE;
+ }
+ case wxPercentOf:
+ {
+ int edgePos = GetEdge(otherEdge, win, otherWin);
+ if (edgePos != -1)
+ {
+ value = (int)(edgePos*(((float)percent)*0.01) + margin);
+ done = TRUE;
+ return TRUE;
+ }
+ else
+ return FALSE;
+ }
+ case wxUnconstrained:
+ {
+ // We know the centre position if we know
+ // the left-hand edge and we know the width, OR
+ // the right-hand edge and the width
+ if (constraints->left.GetDone() && constraints->width.GetDone())
+ {
+ value = (int)(constraints->left.GetValue() + (constraints->width.GetValue()/2) + margin);
+ done = TRUE;
+ return TRUE;
+ }
+ else if (constraints->right.GetDone() && constraints->width.GetDone())
+ {
+ value = (int)(constraints->left.GetValue() - (constraints->width.GetValue()/2) + margin);
+ done = TRUE;
+ return TRUE;
+ }
+ else
+ return FALSE;
+ }
+ default:
+ break;
+ }
+ break;
}
- default:
- break;
- }
- break;
- }
- case wxHeight:
- {
- switch (relationship)
- {
- case wxPercentOf:
+ case wxCentreY:
{
- int edgePos = GetEdge(otherEdge, win, otherWin);
- if (edgePos != -1)
- {
- value = (int)(edgePos*(((float)percent)*0.01));
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
+ switch (relationship)
+ {
+ case wxAbove:
+ {
+ // We can know this edge if: otherWin is win's parent,
+ // or otherWin has a satisfied constraint, or otherWin
+ // has no constraint.
+ int edgePos = GetEdge(otherEdge, win, otherWin);
+ if (edgePos != -1)
+ {
+ value = edgePos - margin;
+ done = TRUE;
+ return TRUE;
+ }
+ else
+ return FALSE;
+ }
+ case wxBelow:
+ {
+ int edgePos = GetEdge(otherEdge, win, otherWin);
+ if (edgePos != -1)
+ {
+ value = edgePos + margin;
+ done = TRUE;
+ return TRUE;
+ }
+ else
+ return FALSE;
+ }
+ case wxPercentOf:
+ {
+ int edgePos = GetEdge(otherEdge, win, otherWin);
+ if (edgePos != -1)
+ {
+ value = (int)(edgePos*(((float)percent)*0.01) + margin);
+ done = TRUE;
+ return TRUE;
+ }
+ else
+ return FALSE;
+ }
+ case wxUnconstrained:
+ {
+ // We know the centre position if we know
+ // the top edge and we know the height, OR
+ // the bottom edge and the height.
+ if (constraints->bottom.GetDone() && constraints->height.GetDone())
+ {
+ value = (int)(constraints->bottom.GetValue() - (constraints->height.GetValue()/2) + margin);
+ done = TRUE;
+ return TRUE;
+ }
+ else if (constraints->top.GetDone() && constraints->height.GetDone())
+ {
+ value = (int)(constraints->top.GetValue() + (constraints->height.GetValue()/2) + margin);
+ done = TRUE;
+ return TRUE;
+ }
+ else
+ return FALSE;
+ }
+ default:
+ break;
+ }
+ break;
}
- case wxAsIs:
+ case wxWidth:
{
- if (win)
- {
- int w;
- win->GetSize(&w, &value);
- done = TRUE;
- return TRUE;
- }
- else return FALSE;
+ switch (relationship)
+ {
+ case wxPercentOf:
+ {
+ int edgePos = GetEdge(otherEdge, win, otherWin);
+ if (edgePos != -1)
+ {
+ value = (int)(edgePos*(((float)percent)*0.01));
+ done = TRUE;
+ return TRUE;
+ }
+ else
+ return FALSE;
+ }
+ case wxAsIs:
+ {
+ if (win)
+ {
+ int h;
+ win->GetSize(&value, &h);
+ done = TRUE;
+ return TRUE;
+ }
+ else return FALSE;
+ }
+ case wxUnconstrained:
+ {
+ // We know the width if we know the left edge and the right edge, OR
+ // if we know the left edge and the centre, OR
+ // if we know the right edge and the centre
+ if (constraints->left.GetDone() && constraints->right.GetDone())
+ {
+ value = constraints->right.GetValue() - constraints->left.GetValue();
+ done = TRUE;
+ return TRUE;
+ }
+ else if (constraints->centreX.GetDone() && constraints->left.GetDone())
+ {
+ value = (int)(2*(constraints->centreX.GetValue() - constraints->left.GetValue()));
+ done = TRUE;
+ return TRUE;
+ }
+ else if (constraints->centreX.GetDone() && constraints->right.GetDone())
+ {
+ value = (int)(2*(constraints->right.GetValue() - constraints->centreX.GetValue()));
+ done = TRUE;
+ return TRUE;
+ }
+ else
+ return FALSE;
+ }
+ default:
+ break;
+ }
+ break;
}
- case wxUnconstrained:
+ case wxHeight:
{
- // We know the height if we know the top edge and the bottom edge, OR
- // if we know the top edge and the centre, OR
- // if we know the bottom edge and the centre
- if (constraints->top.GetDone() && constraints->bottom.GetDone())
- {
- value = constraints->bottom.GetValue() - constraints->top.GetValue();
- done = TRUE;
- return TRUE;
- }
- else if (constraints->top.GetDone() && constraints->centreY.GetDone())
- {
- value = (int)(2*(constraints->centreY.GetValue() - constraints->top.GetValue()));
- done = TRUE;
- return TRUE;
- }
- else if (constraints->bottom.GetDone() && constraints->centreY.GetDone())
- {
- value = (int)(2*(constraints->bottom.GetValue() - constraints->centreY.GetValue()));
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
+ switch (relationship)
+ {
+ case wxPercentOf:
+ {
+ int edgePos = GetEdge(otherEdge, win, otherWin);
+ if (edgePos != -1)
+ {
+ value = (int)(edgePos*(((float)percent)*0.01));
+ done = TRUE;
+ return TRUE;
+ }
+ else
+ return FALSE;
+ }
+ case wxAsIs:
+ {
+ if (win)
+ {
+ int w;
+ win->GetSize(&w, &value);
+ done = TRUE;
+ return TRUE;
+ }
+ else return FALSE;
+ }
+ case wxUnconstrained:
+ {
+ // We know the height if we know the top edge and the bottom edge, OR
+ // if we know the top edge and the centre, OR
+ // if we know the bottom edge and the centre
+ if (constraints->top.GetDone() && constraints->bottom.GetDone())
+ {
+ value = constraints->bottom.GetValue() - constraints->top.GetValue();
+ done = TRUE;
+ return TRUE;
+ }
+ else if (constraints->top.GetDone() && constraints->centreY.GetDone())
+ {
+ value = (int)(2*(constraints->centreY.GetValue() - constraints->top.GetValue()));
+ done = TRUE;
+ return TRUE;
+ }
+ else if (constraints->bottom.GetDone() && constraints->centreY.GetDone())
+ {
+ value = (int)(2*(constraints->bottom.GetValue() - constraints->centreY.GetValue()));
+ done = TRUE;
+ return TRUE;
+ }
+ else
+ return FALSE;
+ }
+ default:
+ break;
+ }
+ break;
}
default:
- break;
- }
- break;
+ break;
}
- default:
- break;
- }
- return FALSE;
+ return FALSE;
}
-// Get the value of this edge or dimension, or if this
-// is not determinable, -1.
+// Get the value of this edge or dimension, or if this is not determinable, -1.
int wxIndividualLayoutConstraint::GetEdge(wxEdge which,
- wxWindow *thisWin,
- wxWindow *other) const
+ wxWindowBase *thisWin,
+ wxWindowBase *other) const
{
- // If the edge or dimension belongs to the parent, then we
- // know the dimension is obtainable immediately.
- // E.g. a wxExpandSizer may contain a button (but the button's
- // true parent is a panel, not the sizer)
- if (other->GetChildren().Member(thisWin))
- {
- switch (which)
+ // If the edge or dimension belongs to the parent, then we know the
+ // dimension is obtainable immediately. E.g. a wxExpandSizer may contain a
+ // button (but the button's true parent is a panel, not the sizer)
+ if (other->GetChildren().Find(thisWin))
{
- case wxLeft:
- {
- return wxSizerMarginX(other);
- }
- case wxTop:
- {
- return wxSizerMarginY(other);
- }
- case wxRight:
- {
- int w, h;
- other->GetClientSizeConstraint(&w, &h);
- return w - wxSizerMarginX(other);
- }
- case wxBottom:
- {
- int w, h;
- other->GetClientSizeConstraint(&w, &h);
- return h - wxSizerMarginY(other);
- }
- case wxWidth:
- {
- int w, h;
- other->GetClientSizeConstraint(&w, &h);
- return w - 2*wxSizerMarginX(other);
- }
- case wxHeight:
- {
- int w, h;
- other->GetClientSizeConstraint(&w, &h);
- return h - 2*wxSizerMarginY(other);
- }
- case wxCentreX:
- case wxCentreY:
- {
- int w, h;
- other->GetClientSizeConstraint(&w, &h);
- if (which == wxCentreX)
- return (int)(w/2);
- else
- return (int)(h/2);
- }
- default:
- return -1;
- }
- }
- switch (which)
- {
- case wxLeft:
- {
- wxLayoutConstraints *constr = other->GetConstraints();
- // If no constraints, it means the window is not dependent
- // on anything, and therefore we know its value immediately
- if (constr)
- {
- if (constr->left.GetDone())
- return constr->left.GetValue();
- else
- return -1;
- }
- else
- {
- int x, y;
- other->GetPosition(&x, &y);
- return x;
- }
- }
- case wxTop:
- {
- wxLayoutConstraints *constr = other->GetConstraints();
- // If no constraints, it means the window is not dependent
- // on anything, and therefore we know its value immediately
- if (constr)
- {
- if (constr->top.GetDone())
- return constr->top.GetValue();
- else
- return -1;
- }
- else
- {
- int x, y;
- other->GetPosition(&x, &y);
- return y;
- }
- }
- case wxRight:
- {
- wxLayoutConstraints *constr = other->GetConstraints();
- // If no constraints, it means the window is not dependent
- // on anything, and therefore we know its value immediately
- if (constr)
- {
- if (constr->right.GetDone())
- return constr->right.GetValue();
- else
- return -1;
- }
- else
- {
- int x, y, w, h;
- other->GetPosition(&x, &y);
- other->GetSize(&w, &h);
- return (int)(x + w);
- }
- }
- case wxBottom:
- {
- wxLayoutConstraints *constr = other->GetConstraints();
- // If no constraints, it means the window is not dependent
- // on anything, and therefore we know its value immediately
- if (constr)
- {
- if (constr->bottom.GetDone())
- return constr->bottom.GetValue();
- else
- return -1;
- }
- else
- {
- int x, y, w, h;
- other->GetPosition(&x, &y);
- other->GetSize(&w, &h);
- return (int)(y + h);
- }
- }
- case wxWidth:
- {
- wxLayoutConstraints *constr = other->GetConstraints();
- // If no constraints, it means the window is not dependent
- // on anything, and therefore we know its value immediately
- if (constr)
- {
- if (constr->width.GetDone())
- return constr->width.GetValue();
- else
- return -1;
- }
- else
- {
- int w, h;
- other->GetSize(&w, &h);
- return w;
- }
- }
- case wxHeight:
- {
- wxLayoutConstraints *constr = other->GetConstraints();
- // If no constraints, it means the window is not dependent
- // on anything, and therefore we know its value immediately
- if (constr)
- {
- if (constr->height.GetDone())
- return constr->height.GetValue();
- else
- return -1;
- }
- else
- {
- int w, h;
- other->GetSize(&w, &h);
- return h;
- }
- }
- case wxCentreX:
- {
- wxLayoutConstraints *constr = other->GetConstraints();
- // If no constraints, it means the window is not dependent
- // on anything, and therefore we know its value immediately
- if (constr)
- {
- if (constr->centreX.GetDone())
- return constr->centreX.GetValue();
- else
- return -1;
- }
- else
- {
- int x, y, w, h;
- other->GetPosition(&x, &y);
- other->GetSize(&w, &h);
- return (int)(x + (w/2));
- }
+ switch (which)
+ {
+ case wxLeft:
+ {
+ return wxSizerMarginX(other);
+ }
+ case wxTop:
+ {
+ return wxSizerMarginY(other);
+ }
+ case wxRight:
+ {
+ int w, h;
+ other->GetClientSizeConstraint(&w, &h);
+ return w - wxSizerMarginX(other);
+ }
+ case wxBottom:
+ {
+ int w, h;
+ other->GetClientSizeConstraint(&w, &h);
+ return h - wxSizerMarginY(other);
+ }
+ case wxWidth:
+ {
+ int w, h;
+ other->GetClientSizeConstraint(&w, &h);
+ return w - 2*wxSizerMarginX(other);
+ }
+ case wxHeight:
+ {
+ int w, h;
+ other->GetClientSizeConstraint(&w, &h);
+ return h - 2*wxSizerMarginY(other);
+ }
+ case wxCentreX:
+ case wxCentreY:
+ {
+ int w, h;
+ other->GetClientSizeConstraint(&w, &h);
+ if (which == wxCentreX)
+ return (int)(w/2);
+ else
+ return (int)(h/2);
+ }
+ default:
+ return -1;
+ }
}
- case wxCentreY:
+ switch (which)
{
- wxLayoutConstraints *constr = other->GetConstraints();
- // If no constraints, it means the window is not dependent
- // on anything, and therefore we know its value immediately
- if (constr)
- {
- if (constr->centreY.GetDone())
- return constr->centreY.GetValue();
- else
- return -1;
- }
- else
- {
- int x, y, w, h;
- other->GetPosition(&x, &y);
- other->GetSize(&w, &h);
- return (int)(y + (h/2));
- }
+ case wxLeft:
+ {
+ wxLayoutConstraints *constr = other->GetConstraints();
+ // If no constraints, it means the window is not dependent
+ // on anything, and therefore we know its value immediately
+ if (constr)
+ {
+ if (constr->left.GetDone())
+ return constr->left.GetValue();
+ else
+ return -1;
+ }
+ else
+ {
+ int x, y;
+ other->GetPosition(&x, &y);
+ return x;
+ }
+ }
+ case wxTop:
+ {
+ wxLayoutConstraints *constr = other->GetConstraints();
+ // If no constraints, it means the window is not dependent
+ // on anything, and therefore we know its value immediately
+ if (constr)
+ {
+ if (constr->top.GetDone())
+ return constr->top.GetValue();
+ else
+ return -1;
+ }
+ else
+ {
+ int x, y;
+ other->GetPosition(&x, &y);
+ return y;
+ }
+ }
+ case wxRight:
+ {
+ wxLayoutConstraints *constr = other->GetConstraints();
+ // If no constraints, it means the window is not dependent
+ // on anything, and therefore we know its value immediately
+ if (constr)
+ {
+ if (constr->right.GetDone())
+ return constr->right.GetValue();
+ else
+ return -1;
+ }
+ else
+ {
+ int x, y, w, h;
+ other->GetPosition(&x, &y);
+ other->GetSize(&w, &h);
+ return (int)(x + w);
+ }
+ }
+ case wxBottom:
+ {
+ wxLayoutConstraints *constr = other->GetConstraints();
+ // If no constraints, it means the window is not dependent
+ // on anything, and therefore we know its value immediately
+ if (constr)
+ {
+ if (constr->bottom.GetDone())
+ return constr->bottom.GetValue();
+ else
+ return -1;
+ }
+ else
+ {
+ int x, y, w, h;
+ other->GetPosition(&x, &y);
+ other->GetSize(&w, &h);
+ return (int)(y + h);
+ }
+ }
+ case wxWidth:
+ {
+ wxLayoutConstraints *constr = other->GetConstraints();
+ // If no constraints, it means the window is not dependent
+ // on anything, and therefore we know its value immediately
+ if (constr)
+ {
+ if (constr->width.GetDone())
+ return constr->width.GetValue();
+ else
+ return -1;
+ }
+ else
+ {
+ int w, h;
+ other->GetSize(&w, &h);
+ return w;
+ }
+ }
+ case wxHeight:
+ {
+ wxLayoutConstraints *constr = other->GetConstraints();
+ // If no constraints, it means the window is not dependent
+ // on anything, and therefore we know its value immediately
+ if (constr)
+ {
+ if (constr->height.GetDone())
+ return constr->height.GetValue();
+ else
+ return -1;
+ }
+ else
+ {
+ int w, h;
+ other->GetSize(&w, &h);
+ return h;
+ }
+ }
+ case wxCentreX:
+ {
+ wxLayoutConstraints *constr = other->GetConstraints();
+ // If no constraints, it means the window is not dependent
+ // on anything, and therefore we know its value immediately
+ if (constr)
+ {
+ if (constr->centreX.GetDone())
+ return constr->centreX.GetValue();
+ else
+ return -1;
+ }
+ else
+ {
+ int x, y, w, h;
+ other->GetPosition(&x, &y);
+ other->GetSize(&w, &h);
+ return (int)(x + (w/2));
+ }
+ }
+ case wxCentreY:
+ {
+ wxLayoutConstraints *constr = other->GetConstraints();
+ // If no constraints, it means the window is not dependent
+ // on anything, and therefore we know its value immediately
+ if (constr)
+ {
+ if (constr->centreY.GetDone())
+ return constr->centreY.GetValue();
+ else
+ return -1;
+ }
+ else
+ {
+ int x, y, w, h;
+ other->GetPosition(&x, &y);
+ other->GetSize(&w, &h);
+ return (int)(y + (h/2));
+ }
+ }
+ default:
+ break;
}
- default:
- break;
- }
- return -1;
+ return -1;
}
wxLayoutConstraints::wxLayoutConstraints()
{
- left.SetEdge(wxLeft);
- top.SetEdge(wxTop);
- right.SetEdge(wxRight);
- bottom.SetEdge(wxBottom);
- centreX.SetEdge(wxCentreX);
- centreY.SetEdge(wxCentreY);
- width.SetEdge(wxWidth);
- height.SetEdge(wxHeight);
+ left.SetEdge(wxLeft);
+ top.SetEdge(wxTop);
+ right.SetEdge(wxRight);
+ bottom.SetEdge(wxBottom);
+ centreX.SetEdge(wxCentreX);
+ centreY.SetEdge(wxCentreY);
+ width.SetEdge(wxWidth);
+ height.SetEdge(wxHeight);
}
wxLayoutConstraints::~wxLayoutConstraints()
{
}
-bool wxLayoutConstraints::SatisfyConstraints(wxWindow *win, int *nChanges)
+bool wxLayoutConstraints::SatisfyConstraints(wxWindowBase *win, int *nChanges)
{
- int noChanges = 0;
-
- bool done = width.GetDone();
- bool newDone = (done ? TRUE : width.SatisfyConstraint(this, win));
- if (newDone != done)
- noChanges ++;
-
- done = height.GetDone();
- newDone = (done ? TRUE : height.SatisfyConstraint(this, win));
- if (newDone != done)
- noChanges ++;
-
- done = left.GetDone();
- newDone = (done ? TRUE : left.SatisfyConstraint(this, win));
- if (newDone != done)
- noChanges ++;
-
- done = top.GetDone();
- newDone = (done ? TRUE : top.SatisfyConstraint(this, win));
- if (newDone != done)
- noChanges ++;
-
- done = right.GetDone();
- newDone = (done ? TRUE : right.SatisfyConstraint(this, win));
- if (newDone != done)
- noChanges ++;
-
- done = bottom.GetDone();
- newDone = (done ? TRUE : bottom.SatisfyConstraint(this, win));
- if (newDone != done)
- noChanges ++;
-
- done = centreX.GetDone();
- newDone = (done ? TRUE : centreX.SatisfyConstraint(this, win));
- if (newDone != done)
- noChanges ++;
-
- done = centreY.GetDone();
- newDone = (done ? TRUE : centreY.SatisfyConstraint(this, win));
- if (newDone != done)
- noChanges ++;
-
- *nChanges = noChanges;
-
- return AreSatisfied();
+ int noChanges = 0;
+
+ bool done = width.GetDone();
+ bool newDone = (done ? TRUE : width.SatisfyConstraint(this, win));
+ if (newDone != done)
+ noChanges ++;
+
+ done = height.GetDone();
+ newDone = (done ? TRUE : height.SatisfyConstraint(this, win));
+ if (newDone != done)
+ noChanges ++;
+
+ done = left.GetDone();
+ newDone = (done ? TRUE : left.SatisfyConstraint(this, win));
+ if (newDone != done)
+ noChanges ++;
+
+ done = top.GetDone();
+ newDone = (done ? TRUE : top.SatisfyConstraint(this, win));
+ if (newDone != done)
+ noChanges ++;
+
+ done = right.GetDone();
+ newDone = (done ? TRUE : right.SatisfyConstraint(this, win));
+ if (newDone != done)
+ noChanges ++;
+
+ done = bottom.GetDone();
+ newDone = (done ? TRUE : bottom.SatisfyConstraint(this, win));
+ if (newDone != done)
+ noChanges ++;
+
+ done = centreX.GetDone();
+ newDone = (done ? TRUE : centreX.SatisfyConstraint(this, win));
+ if (newDone != done)
+ noChanges ++;
+
+ done = centreY.GetDone();
+ newDone = (done ? TRUE : centreY.SatisfyConstraint(this, win));
+ if (newDone != done)
+ noChanges ++;
+
+ *nChanges = noChanges;
+
+ return AreSatisfied();
}
/*
*/
-bool wxOldDoLayout(wxWindow *win)
+#if WXWIN_COMPATIBILITY
+bool wxOldDoLayout(wxWindowBase *win)
{
// Make sure this isn't called recursively from below
static wxList doneSoFar;
wxNode *node = win->GetChildren().First();
while (node)
{
- wxWindow *child = (wxWindow *)node->Data();
+ wxWindowBase *child = (wxWindowBase *)node->Data();
wxLayoutConstraints *constr = child->GetConstraints();
if (constr)
{
wxNode *node = win->GetChildren().First();
while (node)
{
- wxWindow *child = (wxWindow *)node->Data();
+ wxWindowBase *child = (wxWindowBase *)node->Data();
wxLayoutConstraints *constr = child->GetConstraints();
if (constr)
{
// failed, so we can print a specific diagnostic message.
if (noFailures > 0)
{
- wxDebugMsg(_("wxWindow::Layout() failed.\n"));
+ wxDebugMsg(_("wxWindowBase::Layout() failed.\n"));
}
*/
// Now set the sizes and positions of the children, and
node = win->GetChildren().First();
while (node)
{
- wxWindow *child = (wxWindow *)node->Data();
+ wxWindowBase *child = (wxWindowBase *)node->Data();
wxLayoutConstraints *constr = child->GetConstraints();
if (constr && constr->left.GetDone() && constr->right.GetDone() &&
constr->width.GetDone() && constr->height.GetDone())
return TRUE;
}
+#endif // WXWIN_COMPATIBILITY
wxSizer::wxSizer()
{
- sizerBehaviour = wxSizerNone;
- borderX = 2;
- borderY = 2;
- sizerX = 0;
- sizerY = 0;
- sizerWidth = 0;
- sizerHeight = 0;
+ sizerBehaviour = wxSizerNone;
+ borderX = 2;
+ borderY = 2;
+ sizerX = 0;
+ sizerY = 0;
+ sizerWidth = 0;
+ sizerHeight = 0;
}
-wxSizer::wxSizer(wxWindow *parent, wxSizerBehaviour behav)
+wxSizer::wxSizer(wxWindowBase *parent, wxSizerBehaviour behav)
{
- Create(parent, behav);
+ Create(parent, behav);
}
-bool wxSizer::Create(wxWindow *parent, wxSizerBehaviour behav)
+bool wxSizer::Create(wxWindowBase *parent, wxSizerBehaviour behav)
{
- sizerBehaviour = behav;
- borderX = 2;
- borderY = 2;
- m_sizerParent = parent;
- sizerX = 0;
- sizerY = 0;
- sizerWidth = 0;
- sizerHeight = 0;
-
- // A normal window can have just one top-level sizer
- // associated with it.
- if (!parent->IsKindOf(CLASSINFO(wxSizer)))
- {
- parent->SetSizer(this);
- }
- else
- ((wxSizer *)parent)->AddSizerChild(this);
-
- switch (sizerBehaviour)
- {
- case wxSizerExpand:
+ sizerBehaviour = behav;
+ borderX = 2;
+ borderY = 2;
+ m_sizerParent = parent;
+ sizerX = 0;
+ sizerY = 0;
+ sizerWidth = 0;
+ sizerHeight = 0;
+
+ // A normal window can have just one top-level sizer
+ // associated with it.
+ if (!parent->IsKindOf(CLASSINFO(wxSizer)))
{
- // Defines a set of constraints
- // to expand the sizer to fit the parent window
- wxLayoutConstraints *c = new wxLayoutConstraints;
-
- c->left.SameAs(parent, wxLeft, 0);
- c->top.SameAs(parent, wxTop, 0);
- c->right.SameAs(parent, wxRight, 0);
- c->bottom.SameAs(parent, wxBottom, 0);
-
- SetConstraints(c);
- break;
+ parent->SetSizer(this);
}
- case wxSizerShrink:
- case wxSizerNone:
- default:
+ else
+ ((wxSizer *)parent)->AddSizerChild(this);
+
+ switch (sizerBehaviour)
{
+ case wxSizerExpand:
+ {
+ // Defines a set of constraints
+ // to expand the sizer to fit the parent window
+ wxLayoutConstraints *c = new wxLayoutConstraints;
+
+ c->left.SameAs(parent, wxLeft, 0);
+ c->top.SameAs(parent, wxTop, 0);
+ c->right.SameAs(parent, wxRight, 0);
+ c->bottom.SameAs(parent, wxBottom, 0);
+
+ SetConstraints(c);
+ break;
+ }
+ case wxSizerShrink:
+ case wxSizerNone:
+ default:
+ {
+ }
}
- }
- return TRUE;
+ return TRUE;
}
wxSizer::~wxSizer()
{
- // Remove all children without deleting them,
- // or ~wxbWindow will delete proper windows _twice_
- wxNode *node = GetChildren().First();
- while (node)
- {
- wxNode *next = node->Next();
- wxWindow *win = (wxWindow *)node->Data();
- if (!win->IsKindOf(CLASSINFO(wxSizer)))
- {
- delete node;
- win->SetSizerParent((wxWindow *) NULL);
- }
- else
+ // Remove all children without deleting them,
+ // or ~wxbWindow will delete proper windows _twice_
+ wxNode *node = GetChildren().First();
+ while (node)
{
- RemoveSizerChild(win);
- delete win;
+ wxNode *next = node->Next();
+ wxWindowBase *win = (wxWindowBase *)node->Data();
+ if (!win->IsKindOf(CLASSINFO(wxSizer)))
+ {
+ delete node;
+ win->SetSizerParent((wxWindowBase *) NULL);
+ }
+ else
+ {
+ RemoveSizerChild(win);
+ delete win;
+ }
+ node = next;
}
- node = next;
- }
- if (m_sizerParent) // && !m_sizerParent->IsKindOf(CLASSINFO(wxSizer)))
- {
- m_sizerParent->SetSizer((wxSizer *) NULL);
- m_sizerParent = (wxWindow *) NULL;
- }
+ if (m_sizerParent) // && !m_sizerParent->IsKindOf(CLASSINFO(wxSizer)))
+ {
+ m_sizerParent->SetSizer((wxSizer *) NULL);
+ m_sizerParent = (wxWindowBase *) NULL;
+ }
}
void wxSizer::SetBorder(int x, int y)
{
- borderX = x;
- borderY = y;
-/* No: the margin is for inside, not outside (expansion)
-
- if ( GetConstraints() )
- {
- GetConstraints()->left.SetMargin(x);
- GetConstraints()->right.SetMargin(x);
- GetConstraints()->top.SetMargin(y);
- GetConstraints()->bottom.SetMargin(y);
- }
-*/
+ borderX = x;
+ borderY = y;
+ /* No: the margin is for inside, not outside (expansion)
+
+ if ( GetConstraints() )
+ {
+ GetConstraints()->left.SetMargin(x);
+ GetConstraints()->right.SetMargin(x);
+ GetConstraints()->top.SetMargin(y);
+ GetConstraints()->bottom.SetMargin(y);
+ }
+ */
}
-void wxSizer::AddSizerChild(wxWindow *child)
+void wxSizer::AddSizerChild(wxWindowBase *child)
{
- child->SetSizerParent(this);
- GetChildren().Append(child);
+ child->SetSizerParent(this);
+ GetChildren().Append(child);
- // Add some constraints for the purpose of storing
- // the relative position of the window/sizer
- // during layout calculations.
- if (!child->GetConstraints())
- {
- wxLayoutConstraints *c = new wxLayoutConstraints;
- c->left.AsIs();
- c->top.AsIs();
- c->width.AsIs();
- c->height.AsIs();
- int w, h;
- child->GetSize(&w, &h);
- c->width.SetValue(w);
- c->height.SetValue(h);
-
- child->SetConstraints(c);
- }
+ // Add some constraints for the purpose of storing
+ // the relative position of the window/sizer
+ // during layout calculations.
+ if (!child->GetConstraints())
+ {
+ wxLayoutConstraints *c = new wxLayoutConstraints;
+ c->left.AsIs();
+ c->top.AsIs();
+ c->width.AsIs();
+ c->height.AsIs();
+ int w, h;
+ child->GetSize(&w, &h);
+ c->width.SetValue(w);
+ c->height.SetValue(h);
+
+ child->SetConstraints(c);
+ }
}
-void wxSizer::RemoveSizerChild(wxWindow *child)
+void wxSizer::RemoveSizerChild(wxWindowBase *child)
{
- GetChildren().DeleteObject(child);
+ GetChildren().DeleteObject(child);
}
void wxSizer::DoSetSize(int x, int y, int w, int h, int WXUNUSED(flags))
{
- wxLayoutConstraints *constr = GetConstraints();
- if (x != -1)
- {
- sizerX = x;
- if (constr)
- constr->left.SetValue(x);
- }
- if (y != -1)
- {
- sizerY = y;
- if (constr)
- constr->top.SetValue(y);
- }
- if (w != -1)
- {
- sizerWidth = w;
- if (constr)
- constr->width.SetValue(w);
- }
- if (h != -1)
- {
- sizerHeight = h;
- if (constr)
- constr->height.SetValue(h);
- }
+ wxLayoutConstraints *constr = GetConstraints();
+ if (x != -1)
+ {
+ sizerX = x;
+ if (constr)
+ constr->left.SetValue(x);
+ }
+ if (y != -1)
+ {
+ sizerY = y;
+ if (constr)
+ constr->top.SetValue(y);
+ }
+ if (w != -1)
+ {
+ sizerWidth = w;
+ if (constr)
+ constr->width.SetValue(w);
+ }
+ if (h != -1)
+ {
+ sizerHeight = h;
+ if (constr)
+ constr->height.SetValue(h);
+ }
}
void wxSizer::GetSize(int *w, int *h) const
{
- *w = sizerWidth;
- *h = sizerHeight;
+ *w = sizerWidth;
+ *h = sizerHeight;
}
void wxSizer::GetPosition(int *x, int *y) const
{
- *x = sizerX;
- *y = sizerY;
+ *x = sizerX;
+ *y = sizerY;
}
bool wxSizer::LayoutPhase1(int *noChanges)
{
- *noChanges = 0;
- switch (sizerBehaviour)
- {
- case wxSizerExpand:
- {
- if (!m_sizerParent)
- {
- wxMessageBox(_("wxExpandSizer has no parent!"), _("Sizer error"), wxOK);
- return TRUE;
- }
-
- // Set the size to fill the parent client area
- int pw, ph;
- m_sizerParent->GetClientSize(&pw, &ph);
- SetSize(GetBorderX(), GetBorderY(), pw - 2*GetBorderX(), ph - 2*GetBorderY());
- wxLayoutConstraints *constr = GetConstraints();
-
- // Fill in the constraints
- if (constr)
- {
- constr->left.SetValue(0); constr->left.SetDone(TRUE);
- constr->top.SetValue(0); constr->right.SetDone(TRUE);
- constr->width.SetValue(pw); constr->width.SetDone(TRUE);
- constr->height.SetValue(ph); constr->height.SetDone(TRUE);
- }
-
- return TRUE;
- break;
- }
- case wxSizerShrink:
+ *noChanges = 0;
+ switch (sizerBehaviour)
{
- wxLayoutConstraints *constr = GetConstraints();
-
- if (constr)
- {
- // Force the constraint to have as-is width and height
- // if we're in shrink-to-fit mode, because if left unconstrained,
- // SatisfyConstraints will fail. The shrink-to-fit option
- // essentially specifies the width and height as 'whatever I calculate'.
- constr->width.AsIs();
- constr->height.AsIs();
- }
- DoPhase(1);
- DoPhase(2);
- // Find the bounding box and set own size
- int maxX = 0;
- int maxY = 0;
-
- wxNode *node = GetChildren().First();
- while (node)
- {
- int x, y, width, height;
- wxWindow *win = (wxWindow *)node->Data();
- win->GetSizeConstraint(&width, &height);
- win->GetPositionConstraint(&x, &y);
- if ((x+width) > maxX)
- maxX = (x + width);
- if ((y+height) > maxY)
- maxY = (y + height);
-
- node = node->Next();
- }
- SetSize(GetBorderX(), GetBorderY(), maxX, maxY);
-
- // If this is the only sizer for the parent, size the parent to this sizer.
- if ( m_sizerParent && (m_sizerParent->GetSizer() == this) )
- m_sizerParent->SetClientSize(maxX + 2*GetBorderX(), maxY + 2*GetBorderY());
-
- return TRUE;
- break;
- }
- case wxSizerNone:
- {
- wxLayoutConstraints *constr = GetConstraints();
- if (constr)
- {
- bool success = constr->SatisfyConstraints(this, noChanges);
- if (success)
- {
- int x = constr->left.GetValue();
- int y = constr->top.GetValue();
- int w = constr->width.GetValue();
- int h = constr->height.GetValue();
- SetSize(x, y, w, h);
- }
- return success;
- }
- else
- return TRUE;
- break;
+ case wxSizerExpand:
+ {
+ if (!m_sizerParent)
+ {
+ wxMessageBox(_("wxExpandSizer has no parent!"), _("Sizer error"), wxOK);
+ return TRUE;
+ }
+
+ // Set the size to fill the parent client area
+ int pw, ph;
+ m_sizerParent->GetClientSize(&pw, &ph);
+ SetSize(GetBorderX(), GetBorderY(), pw - 2*GetBorderX(), ph - 2*GetBorderY());
+ wxLayoutConstraints *constr = GetConstraints();
+
+ // Fill in the constraints
+ if (constr)
+ {
+ constr->left.SetValue(0); constr->left.SetDone(TRUE);
+ constr->top.SetValue(0); constr->right.SetDone(TRUE);
+ constr->width.SetValue(pw); constr->width.SetDone(TRUE);
+ constr->height.SetValue(ph); constr->height.SetDone(TRUE);
+ }
+
+ return TRUE;
+ break;
+ }
+ case wxSizerShrink:
+ {
+ wxLayoutConstraints *constr = GetConstraints();
+
+ if (constr)
+ {
+ // Force the constraint to have as-is width and height
+ // if we're in shrink-to-fit mode, because if left unconstrained,
+ // SatisfyConstraints will fail. The shrink-to-fit option
+ // essentially specifies the width and height as 'whatever I calculate'.
+ constr->width.AsIs();
+ constr->height.AsIs();
+ }
+ DoPhase(1);
+ DoPhase(2);
+ // Find the bounding box and set own size
+ int maxX = 0;
+ int maxY = 0;
+
+ wxNode *node = GetChildren().First();
+ while (node)
+ {
+ int x, y, width, height;
+ wxWindowBase *win = (wxWindowBase *)node->Data();
+ win->GetSizeConstraint(&width, &height);
+ win->GetPositionConstraint(&x, &y);
+ if ((x+width) > maxX)
+ maxX = (x + width);
+ if ((y+height) > maxY)
+ maxY = (y + height);
+
+ node = node->Next();
+ }
+ SetSize(GetBorderX(), GetBorderY(), maxX, maxY);
+
+ // If this is the only sizer for the parent, size the parent to this sizer.
+ if ( m_sizerParent && (m_sizerParent->GetSizer() == this) )
+ m_sizerParent->SetClientSize(maxX + 2*GetBorderX(), maxY + 2*GetBorderY());
+
+ return TRUE;
+ break;
+ }
+ case wxSizerNone:
+ {
+ wxLayoutConstraints *constr = GetConstraints();
+ if (constr)
+ {
+ bool success = constr->SatisfyConstraints(this, noChanges);
+ if (success)
+ {
+ int x = constr->left.GetValue();
+ int y = constr->top.GetValue();
+ int w = constr->width.GetValue();
+ int h = constr->height.GetValue();
+ SetSize(x, y, w, h);
+ }
+ return success;
+ }
+ else
+ return TRUE;
+ break;
+ }
}
- }
- return TRUE;
+ return TRUE;
}
bool wxSizer::LayoutPhase2(int *noChanges)
{
- *noChanges = 0;
+ *noChanges = 0;
- switch (sizerBehaviour)
- {
- case wxSizerExpand:
+ switch (sizerBehaviour)
{
- // Layout children
- DoPhase(1);
- DoPhase(2);
- return TRUE;
+ case wxSizerExpand:
+ {
+ // Layout children
+ DoPhase(1);
+ DoPhase(2);
+ return TRUE;
+ }
+ case wxSizerShrink:
+ {
+ wxLayoutConstraints *constr = GetConstraints();
+ if (constr)
+ {
+ bool success = constr->SatisfyConstraints(this, noChanges);
+ if (success)
+ {
+ int x = constr->left.GetValue();
+ int y = constr->top.GetValue();
+ Move(x, y);
+ }
+ return success;
+ }
+ break;
+ }
+ case wxSizerNone:
+ {
+ // Layout children
+ DoPhase(1);
+ DoPhase(2);
+
+ // Is this a dumb fix for lack of constraint evaluation?
+ wxLayoutConstraints *constr = GetConstraints();
+ if (constr)
+ {
+ bool success = constr->SatisfyConstraints(this, noChanges);
+ if (success)
+ {
+ int x = constr->left.GetValue();
+ int y = constr->top.GetValue();
+ int w = constr->width.GetValue();
+ int h = constr->height.GetValue();
+ SetSize(x, y, w, h);
+ }
+ return success;
+ }
+ else
+ return TRUE;
+ }
}
- case wxSizerShrink:
- {
- wxLayoutConstraints *constr = GetConstraints();
- if (constr)
- {
- bool success = constr->SatisfyConstraints(this, noChanges);
- if (success)
- {
- int x = constr->left.GetValue();
- int y = constr->top.GetValue();
- Move(x, y);
- }
- return success;
- }
- break;
- }
- case wxSizerNone:
- {
- // Layout children
- DoPhase(1);
- DoPhase(2);
-
- // Is this a dumb fix for lack of constraint evaluation?
- wxLayoutConstraints *constr = GetConstraints();
- if (constr)
- {
- bool success = constr->SatisfyConstraints(this, noChanges);
- if (success)
- {
- int x = constr->left.GetValue();
- int y = constr->top.GetValue();
- int w = constr->width.GetValue();
- int h = constr->height.GetValue();
- SetSize(x, y, w, h);
- }
- return success;
- }
- else
- return TRUE;
- }
- }
- return TRUE;
+ return TRUE;
}
/*
* wxRowColSizer
*/
-
+
wxRowColSizer::wxRowColSizer()
{
- rowOrCol = TRUE;
- rowOrColSize = 20;
- xSpacing = 2;
- ySpacing = 2;
+ rowOrCol = TRUE;
+ rowOrColSize = 20;
+ xSpacing = 2;
+ ySpacing = 2;
}
-wxRowColSizer::wxRowColSizer(wxWindow *parent, bool rc, int n, wxSizerBehaviour behav)
+wxRowColSizer::wxRowColSizer(wxWindowBase *parent, bool rc, int n, wxSizerBehaviour behav)
{
- Create(parent, rc, n, behav);
+ Create(parent, rc, n, behav);
}
-bool wxRowColSizer::Create(wxWindow *parent, bool rc, int n, wxSizerBehaviour behav)
+bool wxRowColSizer::Create(wxWindowBase *parent, bool rc, int n, wxSizerBehaviour behav)
{
- wxSizer::Create(parent, behav);
-
- rowOrCol = rc;
- rowOrColSize = n;
- xSpacing = 2;
- ySpacing = 2;
+ wxSizer::Create(parent, behav);
- return TRUE;
+ rowOrCol = rc;
+ rowOrColSize = n;
+ xSpacing = 2;
+ ySpacing = 2;
+
+ return TRUE;
}
wxRowColSizer::~wxRowColSizer()
bool wxRowColSizer::LayoutPhase1(int *noChanges)
{
- *noChanges = 0;
- wxLayoutConstraints *constr = GetConstraints();
-
- if (constr)
- {
- // Force the constraint to have as-is width and height
- // if we're in shrink-to-fit mode, because if left unconstrained,
- // SatisfyConstraints will fail. The shrink-to-fit option
- // essentially specifies the width and height as 'whatever I calculate'.
- if (sizerBehaviour == wxSizerShrink)
- {
- constr->width.AsIs();
- constr->height.AsIs();
- }
+ *noChanges = 0;
+ wxLayoutConstraints *constr = GetConstraints();
- // Only evaluate the constraints FIRST if we're NOT
- // in shrink-to-fit mode, i.e. we want to size the rowcol
- // first, then lay the children out in the space we've calculated.
- if (sizerBehaviour != wxSizerShrink)
+ if (constr)
{
- bool success = constr->SatisfyConstraints(this, noChanges);
- if (success)
- {
- int x = constr->left.GetValue();
- int y = constr->top.GetValue();
- int w = constr->width.GetValue();
- int h = constr->height.GetValue();
- SetSize(x, y, w, h);
- }
- else
- return FALSE;
+ // Force the constraint to have as-is width and height
+ // if we're in shrink-to-fit mode, because if left unconstrained,
+ // SatisfyConstraints will fail. The shrink-to-fit option
+ // essentially specifies the width and height as 'whatever I calculate'.
+ if (sizerBehaviour == wxSizerShrink)
+ {
+ constr->width.AsIs();
+ constr->height.AsIs();
+ }
- // Continue to do the rest of the phase when the constraints have been
- // satisfied, i.e. we're on the last iteration of phase 1 and
- // can now do the actual rowcol laying out.
+ // Only evaluate the constraints FIRST if we're NOT
+ // in shrink-to-fit mode, i.e. we want to size the rowcol
+ // first, then lay the children out in the space we've calculated.
+ if (sizerBehaviour != wxSizerShrink)
+ {
+ bool success = constr->SatisfyConstraints(this, noChanges);
+ if (success)
+ {
+ int x = constr->left.GetValue();
+ int y = constr->top.GetValue();
+ int w = constr->width.GetValue();
+ int h = constr->height.GetValue();
+ SetSize(x, y, w, h);
+ }
+ else
+ return FALSE;
+
+ // Continue to do the rest of the phase when the constraints have been
+ // satisfied, i.e. we're on the last iteration of phase 1 and
+ // can now do the actual rowcol laying out.
+ }
}
- }
-
- // If we ARE in shrink-to-fit mode, we must now
- // calculate the child sizes BEFORE laying out in rows or columns.
- if (sizerBehaviour == wxSizerShrink)
- {
- DoPhase(1);
- DoPhase(2);
-
- // WILL THE WINDOW BE SIZED CORRECTLY AT THIS POINT?
- // CHECK CONSTRAINTS IF ANY...
- int noRows = 0;
- int noCols = 0;
- int currentX = borderX;
- int currentY = borderY;
- int maxX = currentX;
- int maxY = currentY;
- wxNode *node = GetChildren().First();
- while (node)
+ // If we ARE in shrink-to-fit mode, we must now
+ // calculate the child sizes BEFORE laying out in rows or columns.
+ if (sizerBehaviour == wxSizerShrink)
{
- wxWindow *win = (wxWindow *)node->Data();
- int childWidth, childHeight;
- if (win->GetConstraints() &&
- win->GetConstraints()->width.GetDone() &&
- win->GetConstraints()->height.GetDone())
- {
- childWidth = win->GetConstraints()->width.GetValue();
- childHeight = win->GetConstraints()->height.GetValue();
- }
- else
- win->GetSize(&childWidth, &childHeight);
-
- win->MoveConstraint(currentX, currentY);
-
- if ((currentX + childWidth) > maxX)
- maxX = (currentX + childWidth);
- if ((currentY + childHeight) > maxY)
- maxY = (currentY + childHeight);
-
- if (rowOrCol)
- {
- currentX += childWidth + xSpacing;
- noCols ++;
-
- // Reset to start of row
- if (noCols == rowOrColSize)
+ DoPhase(1);
+ DoPhase(2);
+
+ // WILL THE WINDOW BE SIZED CORRECTLY AT THIS POINT?
+ // CHECK CONSTRAINTS IF ANY...
+ int noRows = 0;
+ int noCols = 0;
+ int currentX = borderX;
+ int currentY = borderY;
+ int maxX = currentX;
+ int maxY = currentY;
+
+ wxNode *node = GetChildren().First();
+ while (node)
{
- currentX = borderX;
- currentY += childHeight + ySpacing;
- noCols = 0;
+ wxWindowBase *win = (wxWindowBase *)node->Data();
+ int childWidth, childHeight;
+ if (win->GetConstraints() &&
+ win->GetConstraints()->width.GetDone() &&
+ win->GetConstraints()->height.GetDone())
+ {
+ childWidth = win->GetConstraints()->width.GetValue();
+ childHeight = win->GetConstraints()->height.GetValue();
+ }
+ else
+ win->GetSize(&childWidth, &childHeight);
+
+ win->MoveConstraint(currentX, currentY);
+
+ if ((currentX + childWidth) > maxX)
+ maxX = (currentX + childWidth);
+ if ((currentY + childHeight) > maxY)
+ maxY = (currentY + childHeight);
+
+ if (rowOrCol)
+ {
+ currentX += childWidth + xSpacing;
+ noCols ++;
+
+ // Reset to start of row
+ if (noCols == rowOrColSize)
+ {
+ currentX = borderX;
+ currentY += childHeight + ySpacing;
+ noCols = 0;
+ }
+ }
+ else
+ {
+ currentY += childHeight + ySpacing;
+ noRows ++;
+
+ // Reset to start of col
+ if (noRows == rowOrColSize)
+ {
+ currentY = borderY;
+ currentX += childWidth + xSpacing;
+ noRows = 0;
+ }
+ }
+
+ node = node->Next();
}
- }
- else
- {
- currentY += childHeight + ySpacing;
- noRows ++;
+ maxX += borderX;
+ maxY += borderY;
- // Reset to start of col
- if (noRows == rowOrColSize)
- {
- currentY = borderY;
- currentX += childWidth + xSpacing;
- noRows = 0;
- }
- }
-
- node = node->Next();
+ SetSize(-1, -1, maxX, maxY);
}
- maxX += borderX;
- maxY += borderY;
-
- SetSize(-1, -1, maxX, maxY);
- }
- return TRUE;
+ return TRUE;
}
bool wxRowColSizer::LayoutPhase2(int *noChanges)
{
- *noChanges = 0;
-
- // If shrink-to-fit, it's only at Phase 2 that we know the size of
- // the wxRowColSizer, and now we can evaluate the
- // constraints and pass result back up to parent.
- // This implements a depth-first strategy
- if (sizerBehaviour == wxSizerShrink)
- {
- wxLayoutConstraints *constr = GetConstraints();
- if (constr)
+ *noChanges = 0;
+
+ // If shrink-to-fit, it's only at Phase 2 that we know the size of
+ // the wxRowColSizer, and now we can evaluate the
+ // constraints and pass result back up to parent.
+ // This implements a depth-first strategy
+ if (sizerBehaviour == wxSizerShrink)
{
- bool success = constr->SatisfyConstraints(this, noChanges);
- if (success)
- {
- int x = constr->left.GetValue();
- int y = constr->top.GetValue();
- Move(x, y);
- }
- return success;
+ wxLayoutConstraints *constr = GetConstraints();
+ if (constr)
+ {
+ bool success = constr->SatisfyConstraints(this, noChanges);
+ if (success)
+ {
+ int x = constr->left.GetValue();
+ int y = constr->top.GetValue();
+ Move(x, y);
+ }
+ return success;
+ }
+ else return TRUE;
}
- else return TRUE;
- }
- else
- {
- // Lay out the children: breadth-first strategy.
- DoPhase(1);
- DoPhase(2);
+ else
+ {
+ // Lay out the children: breadth-first strategy.
+ DoPhase(1);
+ DoPhase(2);
- // Space them
- }
- return TRUE;
+ // Space them
+ }
+ return TRUE;
}
/*
* wxSpacingSizer
*/
-
+
wxSpacingSizer::wxSpacingSizer()
{
}
-wxSpacingSizer::wxSpacingSizer(wxWindow *parent)
+wxSpacingSizer::wxSpacingSizer(wxWindowBase *parent)
{
- Create(parent);
+ Create(parent);
}
-wxSpacingSizer::wxSpacingSizer(wxWindow *parent, wxRelationship rel, wxWindow *other, int spacing)
+wxSpacingSizer::wxSpacingSizer(wxWindowBase *parent, wxRelationship rel, wxWindowBase *other, int spacing)
{
- Create(parent, rel, other, spacing);
+ Create(parent, rel, other, spacing);
}
-bool wxSpacingSizer::Create(wxWindow *parent)
+bool wxSpacingSizer::Create(wxWindowBase *parent)
{
- wxSizer::Create(parent);
- return TRUE;
+ wxSizer::Create(parent);
+ return TRUE;
}
-bool wxSpacingSizer::Create(wxWindow *parent, wxRelationship rel, wxWindow *other, int spacing)
+bool wxSpacingSizer::Create(wxWindowBase *parent, wxRelationship rel, wxWindowBase *other, int spacing)
{
- wxLayoutConstraints *c = new wxLayoutConstraints;
+ wxLayoutConstraints *c = new wxLayoutConstraints;
- wxSizer::Create(parent);
+ wxSizer::Create(parent);
- switch ( rel )
- {
- case wxLeftOf :
- c->width.Absolute (spacing);
- c->top.SameAs (other, wxTop);
- c->bottom.SameAs (other, wxBottom);
- c->right.LeftOf (other);
- break;
- case wxRightOf :
- c->width.Absolute (spacing);
- c->top.SameAs (other, wxTop);
- c->bottom.SameAs (other, wxBottom);
- c->left.RightOf (other);
- break;
- case wxBelow :
- c->height.Absolute (spacing);
- c->left.SameAs (other, wxLeft);
- c->right.SameAs (other, wxRight);
- c->top.Below (other);
- break;
- case wxAbove :
- c->height.Absolute (spacing);
- c->left.SameAs (other, wxLeft);
- c->right.SameAs (other, wxRight);
- c->bottom.Above (other);
- break;
-
- default :
- break;
- }
- SetConstraints(c);
+ switch ( rel )
+ {
+ case wxLeftOf :
+ c->width.Absolute (spacing);
+ c->top.SameAs (other, wxTop);
+ c->bottom.SameAs (other, wxBottom);
+ c->right.LeftOf (other);
+ break;
+ case wxRightOf :
+ c->width.Absolute (spacing);
+ c->top.SameAs (other, wxTop);
+ c->bottom.SameAs (other, wxBottom);
+ c->left.RightOf (other);
+ break;
+ case wxBelow :
+ c->height.Absolute (spacing);
+ c->left.SameAs (other, wxLeft);
+ c->right.SameAs (other, wxRight);
+ c->top.Below (other);
+ break;
+ case wxAbove :
+ c->height.Absolute (spacing);
+ c->left.SameAs (other, wxLeft);
+ c->right.SameAs (other, wxRight);
+ c->bottom.Above (other);
+ break;
+
+ default :
+ break;
+ }
+ SetConstraints(c);
- return TRUE;
+ return TRUE;
}
wxSpacingSizer::~wxSpacingSizer()
#include "wx/utils.h" // for copystring() (beurk...)
#endif
-// -----------------------------------------------------------------------------
-// implementation of standard lists
-// -----------------------------------------------------------------------------
-
-#include "wx/listimpl.cpp"
-WX_DEFINE_LIST(wxWindowList);
-
// =============================================================================
// implementation
// =============================================================================
* resource loading facility
*/
-bool wxWindow::LoadFromResource(wxWindow *parent, const wxString& resourceName, const wxResourceTable *table)
+bool wxWindowBase::LoadFromResource(wxWindow *parent, const wxString& resourceName, const wxResourceTable *table)
{
if (!table)
table = wxDefaultResourceTable;
}
else
{
- if (!this->Create(parent, -1, wxPoint(x, y), wxSize(width, height), theWindowStyle, name))
+ if (!((wxWindow *)this)->Create(parent, -1, wxPoint(x, y), wxSize(width, height), theWindowStyle, name))
return FALSE;
}
return TRUE;
}
-wxControl *wxWindow::CreateItem(const wxItemResource *resource, const wxItemResource* parentResource, const wxResourceTable *table)
+wxControl *wxWindowBase::CreateItem(const wxItemResource *resource, const wxItemResource* parentResource, const wxResourceTable *table)
{
if (!table)
table = wxDefaultResourceTable;
{
}
-void wxToolBarBase::Layout()
+void wxToolBarBase::LayoutTools()
{
}
}
}
-void wxToolBarSimple::Layout(void)
+void wxToolBarSimple::LayoutTools(void)
{
m_currentRowsOrColumns = 0;
m_lastX = m_xMargin;
if (parent)
{
- for ( wxNode * node = parent->GetChildren().GetFirst();
+ for ( wxWindowList::Node * node = parent->GetChildren().GetFirst();
node;
node = node->GetNext() )
{
wxTextCtrl *control = (wxTextCtrl *) m_validatorWindow ;
// If window is disabled, simply return
- if ( !control->Enabled() )
+ if ( !control->IsEnabled() )
return TRUE;
wxString val(control->GetValue());
/////////////////////////////////////////////////////////////////////////////
-// Name: windows.cpp
+// Name: common/window.cpp
// Purpose: common (to all ports) wxWindow functions
// Author: Julian Smart, Vadim Zeitlin
// Modified by:
// Created: 13/07/98
// RCS-ID: $Id$
-// Copyright: (c) Julian Smart and Markus Holzem
+// Copyright: (c) wxWindows team
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
-// For compilers that support precompilation, includes "wx.h".
-#include "wx/wxprec.h"
+// ============================================================================
+// declarations
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
-#pragma hdrstop
+ #pragma hdrstop
#endif
-#include "wx/frame.h"
-#include "wx/defs.h"
-#include "wx/window.h"
+#ifndef WX_PRECOMP
+ #include "wx/string.h"
+ #include "wx/log.h"
+ #include "wx/intl.h"
+ #include "wx/frame.h"
+ #include "wx/defs.h"
+ #include "wx/window.h"
+ #include "wx/checkbox.h"
+ #include "wx/radiobut.h"
+ #include "wx/settings.h"
+ #include "wx/dialog.h"
+#endif //WX_PRECOMP
+
+#if wxUSE_CONSTRAINTS
+ #include "wx/layout.h"
+#endif // wxUSE_CONSTRAINTS
+
+#if wxUSE_DRAG_AND_DROP
+ #include "wx/dnd.h"
+#endif // wxUSE_DRAG_AND_DROP
+
+#if wxUSE_TOOLTIPS
+ #include "wx/tooltip.h"
+#endif // wxUSE_TOOLTIPS
+
+// ----------------------------------------------------------------------------
+// static data
+// ----------------------------------------------------------------------------
+
+int wxWindowBase::ms_lastControlId = 0;
+
+IMPLEMENT_ABSTRACT_CLASS(wxWindowBase, wxEvtHandler)
+
+// ----------------------------------------------------------------------------
+// event table
+// ----------------------------------------------------------------------------
+
+BEGIN_EVENT_TABLE(wxWindowBase, wxEvtHandler)
+ EVT_SYS_COLOUR_CHANGED(wxWindowBase::OnSysColourChanged)
+ EVT_INIT_DIALOG(wxWindowBase::OnInitDialog)
+END_EVENT_TABLE()
+
+// ============================================================================
+// implementation of the common functionality of the wxWindow class
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// initialization
+// ----------------------------------------------------------------------------
+
+// the default initialization
+void wxWindowBase::InitBase()
+{
+ // no window yet, no parent nor children
+ m_widget = (WXWidget)0;
+ m_parent = (wxWindow *)NULL;
+ m_windowId = -1;
+ m_children.DeleteContents( FALSE ); // don't auto delete node data
+
+ // no constraints on the minimal window size
+ m_minWidth =
+ m_minHeight =
+ m_maxWidth =
+ m_maxHeight = -1;
+
+ // window is created enabled but it's not visible yet
+ m_isShown = FALSE;
+ m_isEnabled = TRUE;
+
+ // no client data
+ m_clientObject = (wxClientData *)NULL;
+ m_clientData = NULL;
+
+ // the default event handler is just this window
+ m_eventHandler = this;
+
+ // no validator
+ m_windowValidator = (wxValidator *) NULL;
+
+ // use the system default colours
+ wxSystemSettings settings;
+
+ m_backgroundColour = settings.GetSystemColour(wxSYS_COLOUR_BTNFACE);
+ m_foregroundColour = *wxBLACK; // TODO take this from sys settings too?
+ m_font = *wxSWISS_FONT; // and this?
+
+ // no style bits
+ m_windowStyle = 0;
+
+ // an optimization for the event processing: checking this flag is much
+ // faster than using IsKindOf(CLASSINFO(wxWindow))
+ m_isWindow = TRUE;
+
+#if wxUSE_CONSTRAINTS
+ // no constraints whatsoever
+ m_constraints = (wxLayoutConstraints *) NULL;
+ m_constraintsInvolvedIn = (wxWindowList *) NULL;
+ m_windowSizer = (wxSizer *) NULL;
+ m_sizerParent = (wxWindowBase *) NULL;
+ m_autoLayout = FALSE;
+#endif // wxUSE_CONSTRAINTS
+
+#if wxUSE_DRAG_AND_DROP
+ m_dropTarget = (wxDropTarget *)NULL;
+#endif // wxUSE_DRAG_AND_DROP
+
+#if wxUSE_TOOLTIPS
+ m_tooltip = (wxToolTip *)NULL;
+#endif // wxUSE_TOOLTIPS
+}
+
+// common part of window creation process
+bool wxWindowBase::CreateBase(wxWindowBase *parent,
+ wxWindowID id,
+ const wxPoint& pos,
+ const wxSize& size,
+ long style,
+ const wxString& name)
+{
+ // m_isWindow is set to TRUE in wxWindowBase::Init() as well as many other
+ // member variables - check that it has been called (will catch the case
+ // when a new ctor is added which doesn't call InitWindow)
+ wxASSERT_MSG( m_isWindow, _T("Init() must have been called before!") );
+
+ // generate a new id if the user doesn't care about it
+ m_windowId = id == -1 ? NewControlId() : id;
+
+ SetName(name);
+ SetWindowStyleFlag(style);
+ SetParent(parent);
+
+ return TRUE;
+}
+
+// ----------------------------------------------------------------------------
+// destruction
+// ----------------------------------------------------------------------------
+
+// common clean up
+wxWindowBase::~wxWindowBase()
+{
+ // FIXME if these 2 cases result from programming errors in the user code
+ // we should probably assert here instead of silently fixing them
+
+ // Just in case the window has been Closed, but we're then deleting
+ // immediately: don't leave dangling pointers.
+ wxPendingDelete.DeleteObject(this);
+
+ // Just in case we've loaded a top-level window via LoadNativeDialog but
+ // we weren't a dialog class
+ wxTopLevelWindows.DeleteObject(this);
+
+ DestroyChildren();
+
+ if ( m_windowValidator )
+ delete m_windowValidator;
+
+ if ( m_clientObject )
+ delete m_clientObject;
+
+#if wxUSE_CONSTRAINTS
+ // Have to delete constraints/sizer FIRST otherwise sizers may try to look
+ // at deleted windows as they delete themselves.
+ DeleteRelatedConstraints();
+
+ if ( m_constraints )
+ {
+ // This removes any dangling pointers to this window in other windows'
+ // constraintsInvolvedIn lists.
+ UnsetConstraints(m_constraints);
+ delete m_constraints;
+ m_constraints = NULL;
+ }
+
+ if ( m_windowSizer )
+ delete m_windowSizer;
+
+ // If this is a child of a sizer, remove self from parent
+ if ( m_sizerParent )
+ m_sizerParent->RemoveChild(this);
+#endif // wxUSE_CONSTRAINTS
+
+#if wxUSE_DRAG_AND_DROP
+ if ( m_dropTarget )
+ delete m_dropTarget;
+#endif // wxUSE_DRAG_AND_DROP
+
+#if wxUSE_TOOLTIPS
+ if ( m_tooltip )
+ delete m_tooltip;
+#endif // wxUSE_TOOLTIPS
+}
+
+bool wxWindowBase::Destroy()
+{
+ delete this;
+
+ return TRUE;
+}
+
+bool wxWindowBase::Close(bool force)
+{
+ wxCloseEvent event(wxEVT_CLOSE_WINDOW, m_windowId);
+ event.SetEventObject(this);
+#if WXWIN_COMPATIBILITY
+ event.SetForce(force);
+#endif // WXWIN_COMPATIBILITY
+ event.SetCanVeto(!force);
+
+ // return FALSE if window wasn't closed because the application vetoed the
+ // close event
+ return GetEventHandler()->ProcessEvent(event) && !event.GetVeto();
+}
+
+bool wxWindowBase::DestroyChildren()
+{
+ wxWindowList::Node *node;
+ for ( node = m_children.GetFirst(); node; node = node->GetNext() )
+ {
+ wxWindow *child = node->GetData();
+ if ( child )
+ {
+ delete child;
+ delete node;
+ }
+ }
+
+ return TRUE;
+}
+
+// ----------------------------------------------------------------------------
+// centre/fit the window
+// ----------------------------------------------------------------------------
+
+// centre the window with respect to its parent in either (or both) directions
+void wxWindowBase::Centre(int direction)
+{
+ int widthParent, heightParent;
+
+ wxWindow *parent = GetParent();
+ if ( parent )
+ {
+ parent->GetClientSize(&widthParent, &heightParent);
+ }
+ else
+ {
+ // centre with respect to the whole screen
+ wxDisplaySize(&widthParent, &heightParent);
+ }
+
+ int width, height;
+ GetSize(&width, &height);
+
+ int new_x = -1,
+ new_y = -1;
+
+ if ( direction & wxHORIZONTAL )
+ new_x = (widthParent - width)/2;
+
+ if ( direction & wxVERTICAL )
+ new_y = (heightParent - height)/2;
+
+ Move(new_x, new_y);
+}
+
+// fits the window around the children
+void wxWindowBase::Fit()
+{
+ int maxX = 0,
+ maxY = 0;
+
+ wxWindowList::Node *node = GetChildren().GetFirst();
+ while ( node )
+ {
+ wxWindow *win = node->GetData();
+ int wx, wy, ww, wh;
+ win->GetPosition(&wx, &wy);
+ win->GetSize(&ww, &wh);
+ if ( wx + ww > maxX )
+ maxX = wx + ww;
+ if ( wy + wh > maxY )
+ maxY = wy + wh;
+
+ node = node->GetNext();
+ }
+
+ // leave a margin
+ SetClientSize(maxX + 7, maxY + 14);
+}
+
+// set the min/max size of the window
+
+void wxWindowBase::SetSizeHints(int minW, int minH,
+ int maxW, int maxH,
+ int WXUNUSED(incW), int WXUNUSED(incH))
+{
+ m_minWidth = minW;
+ m_maxWidth = maxW;
+ m_minHeight = minH;
+ m_maxHeight = maxH;
+}
+
+// ----------------------------------------------------------------------------
+// show/hide/enable/disable the window
+// ----------------------------------------------------------------------------
+
+bool wxWindowBase::Show(bool show)
+{
+ if ( show != m_isShown )
+ {
+ m_isShown = show;
+
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
+}
+
+bool wxWindowBase::Enable(bool enable)
+{
+ if ( enable != m_isEnabled )
+ {
+ m_isEnabled = enable;
+
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
+}
+
+// ----------------------------------------------------------------------------
+// reparenting the window
+// ----------------------------------------------------------------------------
+
+void wxWindowBase::AddChild(wxWindowBase *child)
+{
+ wxCHECK_RET( child, _T("can't add a NULL child") );
+
+ GetChildren().Append(child);
+ child->SetParent(this);
+}
+
+void wxWindowBase::RemoveChild(wxWindowBase *child)
+{
+ wxCHECK_RET( child, _T("can't remove a NULL child") );
+
+ GetChildren().DeleteObject(child);
+ child->SetParent((wxWindow *)NULL);
+}
-// Do Update UI processing for child controls
+bool wxWindowBase::Reparent(wxWindowBase *newParent)
+{
+ wxWindow *oldParent = GetParent();
+ if ( newParent == oldParent )
+ {
+ // nothing done
+ return FALSE;
+ }
+
+ // unlink this window from the existing parent.
+ if ( oldParent )
+ {
+ oldParent->RemoveChild(this);
+ }
+ else
+ {
+ wxTopLevelWindows.DeleteObject(this);
+ }
+
+ // add it to the new one
+ if ( newParent )
+ {
+ newParent->AddChild(this);
+ }
+ else
+ {
+ wxTopLevelWindows.Append(this);
+ }
+
+ return TRUE;
+}
+
+// ----------------------------------------------------------------------------
+// event handler stuff
+// ----------------------------------------------------------------------------
+
+void wxWindowBase::PushEventHandler(wxEvtHandler *handler)
+{
+ handler->SetNextHandler(GetEventHandler());
+ SetEventHandler(handler);
+}
+
+wxEvtHandler *wxWindowBase::PopEventHandler(bool deleteHandler)
+{
+ wxEvtHandler *handlerA = GetEventHandler();
+ if ( handlerA )
+ {
+ wxEvtHandler *handlerB = handlerA->GetNextHandler();
+ handlerA->SetNextHandler((wxEvtHandler *)NULL);
+ SetEventHandler(handlerB);
+ if ( deleteHandler )
+ {
+ delete handlerA;
+ handlerA = (wxEvtHandler *)NULL;
+ }
+ }
+
+ return handlerA;
+}
+
+// ----------------------------------------------------------------------------
+// cursors, fonts &c
+// ----------------------------------------------------------------------------
+
+bool wxWindowBase::SetBackgroundColour( const wxColour &colour )
+{
+ if ( !colour.Ok() || (colour == m_backgroundColour) )
+ return FALSE;
+
+ m_backgroundColour = colour;
+
+ return TRUE;
+}
+
+bool wxWindowBase::SetForegroundColour( const wxColour &colour )
+{
+ if ( !colour.Ok() || (colour == m_foregroundColour) )
+ return FALSE;
+
+ m_foregroundColour = colour;
+
+ return TRUE;
+}
+
+bool wxWindowBase::SetCursor(const wxCursor& cursor)
+{
+ // don't try to set invalid cursor, always fall back to the default
+ const wxCursor& cursorOk = cursor.Ok() ? cursor : *wxSTANDARD_CURSOR;
+
+ if ( cursorOk == m_cursor )
+ {
+ // no change
+ return FALSE;
+ }
+
+ m_cursor = cursorOk;
+
+ return TRUE;
+}
+
+bool wxWindowBase::SetFont(const wxFont& font)
+{
+ // don't try to set invalid font, always fall back to the default
+ const wxFont& fontOk = font.Ok() ? font : *wxSWISS_FONT;
+
+ if ( fontOk == m_font )
+ {
+ // no change
+ return FALSE;
+ }
+
+ m_font = fontOk;
+
+ return TRUE;
+}
+
+// ----------------------------------------------------------------------------
+// validators
+// ----------------------------------------------------------------------------
+
+void wxWindowBase::SetValidator(const wxValidator& validator)
+{
+ if ( m_windowValidator )
+ delete m_windowValidator;
+
+ m_windowValidator = (wxValidator *)validator.Clone();
+
+ if ( m_windowValidator )
+ m_windowValidator->SetWindow(this) ;
+}
+
+// ----------------------------------------------------------------------------
+// update region testing
+// ----------------------------------------------------------------------------
+
+bool wxWindowBase::IsExposed(int x, int y) const
+{
+ return m_updateRegion.Contains(x, y) != wxOutRegion;
+}
+
+bool wxWindowBase::IsExposed(int x, int y, int w, int h) const
+{
+ return m_updateRegion.Contains(x, y, w, h) != wxOutRegion;
+}
+
+// ----------------------------------------------------------------------------
+// find window by id or name
+// ----------------------------------------------------------------------------
+
+wxWindow *wxWindowBase::FindWindow( long id )
+{
+ if ( id == m_windowId )
+ return (wxWindow *)this;
+
+ wxWindowBase *res = (wxWindow *)NULL;
+ wxWindowList::Node *node;
+ for ( node = m_children.GetFirst(); node && !res; node = node->GetNext() )
+ {
+ wxWindowBase *child = node->GetData();
+ res = child->FindWindow( id );
+ }
+
+ return (wxWindow *)res;
+}
+
+wxWindow *wxWindowBase::FindWindow( const wxString& name )
+{
+ if ( name == m_windowName )
+ return (wxWindow *)this;
+
+ wxWindowBase *res = (wxWindow *)NULL;
+ wxWindowList::Node *node;
+ for ( node = m_children.GetFirst(); node && !res; node = node->GetNext() )
+ {
+ wxWindow *child = node->GetData();
+ res = child->FindWindow(name);
+ }
+
+ return (wxWindow *)res;
+}
+
+// ----------------------------------------------------------------------------
+// dialog oriented functions
+// ----------------------------------------------------------------------------
+
+void wxWindowBase::MakeModal(bool modal)
+{
+ wxFAIL_MSG("TODO");
+}
+
+bool wxWindowBase::Validate()
+{
+ wxWindowList::Node *node;
+ for ( node = m_children.GetFirst(); node; node = node->GetNext() )
+ {
+ wxWindowBase *child = node->GetData();
+ wxValidator *validator = child->GetValidator();
+ if ( validator && validator->Validate(this) )
+ {
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+}
+
+bool wxWindowBase::TransferDataToWindow()
+{
+ wxWindowList::Node *node;
+ for ( node = m_children.GetFirst(); node; node = node->GetNext() )
+ {
+ wxWindowBase *child = node->GetData();
+ wxValidator *validator = child->GetValidator();
+ if ( validator && !validator->TransferToWindow() )
+ {
+ wxLog *log = wxLog::GetActiveTarget();
+ if ( log )
+ {
+ wxLogWarning(_("Could not transfer data to window"));
+ log->Flush();
+ }
+
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+}
+
+bool wxWindowBase::TransferDataFromWindow()
+{
+ wxWindowList::Node *node;
+ for ( node = m_children.GetFirst(); node; node = node->GetNext() )
+ {
+ wxWindow *child = node->GetData();
+ if ( child->GetValidator() &&
+ !child->GetValidator()->TransferFromWindow() )
+ {
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+}
+
+void wxWindowBase::InitDialog()
+{
+ wxInitDialogEvent event(GetId());
+ event.SetEventObject( this );
+ GetEventHandler()->ProcessEvent(event);
+}
+
+// ----------------------------------------------------------------------------
+// tooltips
+// ----------------------------------------------------------------------------
+
+#if wxUSE_TOOLTIPS
+
+void wxWindowBase::SetToolTip( const wxString &tip )
+{
+ // don't create the new tooltip if we already have one
+ if ( m_tooltip )
+ {
+ m_tooltip->SetTip( tip );
+ }
+ else
+ {
+ SetToolTip( new wxToolTip( tip ) );
+ }
+
+ // setting empty tooltip text does not remove the tooltip any more - use
+ // SetToolTip((wxToolTip *)NULL) for this
+}
+
+void wxWindowBase::DoSetToolTip(wxToolTip *tooltip)
+{
+ if ( m_tooltip )
+ delete m_tooltip;
+
+ m_tooltip = tooltip;
+}
+
+#endif // wxUSE_TOOLTIPS
+
+// ----------------------------------------------------------------------------
+// constraints and sizers
+// ----------------------------------------------------------------------------
+
+#if wxUSE_CONSTRAINTS
+
+void wxWindowBase::SetConstraints( wxLayoutConstraints *constraints )
+{
+ if ( m_constraints )
+ {
+ UnsetConstraints(m_constraints);
+ delete m_constraints;
+ }
+ m_constraints = constraints;
+ if ( m_constraints )
+ {
+ // Make sure other windows know they're part of a 'meaningful relationship'
+ if ( m_constraints->left.GetOtherWindow() && (m_constraints->left.GetOtherWindow() != this) )
+ m_constraints->left.GetOtherWindow()->AddConstraintReference(this);
+ if ( m_constraints->top.GetOtherWindow() && (m_constraints->top.GetOtherWindow() != this) )
+ m_constraints->top.GetOtherWindow()->AddConstraintReference(this);
+ if ( m_constraints->right.GetOtherWindow() && (m_constraints->right.GetOtherWindow() != this) )
+ m_constraints->right.GetOtherWindow()->AddConstraintReference(this);
+ if ( m_constraints->bottom.GetOtherWindow() && (m_constraints->bottom.GetOtherWindow() != this) )
+ m_constraints->bottom.GetOtherWindow()->AddConstraintReference(this);
+ if ( m_constraints->width.GetOtherWindow() && (m_constraints->width.GetOtherWindow() != this) )
+ m_constraints->width.GetOtherWindow()->AddConstraintReference(this);
+ if ( m_constraints->height.GetOtherWindow() && (m_constraints->height.GetOtherWindow() != this) )
+ m_constraints->height.GetOtherWindow()->AddConstraintReference(this);
+ if ( m_constraints->centreX.GetOtherWindow() && (m_constraints->centreX.GetOtherWindow() != this) )
+ m_constraints->centreX.GetOtherWindow()->AddConstraintReference(this);
+ if ( m_constraints->centreY.GetOtherWindow() && (m_constraints->centreY.GetOtherWindow() != this) )
+ m_constraints->centreY.GetOtherWindow()->AddConstraintReference(this);
+ }
+}
+
+// This removes any dangling pointers to this window in other windows'
+// constraintsInvolvedIn lists.
+void wxWindowBase::UnsetConstraints(wxLayoutConstraints *c)
+{
+ if ( c )
+ {
+ if ( c->left.GetOtherWindow() && (c->top.GetOtherWindow() != this) )
+ c->left.GetOtherWindow()->RemoveConstraintReference(this);
+ if ( c->top.GetOtherWindow() && (c->top.GetOtherWindow() != this) )
+ c->top.GetOtherWindow()->RemoveConstraintReference(this);
+ if ( c->right.GetOtherWindow() && (c->right.GetOtherWindow() != this) )
+ c->right.GetOtherWindow()->RemoveConstraintReference(this);
+ if ( c->bottom.GetOtherWindow() && (c->bottom.GetOtherWindow() != this) )
+ c->bottom.GetOtherWindow()->RemoveConstraintReference(this);
+ if ( c->width.GetOtherWindow() && (c->width.GetOtherWindow() != this) )
+ c->width.GetOtherWindow()->RemoveConstraintReference(this);
+ if ( c->height.GetOtherWindow() && (c->height.GetOtherWindow() != this) )
+ c->height.GetOtherWindow()->RemoveConstraintReference(this);
+ if ( c->centreX.GetOtherWindow() && (c->centreX.GetOtherWindow() != this) )
+ c->centreX.GetOtherWindow()->RemoveConstraintReference(this);
+ if ( c->centreY.GetOtherWindow() && (c->centreY.GetOtherWindow() != this) )
+ c->centreY.GetOtherWindow()->RemoveConstraintReference(this);
+ }
+}
+
+// Back-pointer to other windows we're involved with, so if we delete this
+// window, we must delete any constraints we're involved with.
+void wxWindowBase::AddConstraintReference(wxWindowBase *otherWin)
+{
+ if ( !m_constraintsInvolvedIn )
+ m_constraintsInvolvedIn = new wxWindowList;
+ if ( !m_constraintsInvolvedIn->Find(otherWin) )
+ m_constraintsInvolvedIn->Append(otherWin);
+}
+
+// REMOVE back-pointer to other windows we're involved with.
+void wxWindowBase::RemoveConstraintReference(wxWindowBase *otherWin)
+{
+ if ( m_constraintsInvolvedIn )
+ m_constraintsInvolvedIn->DeleteObject(otherWin);
+}
+
+// Reset any constraints that mention this window
+void wxWindowBase::DeleteRelatedConstraints()
+{
+ if ( m_constraintsInvolvedIn )
+ {
+ wxWindowList::Node *node = m_constraintsInvolvedIn->GetFirst();
+ while (node)
+ {
+ wxWindow *win = node->GetData();
+ wxLayoutConstraints *constr = win->GetConstraints();
+
+ // Reset any constraints involving this window
+ if ( constr )
+ {
+ constr->left.ResetIfWin(this);
+ constr->top.ResetIfWin(this);
+ constr->right.ResetIfWin(this);
+ constr->bottom.ResetIfWin(this);
+ constr->width.ResetIfWin(this);
+ constr->height.ResetIfWin(this);
+ constr->centreX.ResetIfWin(this);
+ constr->centreY.ResetIfWin(this);
+ }
+
+ wxWindowList::Node *next = node->GetNext();
+ delete node;
+ node = next;
+ }
+
+ delete m_constraintsInvolvedIn;
+ m_constraintsInvolvedIn = (wxWindowList *) NULL;
+ }
+}
+
+void wxWindowBase::SetSizer(wxSizer *sizer)
+{
+ m_windowSizer = sizer;
+ if ( sizer )
+ sizer->SetSizerParent(this);
+}
+
+bool wxWindowBase::Layout()
+{
+ if ( GetConstraints() )
+ {
+ int w, h;
+ GetClientSize(&w, &h);
+ GetConstraints()->width.SetValue(w);
+ GetConstraints()->height.SetValue(h);
+ }
+
+ // If top level (one sizer), evaluate the sizer's constraints.
+ if ( GetSizer() )
+ {
+ int noChanges;
+ GetSizer()->ResetConstraints(); // Mark all constraints as unevaluated
+ GetSizer()->LayoutPhase1(&noChanges);
+ GetSizer()->LayoutPhase2(&noChanges);
+ GetSizer()->SetConstraintSizes(); // Recursively set the real window sizes
+ return TRUE;
+ }
+ else
+ {
+ // Otherwise, evaluate child constraints
+ ResetConstraints(); // Mark all constraints as unevaluated
+ DoPhase(1); // Just one phase need if no sizers involved
+ DoPhase(2);
+ SetConstraintSizes(); // Recursively set the real window sizes
+ }
+ return TRUE;
+}
+
+
+// Do a phase of evaluating constraints: the default behaviour. wxSizers may
+// do a similar thing, but also impose their own 'constraints' and order the
+// evaluation differently.
+bool wxWindowBase::LayoutPhase1(int *noChanges)
+{
+ wxLayoutConstraints *constr = GetConstraints();
+ if ( constr )
+ {
+ return constr->SatisfyConstraints(this, noChanges);
+ }
+ else
+ return TRUE;
+}
+
+bool wxWindowBase::LayoutPhase2(int *noChanges)
+{
+ *noChanges = 0;
+
+ // Layout children
+ DoPhase(1);
+ DoPhase(2);
+ return TRUE;
+}
+
+// Do a phase of evaluating child constraints
+bool wxWindowBase::DoPhase(int phase)
+{
+ int noIterations = 0;
+ int maxIterations = 500;
+ int noChanges = 1;
+ int noFailures = 0;
+ wxWindowList succeeded;
+ while ((noChanges > 0) && (noIterations < maxIterations))
+ {
+ noChanges = 0;
+ noFailures = 0;
+ wxWindowList::Node *node = GetChildren().GetFirst();
+ while (node)
+ {
+ wxWindow *child = node->GetData();
+ if ( !child->IsKindOf(CLASSINFO(wxFrame)) && !child->IsKindOf(CLASSINFO(wxDialog)) )
+ {
+ wxLayoutConstraints *constr = child->GetConstraints();
+ if ( constr )
+ {
+ if ( !succeeded.Find(child) )
+ {
+ int tempNoChanges = 0;
+ bool success = ( (phase == 1) ? child->LayoutPhase1(&tempNoChanges) : child->LayoutPhase2(&tempNoChanges) ) ;
+ noChanges += tempNoChanges;
+ if ( success )
+ {
+ succeeded.Append(child);
+ }
+ }
+ }
+ }
+ node = node->GetNext();
+ }
+
+ noIterations++;
+ }
+
+ return TRUE;
+}
+
+void wxWindowBase::ResetConstraints()
+{
+ wxLayoutConstraints *constr = GetConstraints();
+ if ( constr )
+ {
+ constr->left.SetDone(FALSE);
+ constr->top.SetDone(FALSE);
+ constr->right.SetDone(FALSE);
+ constr->bottom.SetDone(FALSE);
+ constr->width.SetDone(FALSE);
+ constr->height.SetDone(FALSE);
+ constr->centreX.SetDone(FALSE);
+ constr->centreY.SetDone(FALSE);
+ }
+ wxWindowList::Node *node = GetChildren().GetFirst();
+ while (node)
+ {
+ wxWindow *win = node->GetData();
+ if ( !win->IsKindOf(CLASSINFO(wxFrame)) && !win->IsKindOf(CLASSINFO(wxDialog)) )
+ win->ResetConstraints();
+ node = node->GetNext();
+ }
+}
+
+// Need to distinguish between setting the 'fake' size for windows and sizers,
+// and setting the real values.
+void wxWindowBase::SetConstraintSizes(bool recurse)
+{
+ wxLayoutConstraints *constr = GetConstraints();
+ if ( constr && constr->left.GetDone() && constr->right.GetDone( ) &&
+ constr->width.GetDone() && constr->height.GetDone())
+ {
+ int x = constr->left.GetValue();
+ int y = constr->top.GetValue();
+ int w = constr->width.GetValue();
+ int h = constr->height.GetValue();
+
+ // If we don't want to resize this window, just move it...
+ if ( (constr->width.GetRelationship() != wxAsIs ) ||
+ (constr->height.GetRelationship() != wxAsIs))
+ {
+ // Calls Layout() recursively. AAAGH. How can we stop that.
+ // Simply take Layout() out of non-top level OnSizes.
+ SizerSetSize(x, y, w, h);
+ }
+ else
+ {
+ SizerMove(x, y);
+ }
+ }
+ else if ( constr )
+ {
+ wxChar *windowClass = GetClassInfo()->GetClassName();
+
+ wxString winName;
+ if ( GetName() == _T("") )
+ winName = _T("unnamed");
+ else
+ winName = GetName();
+ wxLogDebug( _T("Constraint(s) not satisfied for window of type %s, name %s:\n"),
+ (const wxChar *)windowClass,
+ (const wxChar *)winName);
+ if ( !constr->left.GetDone()) wxLogDebug( _T(" unsatisfied 'left' constraint.\n") );
+ if ( !constr->right.GetDone()) wxLogDebug( _T(" unsatisfied 'right' constraint.\n") );
+ if ( !constr->width.GetDone()) wxLogDebug( _T(" unsatisfied 'width' constraint.\n") );
+ if ( !constr->height.GetDone()) wxLogDebug( _T(" unsatisfied 'height' constraint.\n") );
+ wxLogDebug( _T("Please check constraints: try adding AsIs() constraints.\n") );
+ }
+
+ if ( recurse )
+ {
+ wxWindowList::Node *node = GetChildren().GetFirst();
+ while (node)
+ {
+ wxWindow *win = node->GetData();
+ if ( !win->IsKindOf(CLASSINFO(wxFrame)) && !win->IsKindOf(CLASSINFO(wxDialog)) )
+ win->SetConstraintSizes();
+ node = node->GetNext();
+ }
+ }
+}
+
+// This assumes that all sizers are 'on' the same window, i.e. the parent of
+// this window.
+void wxWindowBase::TransformSizerToActual(int *x, int *y) const
+{
+ if ( !m_sizerParent || m_sizerParent->IsKindOf(CLASSINFO(wxDialog) ) ||
+ m_sizerParent->IsKindOf(CLASSINFO(wxFrame)) )
+ return;
+
+ int xp, yp;
+ m_sizerParent->GetPosition(&xp, &yp);
+ m_sizerParent->TransformSizerToActual(&xp, &yp);
+ *x += xp;
+ *y += yp;
+}
+
+void wxWindowBase::SizerSetSize(int x, int y, int w, int h)
+{
+ int xx = x;
+ int yy = y;
+ TransformSizerToActual(&xx, &yy);
+ SetSize(xx, yy, w, h);
+}
+
+void wxWindowBase::SizerMove(int x, int y)
+{
+ int xx = x;
+ int yy = y;
+ TransformSizerToActual(&xx, &yy);
+ Move(xx, yy);
+}
+
+// Only set the size/position of the constraint (if any)
+void wxWindowBase::SetSizeConstraint(int x, int y, int w, int h)
+{
+ wxLayoutConstraints *constr = GetConstraints();
+ if ( constr )
+ {
+ if ( x != -1 )
+ {
+ constr->left.SetValue(x);
+ constr->left.SetDone(TRUE);
+ }
+ if ( y != -1 )
+ {
+ constr->top.SetValue(y);
+ constr->top.SetDone(TRUE);
+ }
+ if ( w != -1 )
+ {
+ constr->width.SetValue(w);
+ constr->width.SetDone(TRUE);
+ }
+ if ( h != -1 )
+ {
+ constr->height.SetValue(h);
+ constr->height.SetDone(TRUE);
+ }
+ }
+}
+
+void wxWindowBase::MoveConstraint(int x, int y)
+{
+ wxLayoutConstraints *constr = GetConstraints();
+ if ( constr )
+ {
+ if ( x != -1 )
+ {
+ constr->left.SetValue(x);
+ constr->left.SetDone(TRUE);
+ }
+ if ( y != -1 )
+ {
+ constr->top.SetValue(y);
+ constr->top.SetDone(TRUE);
+ }
+ }
+}
+
+void wxWindowBase::GetSizeConstraint(int *w, int *h) const
+{
+ wxLayoutConstraints *constr = GetConstraints();
+ if ( constr )
+ {
+ *w = constr->width.GetValue();
+ *h = constr->height.GetValue();
+ }
+ else
+ GetSize(w, h);
+}
+
+void wxWindowBase::GetClientSizeConstraint(int *w, int *h) const
+{
+ wxLayoutConstraints *constr = GetConstraints();
+ if ( constr )
+ {
+ *w = constr->width.GetValue();
+ *h = constr->height.GetValue();
+ }
+ else
+ GetClientSize(w, h);
+}
+
+void wxWindowBase::GetPositionConstraint(int *x, int *y) const
+{
+ wxLayoutConstraints *constr = GetConstraints();
+ if ( constr )
+ {
+ *x = constr->left.GetValue();
+ *y = constr->top.GetValue();
+ }
+ else
+ GetPosition(x, y);
+}
+
+#endif // wxUSE_CONSTRAINTS
+
+// ----------------------------------------------------------------------------
+// do Update UI processing for child controls
+// ----------------------------------------------------------------------------
// TODO: should this be implemented for the child window rather
// than the parent? Then you can override it e.g. for wxCheckBox
// to do the Right Thing rather than having to assume a fixed number
// of control classes.
-#include "wx/checkbox.h"
-#include "wx/radiobut.h"
-
-void wxWindow::UpdateWindowUI()
+void wxWindowBase::UpdateWindowUI()
{
- wxWindowID id = GetId();
- if (id > 0)
- {
- wxUpdateUIEvent event(id);
- event.m_eventObject = this;
-
- if (this->GetEventHandler()->ProcessEvent(event))
+ wxWindowID id = GetId();
+ if ( id > 0 )
{
- if (event.GetSetEnabled())
- this->Enable(event.GetEnabled());
+ wxUpdateUIEvent event(id);
+ event.m_eventObject = this;
- if (event.GetSetText() && this->IsKindOf(CLASSINFO(wxControl)))
- ((wxControl*)this)->SetLabel(event.GetText());
+ if ( GetEventHandler()->ProcessEvent(event) )
+ {
+ if ( event.GetSetEnabled() )
+ Enable(event.GetEnabled());
- if (this->IsKindOf(CLASSINFO(wxCheckBox)))
- {
- if (event.GetSetChecked())
- ((wxCheckBox *) this)->SetValue(event.GetChecked());
- }
- // @@@ No radio buttons in wxGTK yet
+ if ( event.GetSetText() && IsKindOf(CLASSINFO(wxControl)) )
+ ((wxControl*)this)->SetLabel(event.GetText());
+
+ if ( IsKindOf(CLASSINFO(wxCheckBox)) )
+ {
+ if ( event.GetSetChecked() )
+ ((wxCheckBox *)this)->SetValue(event.GetChecked());
+ }
+ // TODO No radio buttons in wxGTK yet
#ifndef __WXGTK__
- else if (this->IsKindOf(CLASSINFO(wxRadioButton)))
- {
- if (event.GetSetChecked())
- ((wxRadioButton *) this)->SetValue(event.GetChecked());
- }
-#endif
+ else if ( IsKindOf(CLASSINFO(wxRadioButton)) )
+ {
+ if ( event.GetSetChecked() )
+ ((wxRadioButton *) this)->SetValue(event.GetChecked());
+ }
+#endif // !wxGTK
+ }
}
- }
}
-// Dialog units translations. Implemented in wincmn.cpp.
-wxPoint wxWindow::ConvertPixelsToDialog(const wxPoint& pt)
+// ----------------------------------------------------------------------------
+// dialog units translations
+// ----------------------------------------------------------------------------
+
+wxPoint wxWindowBase::ConvertPixelsToDialog(const wxPoint& pt)
{
int charWidth = GetCharWidth();
int charHeight = GetCharHeight();
return pt2;
}
-wxPoint wxWindow::ConvertDialogToPixels(const wxPoint& pt)
+wxPoint wxWindowBase::ConvertDialogToPixels(const wxPoint& pt)
{
int charWidth = GetCharWidth();
int charHeight = GetCharHeight();
return pt2;
}
+// ----------------------------------------------------------------------------
+// event handlers
+// ----------------------------------------------------------------------------
+
+// propagate the colour change event to the subwindows
+void wxWindowBase::OnSysColourChanged(wxSysColourChangedEvent& event)
+{
+ wxWindowList::Node *node = GetChildren().GetFirst();
+ while ( node )
+ {
+ // Only propagate to non-top-level windows
+ wxWindow *win = node->GetData();
+ if ( !win->IsTopLevel() )
+ {
+ wxSysColourChangedEvent event2;
+ event.m_eventObject = win;
+ win->GetEventHandler()->ProcessEvent(event2);
+ }
+
+ node = node->GetNext();
+ }
+}
+
+// the default action is to populate dialog with data when it's created
+void wxWindowBase::OnInitDialog( wxInitDialogEvent &WXUNUSED(event) )
+{
+ TransferDataToWindow();
+}
+
+// ----------------------------------------------------------------------------
+// list classes implementation
+// ----------------------------------------------------------------------------
+
+void wxWindowListNode::DeleteData()
+{
+ delete (wxWindow *)GetData();
+}
+
m_mainWin = new wxListMainWindow( this, -1, wxPoint(0,0), size, s );
- if (GetWindowStyleFlag() & wxLC_REPORT)
+ if (HasFlag(wxLC_REPORT))
m_headerWin = new wxListHeaderWindow( this, -1, m_mainWin, wxPoint(0,0), wxSize(size.x,23), wxTAB_TRAVERSAL );
else
m_headerWin = (wxListHeaderWindow *) NULL;
void wxListCtrl::SetSingleStyle( long style, bool add )
{
- long flag = GetWindowStyleFlag();
+ long flag = GetWindowStyle();
if (add)
{
if (flag & wxLC_REPORT)
{
- if (!(GetWindowStyleFlag() & wxLC_REPORT))
+ if (!HasFlag(wxLC_REPORT))
{
// m_mainWin->SetSize( 0, 24, width, height-24 );
if (!m_headerWin)
}
else
{
- if (GetWindowStyleFlag() & wxLC_REPORT)
+ if (HasFlag(wxLC_REPORT))
{
// m_mainWin->SetSize( 0, 0, width, height );
m_headerWin->Show( FALSE );
int w = 0;
int h = 0;
- if (GetWindowStyleFlag() & wxLC_REPORT)
+ if (HasFlag(wxLC_REPORT))
{
m_headerWin->GetPosition( &x, &y );
m_headerWin->GetSize( &w, &h );
m_mainWin->Refresh();
}
-void wxListCtrl::SetBackgroundColour( const wxColour &colour )
+bool wxListCtrl::SetBackgroundColour( const wxColour &colour )
{
- wxWindow::SetBackgroundColour( colour );
+ if ( !wxWindow::SetBackgroundColour( colour ) )
+ return FALSE;
if (m_mainWin)
{
{
m_headerWin->SetBackgroundColour( colour );
}
+
+ return TRUE;
}
-void wxListCtrl::SetForegroundColour( const wxColour &colour )
+bool wxListCtrl::SetForegroundColour( const wxColour &colour )
{
- wxWindow::SetForegroundColour( colour );
+ if ( !wxWindow::SetForegroundColour( colour ) )
+ return FALSE;
if (m_mainWin)
{
{
m_headerWin->SetForegroundColour( colour );
}
+
+ return TRUE;
}
-void wxListCtrl::SetFont( const wxFont &font )
+bool wxListCtrl::SetFont( const wxFont &font )
{
- wxWindow::SetFont( font );
+ if ( !wxWindow::SetFont( font ) )
+ return FALSE;
if (m_mainWin)
{
{
m_headerWin->SetFont( font );
}
+
+ return TRUE;
}
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart, Markus Holzem, Robert Roebling
-// Licence: wxWindows license
+// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
for (uint pos = 0; pos < message.Len(); pos++)
{
if (message[pos] == _T('\n'))
- {
- if (!line.IsEmpty())
- {
- wxStaticText *s1 = new wxStaticText( parent, -1, line, wxPoint(15,y) );
- wxSize size1( s1->GetSize() );
- if (size1.x > w) w = size1.x;
- line = _T("");
- }
- y += 18;
- }
- else
- {
- line += message[pos];
- }
+ {
+ if (!line.IsEmpty())
+ {
+ wxStaticText *s1 = new wxStaticText( parent, -1, line, wxPoint(15,y) );
+ wxSize size1( s1->GetSize() );
+ if (size1.x > w) w = size1.x;
+ line = _T("");
+ }
+ y += 18;
+ }
+ else
+ {
+ line += message[pos];
+ }
}
if (!line.IsEmpty())
{
- wxStaticText *s2 = new wxStaticText( parent, -1, line, wxPoint(15,y) );
- wxSize size2( s2->GetSize() );
- if (size2.x > w) w = size2.x;
+ wxStaticText *s2 = new wxStaticText( parent, -1, line, wxPoint(15,y) );
+ wxSize size2( s2->GetSize() );
+ if (size2.x > w) w = size2.x;
}
-
+
y += 18;
return wxSize(w+30,y);
#if !USE_SHARED_LIBRARY
BEGIN_EVENT_TABLE(wxGenericMessageDialog, wxDialog)
- EVT_BUTTON(wxID_YES, wxGenericMessageDialog::OnYes)
- EVT_BUTTON(wxID_NO, wxGenericMessageDialog::OnNo)
- EVT_BUTTON(wxID_CANCEL, wxGenericMessageDialog::OnCancel)
+ EVT_BUTTON(wxID_YES, wxGenericMessageDialog::OnYes)
+ EVT_BUTTON(wxID_NO, wxGenericMessageDialog::OnNo)
+ EVT_BUTTON(wxID_CANCEL, wxGenericMessageDialog::OnCancel)
END_EVENT_TABLE()
IMPLEMENT_CLASS(wxGenericMessageDialog, wxDialog)
if (style & wxYES_NO)
{
yes = new wxButton( this, wxID_YES, _("Yes"), wxPoint(-1,y), wxSize(80,-1) );
- m_buttons.Append( yes );
+ m_buttons.Append( yes );
no = new wxButton( this, wxID_NO, _("No"), wxPoint(-1,y), wxSize(80,-1) );
- m_buttons.Append( no );
+ m_buttons.Append( no );
}
if (style & wxOK)
{
ok = new wxButton( this, wxID_OK, _("OK"), wxPoint(-1,y), wxSize(80,-1) );
- m_buttons.Append( ok );
+ m_buttons.Append( ok );
}
if (style & wxCANCEL)
{
cancel = new wxButton( this, wxID_CANCEL, _("Cancel"), wxPoint(-1,y), wxSize(80,-1) );
- m_buttons.Append( cancel );
+ m_buttons.Append( cancel );
}
if (ok)
while (node)
{
wxWindow *win = (wxWindow*)node->Data();
- int x = (n*2+1)*space - 40 + 15;
- win->Move( x, -1 );
+ int x = (n*2+1)*space - 40 + 15;
+ win->Move( x, -1 );
node = node->Next();
- n++;
+ n++;
}
#ifdef __WXGTK__
return;
}
- wxNode *start_node = GetChildren().Find( winFocus );
+ wxWindowList::Node *start_node = GetChildren().Find( winFocus );
if (!start_node)
- start_node = GetChildren().First();
+ start_node = GetChildren().GetFirst();
- wxNode *node = event.GetDirection() ? start_node->Next()
- : start_node->Previous();
+ wxWindowList::Node *node = event.GetDirection() ? start_node->GetNext()
+ : start_node->GetPrevious();
while (node != start_node)
{
if (!node)
{
- node = event.GetDirection() ? GetChildren().First()
- : GetChildren().Last();
+ node = event.GetDirection() ? GetChildren().GetFirst()
+ : GetChildren().GetLast();
continue;
}
- wxWindow *child = (wxWindow *)node->Data();
+ wxWindow *child = node->GetData();
if (child->AcceptsFocus())
{
return;
}
- node = event.GetDirection() ? node->Next() : node->Previous();
+ node = event.GetDirection() ? node->GetNext() : node->GetPrevious();
}
// we cycled through all of our children and none of them wanted to accept
m_noTabs --;
// The layout has changed
- Layout();
+ LayoutTabs();
return TRUE;
}
tabNode = tabNode->Next();
// Layout tabs (optional, e.g. if resizing window)
-void wxTabView::Layout(void)
+void wxTabView::LayoutTabs(void)
{
// Make a list of the tab controls, deleting the wxTabLayers.
wxList controls;
wxApp *wxTheApp = (wxApp *) NULL;
wxAppInitializerFunction wxApp::m_appInitFn = (wxAppInitializerFunction) NULL;
-extern wxList wxPendingDelete;
#if wxUSE_THREADS
extern wxList *wxPendingEvents;
extern wxCriticalSection *wxPendingEventsLocker;
m_colorCube = (unsigned char*)malloc(32 * 32 * 32);
- for (int r = 0; r < 32; r++)
- {
+ for (int r = 0; r < 32; r++)
+ {
for (int g = 0; g < 32; g++)
{
for (int b = 0; b < 32; b++)
int gg = (g << 3) | (g >> 2);
int bb = (b << 3) | (b >> 2);
+ int index = -1;
+
GdkColor *colors = cmap->colors;
- if(colors)
- {
- int max = 3 * 65536;
- int index = -1;
-
- for (int i = 0; i < cmap->size; i++)
- {
- int rdiff = ((rr << 8) - colors[i].red);
- int gdiff = ((gg << 8) - colors[i].green);
- int bdiff = ((bb << 8) - colors[i].blue);
- int sum = ABS (rdiff) + ABS (gdiff) + ABS (bdiff);
- if (sum < max) { index = i; max = sum; }
+ if(colors)
+ {
+ int max = 3 * 65536;
+
+ for (int i = 0; i < cmap->size; i++)
+ {
+ int rdiff = ((rr << 8) - colors[i].red);
+ int gdiff = ((gg << 8) - colors[i].green);
+ int bdiff = ((bb << 8) - colors[i].blue);
+ int sum = ABS (rdiff) + ABS (gdiff) + ABS (bdiff);
+ if (sum < max)
+ {
+ index = i; max = sum;
+ }
+ }
}
- }
+
m_colorCube[ (r*1024) + (g*32) + b ] = index;
}
}
delete obj;
- if (wxPendingDelete.Member(obj))
- delete node;
+ if (wxPendingDelete.Find(obj))
+ delete node;
node = wxPendingDelete.First();
}
m_parent->AddChild( this );
- (m_parent->m_insertCallback)( m_parent, this );
+ m_parent->InsertChild( this );
PostCreation();
SetBitmap();
}
-void wxBitmapButton::Enable( const bool enable )
+bool wxBitmapButton::Enable( bool enable )
{
- wxWindow::Enable(enable);
+ if ( !wxWindow::Enable(enable) )
+ return FALSE;
- SetBitmap();
+ SetBitmap();
+
+ return TRUE;
}
void wxBitmapButton::HasFocus()
gtk_signal_connect( GTK_OBJECT(m_widget), "clicked",
GTK_SIGNAL_FUNC(gtk_button_clicked_callback), (gpointer*)this );
- m_parent->AddChild( this );
-
- (m_parent->m_insertCallback)( m_parent, this );
+ m_parent->DoAddChild( this );
PostCreation();
gtk_label_set( GTK_LABEL( GTK_BUTTON(m_widget)->child ), GetLabel().mbc_str() );
}
-void wxButton::Enable( bool enable )
+bool wxButton::Enable( bool enable )
{
- wxCHECK_RET( m_widget != NULL, _T("invalid button") );
-
- wxControl::Enable( enable );
+ if ( !wxControl::Enable( enable ) )
+ return FALSE;
gtk_widget_set_sensitive( GTK_BUTTON(m_widget)->child, enable );
+
+ return TRUE;
}
void wxButton::ApplyWidgetStyle()
GTK_SIGNAL_FUNC(gtk_checkbox_clicked_callback),
(gpointer *)this );
- m_parent->AddChild( this );
-
- (m_parent->m_insertCallback)( m_parent, this );
+ m_parent->DoAddChild( this );
PostCreation();
gtk_label_set( GTK_LABEL(m_widgetLabel), GetLabel().mbc_str() );
}
-void wxCheckBox::Enable( bool enable )
+bool wxCheckBox::Enable( bool enable )
{
- wxCHECK_RET( m_widgetLabel != NULL, _T("invalid checkbox") );
-
- wxControl::Enable( enable );
+ if ( !wxControl::Enable( enable ) )
+ return FALSE;
gtk_widget_set_sensitive( m_widgetLabel, enable );
+
+ return TRUE;
}
void wxCheckBox::ApplyWidgetStyle()
}
gtk_option_menu_set_menu( GTK_OPTION_MENU(m_widget), menu );
- m_parent->AddChild( this );
-
- (m_parent->m_insertCallback)( m_parent, this );
+ m_parent->DoAddChild( this );
PostCreation();
gtk_widget_show( list_item );
}
- m_parent->AddChild( this );
-
- (m_parent->m_insertCallback)( m_parent, this );
+ m_parent->DoAddChild( this );
PostCreation();
void wxComboBox::OnSize( wxSizeEvent &event )
{
- wxControl::OnSize( event );
+ event.Skip();
return;
if (!window) return;
- GtkWidget *widget = window->m_wxwindow;
- if (!widget) return;
+ GtkWidget *widget = window->GetWxWindow();
+ if (!widget)
+ return;
m_window = widget->window;
/* still not realized ? */
if (!m_window) return;
- if (window->m_wxwindow)
- m_cmap = gtk_widget_get_colormap( window->m_wxwindow );
+ if (window->GetWxWindow())
+ m_cmap = gtk_widget_get_colormap( window->GetWxWindow() );
else
- m_cmap = gtk_widget_get_colormap( window->m_widget );
+ m_cmap = gtk_widget_get_colormap( window->GetHandle() );
m_isMemDC = FALSE;
printf( ".\n" );
*/
- if ((win->m_width != alloc->width) || (win->m_height != alloc->height))
+ if ((win->GetWidth() != alloc->width) || (win->GetHeight() != alloc->height))
{
- win->m_sizeSet = FALSE;
- win->m_width = alloc->width;
- win->m_height = alloc->height;
+ win->InternalSetSize( alloc->width, alloc->height );
}
}
if (!win->HasVMT()) return FALSE;
- win->m_x = event->x;
- win->m_y = event->y;
+ win->InternalSetPosition(event->x, event->y);
- wxMoveEvent mevent( wxPoint(win->m_x,win->m_y), win->GetId() );
+ wxMoveEvent mevent( wxPoint(win->GetX(),win->GetY()), win->GetId() );
mevent.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( mevent );
{
wxIcon icon( win->m_icon );
win->m_icon = wxNullIcon;
- win->SetIcon( icon );
+ win->SetIcon( icon );
}
return FALSE;
{
/* I haven''t been able to set the position of
the dialog before it is shown, so I do it here */
- gtk_widget_set_uposition( widget, win->m_x, win->m_y );
+ gtk_widget_set_uposition( widget, win->GetX(), win->GetY() );
/* all this is for Motif Window Manager "hints" and is supposed to be
recognized by other WM as well. not tested. */
long decor = (long) GDK_DECOR_BORDER;
long func = (long) GDK_FUNC_MOVE ;
- if ((win->m_windowStyle & wxCAPTION) != 0)
- decor |= GDK_DECOR_TITLE;
- if ((win->m_windowStyle & wxSYSTEM_MENU) != 0)
+ if ((win->GetWindowStyle() & wxCAPTION) != 0)
+ decor |= GDK_DECOR_TITLE;
+ if ((win->GetWindowStyle() & wxSYSTEM_MENU) != 0)
{
decor |= GDK_DECOR_MENU;
func |= GDK_FUNC_CLOSE;
}
- if ((win->m_windowStyle & wxMINIMIZE_BOX) != 0)
+ if ((win->GetWindowStyle() & wxMINIMIZE_BOX) != 0)
{
- func |= GDK_FUNC_MINIMIZE;
- decor |= GDK_DECOR_MINIMIZE;
+ func |= GDK_FUNC_MINIMIZE;
+ decor |= GDK_DECOR_MINIMIZE;
}
- if ((win->m_windowStyle & wxMAXIMIZE_BOX) != 0)
+ if ((win->GetWindowStyle() & wxMAXIMIZE_BOX) != 0)
{
- decor |= GDK_DECOR_MAXIMIZE;
- func |= GDK_FUNC_MAXIMIZE;
+ decor |= GDK_DECOR_MAXIMIZE;
+ func |= GDK_FUNC_MAXIMIZE;
}
- if ((win->m_windowStyle & wxRESIZE_BORDER) != 0)
+ if ((win->GetWindowStyle() & wxRESIZE_BORDER) != 0)
{
func |= GDK_FUNC_RESIZE;
decor |= GDK_DECOR_RESIZEH;
}
- gdk_window_set_decorations( win->m_widget->window, (GdkWMDecoration)decor);
- gdk_window_set_functions( win->m_widget->window, (GdkWMFunction)func);
+ gdk_window_set_decorations( win->GetHandle()->window, (GdkWMDecoration)decor);
+ gdk_window_set_functions( win->GetHandle()->window, (GdkWMFunction)func);
/* GTK's shrinking/growing policy */
- if ((win->m_windowStyle & wxRESIZE_BORDER) == 0)
- gtk_window_set_policy(GTK_WINDOW(win->m_widget), 0, 0, 1);
+ if ((win->GetWindowStyle() & wxRESIZE_BORDER) == 0)
+ gtk_window_set_policy(GTK_WINDOW(win->GetHandle()), 0, 0, 1);
else
- gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1);
+ gtk_window_set_policy(GTK_WINDOW(win->GetHandle()), 1, 1, 1);
return FALSE;
}
void wxDialog::Init()
{
+ m_returnCode = 0;
m_sizeSet = FALSE;
m_modalShowing = FALSE;
}
/* we cannot set MWM hints before the widget has
been realized, so we do this directly after realization */
gtk_signal_connect( GTK_OBJECT(m_widget), "realize",
- GTK_SIGNAL_FUNC(gtk_dialog_realized_callback), (gpointer) this );
+ GTK_SIGNAL_FUNC(gtk_dialog_realized_callback), (gpointer) this );
/* we set the position of the window after the map event. setting it
before has no effect (with KWM) */
gtk_signal_connect( GTK_OBJECT(m_widget), "map",
- GTK_SIGNAL_FUNC(gtk_dialog_map_callback), (gpointer) this );
+ GTK_SIGNAL_FUNC(gtk_dialog_map_callback), (gpointer) this );
/* the user resized the frame by dragging etc. */
gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
if ((m_x != -1) || (m_y != -1))
{
if ((m_x != old_x) || (m_y != old_y))
- {
- /* we set the position here and when showing the dialog
- for the first time in idle time */
+ {
+ /* we set the position here and when showing the dialog
+ for the first time in idle time */
gtk_widget_set_uposition( m_widget, m_x, m_y );
- }
+ }
}
if ((m_width != old_width) || (m_height != old_height))
{
/* actual resizing is deferred to GtkOnSize in idle time and
- when showing the dialog */
+ when showing the dialog */
m_sizeSet = FALSE;
}
if (show != m_isShown)
{
if (show)
- {
- gtk_widget_show( m_widget );
- }
+ {
+ gtk_widget_show( m_widget );
+ }
else
gtk_widget_hide( m_widget );
-
+
m_isShown = show;
}
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
-// Licence: wxWindows licence
+// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
/* XPM */
static char * gv_xpm[] = {
"40 34 3 1",
-" s None c None",
-". c black",
-"X c white",
+" s None c None",
+". c black",
+"X c white",
" ",
" ",
" ...... ",
" ",
" ",
" "};
-
+
/* XPM */
static char * page_xpm[] = {
/* width height ncolors chars_per_pixel */
"32 32 5 1",
/* colors */
-" s None c None",
-". c black",
-"X c wheat",
-"o c tan",
-"O c #6699FF",
+" s None c None",
+". c black",
+"X c wheat",
+"o c tan",
+"O c #6699FF",
/* pixels */
" ................... ",
" .XXXXXXXXXXXXXXXXX.. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" ......................... "};
-
-
+
+
// ----------------------------------------------------------------------------
// "drag_leave"
// ----------------------------------------------------------------------------
static void target_drag_leave( GtkWidget *WXUNUSED(widget),
- GdkDragContext *context,
- guint WXUNUSED(time),
- wxDropTarget *drop_target )
+ GdkDragContext *context,
+ guint WXUNUSED(time),
+ wxDropTarget *drop_target )
{
if (g_isIdle) wxapp_install_idle_handler();
/* inform the wxDropTarget about the current GdkDragContext.
this is only valid for the duration of this call */
drop_target->SetDragContext( context );
-
+
/* we don't need return values. this event is just for
information */
drop_target->OnLeave();
-
+
/* this has to be done because GDK has no "drag_enter" event */
drop_target->m_firstMotion = TRUE;
-
+
/* after this, invalidate the drop_target's GdkDragContext */
drop_target->SetDragContext( (GdkDragContext*) NULL );
}
// ----------------------------------------------------------------------------
static gboolean target_drag_motion( GtkWidget *WXUNUSED(widget),
- GdkDragContext *context,
- gint x,
- gint y,
- guint time,
- wxDropTarget *drop_target )
+ GdkDragContext *context,
+ gint x,
+ gint y,
+ guint time,
+ wxDropTarget *drop_target )
{
if (g_isIdle) wxapp_install_idle_handler();
/* Owen Taylor: "if the coordinates not in a drop zone,
return FALSE, otherwise call gtk_drag_status() and
return TRUE" */
-
+
/* inform the wxDropTarget about the current GdkDragContext.
this is only valid for the duration of this call */
drop_target->SetDragContext( context );
-
+
if (drop_target->m_firstMotion)
{
/* the first "drag_motion" event substitutes a "drag_enter" event */
- drop_target->OnEnter();
+ drop_target->OnEnter();
}
-
+
/* give program a chance to react (i.e. to say no by returning FALSE) */
bool ret = drop_target->OnMove( x, y );
-
+
/* we don't yet handle which "actions" (i.e. copy or move)
the target accepts. so far we simply accept the
suggested action. TODO. */
if (ret)
gdk_drag_status( context, context->suggested_action, time );
-
+
/* after this, invalidate the drop_target's GdkDragContext */
drop_target->SetDragContext( (GdkDragContext*) NULL );
-
+
/* this has to be done because GDK has no "drag_enter" event */
drop_target->m_firstMotion = FALSE;
-
+
return ret;
}
// ----------------------------------------------------------------------------
static gboolean target_drag_drop( GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time,
- wxDropTarget *drop_target )
+ GdkDragContext *context,
+ gint x,
+ gint y,
+ guint time,
+ wxDropTarget *drop_target )
{
if (g_isIdle) wxapp_install_idle_handler();
otherwise call gtk_drag_data_get()" */
// printf( "drop.\n" );
-
+
/* this seems to make a difference between not accepting
due to wrong target area and due to wrong format. let
us hope that this is not required.. */
-
+
/* inform the wxDropTarget about the current GdkDragContext.
this is only valid for the duration of this call */
drop_target->SetDragContext( context );
-
+
/* inform the wxDropTarget about the current drag widget.
this is only valid for the duration of this call */
drop_target->SetDragWidget( widget );
-
+
/* inform the wxDropTarget about the current drag time.
this is only valid for the duration of this call */
drop_target->SetDragTime( time );
-
+
bool ret = drop_target->OnDrop( x, y );
-
+
if (!ret)
{
/* cancel the whole thing */
gtk_drag_finish( context,
- FALSE, /* no success */
- FALSE, /* don't delete data on dropping side */
- time );
+ FALSE, /* no success */
+ FALSE, /* don't delete data on dropping side */
+ time );
}
-
+
/* after this, invalidate the drop_target's GdkDragContext */
drop_target->SetDragContext( (GdkDragContext*) NULL );
-
+
/* after this, invalidate the drop_target's drag widget */
drop_target->SetDragWidget( (GtkWidget*) NULL );
-
+
/* this has to be done because GDK has no "drag_enter" event */
drop_target->m_firstMotion = TRUE;
-
+
return ret;
}
// ----------------------------------------------------------------------------
static void target_drag_data_received( GtkWidget *WXUNUSED(widget),
- GdkDragContext *context,
- gint x,
- gint y,
- GtkSelectionData *data,
- guint WXUNUSED(info),
- guint time,
- wxDropTarget *drop_target )
+ GdkDragContext *context,
+ gint x,
+ gint y,
+ GtkSelectionData *data,
+ guint WXUNUSED(info),
+ guint time,
+ wxDropTarget *drop_target )
{
if (g_isIdle) wxapp_install_idle_handler();
success == TRUE" */
// printf( "data received.\n" );
-
+
if ((data->length <= 0) || (data->format != 8))
{
/* negative data length and non 8-bit data format
qualifies for junk */
gtk_drag_finish (context, FALSE, FALSE, time);
-
-// printf( "no data.\n" );
-
- return;
+
+// printf( "no data.\n" );
+
+ return;
}
-
+
/* inform the wxDropTarget about the current GtkSelectionData.
this is only valid for the duration of this call */
drop_target->SetDragData( data );
-
+
if (drop_target->OnData( x, y ))
{
- /* tell GTK that data transfer was successfull */
+ /* tell GTK that data transfer was successfull */
gtk_drag_finish( context, TRUE, FALSE, time );
}
else
{
- /* tell GTK that data transfer was not successfull */
+ /* tell GTK that data transfer was not successfull */
gtk_drag_finish( context, FALSE, FALSE, time );
}
-
+
/* after this, invalidate the drop_target's drag data */
drop_target->SetDragData( (GtkSelectionData*) NULL );
}
{
if (!m_dragContext) return FALSE;
if (!m_dragWidget) return FALSE;
-
+
/*
wxPrintf( _T("format: %s.\n"), format.GetId().c_str() );
if (format.GetType() == wxDF_PRIVATE) wxPrintf( _T("private data.\n") );
*/
/* this should trigger an "drag_data_received" event */
- gtk_drag_get_data( m_dragWidget,
- m_dragContext,
- format.GetAtom(),
- m_dragTime );
-
+ gtk_drag_get_data( m_dragWidget,
+ m_dragContext,
+ format.GetAtom(),
+ m_dragTime );
+
return TRUE;
}
bool wxDropTarget::IsSupported( wxDataFormat format )
-{
+{
if (!m_dragContext) return FALSE;
-
+
GList *child = m_dragContext->targets;
while (child)
{
GdkAtom formatAtom = (GdkAtom) GPOINTER_TO_INT(child->data);
-
+
// char *name = gdk_atom_name( formatAtom );
// if (name) printf( "Format available: %s.\n", name );
-
+
if (formatAtom == format.GetAtom()) return TRUE;
child = child->next;
}
return FALSE;
}
-
+
bool wxDropTarget::GetData( wxDataObject *data_object )
{
if (!m_dragData) return FALSE;
-
+
if (m_dragData->target != data_object->GetFormat().GetAtom()) return FALSE;
-
+
if (data_object->GetFormat().GetType() == wxDF_TEXT)
{
wxTextDataObject *text_object = (wxTextDataObject*)data_object;
text_object->SetText( (const char*)m_dragData->data );
} else
-
+
if (data_object->GetFormat().GetType() == wxDF_FILENAME)
{
} else
-
+
if (data_object->GetFormat().GetType() == wxDF_PRIVATE)
{
- wxPrivateDataObject *priv_object = (wxPrivateDataObject*)data_object;
- priv_object->SetData( (const char*)m_dragData->data, (size_t)m_dragData->length );
+ wxPrivateDataObject *priv_object = (wxPrivateDataObject*)data_object;
+ priv_object->SetData( (const char*)m_dragData->data, (size_t)m_dragData->length );
}
-
+
return TRUE;
}
-
+
void wxDropTarget::UnregisterWidget( GtkWidget *widget )
{
wxCHECK_RET( widget != NULL, _T("unregister widget is NULL") );
-
+
gtk_drag_dest_unset( widget );
-
+
gtk_signal_disconnect_by_func( GTK_OBJECT(widget),
- GTK_SIGNAL_FUNC(target_drag_leave), (gpointer) this );
+ GTK_SIGNAL_FUNC(target_drag_leave), (gpointer) this );
gtk_signal_disconnect_by_func( GTK_OBJECT(widget),
- GTK_SIGNAL_FUNC(target_drag_motion), (gpointer) this );
+ GTK_SIGNAL_FUNC(target_drag_motion), (gpointer) this );
gtk_signal_disconnect_by_func( GTK_OBJECT(widget),
- GTK_SIGNAL_FUNC(target_drag_drop), (gpointer) this );
+ GTK_SIGNAL_FUNC(target_drag_drop), (gpointer) this );
gtk_signal_disconnect_by_func( GTK_OBJECT(widget),
- GTK_SIGNAL_FUNC(target_drag_data_received), (gpointer) this );
+ GTK_SIGNAL_FUNC(target_drag_data_received), (gpointer) this );
}
void wxDropTarget::RegisterWidget( GtkWidget *widget )
{
wxCHECK_RET( widget != NULL, _T("register widget is NULL") );
-
+
/* gtk_drag_dest_set() determines what default behaviour we'd like
GTK to supply. we don't want to specify out targets (=formats)
or actions in advance (i.e. not GTK_DEST_DEFAULT_MOTION and
not GTK_DEST_DEFAULT_DROP). instead we react individually to
"drag_motion" and "drag_drop" events. this makes it possible
- to allow dropping on only a small area. we should set
+ to allow dropping on only a small area. we should set
GTK_DEST_DEFAULT_HIGHLIGHT as this will switch on the nice
highlighting if dragging over standard controls, but this
seems to be broken without the other two. */
-
+
gtk_drag_dest_set( widget,
- (GtkDestDefaults) 0, /* no default behaviour */
- (GtkTargetEntry*) NULL, /* we don't supply any formats here */
- 0, /* number of targets = 0 */
- (GdkDragAction) 0 ); /* we don't supply any actions here */
-
+ (GtkDestDefaults) 0, /* no default behaviour */
+ (GtkTargetEntry*) NULL, /* we don't supply any formats here */
+ 0, /* number of targets = 0 */
+ (GdkDragAction) 0 ); /* we don't supply any actions here */
+
gtk_signal_connect( GTK_OBJECT(widget), "drag_leave",
- GTK_SIGNAL_FUNC(target_drag_leave), (gpointer) this );
+ GTK_SIGNAL_FUNC(target_drag_leave), (gpointer) this );
gtk_signal_connect( GTK_OBJECT(widget), "drag_motion",
- GTK_SIGNAL_FUNC(target_drag_motion), (gpointer) this );
+ GTK_SIGNAL_FUNC(target_drag_motion), (gpointer) this );
gtk_signal_connect( GTK_OBJECT(widget), "drag_drop",
- GTK_SIGNAL_FUNC(target_drag_drop), (gpointer) this );
+ GTK_SIGNAL_FUNC(target_drag_drop), (gpointer) this );
gtk_signal_connect( GTK_OBJECT(widget), "drag_data_received",
- GTK_SIGNAL_FUNC(target_drag_data_received), (gpointer) this );
+ GTK_SIGNAL_FUNC(target_drag_data_received), (gpointer) this );
}
//-------------------------------------------------------------------------
if (IsSupported( wxDF_TEXT ))
{
RequestData( wxDF_TEXT );
- return TRUE;
+ return TRUE;
}
-
+
return FALSE;
}
{
wxTextDataObject data;
if (!GetData( &data )) return FALSE;
-
+
OnDropText( x, y, data.GetText() );
-
+
return TRUE;
}
bool wxPrivateDropTarget::OnDrop( int WXUNUSED(x), int WXUNUSED(y) )
{
if (!IsSupported( m_id ))
- {
+ {
RequestData( m_id );
return FALSE;
}
-
+
return FALSE;
}
bool wxPrivateDropTarget::OnData( int x, int y )
{
if (!IsSupported( m_id )) return FALSE;
-
+
wxPrivateDataObject data;
if (!GetData( &data )) return FALSE;
-
+
OnDropData( x, y, data.GetData(), data.GetSize() );
-
+
return TRUE;
}
if (IsSupported( wxDF_FILENAME ))
{
RequestData( wxDF_FILENAME );
- return TRUE;
+ return TRUE;
}
-
+
return FALSE;
}
if (text[i] == 0) number++;
if (number == 0) return FALSE;
-
+
wxChar **files = new wxChar*[number];
-
+
text = WXSTRINGCAST data.GetFiles();
for (i = 0; i < number; i++)
{
text += len+1;
}
- OnDropFiles( x, y, number, files );
-
+ OnDropFiles( x, y, number, files );
+
free( files );
-
+
return TRUE;
}
// "drag_data_get"
//----------------------------------------------------------------------------
-static void
+static void
source_drag_data_get (GtkWidget *WXUNUSED(widget),
- GdkDragContext *context,
- GtkSelectionData *selection_data,
- guint WXUNUSED(info),
- guint WXUNUSED(time),
- wxDropSource *drop_source )
+ GdkDragContext *context,
+ GtkSelectionData *selection_data,
+ guint WXUNUSED(info),
+ guint WXUNUSED(time),
+ wxDropSource *drop_source )
{
if (g_isIdle) wxapp_install_idle_handler();
// char *name = gdk_atom_name( selection_data->target );
// if (name) printf( "Format requested: %s.\n", name );
-
+
wxNode *node = drop_source->m_data->m_dataObjects.First();
while (node)
{
wxDataObject *data_object = (wxDataObject*) node->Data();
- if (data_object->GetFormat().GetAtom() == selection_data->target)
- {
-// printf( "format found.\n" );
-
- size_t data_size = data_object->GetSize();
-
- if (data_size > 0)
- {
-// printf( "data size: %d.\n", (int)data_size );
-
- guchar *buffer = new guchar[data_size];
- data_object->WriteData( buffer );
-
+ if (data_object->GetFormat().GetAtom() == selection_data->target)
+ {
+// printf( "format found.\n" );
+
+ size_t data_size = data_object->GetSize();
+
+ if (data_size > 0)
+ {
+// printf( "data size: %d.\n", (int)data_size );
+
+ guchar *buffer = new guchar[data_size];
+ data_object->WriteData( buffer );
+
gtk_selection_data_set( selection_data,
- selection_data->target,
- 8, // 8-bit
- buffer,
- data_size );
-
- free( buffer );
-
- /* so far only copy, no moves. TODO. */
+ selection_data->target,
+ 8, // 8-bit
+ buffer,
+ data_size );
+
+ free( buffer );
+
+ /* so far only copy, no moves. TODO. */
drop_source->m_retValue = wxDragCopy;
-
- return;
- }
- }
-
+
+ return;
+ }
+ }
+
node = node->Next();
}
-
+
drop_source->m_retValue = wxDragCancel;
}
-
+
//----------------------------------------------------------------------------
// "drag_data_delete"
//----------------------------------------------------------------------------
static void source_drag_data_delete( GtkWidget *WXUNUSED(widget),
- GdkDragContext *WXUNUSED(context),
- wxDropSource *drop_source )
+ GdkDragContext *WXUNUSED(context),
+ wxDropSource *drop_source )
{
if (g_isIdle) wxapp_install_idle_handler();
drop_source->m_retValue = wxDragMove;
}
-
+
//----------------------------------------------------------------------------
// "drag_begin"
//----------------------------------------------------------------------------
static void source_drag_begin( GtkWidget *WXUNUSED(widget),
- GdkDragContext *WXUNUSED(context),
- wxDropSource *WXUNUSED(drop_source) )
+ GdkDragContext *WXUNUSED(context),
+ wxDropSource *WXUNUSED(drop_source) )
{
if (g_isIdle) wxapp_install_idle_handler();
// printf( "drag_begin.\n" );
}
-
+
//----------------------------------------------------------------------------
// "drag_end"
//----------------------------------------------------------------------------
static void source_drag_end( GtkWidget *WXUNUSED(widget),
- GdkDragContext *WXUNUSED(context),
- wxDropSource *drop_source )
+ GdkDragContext *WXUNUSED(context),
+ wxDropSource *drop_source )
{
if (g_isIdle) wxapp_install_idle_handler();
drop_source->m_waiting = FALSE;
}
-
+
//---------------------------------------------------------------------------
// wxDropSource
//---------------------------------------------------------------------------
{
g_blockEventsOnDrag = TRUE;
m_waiting = TRUE;
-
+
m_window = win;
- m_widget = win->m_widget;
- if (win->m_wxwindow) m_widget = win->m_wxwindow;
-
+ m_widget = win->GetWidget();
+ if (win->GetWxWindow()) m_widget = win->GetWxWindow();
+
m_data = (wxDataBroker*) NULL;
m_retValue = wxDragCancel;
m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
m_goaheadCursor = wxCursor( wxCURSOR_HAND );
-
+
m_goIcon = go;
if (wxNullIcon == go) m_goIcon = wxIcon( page_xpm );
m_stopIcon = stop;
wxDropSource::wxDropSource( wxDataObject *data, wxWindow *win, const wxIcon &go, const wxIcon &stop )
{
m_waiting = TRUE;
-
+
m_window = win;
- m_widget = win->m_widget;
- if (win->m_wxwindow) m_widget = win->m_wxwindow;
+ m_widget = win->GetWidget();
+ if (win->GetWxWindow()) m_widget = win->GetWxWindow();
m_retValue = wxDragCancel;
-
+
if (data)
{
m_data = new wxDataBroker();
- m_data->Add( data );
+ m_data->Add( data );
}
else
{
m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
m_goaheadCursor = wxCursor( wxCURSOR_HAND );
-
+
m_goIcon = go;
if (wxNullIcon == go) m_goIcon = wxIcon( page_xpm );
m_stopIcon = stop;
wxDropSource::wxDropSource( wxDataBroker *data, wxWindow *win )
{
m_window = win;
- m_widget = win->m_widget;
- if (win->m_wxwindow) m_widget = win->m_wxwindow;
+ m_widget = win->GetWidget();
+ if (win->GetWxWindow()) m_widget = win->GetWxWindow();
m_retValue = wxDragCancel;
-
+
m_data = data;
m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
void wxDropSource::SetData( wxDataObject *data )
{
if (m_data) delete m_data;
-
+
if (data)
{
m_data = new wxDataBroker();
- m_data->Add( data );
+ m_data->Add( data );
}
else
{
void wxDropSource::SetData( wxDataBroker *data )
{
if (m_data) delete m_data;
-
+
m_data = data;
}
g_blockEventsOnDrag = FALSE;
}
-
+
wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) )
{
wxASSERT_MSG( m_data, _T("wxDragSource: no data") );
-
+
if (!m_data) return (wxDragResult) wxDragNone;
-
+
g_blockEventsOnDrag = TRUE;
-
+
RegisterWindow();
-
+
m_waiting = TRUE;
GdkAtom atom = gdk_atom_intern( "STRING", FALSE );
GtkTargetList *target_list = gtk_target_list_new( (GtkTargetEntry*) NULL, 0 );
gtk_target_list_add( target_list, atom, 0, 0 );
-
+
GdkEventMotion event;
event.window = m_widget->window;
int x = 0;
event.y = y;
event.state = state;
event.time = GDK_CURRENT_TIME;
-
+
/* GTK wants to know which button was pressed which caused the dragging */
int button_number = 0;
if (event.state & GDK_BUTTON1_MASK) button_number = 1;
{
GdkDragContext *context = gtk_drag_begin( m_widget,
target_list,
- GDK_ACTION_COPY,
- button_number, /* number of mouse button which started drag */
- (GdkEvent*) &event );
-
+ GDK_ACTION_COPY,
+ button_number, /* number of mouse button which started drag */
+ (GdkEvent*) &event );
+
wxMask *mask = m_goIcon.GetMask();
GdkBitmap *bm = (GdkBitmap *) NULL;
if (mask) bm = mask->GetBitmap();
- GdkPixmap *pm = m_goIcon.GetPixmap();
-
+ GdkPixmap *pm = m_goIcon.GetPixmap();
+
gtk_drag_set_icon_pixmap( context,
- gtk_widget_get_colormap( m_widget ),
- pm,
- bm,
- 0,
- 0 );
-
+ gtk_widget_get_colormap( m_widget ),
+ pm,
+ bm,
+ 0,
+ 0 );
+
while (m_waiting) gtk_main_iteration();;
}
g_blockEventsOnDrag = FALSE;
-
+
UnregisterWindow();
return m_retValue;
void wxDropSource::RegisterWindow()
{
if (!m_widget) return;
-
+
gtk_signal_connect( GTK_OBJECT(m_widget), "drag_data_get",
- GTK_SIGNAL_FUNC (source_drag_data_get), (gpointer) this);
+ GTK_SIGNAL_FUNC (source_drag_data_get), (gpointer) this);
gtk_signal_connect (GTK_OBJECT(m_widget), "drag_data_delete",
- GTK_SIGNAL_FUNC (source_drag_data_delete), (gpointer) this );
+ GTK_SIGNAL_FUNC (source_drag_data_delete), (gpointer) this );
gtk_signal_connect (GTK_OBJECT(m_widget), "drag_begin",
- GTK_SIGNAL_FUNC (source_drag_begin), (gpointer) this );
+ GTK_SIGNAL_FUNC (source_drag_begin), (gpointer) this );
gtk_signal_connect (GTK_OBJECT(m_widget), "drag_end",
- GTK_SIGNAL_FUNC (source_drag_end), (gpointer) this );
+ GTK_SIGNAL_FUNC (source_drag_end), (gpointer) this );
}
void wxDropSource::UnregisterWindow()
{
if (!m_widget) return;
-
+
gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget),
- GTK_SIGNAL_FUNC(source_drag_data_get), (gpointer) this );
+ GTK_SIGNAL_FUNC(source_drag_data_get), (gpointer) this );
gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget),
- GTK_SIGNAL_FUNC(source_drag_data_delete), (gpointer) this );
+ GTK_SIGNAL_FUNC(source_drag_data_delete), (gpointer) this );
gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget),
- GTK_SIGNAL_FUNC(source_drag_begin), (gpointer) this );
+ GTK_SIGNAL_FUNC(source_drag_begin), (gpointer) this );
gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget),
- GTK_SIGNAL_FUNC(source_drag_end), (gpointer) this );
+ GTK_SIGNAL_FUNC(source_drag_end), (gpointer) this );
}
#endif
int style = dialog->GetStyle();
- GtkFileSelection *filedlg = GTK_FILE_SELECTION(dialog->m_widget);
+ GtkFileSelection *filedlg = GTK_FILE_SELECTION(dialog->GetHandle());
char *filename = gtk_file_selection_get_filename(filedlg);
if ( (style & wxSAVE) && ( style & wxOVERWRITE_PROMPT ) )
return *this;
}
-bool wxFont::operator == ( const wxFont& font )
+bool wxFont::operator == ( const wxFont& font ) const
{
return m_refData == font.m_refData;
}
-bool wxFont::operator != ( const wxFont& font )
+bool wxFont::operator != ( const wxFont& font ) const
{
return m_refData != font.m_refData;
}
printf( ".\n" );
*/
- if ((win->m_width != alloc->width) || (win->m_height != alloc->height))
+ if ((win->GetWidth() != alloc->width) || (win->GetHeight() != alloc->height))
{
- win->m_sizeSet = FALSE;
- win->m_width = alloc->width;
- win->m_height = alloc->height;
+ win->InternalSetSize( alloc->width, alloc->height );
}
}
if (!win->HasVMT()) return;
win->m_menuBarDetached = FALSE;
- win->m_sizeSet = FALSE;
+ win->UpdateSize();
}
//-----------------------------------------------------------------------------
if (!win->HasVMT()) return;
win->m_menuBarDetached = TRUE;
- win->m_sizeSet = FALSE;
+ win->UpdateSize();
}
//-----------------------------------------------------------------------------
if (!win->HasVMT()) return;
win->m_toolBarDetached = FALSE;
- win->m_sizeSet = FALSE;
+ win->UpdateSize();
}
//-----------------------------------------------------------------------------
if (!win->HasVMT()) return;
win->m_toolBarDetached = TRUE;
- win->m_sizeSet = FALSE;
+ win->UpdateSize();
}
//-----------------------------------------------------------------------------
if (!win->HasVMT()) return FALSE;
- win->m_x = event->x;
- win->m_y = event->y;
+ win->InternalSetPosition(event->x, event->y);
- wxMoveEvent mevent( wxPoint(win->m_x,win->m_y), win->GetId() );
+ wxMoveEvent mevent( wxPoint(win->GetX(),win->GetY()), win->GetId() );
mevent.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( mevent );
long decor = (long) GDK_DECOR_BORDER;
long func = (long) GDK_FUNC_MOVE;
- if ((win->m_windowStyle & wxCAPTION) != 0)
- decor |= GDK_DECOR_TITLE;
- if ((win->m_windowStyle & wxSYSTEM_MENU) != 0)
+ if ((win->GetWindowStyle() & wxCAPTION) != 0)
+ decor |= GDK_DECOR_TITLE;
+ if ((win->GetWindowStyle() & wxSYSTEM_MENU) != 0)
{
decor |= GDK_DECOR_MENU;
func |= GDK_FUNC_CLOSE;
}
- if ((win->m_windowStyle & wxMINIMIZE_BOX) != 0)
+ if ((win->GetWindowStyle() & wxMINIMIZE_BOX) != 0)
{
- func |= GDK_FUNC_MINIMIZE;
- decor |= GDK_DECOR_MINIMIZE;
+ func |= GDK_FUNC_MINIMIZE;
+ decor |= GDK_DECOR_MINIMIZE;
}
- if ((win->m_windowStyle & wxMAXIMIZE_BOX) != 0)
+ if ((win->GetWindowStyle() & wxMAXIMIZE_BOX) != 0)
{
- func |= GDK_FUNC_MAXIMIZE;
- decor |= GDK_DECOR_MAXIMIZE;
+ func |= GDK_FUNC_MAXIMIZE;
+ decor |= GDK_DECOR_MAXIMIZE;
}
- if ((win->m_windowStyle & wxRESIZE_BORDER) != 0)
+ if ((win->GetWindowStyle() & wxRESIZE_BORDER) != 0)
{
func |= GDK_FUNC_RESIZE;
decor |= GDK_DECOR_RESIZEH;
}
- gdk_window_set_decorations( win->m_widget->window, (GdkWMDecoration)decor);
- gdk_window_set_functions( win->m_widget->window, (GdkWMFunction)func);
+ gdk_window_set_decorations( win->GetHandle()->window, (GdkWMDecoration)decor);
+ gdk_window_set_functions( win->GetHandle()->window, (GdkWMFunction)func);
/* GTK's shrinking/growing policy */
- if ((win->m_windowStyle & wxRESIZE_BORDER) == 0)
- gtk_window_set_policy(GTK_WINDOW(win->m_widget), 0, 0, 1);
+ if ((win->GetWindowStyle() & wxRESIZE_BORDER) == 0)
+ gtk_window_set_policy(GTK_WINDOW(win->GetHandle()), 0, 0, 1);
else
- gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1);
+ gtk_window_set_policy(GTK_WINDOW(win->GetHandle()), 1, 1, 1);
/* reset the icon */
if (win->m_icon != wxNullIcon)
{
wxIcon icon( win->m_icon );
win->m_icon = wxNullIcon;
- win->SetIcon( icon );
+ win->SetIcon( icon );
}
/* we set the focus to the child that accepts the focus. this
doesn't really have to be done in "realize" but why not? */
- wxNode *node = win->m_children.First();
+ wxWindowList::Node *node = win->GetChildren().GetFirst();
while (node)
{
- wxWindow *child = (wxWindow*) node->Data();
- if (child->AcceptsFocus())
- {
- child->SetFocus();
- break;
- }
-
- node = node->Next();
+ wxWindow *child = node->GetData();
+ if (child->AcceptsFocus())
+ {
+ child->SetFocus();
+ break;
+ }
+
+ node = node->GetNext();
}
return FALSE;
if (wxIS_KIND_OF(child,wxToolBar) || wxIS_KIND_OF(child,wxMenuBar))
{
/* actually, menubars are never inserted here, but this
- may change one day */
+ may change one day */
/* these are outside the client area */
- wxFrame* frame = (wxFrame*) parent;
+ wxFrame* frame = (wxFrame*) parent;
gtk_myfixed_put( GTK_MYFIXED(frame->m_mainWidget),
- GTK_WIDGET(child->m_widget),
- child->m_x,
- child->m_y,
- child->m_width,
- child->m_height );
-
- /* we connect to these events for recalculating the client area
- space when the toolbar is floating */
- if (wxIS_KIND_OF(child,wxToolBar))
- {
- wxToolBar *toolBar = (wxToolBar*) child;
- if (toolBar->m_windowStyle & wxTB_DOCKABLE)
- {
- gtk_signal_connect( GTK_OBJECT(toolBar->m_widget), "child_attached",
+ GTK_WIDGET(child->GetHandle()),
+ child->GetX(),
+ child->GetY(),
+ child->GetWidth(),
+ child->GetHeight() );
+
+ /* we connect to these events for recalculating the client area
+ space when the toolbar is floating */
+ if (wxIS_KIND_OF(child,wxToolBar))
+ {
+ wxToolBar *toolBar = (wxToolBar*) child;
+ if (toolBar->GetWindowStyle() & wxTB_DOCKABLE)
+ {
+ gtk_signal_connect( GTK_OBJECT(toolBar->GetHandle()), "child_attached",
GTK_SIGNAL_FUNC(gtk_toolbar_attached_callback), (gpointer)parent );
-
- gtk_signal_connect( GTK_OBJECT(toolBar->m_widget), "child_detached",
+
+ gtk_signal_connect( GTK_OBJECT(toolBar->GetHandle()), "child_detached",
GTK_SIGNAL_FUNC(gtk_toolbar_detached_callback), (gpointer)parent );
- }
- }
+ }
+ }
}
else
{
/* these are inside the client area */
- gtk_myfixed_put( GTK_MYFIXED(parent->m_wxwindow),
- GTK_WIDGET(child->m_widget),
- child->m_x,
- child->m_y,
- child->m_width,
- child->m_height );
+ gtk_myfixed_put( GTK_MYFIXED(parent->GetWxWindow()),
+ GTK_WIDGET(child->GetHandle()),
+ child->GetX(),
+ child->GetY(),
+ child->GetWidth(),
+ child->GetHeight() );
}
/* resize on OnInternalIdle */
- parent->m_sizeSet = FALSE;
+ parent->UpdateSize();
}
//-----------------------------------------------------------------------------
/* we cannot set MWM hints and icons before the widget has
been realized, so we do this directly after realization */
gtk_signal_connect( GTK_OBJECT(m_widget), "realize",
- GTK_SIGNAL_FUNC(gtk_frame_realized_callback), (gpointer) this );
+ GTK_SIGNAL_FUNC(gtk_frame_realized_callback), (gpointer) this );
/* the user resized the frame by dragging etc. */
gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
if ((m_x != old_x) || (m_y != old_y))
{
/* we set the size here and in gtk_frame_map_callback */
- gtk_widget_set_uposition( m_widget, m_x, m_y );
+ gtk_widget_set_uposition( m_widget, m_x, m_y );
}
}
if ((m_width != old_width) || (m_height != old_height))
{
/* we set the size in GtkOnSize, i.e. mostly the actual resizing is
- done either directly before the frame is shown or in idle time
- so that different calls to SetSize() don't lead to flicker. */
+ done either directly before the frame is shown or in idle time
+ so that different calls to SetSize() don't lead to flicker. */
m_sizeSet = FALSE;
}
{
/* menu bar */
if (m_frameMenuBar)
- {
- if (!m_menuBarDetached)
- (*height) -= wxMENU_HEIGHT;
- else
- (*height) -= wxPLACE_HOLDER;
- }
-
- /* status bar */
+ {
+ if (!m_menuBarDetached)
+ (*height) -= wxMENU_HEIGHT;
+ else
+ (*height) -= wxPLACE_HOLDER;
+ }
+
+ /* status bar */
if (m_frameStatusBar) (*height) -= wxSTATUS_HEIGHT;
-
- /* tool bar */
+
+ /* tool bar */
if (m_frameToolBar)
{
- if (!m_toolBarDetached)
- {
+ if (!m_toolBarDetached)
+ {
int y = 0;
m_frameToolBar->GetSize( (int *) NULL, &y );
(*height) -= y;
- }
- else
+ }
+ else
(*height) -= wxPLACE_HOLDER;
}
-
- /* mini edge */
+
+ /* mini edge */
(*height) -= m_miniEdge*2 + m_miniTitle;
}
if (width)
/* menu bar */
if (m_frameMenuBar)
- {
- if (!m_menuBarDetached)
- height += wxMENU_HEIGHT;
- else
- height += wxPLACE_HOLDER;
- }
-
- /* status bar */
+ {
+ if (!m_menuBarDetached)
+ height += wxMENU_HEIGHT;
+ else
+ height += wxPLACE_HOLDER;
+ }
+
+ /* status bar */
if (m_frameStatusBar) height += wxSTATUS_HEIGHT;
-
- /* tool bar */
+
+ /* tool bar */
if (m_frameToolBar)
{
- if (!m_toolBarDetached)
- {
+ if (!m_toolBarDetached)
+ {
int y = 0;
m_frameToolBar->GetSize( (int *) NULL, &y );
height += y;
- }
- else
+ }
+ else
height += wxPLACE_HOLDER;
}
-
+
wxWindow::DoSetClientSize( width + m_miniEdge*2, height + m_miniEdge*2 + m_miniTitle );
}
int yy = m_miniEdge + m_miniTitle;
int ww = m_width - 2*m_miniEdge;
int hh = wxMENU_HEIGHT;
- if (m_menuBarDetached) hh = wxPLACE_HOLDER;
- m_frameMenuBar->m_x = xx;
- m_frameMenuBar->m_y = yy;
- m_frameMenuBar->m_width = ww;
- m_frameMenuBar->m_height = hh;
+ if (m_menuBarDetached) hh = wxPLACE_HOLDER;
+ m_frameMenuBar->InternalSetPosition(xx, yy);
+ m_frameMenuBar->InternalSetSize(ww, hh);
gtk_myfixed_set_size( GTK_MYFIXED(m_mainWidget),
- m_frameMenuBar->m_widget,
- xx, yy, ww, hh );
- client_area_y_offset += hh;
+ m_frameMenuBar->GetHandle(),
+ xx, yy, ww, hh );
+ client_area_y_offset += hh;
}
if (m_frameToolBar)
int xx = m_miniEdge;
int yy = m_miniEdge + m_miniTitle;
if (m_frameMenuBar)
- {
- if (!m_menuBarDetached)
- yy += wxMENU_HEIGHT;
- else
- yy += wxPLACE_HOLDER;
- }
+ {
+ if (!m_menuBarDetached)
+ yy += wxMENU_HEIGHT;
+ else
+ yy += wxPLACE_HOLDER;
+ }
int ww = m_width - 2*m_miniEdge;
- int hh = m_frameToolBar->m_height;
- if (m_toolBarDetached) hh = wxPLACE_HOLDER;
- m_frameToolBar->m_x = xx;
- m_frameToolBar->m_y = yy;
- /* m_frameToolBar->m_height = hh; don't change the toolbar's height */
- m_frameToolBar->m_width = ww;
+ int hh = m_frameToolBar->GetHeight();
+ // VZ: according to earlier comments in this file, the tbar height
+ // shouldn't be changed, so I comment out the next line
+ // (09.05.99)
+ //if (m_toolBarDetached) hh = wxPLACE_HOLDER;
+
+ m_frameToolBar->InternalSetPosition(xx, yy);
+ m_frameToolBar->InternalSetSize(ww, hh);
+
gtk_myfixed_set_size( GTK_MYFIXED(m_mainWidget),
- m_frameToolBar->m_widget,
- xx, yy, ww, hh );
- client_area_y_offset += hh;
+ m_frameToolBar->GetHandle(),
+ xx, yy, ww, hh );
+ client_area_y_offset += hh;
}
int client_x = m_miniEdge;
- int client_y = client_area_y_offset + m_miniEdge + m_miniTitle;
+ int client_y = client_area_y_offset + m_miniEdge + m_miniTitle;
int client_w = m_width - 2*m_miniEdge;
- int client_h = m_height - client_area_y_offset- 2*m_miniEdge - m_miniTitle;
+ int client_h = m_height - client_area_y_offset- 2*m_miniEdge - m_miniTitle;
gtk_myfixed_set_size( GTK_MYFIXED(m_mainWidget),
- m_wxwindow,
- client_x, client_y, client_w, client_h );
+ m_wxwindow,
+ client_x, client_y, client_w, client_h );
}
else
{
/* if there is no m_mainWidget between m_widget and m_wxwindow there
- is no need to set the size or position of m_wxwindow. */
+ is no need to set the size or position of m_wxwindow. */
}
if (m_frameStatusBar)
int yy = m_height - wxSTATUS_HEIGHT - m_miniEdge - client_area_y_offset;
int ww = m_width - 2*m_miniEdge;
int hh = wxSTATUS_HEIGHT;
- m_frameStatusBar->m_x = xx;
- m_frameStatusBar->m_y = yy;
- m_frameStatusBar->m_width = ww;
- m_frameStatusBar->m_height = hh;
+ m_frameStatusBar->InternalSetPosition(xx, yy);
+ m_frameStatusBar->InternalSetSize(ww, hh);
gtk_myfixed_set_size( GTK_MYFIXED(m_wxwindow),
- m_frameStatusBar->m_widget,
- xx, yy, ww, hh );
+ m_frameStatusBar->GetHandle(),
+ xx, yy, ww, hh );
}
/* we actually set the size of a frame here and no-where else */
/* send size event to status bar */
if (m_frameStatusBar)
{
- wxSizeEvent event2( wxSize(m_frameStatusBar->m_width,m_frameStatusBar->m_height), m_frameStatusBar->GetId() );
+ wxSizeEvent event2( wxSize(m_frameStatusBar->GetWidth(),m_frameStatusBar->GetHeight()), m_frameStatusBar->GetId() );
event2.SetEventObject( m_frameStatusBar );
m_frameStatusBar->GetEventHandler()->ProcessEvent( event2 );
}
#if (GTK_MINOR_VERSION > 0)
/* support for native hot keys */
- gtk_accel_group_attach( menu->m_accel, GTK_OBJECT(win->m_widget));
+ gtk_accel_group_attach( menu->m_accel, GTK_OBJECT(win->GetHandle()));
#endif
wxNode *node = menu->GetItems().First();
node = node->Next();
}
- if (m_frameMenuBar->m_parent != this)
+ if (m_frameMenuBar->GetParent() != this)
{
- m_frameMenuBar->m_parent = this;
+ m_frameMenuBar->SetParent(this);
gtk_myfixed_put( GTK_MYFIXED(m_mainWidget),
- m_frameMenuBar->m_widget,
- m_frameMenuBar->m_x,
- m_frameMenuBar->m_y,
- m_frameMenuBar->m_width,
- m_frameMenuBar->m_height );
-
- if (menuBar->m_windowStyle & wxMB_DOCKABLE)
- {
- gtk_signal_connect( GTK_OBJECT(menuBar->m_widget), "child_attached",
+ m_frameMenuBar->GetHandle(),
+ m_frameMenuBar->GetX(),
+ m_frameMenuBar->GetY(),
+ m_frameMenuBar->GetWidth(),
+ m_frameMenuBar->GetHeight() );
+
+ if (menuBar->GetWindowStyle() & wxMB_DOCKABLE)
+ {
+ gtk_signal_connect( GTK_OBJECT(menuBar->GetHandle()), "child_attached",
GTK_SIGNAL_FUNC(gtk_menu_attached_callback), (gpointer)this );
-
- gtk_signal_connect( GTK_OBJECT(menuBar->m_widget), "child_detached",
+
+ gtk_signal_connect( GTK_OBJECT(menuBar->GetHandle()), "child_detached",
GTK_SIGNAL_FUNC(gtk_menu_detached_callback), (gpointer)this );
- }
+ }
}
}
m_widget = gtk_progress_bar_new();
- m_parent->AddChild( this );
-
- (m_parent->m_insertCallback)( m_parent, this );
+ m_parent->DoAddChild( this );
PostCreation();
gtk_widget_show( list_item );
}
- m_parent->AddChild( this );
-
- (m_parent->m_insertCallback)( m_parent, this );
+ m_parent->DoAddChild( this );
PostCreation();
gtk_signal_connect( GTK_OBJECT(list_item), "select",
GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );
- if (GetWindowStyleFlag() & wxLB_MULTIPLE)
+ if (HasFlag(wxLB_MULTIPLE))
gtk_signal_connect( GTK_OBJECT(list_item), "deselect",
GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );
#endif
#if wxUSE_TOOLTIPS
- if (m_toolTip) m_toolTip->Apply( this );
+ if (m_tooltip) m_tooltip->Apply( this );
#endif
}
}
if (m_backgroundColour.Ok())
{
GdkWindow *window = GTK_WIDGET(m_list)->window;
- m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) );
- gdk_window_set_background( window, m_backgroundColour.GetColor() );
- gdk_window_clear( window );
+ if ( window )
+ {
+ m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) );
+ gdk_window_set_background( window, m_backgroundColour.GetColor() );
+ gdk_window_clear( window );
+ }
}
GList *child = m_list->children;
wxMenuBar *menu_bar = child_frame->m_menuBar;
if (!menu_bar) return;
- if (!menu_bar->m_widget) return;
+ if (!menu_bar->GetHandle()) return;
- menu_bar->m_x = 0;
- menu_bar->m_y = 0;
- menu_bar->m_width = m_width;
- menu_bar->m_height = wxMENU_HEIGHT;
+ menu_bar->InternalSetPosition(0, 0);
+ menu_bar->InternalSetSize(m_width, wxMENU_HEIGHT);
gtk_myfixed_set_size( GTK_MYFIXED(m_mainWidget),
- menu_bar->m_widget,
- 0, 0, m_width, wxMENU_HEIGHT );
+ menu_bar->GetHandle(),
+ 0, 0, m_width, wxMENU_HEIGHT );
}
void wxMDIParentFrame::OnInternalIdle()
if (m_justInserted)
{
- GtkNotebook *notebook = GTK_NOTEBOOK(m_clientWindow->m_widget);
+ GtkNotebook *notebook = GTK_NOTEBOOK(m_clientWindow->GetHandle());
gtk_notebook_set_page( notebook, g_list_length( notebook->children ) - 1 );
m_justInserted = FALSE;
wxMDIChildFrame *active_child_frame = GetActiveChild();
bool visible_child_menu = FALSE;
- wxNode *node = m_clientWindow->m_children.First();
+ wxNode *node = m_clientWindow->GetChildren().First();
while (node)
{
wxMDIChildFrame *child_frame = (wxMDIChildFrame *)node->Data();
if (child_frame->m_menuBar)
{
if (child_frame == active_child_frame)
- {
- gtk_widget_show( child_frame->m_menuBar->m_widget );
- visible_child_menu = TRUE;
- }
+ {
+ gtk_widget_show( child_frame->m_menuBar->GetHandle() );
+ visible_child_menu = TRUE;
+ }
else
- gtk_widget_hide( child_frame->m_menuBar->m_widget );
+ gtk_widget_hide( child_frame->m_menuBar->GetHandle() );
}
node = node->Next();
}
{
if (!m_clientWindow) return (wxMDIChildFrame*) NULL;
- GtkNotebook *notebook = GTK_NOTEBOOK(m_clientWindow->m_widget);
+ GtkNotebook *notebook = GTK_NOTEBOOK(m_clientWindow->GetHandle());
if (!notebook) return (wxMDIChildFrame*) NULL;
#if (GTK_MINOR_VERSION > 0)
GtkNotebookPage* page = (GtkNotebookPage*) (g_list_nth(notebook->children,i)->data);
if (!page) return (wxMDIChildFrame*) NULL;
- wxNode *node = m_clientWindow->m_children.First();
+ wxNode *node = m_clientWindow->GetChildren().First();
while (node)
{
wxMDIChildFrame *child_frame = (wxMDIChildFrame *)node->Data();
void wxMDIParentFrame::ActivateNext()
{
if (m_clientWindow)
- gtk_notebook_next_page( GTK_NOTEBOOK(m_clientWindow->m_widget) );
+ gtk_notebook_next_page( GTK_NOTEBOOK(m_clientWindow->GetHandle()) );
}
void wxMDIParentFrame::ActivatePrevious()
{
if (m_clientWindow)
- gtk_notebook_prev_page( GTK_NOTEBOOK(m_clientWindow->m_widget) );
+ gtk_notebook_prev_page( GTK_NOTEBOOK(m_clientWindow->GetHandle()) );
}
void wxMDIParentFrame::OnActivate( wxActivateEvent& WXUNUSED(event) )
if (m_menuBar)
{
- wxMDIParentFrame *mdi_frame = (wxMDIParentFrame*)m_parent->m_parent;
+ wxMDIParentFrame *mdi_frame = (wxMDIParentFrame*)m_parent->GetParent();
- if (m_menuBar->m_parent != this)
+ if (m_menuBar->GetParent() != this)
{
wxNode *node = m_menuBar->GetMenus().First();
while (node)
node = node->Next();
}
- m_menuBar->m_parent = mdi_frame;
+ m_menuBar->SetParent( mdi_frame );
}
/* the menu bar of the child window is shown in idle time as needed */
- gtk_widget_hide( m_menuBar->m_widget );
+ gtk_widget_hide( m_menuBar->GetHandle() );
/* insert the invisible menu bar into the _parent_ mdi frame */
gtk_myfixed_put( GTK_MYFIXED(mdi_frame->m_mainWidget),
- m_menuBar->m_widget,
- 0, 0, mdi_frame->m_width, wxMENU_HEIGHT );
+ m_menuBar->GetHandle(),
+ 0, 0, mdi_frame->GetWidth(), wxMENU_HEIGHT );
}
}
{
if (g_isIdle) wxapp_install_idle_handler();
- if ((win->m_x == alloc->x) &&
- (win->m_y == alloc->y) &&
- (win->m_width == alloc->width) &&
- (win->m_height == alloc->height) &&
- (win->m_sizeSet))
+ if ((win->GetX() == alloc->x) &&
+ (win->GetY() == alloc->y) &&
+ (win->GetWidth() == alloc->width) &&
+ (win->GetHeight() == alloc->height) &&
+ (win->IsSizeSet()))
{
return;
}
GtkWidget *label_widget = gtk_label_new( s.mbc_str() );
gtk_misc_set_alignment( GTK_MISC(label_widget), 0.0, 0.5 );
- gtk_signal_connect( GTK_OBJECT(child->m_widget), "size_allocate",
+ gtk_signal_connect( GTK_OBJECT(child->GetHandle()), "size_allocate",
GTK_SIGNAL_FUNC(gtk_page_size_callback), (gpointer)child );
- GtkNotebook *notebook = GTK_NOTEBOOK(parent->m_widget);
+ GtkNotebook *notebook = GTK_NOTEBOOK(parent->GetHandle());
- gtk_notebook_append_page( notebook, child->m_widget, label_widget );
+ gtk_notebook_append_page( notebook, child->GetHandle(), label_widget );
child->m_page = (GtkNotebookPage*) (g_list_last(notebook->children)->data);
- wxMDIParentFrame *parent_frame = (wxMDIParentFrame*) parent->m_parent;
+ wxMDIParentFrame *parent_frame = (wxMDIParentFrame*) parent->GetParent();
parent_frame->m_justInserted = TRUE;
}
gtk_notebook_set_scrollable( GTK_NOTEBOOK(m_widget), 1 );
- m_parent->AddChild( this );
-
- (m_parent->m_insertCallback)( m_parent, this );
+ m_parent->DoAddChild( this );
PostCreation();
return TRUE;
}
-
-
gtk_draw_shadow( widget->style,
widget->window,
- GTK_STATE_NORMAL,
- GTK_SHADOW_OUT,
- 0, 0,
- win->m_width, win->m_height );
+ GTK_STATE_NORMAL,
+ GTK_SHADOW_OUT,
+ 0, 0,
+ win->GetWidth(), win->GetHeight() );
if (!win->m_title.IsEmpty() &&
- ((win->m_windowStyle & wxCAPTION) ||
- (win->m_windowStyle & wxTINY_CAPTION_HORIZ) ||
- (win->m_windowStyle & wxTINY_CAPTION_VERT)))
+ ((win->GetWindowStyle() & wxCAPTION) ||
+ (win->GetWindowStyle() & wxTINY_CAPTION_HORIZ) ||
+ (win->GetWindowStyle() & wxTINY_CAPTION_VERT)))
{
GdkGC *gc = gdk_gc_new( widget->window );
- GdkFont *font = wxSMALL_FONT->GetInternalFont(1.0);
- int x = 2;
- if (win->m_windowStyle & wxSYSTEM_MENU) x = 18;
-
+ GdkFont *font = wxSMALL_FONT->GetInternalFont(1.0);
+ int x = 2;
+ if (win->GetWindowStyle() & wxSYSTEM_MENU) x = 18;
+
gdk_gc_set_foreground( gc, &widget->style->bg[GTK_STATE_SELECTED] );
- gdk_draw_rectangle( widget->window, gc, TRUE,
- x,
- 3,
- win->m_width - 4 - x,
- font->ascent + font->descent+1 );
-
+ gdk_draw_rectangle( widget->window, gc, TRUE,
+ x,
+ 3,
+ win->GetWidth() - 4 - x,
+ font->ascent + font->descent+1 );
+
gdk_gc_set_foreground( gc, &widget->style->white );
gdk_draw_string( widget->window, font, gc,
- x+2,
- 3+font->ascent,
- win->m_title.mb_str() );
-
+ x+2,
+ 3+font->ascent,
+ win->m_title.mb_str() );
+
gdk_gc_unref( gc );
}
}
gtk_draw_shadow( widget->style,
widget->window,
- GTK_STATE_NORMAL,
- GTK_SHADOW_OUT,
- 0, 0,
- win->m_width, win->m_height );
-
+ GTK_STATE_NORMAL,
+ GTK_SHADOW_OUT,
+ 0, 0,
+ win->GetWidth(), win->GetHeight() );
+
if (!win->m_title.IsEmpty() &&
- ((win->m_windowStyle & wxCAPTION) ||
- (win->m_windowStyle & wxTINY_CAPTION_HORIZ) ||
- (win->m_windowStyle & wxTINY_CAPTION_VERT)))
+ ((win->GetWindowStyle() & wxCAPTION) ||
+ (win->GetWindowStyle() & wxTINY_CAPTION_HORIZ) ||
+ (win->GetWindowStyle() & wxTINY_CAPTION_VERT)))
{
GdkGC *gc = gdk_gc_new( widget->window );
- GdkFont *font = wxSMALL_FONT->GetInternalFont(1.0);
- int x = 2;
- if (win->m_windowStyle & wxSYSTEM_MENU) x = 17;
-
+ GdkFont *font = wxSMALL_FONT->GetInternalFont(1.0);
+ int x = 2;
+ if (win->GetWindowStyle() & wxSYSTEM_MENU) x = 17;
+
gdk_gc_set_foreground( gc, &widget->style->bg[GTK_STATE_SELECTED] );
- gdk_draw_rectangle( widget->window, gc, TRUE,
- x,
- 3,
- win->m_width - 4 - x,
- font->ascent + font->descent+1 );
-
+ gdk_draw_rectangle( widget->window, gc, TRUE,
+ x,
+ 3,
+ win->GetWidth() - 4 - x,
+ font->ascent + font->descent+1 );
+
gdk_gc_set_foreground( gc, &widget->style->white );
gdk_draw_string( widget->window, font, gc,
- x+2,
- 3+font->ascent,
- win->m_title.mb_str() );
-
+ x+2,
+ 3+font->ascent,
+ win->m_title.mb_str() );
+
gdk_gc_unref( gc );
}
}
(GdkEventMask)
(GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
- GDK_POINTER_MOTION_MASK |
+ GDK_POINTER_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK |
- GDK_BUTTON_MOTION_MASK |
+ GDK_BUTTON_MOTION_MASK |
GDK_BUTTON1_MOTION_MASK),
(GdkWindow *) NULL,
(GdkCursor *) NULL,
GDK_CURRENT_TIME );
-
+
win->m_diffX = (int)gdk_event->x;
win->m_diffY = (int)gdk_event->y;
- DrawFrame( widget, 0, 0, win->m_width, win->m_height );
+ DrawFrame( widget, 0, 0, win->GetWidth(), win->GetHeight() );
win->m_oldX = 0;
win->m_oldY = 0;
int x = (int)gdk_event->x;
int y = (int)gdk_event->y;
- DrawFrame( widget, win->m_oldX, win->m_oldY, win->m_width, win->m_height );
+ DrawFrame( widget, win->m_oldX, win->m_oldY, win->GetWidth(), win->GetHeight() );
gdk_pointer_ungrab ( GDK_CURRENT_TIME );
int org_x = 0;
int org_y = 0;
gdk_window_get_origin( widget->window, &org_x, &org_y );
x += org_x - win->m_diffX;
y += org_y - win->m_diffY;
- win->m_x = x;
- win->m_y = y;
- gtk_widget_set_uposition( win->m_widget, x, y );
+ win->InternalSetPosition(x, y);
+ gtk_widget_set_uposition( win->GetWidget(), x, y );
return TRUE;
}
gdk_event->state = state;
}
- DrawFrame( widget, win->m_oldX, win->m_oldY, win->m_width, win->m_height );
+ DrawFrame( widget, win->m_oldX, win->m_oldY, win->GetWidth(), win->GetHeight() );
win->m_oldX = (int)gdk_event->x - win->m_diffX;
win->m_oldY = (int)gdk_event->y - win->m_diffY;
- DrawFrame( widget, win->m_oldX, win->m_oldY, win->m_width, win->m_height );
+ DrawFrame( widget, win->m_oldX, win->m_oldY, win->GetWidth(), win->GetHeight() );
return TRUE;
}
if ((style & wxCAPTION) || (style & wxTINY_CAPTION_HORIZ) || (style & wxTINY_CAPTION_VERT))
m_miniTitle = 13;
-
+
m_miniEdge = 3;
m_isDragging = FALSE;
m_oldX = -1;
GtkWidget *close_button = gtk_button_new_with_label( "x" );
gtk_myfixed_put( GTK_MYFIXED(m_mainWidget),
- close_button,
- 4, 4, 12, 11 );
+ close_button,
+ 4, 4, 12, 11 );
gtk_widget_show( close_button );
{
if (g_isIdle) wxapp_install_idle_handler();
- if ((win->m_x == alloc->x) &&
- (win->m_y == alloc->y) &&
- (win->m_width == alloc->width) &&
- (win->m_height == alloc->height))
+ if ((win->GetX() == alloc->x) &&
+ (win->GetY() == alloc->y) &&
+ (win->GetWidth() == alloc->width) &&
+ (win->GetHeight() == alloc->height))
{
return;
}
page->m_box = gtk_hbox_new (FALSE, 0);
gtk_container_border_width(GTK_CONTAINER(page->m_box), 2);
- GtkNotebook *notebook = GTK_NOTEBOOK(parent->m_widget);
+ GtkNotebook *notebook = GTK_NOTEBOOK(parent->GetWidget());
page->m_client = child;
- gtk_notebook_append_page( notebook, child->m_widget, page->m_box );
+ gtk_notebook_append_page( notebook, child->GetWidget(), page->m_box );
page->m_page = (GtkNotebookPage*) (g_list_last(notebook->children)->data);
page->m_parent = notebook;
- gtk_signal_connect( GTK_OBJECT(child->m_widget), "size_allocate",
+ gtk_signal_connect( GTK_OBJECT(child->GetWidget()), "size_allocate",
GTK_SIGNAL_FUNC(gtk_page_size_callback), (gpointer)child );
wxASSERT_MSG( page->m_page, _T("Notebook page creation error") );
GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback),
(gpointer)this );
- m_parent->AddChild( this );
-
- (m_parent->m_insertCallback)( m_parent, this );
+ m_parent->DoAddChild( this );
gtk_signal_connect( GTK_OBJECT(m_widget), "key_press_event",
GTK_SIGNAL_FUNC(gtk_notebook_key_press_callback), (gpointer)this );
EVT_SIZE(wxRadioBox::OnSize)
END_EVENT_TABLE()
-wxRadioBox::wxRadioBox(void)
+wxRadioBox::wxRadioBox()
{
}
gtk_signal_connect( GTK_OBJECT(m_radio), "clicked",
GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this );
- gtk_myfixed_put( GTK_MYFIXED(m_parent->m_wxwindow),
- GTK_WIDGET(m_radio),
- m_x+10, m_y+10+(i*24), 10, 10 );
+ gtk_myfixed_put( GTK_MYFIXED(m_parent->GetWxWindow()),
+ GTK_WIDGET(m_radio),
+ m_x+10, m_y+10+(i*24), 10, 10 );
}
wxSize ls = LayoutItems();
if (newSize.y == -1) newSize.y = ls.y;
SetSize( newSize.x, newSize.y );
- m_parent->AddChild( this );
-
- (m_parent->m_insertCallback)( m_parent, this );
+ m_parent->DoAddChild( this );
PostCreation();
return TRUE;
}
-wxRadioBox::~wxRadioBox(void)
+wxRadioBox::~wxRadioBox()
{
wxNode *node = m_boxes.First();
while (node)
void wxRadioBox::OnSize( wxSizeEvent &event )
{
- wxControl::OnSize( event );
-
LayoutItems();
+
+ event.Skip();
}
wxSize wxRadioBox::LayoutItems()
int len = 22+gdk_string_measure( font, label->label );
if (len > max_len) max_len = len;
- gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), button, m_x+x, m_y+y );
+ gtk_myfixed_move( GTK_MYFIXED(m_parent->GetWxWindow()), button, m_x+x, m_y+y );
y += 20;
node = node->Next();
{
GtkWidget *button = GTK_WIDGET( node->Data() );
- gtk_myfixed_resize( GTK_MYFIXED(m_parent->m_wxwindow), button, max_len, 20 );
+ gtk_myfixed_resize( GTK_MYFIXED(m_parent->GetWxWindow()), button, max_len, 20 );
node = node->Next();
if (!node) break;
{
GtkWidget *button = GTK_WIDGET( node->Data() );
- gtk_myfixed_set_size( GTK_MYFIXED(m_parent->m_wxwindow), button, m_x+x, m_y+y, max, 20 );
+ gtk_myfixed_set_size( GTK_MYFIXED(m_parent->GetWxWindow()), button, m_x+x, m_y+y, max, 20 );
x += max;
node = node->Next();
wxFAIL_MSG(_T("wxRadioBox::SetLabel not implemented."));
}
-void wxRadioBox::Enable( bool enable )
+bool wxRadioBox::Enable( bool enable )
{
- wxControl::Enable( enable );
+ if ( !wxControl::Enable( enable ) )
+ return FALSE;
wxNode *node = m_boxes.First();
while (node)
gtk_widget_set_sensitive( label, enable );
node = node->Next();
}
+
+ return TRUE;
}
void wxRadioBox::Enable( int item, bool enable )
gtk_signal_connect( GTK_OBJECT(m_widget), "clicked",
GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this );
- m_parent->AddChild( this );
-
- (m_parent->m_insertCallback)( m_parent, this );
+ m_parent->DoAddChild( this );
PostCreation();
return GTK_TOGGLE_BUTTON(m_widget)->active;
}
-void wxRadioButton::Enable( bool enable )
+bool wxRadioButton::Enable( bool enable )
{
- wxCHECK_RET( m_widget != NULL, _T("invalid radiobutton") );
-
- wxControl::Enable( enable );
+ if ( !wxControl::Enable( enable ) )
+ return FALSE;
gtk_widget_set_sensitive( GTK_BUTTON(m_widget)->child, enable );
+
+ return TRUE;
}
void wxRadioButton::ApplyWidgetStyle()
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
float line_step = win->m_adjust->step_increment;
float page_step = win->m_adjust->page_increment;
- if (win->m_isScrolling)
+ if (win->IsScrolling())
{
command = wxEVT_SCROLL_THUMBTRACK;
}
int value = (int)(win->m_adjust->value+0.5);
- int orient = wxHORIZONTAL;
- if (win->GetWindowStyleFlag() & wxSB_VERTICAL == wxSB_VERTICAL) orient = wxVERTICAL;
+ int orient = win->HasFlag(wxSB_VERTICAL) ? wxVERTICAL : wxHORIZONTAL;
wxScrollEvent event( command, win->GetId(), value, orient );
event.SetEventObject( win );
static gint gtk_scrollbar_button_press_callback( GtkRange *WXUNUSED(widget),
GdkEventButton *WXUNUSED(gdk_event),
- wxScrollBar *win )
+ wxScrollBar *win )
{
if (g_isIdle) wxapp_install_idle_handler();
- win->m_isScrolling = TRUE;
+ win->SetScrolling(TRUE);
// g_blockEventsOnScroll = TRUE; doesn't work in DialogEd
return FALSE;
static gint gtk_scrollbar_button_release_callback( GtkRange *WXUNUSED(widget),
GdkEventButton *WXUNUSED(gdk_event),
- wxScrollBar *win )
+ wxScrollBar *win )
{
if (g_isIdle) wxapp_install_idle_handler();
- win->m_isScrolling = FALSE;
+ win->SetScrolling(FALSE);
// g_blockEventsOnScroll = FALSE;
gtk_signal_emit_by_name( GTK_OBJECT(win->m_adjust), "value_changed" );
gtk_signal_connect( GTK_OBJECT(m_adjust),
"value_changed",
- (GtkSignalFunc) gtk_scrollbar_callback,
- (gpointer) this );
+ (GtkSignalFunc) gtk_scrollbar_callback,
+ (gpointer) this );
gtk_signal_connect( GTK_OBJECT(m_widget),
"button_press_event",
(GtkSignalFunc)gtk_scrollbar_button_press_callback,
- (gpointer) this );
+ (gpointer) this );
gtk_signal_connect( GTK_OBJECT(m_widget),
"button_release_event",
(GtkSignalFunc)gtk_scrollbar_button_release_callback,
- (gpointer) this );
+ (gpointer) this );
- m_parent->AddChild( this );
-
- (m_parent->m_insertCallback)( m_parent, this );
+ m_parent->DoAddChild( this );
PostCreation();
GtkRange *range = GTK_RANGE(m_widget);
return ( (window == GTK_WIDGET(range)->window) ||
(window == range->trough) ||
- (window == range->slider) ||
- (window == range->step_forw) ||
- (window == range->step_back) );
+ (window == range->slider) ||
+ (window == range->step_forw) ||
+ (window == range->step_back) );
}
void wxScrollBar::ApplyWidgetStyle()
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
if (style & wxSL_LABELS)
{
gtk_scale_set_draw_value( GTK_SCALE( m_widget ), TRUE );
-
- /* labels need more space and too small window will
- cause junk to appear on the dialog */
+
+ /* labels need more space and too small window will
+ cause junk to appear on the dialog */
if (style & wxSL_VERTICAL)
- {
- wxSize sz( size );
- if (sz.x < 35)
- {
- sz.x = 35;
- SetSize( sz );
- }
- }
+ {
+ wxSize sz( size );
+ if (sz.x < 35)
+ {
+ sz.x = 35;
+ SetSize( sz );
+ }
+ }
else
- {
- wxSize sz( size );
- if (sz.y < 35)
- {
- sz.y = 35;
- SetSize( sz );
- }
- }
+ {
+ wxSize sz( size );
+ if (sz.y < 35)
+ {
+ sz.y = 35;
+ SetSize( sz );
+ }
+ }
}
else
gtk_scale_set_draw_value( GTK_SCALE( m_widget ), FALSE );
gtk_signal_connect( GTK_OBJECT(m_adjust),
"value_changed",
- (GtkSignalFunc) gtk_slider_callback,
- (gpointer) this );
-
+ (GtkSignalFunc) gtk_slider_callback,
+ (gpointer) this );
+
SetRange( minValue, maxValue );
SetValue( value );
- m_parent->AddChild( this );
-
- (m_parent->m_insertCallback)( m_parent, this );
+ m_parent->DoAddChild( this );
PostCreation();
GtkRange *range = GTK_RANGE(m_widget);
return ( (window == GTK_WIDGET(range)->window) ||
(window == range->trough) ||
- (window == range->slider) ||
- (window == range->step_forw) ||
- (window == range->step_back) );
+ (window == range->slider) ||
+ (window == range->step_forw) ||
+ (window == range->step_back) );
}
void wxSlider::ApplyWidgetStyle()
(GtkSignalFunc) gtk_spinbutt_callback,
(gpointer) this );
- m_parent->AddChild( this );
-
- (m_parent->m_insertCallback)( m_parent, this );
+ m_parent->DoAddChild( this );
PostCreation();
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
m_widget = gtk_label_new( "Bitmap" );
}
- m_parent->AddChild( this );
-
- (m_parent->m_insertCallback)( m_parent, this );
+ m_parent->DoAddChild( this );
PostCreation();
m_widget = gtk_frame_new(m_label.mbc_str());
- m_parent->AddChild( this );
-
- (m_parent->m_insertCallback)( m_parent, this );
+ m_parent->DoAddChild( this );
PostCreation();
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
else
m_widget = gtk_hseparator_new();
- m_parent->AddChild( this );
-
- (m_parent->m_insertCallback)( m_parent, this );
+ m_parent->DoAddChild( this );
PostCreation();
SetSize( newSize.x, newSize.y );
- m_parent->AddChild( this );
-
- (m_parent->m_insertCallback)( m_parent, this );
+ m_parent->DoAddChild( this );
PostCreation();
if (tool->m_enabled)
{
if (tb->m_fg->red != 0)
- {
+ {
tb->m_fg->red = 0;
tb->m_fg->green = 0;
tb->m_fg->blue = 0;
gdk_color_alloc( gtk_widget_get_colormap( GTK_WIDGET(tb->m_toolbar) ), tb->m_fg );
-
+
#if (GTK_MINOR_VERSION > 0)
GtkStyle *g_style =
gtk_style_copy(
gtk_widget_get_style(
GTK_TOOLBAR(tb->m_toolbar)->tooltips->tip_window ) );
-
+
g_style->fg[GTK_STATE_NORMAL] = *tb->m_fg;
gtk_widget_set_style( GTK_TOOLBAR(tb->m_toolbar)->tooltips->tip_window, g_style );
#else
gtk_tooltips_set_colors( GTK_TOOLBAR(tb->m_toolbar)->tooltips, tb->m_bg, tb->m_fg );
#endif
- }
+ }
}
else
{
if (tb->m_fg->red == 0)
- {
+ {
tb->m_fg->red = 33000;
tb->m_fg->green = 33000;
tb->m_fg->blue = 33000;
gtk_style_copy(
gtk_widget_get_style(
GTK_TOOLBAR(tb->m_toolbar)->tooltips->tip_window ) );
-
+
g_style->fg[GTK_STATE_NORMAL] = *tb->m_fg;
gtk_widget_set_style( GTK_TOOLBAR(tb->m_toolbar)->tooltips->tip_window, g_style );
#else
gtk_tooltips_set_colors( GTK_TOOLBAR(tb->m_toolbar)->tooltips, tb->m_bg, tb->m_fg );
#endif
- }
+ }
}
/* emit the event */
if (style & wxTB_DOCKABLE)
{
m_widget = gtk_handle_box_new();
- gtk_container_add( GTK_CONTAINER(m_widget), GTK_WIDGET(m_toolbar) );
- gtk_widget_show( GTK_WIDGET(m_toolbar) );
-
+ gtk_container_add( GTK_CONTAINER(m_widget), GTK_WIDGET(m_toolbar) );
+ gtk_widget_show( GTK_WIDGET(m_toolbar) );
+
#if (GTK_MINOR_VERSION > 0)
- if (style & wxTB_FLAT)
+ if (style & wxTB_FLAT)
gtk_handle_box_set_shadow_type( GTK_HANDLE_BOX(m_widget), GTK_SHADOW_NONE );
#endif
}
{
m_widget = GTK_WIDGET(m_toolbar);
}
-
+
gtk_toolbar_set_tooltips( GTK_TOOLBAR(m_toolbar), TRUE );
#if (GTK_MINOR_VERSION > 0)
gtk_style_copy(
gtk_widget_get_style(
GTK_TOOLBAR(m_toolbar)->tooltips->tip_window ) );
-
+
g_style->bg[GTK_STATE_NORMAL] = *m_bg;
gtk_widget_set_style( GTK_TOOLBAR(m_toolbar)->tooltips->tip_window, g_style );
#else
m_xMargin = 0;
m_yMargin = 0;
- m_parent->AddChild( this );
-
- (m_parent->m_insertCallback)( m_parent, this );
+ m_parent->DoAddChild( this );
PostCreation();
wxToolBarTool *tool = new wxToolBarTool( this, toolIndex, bitmap, pushedBitmap,
toggle, clientData,
helpString1, helpString2,
- tool_pixmap );
+ tool_pixmap );
GtkToolbarChildType ctype = toggle ? GTK_TOOLBAR_CHILD_TOGGLEBUTTON
: GTK_TOOLBAR_CHILD_BUTTON;
if (tool->m_index == toolIndex)
{
tool->m_enabled = enable;
-
+
/* we don't disable the tools for now as the bitmaps don't get
greyed anyway and this also disables tooltips
- if (tool->m_item)
- gtk_widget_set_sensitive( tool->m_item, enable );
+ if (tool->m_item)
+ gtk_widget_set_sensitive( tool->m_item, enable );
*/
-
+
return;
}
node = node->Next();
if (tool->m_index == toolIndex)
{
tool->m_longHelpString = helpString;
- return;
+ return;
}
node = node->Next();
}
if (tool->m_index == toolIndex)
{
tool->m_shortHelpString = helpString;
- return;
+ return;
}
node = node->Next();
}
{
if (g_isIdle) wxapp_install_idle_handler();
- if (!win->m_hasVMT) return;
+ if (!win->HasVMT()) return;
win->SetModified();
- wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, win->m_windowId );
+ wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, win->GetId() );
event.SetString( win->GetValue() );
event.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( event );
if (g_isIdle) wxapp_install_idle_handler();
win->CalculateScrollbar();
-
- if (!win->m_hasVMT) return;
+
+ if (!win->HasVMT()) return;
}
//-----------------------------------------------------------------------------
/* ... and put into the upper left hand corner of the table */
m_widget = gtk_table_new(bHasHScrollbar ? 2 : 1, 2, FALSE);
GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
-
gtk_table_attach( GTK_TABLE(m_widget), m_text, 0, 1, 0, 1,
(GtkAttachOptions)(GTK_FILL | GTK_EXPAND | GTK_SHRINK),
(GtkAttachOptions)(GTK_FILL | GTK_EXPAND | GTK_SHRINK),
/* always wrap words */
gtk_text_set_word_wrap( GTK_TEXT(m_text), TRUE );
-
/* put the horizontal scrollbar in the lower left hand corner */
if (bHasHScrollbar)
{
GtkWidget *hscrollbar = gtk_hscrollbar_new(GTK_TEXT(m_text)->hadj);
GTK_WIDGET_UNSET_FLAGS( hscrollbar, GTK_CAN_FOCUS );
-
gtk_table_attach(GTK_TABLE(m_widget), hscrollbar, 0, 1, 1, 2,
(GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
GTK_FILL,
gtk_text_set_line_wrap( GTK_TEXT(m_text), FALSE );
#endif
}
-
/* finally, put the vertical scrollbar in the upper right corner */
m_vScrollbar = gtk_vscrollbar_new( GTK_TEXT(m_text)->vadj );
GTK_WIDGET_UNSET_FLAGS( m_vScrollbar, GTK_CAN_FOCUS );
-
gtk_table_attach(GTK_TABLE(m_widget), m_vScrollbar, 1, 2, 0, 1,
GTK_FILL,
(GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK),
if (newSize.y == -1) newSize.y = 26;
SetSize( newSize.x, newSize.y );
- m_parent->AddChild( this );
-
- (m_parent->m_insertCallback)( m_parent, this );
+ m_parent->DoAddChild( this );
PostCreation();
return (window == GTK_ENTRY(m_text)->text_area);
}
-void wxTextCtrl::SetFont( const wxFont &WXUNUSED(font) )
+bool wxTextCtrl::SetFont( const wxFont &WXUNUSED(font) )
{
- wxCHECK_RET( m_text != NULL, _T("invalid text ctrl") );
+ wxCHECK_MSG( m_text != NULL, FALSE, _T("invalid text ctrl") );
// doesn't work
+ return FALSE;
}
-void wxTextCtrl::SetForegroundColour( const wxColour &WXUNUSED(colour) )
+bool wxTextCtrl::SetForegroundColour( const wxColour &WXUNUSED(colour) )
{
- wxCHECK_RET( m_text != NULL, _T("invalid text ctrl") );
+ wxCHECK_MSG( m_text != NULL, FALSE, _T("invalid text ctrl") );
// doesn't work
+ return FALSE;
}
-void wxTextCtrl::SetBackgroundColour( const wxColour &colour )
+bool wxTextCtrl::SetBackgroundColour( const wxColour &colour )
{
- wxCHECK_RET( m_text != NULL, _T("invalid text ctrl") );
+ wxCHECK_MSG( m_text != NULL, FALSE, _T("invalid text ctrl") );
wxControl::SetBackgroundColour( colour );
- if (!m_widget->window) return;
+ if (!m_widget->window)
+ return FALSE;
wxColour sysbg = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE );
if (sysbg.Red() == colour.Red() &&
sysbg.Green() == colour.Green() &&
sysbg.Blue() == colour.Blue())
{
- return;
+ return FALSE; // FIXME or TRUE?
}
- if (!m_backgroundColour.Ok()) return;
+ if (!m_backgroundColour.Ok())
+ return FALSE;
if (m_windowStyle & wxTE_MULTILINE)
{
GdkWindow *window = GTK_TEXT(m_text)->text_area;
- if (!window) return;
+ if (!window)
+ return FALSE;
m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) );
gdk_window_set_background( window, m_backgroundColour.GetColor() );
gdk_window_clear( window );
}
+
+ return TRUE;
}
void wxTextCtrl::ApplyWidgetStyle()
SetValidator(validator);
printf("Robert's new insertion code :-)\n");
- m_parent->AddChild( this );
- (m_parent->m_insertCallback)( m_parent, this );
-
+ m_parent->DoAddChild( this );
printf("postcreate\n");
PostCreation();
*/
+//-----------------------------------------------------------------------------
+// data
+//-----------------------------------------------------------------------------
+
+extern wxList wxPendingDelete;
+extern bool g_blockEventsOnDrag;
+extern bool g_blockEventsOnScroll;
+static bool g_capturing = FALSE;
+static wxWindow *g_focusWindow = (wxWindow*) NULL;
+
+/* hack: we need something to pass to gtk_menu_popup, so we store the time of
+ the last click here */
+static guint32 gs_timeLastClick = 0;
+
//-----------------------------------------------------------------------------
// debug
//-----------------------------------------------------------------------------
GTK_SIGNAL_FUNC(gtk_debug_focus_in_callback), (gpointer)s );
}
-#endif
-
-//-----------------------------------------------------------------------------
-// data
-//-----------------------------------------------------------------------------
-
-extern wxList wxPendingDelete;
-extern bool g_blockEventsOnDrag;
-extern bool g_blockEventsOnScroll;
-extern bool g_isIdle;
-static bool g_capturing = FALSE;
-static wxWindow *g_focusWindow = (wxWindow*) NULL;
-
-/* hack: we need something to pass to gtk_menu_popup, so we store the time of
- the last click here */
-static guint32 gs_timeLastClick = 0;
+#endif // Debug
//-----------------------------------------------------------------------------
-// idle system
+// local code (see below)
//-----------------------------------------------------------------------------
-extern void wxapp_install_idle_handler();
-extern bool g_isIdle;
+static void InitAdjustment(GtkAdjustment *adjust)
+{
+ adjust->lower = 0.0;
+ adjust->upper = 1.0;
+ adjust->value = 0.0;
+ adjust->step_increment = 1.0;
+ adjust->page_increment = 1.0;
+ adjust->page_size = 5.0;
+ gtk_signal_emit_by_name( GTK_OBJECT(adjust), "changed" );
+}
#if (GTK_MINOR_VERSION > 0)
-//-----------------------------------------------------------------------------
-// local code (see below)
-//-----------------------------------------------------------------------------
-
static void draw_frame( GtkWidget *widget, wxWindow *win )
{
- if (!win->HasVMT()) return;
+ if (!win->HasVMT())
+ return;
int dw = 0;
int dh = 0;
- if (win->m_hasScrolling)
+ if (win->HasScrolling())
{
GtkScrolledWindow *scroll_window = GTK_SCROLLED_WINDOW(widget);
GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(widget)->klass );
GtkWidget *hscrollbar = scroll_window->hscrollbar;
GtkWidget *vscrollbar = scroll_window->vscrollbar;
- we use this instead: range.slider_width = 11 + 2*2pts edge
+ we use this instead: range.slider_width = 11 + 2*2pts edge
*/
if (scroll_window->vscrollbar_visible)
dy += widget->allocation.y;
}
- if (win->m_windowStyle & wxRAISED_BORDER)
+ if (win->HasFlag(wxRAISED_BORDER))
{
gtk_draw_shadow( widget->style,
widget->window,
- GTK_STATE_NORMAL,
- GTK_SHADOW_OUT,
- dx, dy,
- win->m_width-dw, win->m_height-dh );
- return;
+ GTK_STATE_NORMAL,
+ GTK_SHADOW_OUT,
+ dx, dy,
+ win->GetWidth()-dw, win->GetHeight()-dh );
+ return;
}
- if (win->m_windowStyle & wxSUNKEN_BORDER)
+ if (win->HasFlag(wxSUNKEN_BORDER))
{
gtk_draw_shadow( widget->style,
widget->window,
- GTK_STATE_NORMAL,
- GTK_SHADOW_IN,
- dx, dy,
- win->m_width-dw, win->m_height-dh );
- return;
+ GTK_STATE_NORMAL,
+ GTK_SHADOW_IN,
+ dx, dy,
+ win->GetWidth()-dw, win->GetHeight()-dh );
+ return;
}
}
draw_frame( widget, win );
}
-#endif
+#endif // GTK_MINOR_VERSION > 0
//-----------------------------------------------------------------------------
// "expose_event" of m_wxwindow
static void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExpose *gdk_event, wxWindow *win )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
- if (!win->HasVMT()) return;
+ if ( !win->HasVMT() )
+ return;
- win->m_updateRegion.Union( gdk_event->area.x,
- gdk_event->area.y,
- gdk_event->area.width,
- gdk_event->area.height );
+ win->GetUpdateRegion().Union( gdk_event->area.x,
+ gdk_event->area.y,
+ gdk_event->area.width,
+ gdk_event->area.height );
- if (gdk_event->count > 0) return;
+ if ( gdk_event->count > 0 )
+ return;
/*
printf( "OnExpose from " );
event.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( event );
- win->m_updateRegion.Clear();
+ win->GetUpdateRegion().Clear();
}
//-----------------------------------------------------------------------------
static void gtk_window_draw_callback( GtkWidget *WXUNUSED(widget), GdkRectangle *rect, wxWindow *win )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
- if (!win->HasVMT()) return;
+ if ( !win->HasVMT() )
+ return;
- win->m_updateRegion.Union( rect->x, rect->y, rect->width, rect->height );
+ win->GetUpdateRegion().Union( rect->x, rect->y,
+ rect->width, rect->height );
wxPaintEvent event( win->GetId() );
event.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( event );
- win->m_updateRegion.Clear();
+ win->GetUpdateRegion().Clear();
}
//-----------------------------------------------------------------------------
static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxWindow *win )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
/*
- wxPrintf( _T("OnKeyPress from ") );
+ printf( "OnKeyPress from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
- wxPrintf( win->GetClassInfo()->GetClassName() );
- wxPrintf( _T(".\n") );
-
- wxPrintf( _T("keyval: %d.\n"), (int) gdk_event->keyval );
+ printf( win->GetClassInfo()->GetClassName() );
+ printf( ".\n" );
*/
long key_code = 0;
switch (gdk_event->keyval)
{
case GDK_BackSpace: key_code = WXK_BACK; break;
- case GDK_ISO_Left_Tab:
+ case GDK_ISO_Left_Tab:
case GDK_KP_Tab:
case GDK_Tab: key_code = WXK_TAB; break;
case GDK_Linefeed: key_code = WXK_RETURN; break;
// win is a control: tab can be propagated up
if ( (!ret) &&
((gdk_event->keyval == GDK_Tab) || (gdk_event->keyval == GDK_ISO_Left_Tab)) &&
- ((win->m_windowStyle & wxTE_PROCESS_TAB) == 0))
+ (win->HasFlag(wxTE_PROCESS_TAB) == 0))
{
wxNavigationKeyEvent new_event;
- /* GDK reports GDK_ISO_Left_Tab for SHIFT-TAB */
+ /* GDK reports GDK_ISO_Left_Tab for SHIFT-TAB */
new_event.SetDirection( (gdk_event->keyval == GDK_Tab) );
- /* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
+ /* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
new_event.SetWindowChange( (gdk_event->state & GDK_CONTROL_MASK) );
new_event.SetCurrentFocus( win );
ret = win->GetEventHandler()->ProcessEvent( new_event );
Damn, I forgot why this didn't work, but it didn't work.
// win is a panel: up can be propagated to the panel
- if ((!ret) && (win->m_wxwindow) && (win->m_parent) && (win->m_parent->AcceptsFocus()) &&
+ if ((!ret) && (win->GetWxWindow()) && (win->m_parent) && (win->m_parent->AcceptsFocus()) &&
(gdk_event->keyval == GDK_Up))
{
win->m_parent->SetFocus();
}
// win is a panel: left/right can be propagated to the panel
- if ((!ret) && (win->m_wxwindow) &&
+ if ((!ret) && (win->GetWxWindow()) &&
((gdk_event->keyval == GDK_Right) || (gdk_event->keyval == GDK_Left) ||
(gdk_event->keyval == GDK_Up) || (gdk_event->keyval == GDK_Down)))
{
if (ret)
{
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_press_event" );
- return TRUE;
+ return TRUE;
}
return FALSE;
static gint gtk_window_key_release_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxWindow *win )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
switch (gdk_event->keyval)
{
case GDK_BackSpace: key_code = WXK_BACK; break;
- case GDK_ISO_Left_Tab:
+ case GDK_ISO_Left_Tab:
case GDK_KP_Tab:
case GDK_Tab: key_code = WXK_TAB; break;
case GDK_Linefeed: key_code = WXK_RETURN; break;
if (win->GetEventHandler()->ProcessEvent( event ))
{
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_release_event" );
- return TRUE;
+ return TRUE;
}
return FALSE;
static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
-/*
- wxPrintf( _T("1) OnButtonPress from ") );
- if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
- wxPrintf( win->GetClassInfo()->GetClassName() );
- wxPrintf( _T(".\n") );
-*/
-
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return TRUE;
if (g_blockEventsOnScroll) return TRUE;
if (!win->IsOwnGtkWindow( gdk_event->window )) return FALSE;
- if (win->m_wxwindow)
+ if (win->GetWxWindow())
{
- if (GTK_WIDGET_CAN_FOCUS(win->m_wxwindow) && !GTK_WIDGET_HAS_FOCUS (win->m_wxwindow) )
+ if (GTK_WIDGET_CAN_FOCUS(win->GetWxWindow()) && !GTK_WIDGET_HAS_FOCUS (win->GetWxWindow()) )
{
- gtk_widget_grab_focus (win->m_wxwindow);
+ gtk_widget_grab_focus (win->GetWxWindow());
/*
- wxPrintf( _T("GrabFocus from ") );
+ printf( "GrabFocus from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
- wxPrintf( win->GetClassInfo()->GetClassName() );
- wxPrintf( _T(".\n") );
+ printf( win->GetClassInfo()->GetClassName() );
+ printf( ".\n" );
*/
}
-/*
- else
- {
- wxPrintf( _T("No GrabFocus from ") );
- if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
- wxPrintf( win->GetClassInfo()->GetClassName() );
- if (GTK_WIDGET_CAN_FOCUS(win->m_wxwindow))
- wxPrintf( _T(" because it already has") );
- wxPrintf( _T(".\n") );
- }
-*/
}
/*
- wxPrintf( _T("2) OnButtonPress from ") );
+ printf( "OnButtonPress from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
- wxPrintf( win->GetClassInfo()->GetClassName() );
- wxPrintf( _T(".\n") );
+ printf( win->GetClassInfo()->GetClassName() );
+ printf( ".\n" );
*/
wxEventType event_type = wxEVT_LEFT_DOWN;
{
wxWindow *child = (wxWindow*)node->Data();
- if (child->m_isStaticBox)
+ if ( child->IsStaticBox() )
{
// wxStaticBox is transparent in the box itself
- int x = event.m_x;
- int y = event.m_y;
- int xx1 = child->m_x;
- int yy1 = child->m_y;
- int xx2 = child->m_x + child->m_width;
- int yy2 = child->m_x + child->m_height;
+ int x = event.m_x,
+ y = event.m_y;
+
+ wxRect rectChild(child->GetRect());
+ int xx1 = rectChild.GetLeft(),
+ yy1 = rectChild.GetTop(),
+ xx2 = rectChild.GetRight(),
+ yy2 = rectChild.GetBottom();
// left
if (((x >= xx1) && (x <= xx1+10) && (y >= yy1) && (y <= yy2)) ||
((x >= xx1) && (x <= xx2) && (y >= yy2-1) && (y <= yy2)))
{
win = child;
- event.m_x -= child->m_x;
- event.m_y -= child->m_y;
+ event.m_x -= child->GetX();
+ event.m_y -= child->GetY();
break;
}
}
else
{
- if ((child->m_wxwindow == (GtkWidget*) NULL) &&
- (child->m_x <= event.m_x) &&
- (child->m_y <= event.m_y) &&
- (child->m_x+child->m_width >= event.m_x) &&
- (child->m_y+child->m_height >= event.m_y))
+ if ((child->GetWxWindow() == (GtkWidget*) NULL) &&
+ (child->GetX() <= event.m_x) &&
+ (child->GetY() <= event.m_y) &&
+ (child->GetX()+child->GetWidth() >= event.m_x) &&
+ (child->GetY()+child->GetHeight() >= event.m_y))
{
win = child;
- event.m_x -= child->m_x;
- event.m_y -= child->m_y;
+ event.m_x -= child->GetX();
+ event.m_y -= child->GetY();
break;
}
}
if (win->GetEventHandler()->ProcessEvent( event ))
{
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "button_press_event" );
- return TRUE;
+ return TRUE;
}
return FALSE;
static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
if (g_blockEventsOnScroll) return FALSE;
{
wxWindow *child = (wxWindow*)node->Data();
- if (child->m_isStaticBox)
+ if (child->IsStaticBox() )
{
// wxStaticBox is transparent in the box itself
int x = event.m_x;
int y = event.m_y;
- int xx1 = child->m_x;
- int yy1 = child->m_y;
- int xx2 = child->m_x + child->m_width;
- int yy2 = child->m_x + child->m_height;
+ int xx1 = child->GetX();
+ int yy1 = child->GetY();
+ int xx2 = child->GetX() + child->GetWidth();
+ int yy2 = child->GetX() + child->GetHeight();
// left
if (((x >= xx1) && (x <= xx1+10) && (y >= yy1) && (y <= yy2)) ||
((x >= xx1) && (x <= xx2) && (y >= yy2-1) && (y <= yy2)))
{
win = child;
- event.m_x -= child->m_x;
- event.m_y -= child->m_y;
+ event.m_x -= child->GetX();
+ event.m_y -= child->GetY();
break;
}
}
else
{
- if ((child->m_wxwindow == (GtkWidget*) NULL) &&
- (child->m_x <= event.m_x) &&
- (child->m_y <= event.m_y) &&
- (child->m_x+child->m_width >= event.m_x) &&
- (child->m_y+child->m_height >= event.m_y))
+ if ((child->GetWxWindow() == (GtkWidget*) NULL) &&
+ (child->GetX() <= event.m_x) &&
+ (child->GetY() <= event.m_y) &&
+ (child->GetX()+child->GetWidth() >= event.m_x) &&
+ (child->GetY()+child->GetHeight() >= event.m_y))
{
win = child;
- event.m_x -= child->m_x;
- event.m_y -= child->m_y;
+ event.m_x -= child->GetX();
+ event.m_y -= child->GetY();
break;
}
}
if (win->GetEventHandler()->ProcessEvent( event ))
{
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "button_release_event" );
- return TRUE;
+ return TRUE;
}
return FALSE;
static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_event, wxWindow *win )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
if (g_blockEventsOnScroll) return FALSE;
{
wxWindow *child = (wxWindow*)node->Data();
- if (child->m_isStaticBox)
+ if ( child->IsStaticBox() )
{
// wxStaticBox is transparent in the box itself
int x = event.m_x;
int y = event.m_y;
- int xx1 = child->m_x;
- int yy1 = child->m_y;
- int xx2 = child->m_x + child->m_width;
- int yy2 = child->m_x + child->m_height;
+ int xx1 = child->GetX();
+ int yy1 = child->GetY();
+ int xx2 = child->GetX() + child->GetWidth();
+ int yy2 = child->GetX() + child->GetHeight();
// left
if (((x >= xx1) && (x <= xx1+10) && (y >= yy1) && (y <= yy2)) ||
((x >= xx1) && (x <= xx2) && (y >= yy2-1) && (y <= yy2)))
{
win = child;
- event.m_x -= child->m_x;
- event.m_y -= child->m_y;
+ event.m_x -= child->GetX();
+ event.m_y -= child->GetY();
break;
}
}
else
{
- if ((child->m_wxwindow == (GtkWidget*) NULL) &&
- (child->m_x <= event.m_x) &&
- (child->m_y <= event.m_y) &&
- (child->m_x+child->m_width >= event.m_x) &&
- (child->m_y+child->m_height >= event.m_y))
+ if ((child->GetWxWindow() == (GtkWidget*) NULL) &&
+ (child->GetX() <= event.m_x) &&
+ (child->GetY() <= event.m_y) &&
+ (child->GetX()+child->GetWidth() >= event.m_x) &&
+ (child->GetY()+child->GetHeight() >= event.m_y))
{
win = child;
- event.m_x -= child->m_x;
- event.m_y -= child->m_y;
+ event.m_x -= child->GetX();
+ event.m_y -= child->GetY();
break;
}
}
if (win->GetEventHandler()->ProcessEvent( event ))
{
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "motion_notify_event" );
- return TRUE;
+ return TRUE;
}
return FALSE;
static gint gtk_window_focus_in_callback( GtkWidget *widget, GdkEvent *WXUNUSED(event), wxWindow *win )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
g_focusWindow = win;
- if (win->m_wxwindow)
+ if (win->GetWxWindow())
{
- if (GTK_WIDGET_CAN_FOCUS(win->m_wxwindow))
+ if (GTK_WIDGET_CAN_FOCUS(win->GetWxWindow()))
{
- GTK_WIDGET_SET_FLAGS (win->m_wxwindow, GTK_HAS_FOCUS);
+ GTK_WIDGET_SET_FLAGS (win->GetWxWindow(), GTK_HAS_FOCUS);
/*
printf( "SetFocus flag from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
/*
- wxPrintf( _T("OnSetFocus from ") );
+ printf( "OnSetFocus from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
- wxPrintf( win->GetClassInfo()->GetClassName() );
- wxPrintf( _T(" ") );
- wxPrintf( win->GetLabel() );
- wxPrintf( _T(".\n") );
+ printf( win->GetClassInfo()->GetClassName() );
+ printf( " " );
+ printf( WXSTRINGCAST win->GetLabel() );
+ printf( ".\n" );
*/
wxFocusEvent event( wxEVT_SET_FOCUS, win->GetId() );
static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEvent *WXUNUSED(event), wxWindow *win )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
- if (win->m_wxwindow)
+ if (win->GetWxWindow())
{
- if (GTK_WIDGET_CAN_FOCUS(win->m_wxwindow))
- GTK_WIDGET_UNSET_FLAGS (win->m_wxwindow, GTK_HAS_FOCUS);
+ if (GTK_WIDGET_CAN_FOCUS(win->GetWxWindow()))
+ GTK_WIDGET_UNSET_FLAGS (win->GetWxWindow(), GTK_HAS_FOCUS);
}
/*
- wxPrintf( _T("OnKillFocus from ") );
+ printf( "OnKillFocus from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
- wxPrintf( win->GetClassInfo()->GetClassName() );
- wxPrintf( _T(" ") );
- wxPrintf( win->GetLabel() );
- wxPrintf( _T(".\n") );
+ printf( win->GetClassInfo()->GetClassName() );
+ printf( ".\n" );
*/
wxFocusEvent event( wxEVT_KILL_FOCUS, win->GetId() );
static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
- if (!win->HasVMT()) return FALSE;
- if (g_blockEventsOnDrag) return FALSE;
+ if ( !win->HasVMT() || g_blockEventsOnDrag )
+ return FALSE;
- if (!win->IsOwnGtkWindow( gdk_event->window )) return FALSE;
+ GdkWindow *window = widget->window;
+ if ( window != gdk_event->window )
+ return FALSE;
- if ((widget->window) && (win->m_cursor.Ok()))
- gdk_window_set_cursor( widget->window, win->m_cursor.GetCursor() );
+ if ( window && win->GetCursor().Ok() )
+ gdk_window_set_cursor( window, win->GetCursor().GetCursor() );
/*
printf( "OnEnter from " );
int y = 0;
GdkModifierType state = (GdkModifierType)0;
- gdk_window_get_pointer( widget->window, &x, &y, &state );
+ gdk_window_get_pointer( window, &x, &y, &state );
event.m_shiftDown = (state & GDK_SHIFT_MASK);
event.m_controlDown = (state & GDK_CONTROL_MASK);
static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win )
{
- if (g_isIdle) wxapp_install_idle_handler();
+ if ( !win->HasVMT() || g_blockEventsOnDrag )
+ return FALSE;
- if (!win->HasVMT()) return FALSE;
- if (g_blockEventsOnDrag) return FALSE;
-
- if (!win->IsOwnGtkWindow( gdk_event->window )) return FALSE;
+ GdkWindow *window = widget->window;
+ if ( window != gdk_event->window )
+ return FALSE;
- if (widget->window)
- gdk_window_set_cursor( widget->window, wxSTANDARD_CURSOR->GetCursor() );
+ if ( window && win->GetCursor().Ok() )
+ gdk_window_set_cursor( window, wxSTANDARD_CURSOR->GetCursor() );
/*
- wxPrintf( _T("OnLeave from ") );
+ printf( "OnLeave from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
- wxPrintf( win->GetClassInfo()->GetClassName() );
- wxPrintf( _T(".\n") );
+ printf( win->GetClassInfo()->GetClassName() );
+ printf( ".\n" );
*/
wxMouseEvent event( wxEVT_LEAVE_WINDOW );
static void gtk_window_vscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow *win )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
if (g_blockEventsOnDrag) return;
/*
if (!win->HasVMT()) return;
- float diff = win->m_vAdjust->value - win->m_oldVerticalPos;
+ float diff = win->GetVAdjust()->value - win->GetOldVerticalPos();
if (fabs(diff) < 0.2) return;
- win->m_oldVerticalPos = win->m_vAdjust->value;
+ win->SetOldVerticalPos(win->GetVAdjust()->value);
wxEventType command = wxEVT_NULL;
- float line_step = win->m_vAdjust->step_increment;
- float page_step = win->m_vAdjust->page_increment;
+ float line_step = win->GetVAdjust()->step_increment;
+ float page_step = win->GetVAdjust()->page_increment;
- if (win->m_isScrolling)
+ if (win->IsScrolling())
{
command = wxEVT_SCROLL_THUMBTRACK;
}
else
{
- if (fabs(win->m_vAdjust->value-win->m_vAdjust->lower) < 0.2) command = wxEVT_SCROLL_BOTTOM;
- else if (fabs(win->m_vAdjust->value-win->m_vAdjust->upper) < 0.2) command = wxEVT_SCROLL_TOP;
+ if (fabs(win->GetVAdjust()->value-win->GetVAdjust()->lower) < 0.2) command = wxEVT_SCROLL_BOTTOM;
+ else if (fabs(win->GetVAdjust()->value-win->GetVAdjust()->upper) < 0.2) command = wxEVT_SCROLL_TOP;
else if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLL_LINEDOWN;
else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLL_LINEUP;
else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLL_PAGEDOWN;
else command = wxEVT_SCROLL_THUMBTRACK;
}
- int value = (int)(win->m_vAdjust->value+0.5);
+ int value = (int)(win->GetVAdjust()->value+0.5);
wxScrollEvent event( command, win->GetId(), value, wxVERTICAL );
event.SetEventObject( win );
static void gtk_window_hscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow *win )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
if (g_blockEventsOnDrag) return;
/*
if (!win->HasVMT()) return;
- float diff = win->m_hAdjust->value - win->m_oldHorizontalPos;
+ float diff = win->GetHAdjust()->value - win->GetOldHorizontalPos();
if (fabs(diff) < 0.2) return;
- win->m_oldHorizontalPos = win->m_hAdjust->value;
+ win->SetOldHorizontalPos( win->GetHAdjust()->value );
wxEventType command = wxEVT_NULL;
- float line_step = win->m_hAdjust->step_increment;
- float page_step = win->m_hAdjust->page_increment;
+ float line_step = win->GetHAdjust()->step_increment;
+ float page_step = win->GetHAdjust()->page_increment;
- if (win->m_isScrolling)
+ if (win->IsScrolling())
{
command = wxEVT_SCROLL_THUMBTRACK;
}
else
{
- if (fabs(win->m_hAdjust->value-win->m_hAdjust->lower) < 0.2) command = wxEVT_SCROLL_BOTTOM;
- else if (fabs(win->m_hAdjust->value-win->m_hAdjust->upper) < 0.2) command = wxEVT_SCROLL_TOP;
+ if (fabs(win->GetHAdjust()->value-win->GetHAdjust()->lower) < 0.2) command = wxEVT_SCROLL_BOTTOM;
+ else if (fabs(win->GetHAdjust()->value-win->GetHAdjust()->upper) < 0.2) command = wxEVT_SCROLL_TOP;
else if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLL_LINEDOWN;
else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLL_LINEUP;
else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLL_PAGEDOWN;
else command = wxEVT_SCROLL_THUMBTRACK;
}
- int value = (int)(win->m_hAdjust->value+0.5);
+ int value = (int)(win->GetHAdjust()->value+0.5);
wxScrollEvent event( command, win->GetId(), value, wxHORIZONTAL );
event.SetEventObject( win );
static void gtk_window_vscroll_change_callback( GtkWidget *WXUNUSED(widget), wxWindow *win )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
if (g_blockEventsOnDrag) return;
/*
if (!win->HasVMT()) return;
wxEventType command = wxEVT_SCROLL_THUMBTRACK;
- int value = (int)(win->m_vAdjust->value+0.5);
+ int value = (int)(win->GetVAdjust()->value+0.5);
wxScrollEvent event( command, win->GetId(), value, wxVERTICAL );
event.SetEventObject( win );
static void gtk_window_hscroll_change_callback( GtkWidget *WXUNUSED(widget), wxWindow *win )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
if (g_blockEventsOnDrag) return;
/*
if (!win->HasVMT()) return;
wxEventType command = wxEVT_SCROLL_THUMBTRACK;
- int value = (int)(win->m_hAdjust->value+0.5);
+ int value = (int)(win->GetHAdjust()->value+0.5);
wxScrollEvent event( command, win->GetId(), value, wxHORIZONTAL );
event.SetEventObject( win );
GdkEventButton *WXUNUSED(gdk_event),
wxWindow *win )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
// don't test here as we can release the mouse while being over
// a different window then the slider
//
// if (gdk_event->window != widget->slider) return FALSE;
- win->m_isScrolling = TRUE;
- g_blockEventsOnScroll = TRUE;
+ win->SetScrolling( TRUE );
return FALSE;
}
GdkEventButton *WXUNUSED(gdk_event),
wxWindow *win )
{
- if (g_isIdle) wxapp_install_idle_handler();
// don't test here as we can release the mouse while being over
// a different window then the slider
//
// if (gdk_event->window != widget->slider) return FALSE;
- GtkScrolledWindow *s_window = GTK_SCROLLED_WINDOW(win->m_widget);
+ GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(win->GetHandle());
- if (widget == GTK_RANGE(s_window->vscrollbar))
- gtk_signal_emit_by_name( GTK_OBJECT(win->m_hAdjust), "value_changed" );
+ if (widget == GTK_RANGE(scrolledWindow->vscrollbar))
+ gtk_signal_emit_by_name( GTK_OBJECT(win->GetHAdjust()), "value_changed" );
else
- gtk_signal_emit_by_name( GTK_OBJECT(win->m_vAdjust), "value_changed" );
+ gtk_signal_emit_by_name( GTK_OBJECT(win->GetVAdjust()), "value_changed" );
- win->m_isScrolling = FALSE;
- g_blockEventsOnScroll = FALSE;
+ win->SetScrolling( FALSE );
return FALSE;
}
-//-----------------------------------------------------------------------------
-// "realize" from m_widget
-//-----------------------------------------------------------------------------
-
-/* we cannot set colours, fonts and cursors before the widget has
- been realized, so we do this directly after realization */
+// ----------------------------------------------------------------------------
+// this wxWindowBase function is implemented here (in platform-specific file)
+// because it is static and so couldn't be made virtual
+// ----------------------------------------------------------------------------
-static gint
-gtk_window_realized_callback( GtkWidget *widget, wxWindow *win )
+wxWindow *wxWindowBase::FindFocus()
{
- if (g_isIdle) wxapp_install_idle_handler();
-
- if (win->m_font != *wxSWISS_FONT)
- {
- wxFont font( win->m_font );
- win->m_font = wxNullFont;
- win->SetFont( font );
- }
-
- if (win->m_backgroundColour != wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE ))
- {
- wxColour bg( win->m_backgroundColour );
- win->m_backgroundColour = wxNullColour;
- win->SetBackgroundColour( bg );
- }
-
- if (win->m_foregroundColour != *wxBLACK)
- {
- wxColour fg( win->m_foregroundColour );
- win->m_foregroundColour = wxNullColour;
- win->SetForegroundColour( fg );
- }
-
- wxCursor cursor( win->m_cursor );
- win->m_cursor = wxNullCursor;
- win->SetCursor( cursor );
-
- return FALSE;
+ return g_focusWindow;
}
//-----------------------------------------------------------------------------
static void wxInsertChildInWindow( wxWindow* parent, wxWindow* child )
{
- gtk_myfixed_put( GTK_MYFIXED(parent->m_wxwindow),
- GTK_WIDGET(child->m_widget),
- child->m_x,
- child->m_y,
- child->m_width,
- child->m_height );
-
- if (parent->m_windowStyle & wxTAB_TRAVERSAL)
+ gtk_myfixed_put( GTK_MYFIXED(parent->GetWxWindow()),
+ GTK_WIDGET(child->GetHandle()),
+ child->GetX(),
+ child->GetY(),
+ child->GetWidth(),
+ child->GetHeight() );
+
+ gtk_widget_set_usize( GTK_WIDGET(child->GetHandle()),
+ child->GetWidth(),
+ child->GetHeight() );
+
+ if (parent->HasFlag(wxTAB_TRAVERSAL))
{
/* we now allow a window to get the focus as long as it
doesn't have any children. */
- GTK_WIDGET_UNSET_FLAGS( parent->m_wxwindow, GTK_CAN_FOCUS );
+ GTK_WIDGET_UNSET_FLAGS( parent->GetWxWindow(), GTK_CAN_FOCUS );
}
}
wxWindow* wxGetActiveWindow()
{
- return g_focusWindow;
+ return g_focusWindow;
}
//-----------------------------------------------------------------------------
// wxWindow
//-----------------------------------------------------------------------------
-IMPLEMENT_DYNAMIC_CLASS(wxWindow,wxEvtHandler)
+IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowBase)
-BEGIN_EVENT_TABLE(wxWindow, wxEvtHandler)
- EVT_SIZE(wxWindow::OnSize)
- EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged)
- EVT_INIT_DIALOG(wxWindow::OnInitDialog)
+BEGIN_EVENT_TABLE(wxWindow, wxWindowBase)
EVT_KEY_DOWN(wxWindow::OnKeyDown)
END_EVENT_TABLE()
void wxWindow::Init()
{
- m_isWindow = TRUE;
+ // common init
+ InitBase();
- m_widget = (GtkWidget *) NULL;
+ // GTK specific
m_wxwindow = (GtkWidget *) NULL;
- m_parent = (wxWindow *) NULL;
- m_children.DeleteContents( FALSE );
- m_x = 0;
- m_y = 0;
- m_width = 0;
+ // position/size
+ m_x =
+ m_y =
+ m_width =
m_height = 0;
- m_minWidth = -1;
- m_minHeight = -1;
- m_maxWidth = -1;
- m_maxHeight = -1;
-
- m_retCode = 0;
-
- m_eventHandler = this;
- m_windowValidator = (wxValidator *) NULL;
- m_windowId = -1;
-
- m_cursor = *wxSTANDARD_CURSOR;
m_font = *wxSWISS_FONT;
- m_windowStyle = 0;
m_windowName = "noname";
- m_constraints = (wxLayoutConstraints *) NULL;
- m_constraintsInvolvedIn = (wxList *) NULL;
- m_windowSizer = (wxSizer *) NULL;
- m_sizerParent = (wxWindow *) NULL;
- m_autoLayout = FALSE;
-
m_sizeSet = FALSE;
m_hasVMT = FALSE;
m_needParent = TRUE;
- m_hasScrolling = FALSE;
+ m_hasScrolling =
m_isScrolling = FALSE;
- m_hAdjust = (GtkAdjustment*) NULL;
+
+ m_hAdjust =
m_vAdjust = (GtkAdjustment*) NULL;
- m_oldHorizontalPos = 0.0;
+ m_oldHorizontalPos =
m_oldVerticalPos = 0.0;
- m_isShown = FALSE;
- m_isEnabled = TRUE;
-
-#if wxUSE_DRAG_AND_DROP
- m_dropTarget = (wxDropTarget*) NULL;
-#endif
m_resizing = FALSE;
m_scrollGC = (GdkGC*) NULL;
m_widgetStyle = (GtkStyle*) NULL;
m_insertCallback = wxInsertChildInWindow;
- m_clientObject = (wxClientData*) NULL;
- m_clientData = NULL;
-
m_isStaticBox = FALSE;
m_acceptsFocus = FALSE;
-
-#if wxUSE_TOOLTIPS
- m_toolTip = (wxToolTip*) NULL;
-#endif // wxUSE_TOOLTIPS
}
wxWindow::wxWindow()
const wxPoint &pos, const wxSize &size,
long style, const wxString &name )
{
- wxASSERT_MSG( m_isWindow, _T("Init() must have been called before!") );
-
PreCreation( parent, id, pos, size, style, name );
m_widget = gtk_scrolled_window_new( (GtkAdjustment *) NULL, (GtkAdjustment *) NULL );
debug_focus_in( m_widget, _T("wxWindow::m_widget"), name );
#endif
- GtkScrolledWindow *s_window = GTK_SCROLLED_WINDOW(m_widget);
+ GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(m_widget);
#ifdef __WXDEBUG__
- debug_focus_in( s_window->hscrollbar, _T("wxWindow::hsrcollbar"), name );
- debug_focus_in( s_window->vscrollbar, _T("wxWindow::vsrcollbar"), name );
+ debug_focus_in( scrolledWindow->hscrollbar, _T("wxWindow::hsrcollbar"), name );
+ debug_focus_in( scrolledWindow->vscrollbar, _T("wxWindow::vsrcollbar"), name );
#endif
GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(m_widget)->klass );
scroll_class->scrollbar_spacing = 0;
- gtk_scrolled_window_set_policy( s_window, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
-
- m_oldHorizontalPos = 0.0;
- m_oldVerticalPos = 0.0;
+ gtk_scrolled_window_set_policy( scrolledWindow, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
- m_hAdjust = gtk_range_get_adjustment( GTK_RANGE(s_window->hscrollbar) );
- m_vAdjust = gtk_range_get_adjustment( GTK_RANGE(s_window->vscrollbar) );
+ m_hAdjust = gtk_range_get_adjustment( GTK_RANGE(scrolledWindow->hscrollbar) );
+ m_vAdjust = gtk_range_get_adjustment( GTK_RANGE(scrolledWindow->vscrollbar) );
m_wxwindow = gtk_myfixed_new();
#if (GTK_MINOR_VERSION > 0)
GtkMyFixed *myfixed = GTK_MYFIXED(m_wxwindow);
- if (m_windowStyle & wxRAISED_BORDER)
+ if (HasFlag(wxRAISED_BORDER))
{
gtk_myfixed_set_shadow_type( myfixed, GTK_SHADOW_OUT );
}
- else if (m_windowStyle & wxSUNKEN_BORDER)
+ else if (HasFlag(wxSUNKEN_BORDER))
{
gtk_myfixed_set_shadow_type( myfixed, GTK_SHADOW_IN );
}
{
gtk_myfixed_set_shadow_type( myfixed, GTK_SHADOW_NONE );
}
-#else
- GtkViewport *viewport = GTK_VIEWPORT(s_window->viewport);
+#else // GTK_MINOR_VERSION == 0
+ GtkViewport *viewport = GTK_VIEWPORT(scrolledWindow->viewport);
- if (m_windowStyle & wxRAISED_BORDER)
+ if (HasFlag(wxRAISED_BORDER))
{
gtk_viewport_set_shadow_type( viewport, GTK_SHADOW_OUT );
}
- else if (m_windowStyle & wxSUNKEN_BORDER)
+ else if (HasFlag(wxSUNKEN_BORDER))
{
gtk_viewport_set_shadow_type( viewport, GTK_SHADOW_IN );
}
{
gtk_viewport_set_shadow_type( viewport, GTK_SHADOW_NONE );
}
-#endif
+#endif // GTK_MINOR_VERSION
- /* we always allow a window to get the focus as long as it
- doesn't have any children. */
- if (m_windowStyle & wxTAB_TRAVERSAL)
+ if (HasFlag(wxTAB_TRAVERSAL))
{
+ /* we now allow a window to get the focus as long as it
+ doesn't have any children. */
GTK_WIDGET_SET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
m_acceptsFocus = FALSE;
}
m_acceptsFocus = TRUE;
}
- /* grab the actual focus */
-// gtk_widget_grab_focus( m_wxwindow );
-
- gtk_widget_show( m_wxwindow );
-
-
#if (GTK_MINOR_VERSION == 0)
// shut the viewport up
gtk_viewport_set_hadjustment( viewport, (GtkAdjustment*) gtk_adjustment_new( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) );
gtk_viewport_set_vadjustment( viewport, (GtkAdjustment*) gtk_adjustment_new( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) );
-#endif
+#endif // GTK_MINOR_VERSION == 0
// I _really_ don't want scrollbars in the beginning
- m_vAdjust->lower = 0.0;
- m_vAdjust->upper = 1.0;
- m_vAdjust->value = 0.0;
- m_vAdjust->step_increment = 1.0;
- m_vAdjust->page_increment = 1.0;
- m_vAdjust->page_size = 5.0;
- gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust), "changed" );
- m_hAdjust->lower = 0.0;
- m_hAdjust->upper = 1.0;
- m_hAdjust->value = 0.0;
- m_hAdjust->step_increment = 1.0;
- m_hAdjust->page_increment = 1.0;
- m_hAdjust->page_size = 5.0;
- gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "changed" );
-
- // these handlers block mouse events to any window during scrolling
- // such as motion events and prevent GTK and wxWindows from fighting
- // over where the slider should be
-
- gtk_signal_connect( GTK_OBJECT(s_window->vscrollbar), "button_press_event",
+ InitAdjustment(m_vAdjust);
+ InitAdjustment(m_hAdjust);
+
+ // these handlers block mouse events to any window during scrolling such as
+ // motion events and prevent GTK and wxWindows from fighting over where the
+ // slider should be
+
+ gtk_signal_connect( GTK_OBJECT(scrolledWindow->vscrollbar), "button_press_event",
(GtkSignalFunc)gtk_scrollbar_button_press_callback, (gpointer) this );
- gtk_signal_connect( GTK_OBJECT(s_window->hscrollbar), "button_press_event",
+ gtk_signal_connect( GTK_OBJECT(scrolledWindow->hscrollbar), "button_press_event",
(GtkSignalFunc)gtk_scrollbar_button_press_callback, (gpointer) this );
- gtk_signal_connect( GTK_OBJECT(s_window->vscrollbar), "button_release_event",
+ gtk_signal_connect( GTK_OBJECT(scrolledWindow->vscrollbar), "button_release_event",
(GtkSignalFunc)gtk_scrollbar_button_release_callback, (gpointer) this );
- gtk_signal_connect( GTK_OBJECT(s_window->hscrollbar), "button_release_event",
+ gtk_signal_connect( GTK_OBJECT(scrolledWindow->hscrollbar), "button_release_event",
(GtkSignalFunc)gtk_scrollbar_button_release_callback, (gpointer) this );
// these handlers get notified when screen updates are required either when
gtk_signal_connect(GTK_OBJECT(m_vAdjust), "changed",
(GtkSignalFunc) gtk_window_vscroll_change_callback, (gpointer) this );
- if (m_parent) m_parent->AddChild( this );
+ gtk_widget_show( m_wxwindow );
- (m_parent->m_insertCallback)( m_parent, this );
+ if (m_parent)
+ m_parent->DoAddChild( this );
PostCreation();
{
m_hasVMT = FALSE;
-#if wxUSE_DRAG_AND_DROP
- if (m_dropTarget)
- {
- delete m_dropTarget;
- m_dropTarget = (wxDropTarget*) NULL;
- }
-#endif
-
-#if wxUSE_TOOLTIPS
- if (m_toolTip)
- {
- delete m_toolTip;
- m_toolTip = (wxToolTip*) NULL;
- }
-#endif // wxUSE_TOOLTIPS
-
- if (m_widget) Show( FALSE );
-
- DestroyChildren();
-
- if (m_parent) m_parent->RemoveChild( this );
-
- if (m_widgetStyle) gtk_style_unref( m_widgetStyle );
-
- if (m_scrollGC) gdk_gc_unref( m_scrollGC );
+ if (m_widget)
+ Show( FALSE );
- if (m_wxwindow) gtk_widget_destroy( m_wxwindow );
-
- if (m_widget) gtk_widget_destroy( m_widget );
-
- DeleteRelatedConstraints();
- if (m_constraints)
- {
- /* This removes any dangling pointers to this window
- * in other windows' constraintsInvolvedIn lists. */
- UnsetConstraints(m_constraints);
- delete m_constraints;
- m_constraints = (wxLayoutConstraints *) NULL;
- }
-
- if (m_windowSizer)
- {
- delete m_windowSizer;
- m_windowSizer = (wxSizer *) NULL;
- }
- /* If this is a child of a sizer, remove self from parent */
- if (m_sizerParent) m_sizerParent->RemoveChild((wxWindow *)this);
+ if (m_parent)
+ m_parent->RemoveChild( this );
- /* Just in case the window has been Closed, but
- * we're then deleting immediately: don't leave
- * dangling pointers. */
- wxPendingDelete.DeleteObject(this);
+ if (m_widgetStyle)
+ gtk_style_unref( m_widgetStyle );
- /* Just in case we've loaded a top-level window via
- * wxWindow::LoadNativeDialog but we weren't a dialog
- * class */
- wxTopLevelWindows.DeleteObject(this);
+ if (m_scrollGC)
+ gdk_gc_unref( m_scrollGC );
- if (m_windowValidator) delete m_windowValidator;
+ if (m_wxwindow)
+ gtk_widget_destroy( m_wxwindow );
- if (m_clientObject) delete m_clientObject;
+ if (m_widget)
+ gtk_widget_destroy( m_widget );
}
-void wxWindow::PreCreation( wxWindow *parent, wxWindowID id,
- const wxPoint &pos, const wxSize &size,
- long style, const wxString &name )
+void wxWindow::PreCreation( wxWindow *parent,
+ wxWindowID id,
+ const wxPoint &pos,
+ const wxSize &size,
+ long style,
+ const wxString &name )
{
- wxASSERT_MSG( (!m_needParent) || (parent), _T("Need complete parent.") );
+ wxASSERT_MSG( !m_needParent || parent, _T("Need complete parent.") );
- m_widget = (GtkWidget*) NULL;
- m_wxwindow = (GtkWidget*) NULL;
- m_hasVMT = FALSE;
- m_parent = parent;
- m_children.DeleteContents( FALSE );
+ if ( !CreateBase(parent, id, pos, size, style, name) )
+ {
+ wxFAIL_MSG(_T("window creation failed"));
+ }
- m_width = size.x;
- if (m_width == -1) m_width = 20;
- m_height = size.y;
- if (m_height == -1) m_height = 20;
+ m_width = WidthDefault(size.x);
+ m_height = HeightDefault(size.y);
m_x = (int)pos.x;
m_y = (int)pos.y;
- if (!m_needParent) /* some reasonable defaults */
+ if (!parent) /* some reasonable defaults */
{
if (m_x == -1)
{
if (m_y < 10) m_y = 10;
}
}
-
- m_minWidth = -1;
- m_minHeight = -1;
- m_maxWidth = -1;
- m_maxHeight = -1;
-
- m_retCode = 0;
-
- m_eventHandler = this;
-
- m_windowId = id == -1 ? wxNewId() : id;
-
- m_sizeSet = FALSE;
-
- m_cursor = *wxSTANDARD_CURSOR;
- m_font = *wxSWISS_FONT;
- m_backgroundColour = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE );
- m_foregroundColour = *wxBLACK;
- m_windowStyle = style;
- m_windowName = name;
-
- m_constraints = (wxLayoutConstraints *) NULL;
- m_constraintsInvolvedIn = (wxList *) NULL;
- m_windowSizer = (wxSizer *) NULL;
- m_sizerParent = (wxWindow *) NULL;
- m_autoLayout = FALSE;
-
- m_hasScrolling = FALSE;
- m_isScrolling = FALSE;
- m_hAdjust = (GtkAdjustment *) NULL;
- m_vAdjust = (GtkAdjustment *) NULL;
- m_oldHorizontalPos = 0.0;
- m_oldVerticalPos = 0.0;
-
- m_isShown = FALSE;
- m_isEnabled = TRUE;
-
-#if wxUSE_DRAG_AND_DROP
- m_dropTarget = (wxDropTarget *) NULL;
-#endif
- m_resizing = FALSE;
- m_windowValidator = (wxValidator *) NULL;
- m_scrollGC = (GdkGC*) NULL;
- m_widgetStyle = (GtkStyle*) NULL;
-
- m_clientObject = (wxClientData*)NULL;
- m_clientData = NULL;
-
- m_isStaticBox = FALSE;
-
-#if wxUSE_TOOLTIPS
- m_toolTip = (wxToolTip*) NULL;
-#endif // wxUSE_TOOLTIPS
}
void wxWindow::PostCreation()
GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this );
#if (GTK_MINOR_VERSION > 0)
- /* these are called when the "sunken" or "raised" borders are drawn */
+ /* these are called when the "sunken" or "raised" borders are drawn */
gtk_signal_connect( GTK_OBJECT(m_widget), "expose_event",
GTK_SIGNAL_FUNC(gtk_window_own_expose_callback), (gpointer)this );
#endif
}
- GtkWidget *connect_widget = GetConnectWidget();
+ ConnectWidget( GetConnectWidget() );
- ConnectWidget( connect_widget );
+ /* we force the creation of wxFrame and wxDialog in the respective code */
+ if (m_parent)
+ gtk_widget_realize( m_widget );
+
+ if (m_wxwindow)
+ gtk_widget_realize( m_wxwindow );
- /* we cannot set colours, fonts and cursors before the widget has
- been realized, so we do this directly after realization */
- gtk_signal_connect( GTK_OBJECT(connect_widget), "realize",
- GTK_SIGNAL_FUNC(gtk_window_realized_callback), (gpointer) this );
+ SetCursor( *wxSTANDARD_CURSOR );
m_hasVMT = TRUE;
}
GTK_SIGNAL_FUNC(gtk_window_leave_callback), (gpointer)this );
}
-bool wxWindow::HasVMT()
-{
- return m_hasVMT;
-}
-
-bool wxWindow::Close( bool force )
-{
- wxASSERT_MSG( (m_widget != NULL), _T("invalid window") );
-
- wxCloseEvent event(wxEVT_CLOSE_WINDOW, m_windowId);
- event.SetEventObject(this);
- event.SetCanVeto(!force);
-
- /* return FALSE if window wasn't closed because the application vetoed the
- * close event */
- return GetEventHandler()->ProcessEvent(event) && !event.GetVeto();
-}
-
bool wxWindow::Destroy()
{
wxASSERT_MSG( (m_widget != NULL), _T("invalid window") );
m_hasVMT = FALSE;
- delete this;
- return TRUE;
-}
-
-bool wxWindow::DestroyChildren()
-{
- wxNode *node;
- while ((node = m_children.First()) != (wxNode *)NULL)
- {
- wxWindow *child;
- if ((child = (wxWindow *)node->Data()) != (wxWindow *)NULL)
- {
- delete child;
- if (m_children.Member(child)) delete node;
- }
- }
- return TRUE;
-}
-void wxWindow::PrepareDC( wxDC &WXUNUSED(dc) )
-{
- // are we to set fonts here ?
+ return wxWindowBase::Destroy();
}
void wxWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags )
if (m_resizing) return; /* I don't like recursions */
m_resizing = TRUE;
- if (m_parent->m_wxwindow == NULL) /* i.e. wxNotebook page */
+ if (m_parent->GetWxWindow() == NULL) /* i.e. wxNotebook */
{
/* don't set the size for children of wxNotebook, just take the values. */
m_x = x;
}
else
{
+ int old_width = m_width;
+ int old_height = m_height;
+
if ((sizeFlags & wxSIZE_USE_EXISTING) == wxSIZE_USE_EXISTING)
{
if (x != -1) m_x = x;
if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth;
if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight;
- int border = 0;
-
if (GTK_WIDGET_HAS_DEFAULT(m_widget))
- {
- /* the default button has a border around it */
- border = 5;
- }
-
- /* this is the result of hours of debugging: the following code
- means that if we have a m_wxwindow and we set the size of
- m_widget, m_widget (which is a GtkScrolledWindow) does NOT
- automatically propagate its size down to its m_wxwindow,
- which is its client area. therefore, we have to tell the
- client area directly that it has to resize itself.
- this will lead to that m_widget (GtkScrolledWindow) will
- calculate how much size it needs for scrollbars etc and
- it will then call XXX_size_allocate of its child, which
- is m_wxwindow. m_wxwindow in turn will do the same with its
- children and so on. problems can arise if this happens
- before all the children have been realized as some widgets
- stupidy need to be realized during XXX_size_allocate (e.g.
- GtkNotebook) and they will segv if called otherwise. this
- emergency is tested in gtk_myfixed_size_allocate. Normally
- this shouldn't be needed and only gtk_widget_queue_resize()
- should be enough to provoke a resize at the next appropriate
- moment, but this seems to fail, e.g. when a wxNotebook contains
- a wxSplitterWindow: the splitter window's children won't
- show up properly resized then. */
-
- gtk_myfixed_set_size( GTK_MYFIXED(m_parent->m_wxwindow),
- m_widget,
- m_x-border,
- m_y-border,
- m_width+2*border,
- m_height+2*border );
-
+ {
+ /* the default button has a border around it */
+ int border = 5;
+
+ gtk_myfixed_move( GTK_MYFIXED(m_parent->GetWxWindow()), m_widget, m_x-border, m_y-border );
+
+ gtk_widget_set_usize( m_widget, m_width+2*border, m_height+2*border );
+ }
+ else
+ {
+ gtk_myfixed_move( GTK_MYFIXED(m_parent->GetWxWindow()), m_widget, m_x, m_y );
+
+ if ((old_width != m_width) || (old_height != m_height))
+ gtk_widget_set_usize( m_widget, m_width, m_height );
+ }
}
m_sizeSet = TRUE;
UpdateWindowUI();
}
-void wxWindow::GetSize( int *width, int *height ) const
+void wxWindow::DoGetSize( int *width, int *height ) const
{
wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
{
GtkStyleClass *window_class = m_wxwindow->style->klass;
- if ((m_windowStyle & wxRAISED_BORDER) ||
- (m_windowStyle & wxSUNKEN_BORDER))
+ if (HasFlag(wxRAISED_BORDER) || HasFlag(wxSUNKEN_BORDER))
{
dw += 2 * window_class->xthickness;
dh += 2 * window_class->ythickness;
GtkWidget *viewport = scroll_window->viewport;
GtkStyleClass *viewport_class = viewport->style->klass;
- if ((m_windowStyle & wxRAISED_BORDER) ||
- (m_windowStyle & wxSUNKEN_BORDER))
+ if (HasFlag(wxRAISED_BORDER) || HasFlag(wxSUNKEN_BORDER))
{
dw += 2 * viewport_class->xthickness;
dh += 2 * viewport_class->ythickness;
GtkWidget *hscrollbar = scroll_window->hscrollbar;
GtkWidget *vscrollbar = scroll_window->vscrollbar;
- we use this instead: range.slider_width = 11 + 2*2pts edge
+ we use this instead: range.slider_width = 11 + 2*2pts edge
*/
if (scroll_window->vscrollbar_visible)
}
}
-void wxWindow::GetClientSize( int *width, int *height ) const
+void wxWindow::DoGetClientSize( int *width, int *height ) const
{
wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
{
GtkStyleClass *window_class = m_wxwindow->style->klass;
- if ((m_windowStyle & wxRAISED_BORDER) ||
- (m_windowStyle & wxSUNKEN_BORDER))
+ if (HasFlag(wxRAISED_BORDER) || HasFlag(wxSUNKEN_BORDER))
{
dw += 2 * window_class->xthickness;
dh += 2 * window_class->ythickness;
GtkWidget *viewport = scroll_window->viewport;
GtkStyleClass *viewport_class = viewport->style->klass;
- if ((m_windowStyle & wxRAISED_BORDER) ||
- (m_windowStyle & wxSUNKEN_BORDER))
+ if ( HasFlag(wxRAISED_BORDER) || HasFlag(wxSUNKEN_BORDER) )
{
dw += 2 * viewport_class->xthickness;
dh += 2 * viewport_class->ythickness;
GtkWidget *hscrollbar = scroll_window->hscrollbar;
GtkWidget *vscrollbar = scroll_window->vscrollbar;
- we use this instead: range.slider_width = 11 + 2*2pts edge
+ we use this instead: range.slider_width = 11 + 2*2pts edge
*/
if (scroll_window->vscrollbar_visible)
}
}
-void wxWindow::GetPosition( int *x, int *y ) const
+void wxWindow::DoGetPosition( int *x, int *y ) const
{
wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
if (y) (*y) = m_y;
}
-void wxWindow::ClientToScreen( int *x, int *y )
+void wxWindow::ClientToScreen( int *x, int *y ) const
{
wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
- if (!m_widget->window) return;
-
GdkWindow *source = (GdkWindow *) NULL;
if (m_wxwindow)
source = m_wxwindow->window;
if (y) *y += org_y;
}
-void wxWindow::ScreenToClient( int *x, int *y )
+void wxWindow::ScreenToClient( int *x, int *y ) const
{
wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
- if (!m_widget->window) return;
-
GdkWindow *source = (GdkWindow *) NULL;
if (m_wxwindow)
source = m_wxwindow->window;
if (y) *y -= org_y;
}
-void wxWindow::Centre( int direction )
+bool wxWindow::Show( bool show )
{
- wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
+ wxCHECK_MSG( (m_widget != NULL), FALSE, _T("invalid window") );
- int x = m_x;
- int y = m_y;
+ if ( !wxWindowBase::Show(show) )
+ return FALSE;
- if (m_parent)
- {
- int p_w = 0;
- int p_h = 0;
- m_parent->GetSize( &p_w, &p_h );
- if (direction & wxHORIZONTAL == wxHORIZONTAL) x = (p_w - m_width) / 2;
- if (direction & wxVERTICAL == wxVERTICAL) y = (p_h - m_height) / 2;
- }
+ if (show)
+ gtk_widget_show( m_widget );
else
- {
- if (direction & wxHORIZONTAL == wxHORIZONTAL) x = (gdk_screen_width () - m_width) / 2;
- if (direction & wxVERTICAL == wxVERTICAL) y = (gdk_screen_height () - m_height) / 2;
- }
+ gtk_widget_hide( m_widget );
- Move( x, y );
+ return TRUE;
}
-void wxWindow::Fit()
+bool wxWindow::Enable( bool enable )
{
- wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
+ wxCHECK_MSG( (m_widget != NULL), FALSE, _T("invalid window") );
- int maxX = 0;
- int maxY = 0;
- wxNode *node = m_children.First();
- while (node)
- {
- wxWindow *win = (wxWindow *)node->Data();
- int wx, wy, ww, wh;
- win->GetPosition(&wx, &wy);
- win->GetSize(&ww, &wh);
- if (wx + ww > maxX) maxX = wx + ww;
- if (wy + wh > maxY) maxY = wy + wh;
+ if ( !wxWindowBase::Enable(enable) )
+ return FALSE;
- node = node->Next();
- }
+ gtk_widget_set_sensitive( m_widget, enable );
+ if ( m_wxwindow )
+ gtk_widget_set_sensitive( m_wxwindow, enable );
- SetClientSize(maxX + 7, maxY + 14);
+ return TRUE;
}
-void wxWindow::SetSizeHints( int minW, int minH, int maxW, int maxH, int WXUNUSED(incW), int WXUNUSED(incH) )
+int wxWindow::GetCharHeight() const
{
- wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
+ wxCHECK_MSG( (m_widget != NULL), 12, _T("invalid window") );
- m_minWidth = minW;
- m_minHeight = minH;
- m_maxWidth = maxW;
- m_maxHeight = maxH;
-}
+ wxCHECK_MSG( m_font.Ok(), 12, _T("invalid font") );
-void wxWindow::OnSize( wxSizeEvent &WXUNUSED(event) )
-{
- /* this is commented because it also is commented
- in wxMSW. before I get even more questions about
- this. */
-// if (GetAutoLayout()) Layout();
+ GdkFont *font = m_font.GetInternalFont( 1.0 );
+
+ return font->ascent + font->descent;
}
-bool wxWindow::Show( bool show )
-{
- wxCHECK_MSG( (m_widget != NULL), FALSE, _T("invalid window") );
-
- if (show == m_isShown) return TRUE;
-
- if (show)
- gtk_widget_show( m_widget );
- else
- gtk_widget_hide( m_widget );
-
- m_isShown = show;
-
- return TRUE;
-}
-
-void wxWindow::Enable( bool enable )
-{
- wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
-
- m_isEnabled = enable;
-
- gtk_widget_set_sensitive( m_widget, enable );
- if (m_wxwindow) gtk_widget_set_sensitive( m_wxwindow, enable );
-}
-
-int wxWindow::GetCharHeight() const
-{
- wxCHECK_MSG( (m_widget != NULL), 12, _T("invalid window") );
-
- wxCHECK_MSG( m_font.Ok(), 12, _T("invalid font") );
-
- GdkFont *font = m_font.GetInternalFont( 1.0 );
-
- return font->ascent + font->descent;
-}
-
-int wxWindow::GetCharWidth() const
+int wxWindow::GetCharWidth() const
{
wxCHECK_MSG( (m_widget != NULL), 8, _T("invalid window") );
return gdk_string_width( font, "H" );
}
-void wxWindow::GetTextExtent( const wxString& string, int *x, int *y,
- int *descent, int *externalLeading, const wxFont *theFont, bool WXUNUSED(use16) ) const
+void wxWindow::GetTextExtent( const wxString& string,
+ int *x,
+ int *y,
+ int *descent,
+ int *externalLeading,
+ const wxFont *theFont ) const
{
wxFont fontToUse = m_font;
if (theFont) fontToUse = *theFont;
if (externalLeading) (*externalLeading) = 0; // ??
}
-void wxWindow::MakeModal( bool modal )
-{
- return;
-
- // Disable all other windows
- if (this->IsKindOf(CLASSINFO(wxDialog)) || this->IsKindOf(CLASSINFO(wxFrame)))
- {
- wxNode *node = wxTopLevelWindows.First();
- while (node)
- {
- wxWindow *win = (wxWindow *)node->Data();
- if (win != this) win->Enable(!modal);
-
- node = node->Next();
- }
- }
-}
-
void wxWindow::OnKeyDown( wxKeyEvent &event )
{
event.SetEventType( wxEVT_CHAR );
}
}
-wxWindow *wxWindow::FindFocus()
-{
- return g_focusWindow;
-}
-
bool wxWindow::AcceptsFocus() const
{
- return IsEnabled() && IsShown() && m_acceptsFocus;
+ return m_acceptsFocus && wxWindowBase::AcceptsFocus();
}
-void wxWindow::AddChild( wxWindow *child )
-{
- wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
- wxCHECK_RET( (child != NULL), _T("invalid child") );
-
- m_children.Append( child );
-}
-
-wxWindow *wxWindow::ReParent( wxWindow *newParent )
+bool wxWindow::Reparent( wxWindow *newParent )
{
wxCHECK_MSG( (m_widget != NULL), (wxWindow*) NULL, _T("invalid window") );
- wxWindow *oldParent = GetParent();
-
- if (oldParent) oldParent->RemoveChild( this );
+ if ( !wxWindowBase::Reparent(newParent) )
+ return FALSE;
gtk_widget_unparent( m_widget );
- if (newParent)
- {
- newParent->AddChild( this );
- (newParent->m_insertCallback)( newParent, this );
- }
-
- return oldParent;
-}
-
-void wxWindow::RemoveChild( wxWindow *child )
-{
- m_children.DeleteObject( child );
- child->m_parent = (wxWindow *) NULL;
-}
-
-void wxWindow::SetReturnCode( int retCode )
-{
- m_retCode = retCode;
-}
-
-int wxWindow::GetReturnCode()
-{
- return m_retCode;
+ return TRUE;
}
void wxWindow::Raise()
{
wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
- if (!m_widget->window) return;
-
- if (m_widget) gdk_window_raise( m_widget->window );
+ gdk_window_raise( m_widget->window );
}
void wxWindow::Lower()
{
wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
- if (!m_widget->window) return;
-
- if (m_widget) gdk_window_lower( m_widget->window );
-}
-
-wxEvtHandler *wxWindow::GetEventHandler() const
-{
- return m_eventHandler;
-}
-
-void wxWindow::SetEventHandler( wxEvtHandler *handler )
-{
- m_eventHandler = handler;
+ gdk_window_lower( m_widget->window );
}
-void wxWindow::PushEventHandler(wxEvtHandler *handler)
+bool wxWindow::SetCursor( const wxCursor &cursor )
{
- handler->SetNextHandler(GetEventHandler());
- SetEventHandler(handler);
-}
+ wxCHECK_MSG( (m_widget != NULL), FALSE, _T("invalid window") );
-wxEvtHandler *wxWindow::PopEventHandler(bool deleteHandler)
-{
- if (GetEventHandler())
+ if ( wxWindowBase::SetCursor(cursor) )
{
- wxEvtHandler *handlerA = GetEventHandler();
- wxEvtHandler *handlerB = handlerA->GetNextHandler();
- handlerA->SetNextHandler((wxEvtHandler *) NULL);
- SetEventHandler(handlerB);
- if (deleteHandler)
- {
- delete handlerA;
- return (wxEvtHandler*) NULL;
- }
- else
- return handlerA;
- }
- else
- return (wxEvtHandler *) NULL;
-}
-
-wxValidator *wxWindow::GetValidator()
-{
- return m_windowValidator;
-}
-
-void wxWindow::SetValidator( const wxValidator& validator )
-{
- if (m_windowValidator) delete m_windowValidator;
- m_windowValidator = (wxValidator*)validator.Clone();
- if (m_windowValidator) m_windowValidator->SetWindow(this);
-}
-
-void wxWindow::SetClientObject( wxClientData *data )
-{
- if (m_clientObject) delete m_clientObject;
- m_clientObject = data;
-}
-
-wxClientData *wxWindow::GetClientObject()
-{
- return m_clientObject;
-}
-
-void wxWindow::SetClientData( void *data )
-{
- m_clientData = data;
-}
+ if ((m_widget) && (m_widget->window))
+ gdk_window_set_cursor( m_widget->window, GetCursor().GetCursor() );
-void *wxWindow::GetClientData()
-{
- return m_clientData;
-}
+ if ((m_wxwindow) && (m_wxwindow->window))
+ gdk_window_set_cursor( m_wxwindow->window, GetCursor().GetCursor() );
-bool wxWindow::IsBeingDeleted()
-{
- return FALSE;
-}
-
-void wxWindow::SetId( wxWindowID id )
-{
- m_windowId = id;
-}
-
-wxWindowID wxWindow::GetId() const
-{
- return m_windowId;
-}
-
-void wxWindow::SetCursor( const wxCursor &cursor )
-{
- wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
-
- if (cursor.Ok())
- {
- if (cursor == m_cursor) return;
- m_cursor = cursor;
+ // cursor was set
+ return TRUE;
}
else
{
- m_cursor = *wxSTANDARD_CURSOR;
+ // cursor hasn't been changed
+ return FALSE;
}
-
- if (!m_widget->window) return;
-
- gdk_window_set_cursor( m_widget->window, m_cursor.GetCursor() );
-
- if ((m_wxwindow) && (m_wxwindow->window))
- gdk_window_set_cursor( m_wxwindow->window, m_cursor.GetCursor() );
}
void wxWindow::WarpPointer( int WXUNUSED(x), int WXUNUSED(y) )
{
- // TODO
+ // TODO
}
void wxWindow::Refresh( bool eraseBackground, const wxRect *rect )
{
wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
- if (!m_widget->window) return;
-
if (eraseBackground && m_wxwindow && m_wxwindow->window)
{
if (rect)
}
}
-wxRegion wxWindow::GetUpdateRegion() const
-{
- return m_updateRegion;
-}
-
-bool wxWindow::IsExposed( int x, int y) const
-{
- return (m_updateRegion.Contains( x, y ) != wxOutRegion );
-}
-
-bool wxWindow::IsExposed( int x, int y, int w, int h ) const
-{
- return (m_updateRegion.Contains( x, y, w, h ) != wxOutRegion );
-}
-
-bool wxWindow::IsExposed( const wxPoint& pt ) const
-{
- return (m_updateRegion.Contains( pt.x, pt.y ) != wxOutRegion );
-}
-
-bool wxWindow::IsExposed( const wxRect& rect ) const
-{
- return (m_updateRegion.Contains( rect.x, rect.y, rect.width, rect.height ) != wxOutRegion );
-}
-
void wxWindow::Clear()
{
wxCHECK_RET( m_widget != NULL, _T("invalid window") );
- if (!m_widget->window) return;
-
if (m_wxwindow && m_wxwindow->window)
{
gdk_window_clear( m_wxwindow->window );
}
#if wxUSE_TOOLTIPS
-void wxWindow::SetToolTip( const wxString &tip )
-{
- if (m_toolTip)
- {
- m_toolTip->SetTip( tip );
- }
- else
- {
- SetToolTip( new wxToolTip( tip ) );
- }
-
- // setting empty tooltip text does not remove the tooltip any more for
- // wxMSW compatibility - use SetToolTip((wxToolTip *)NULL) for this
-}
-
-void wxWindow::SetToolTip( wxToolTip *tip )
+void wxWindow::DoSetToolTip( wxToolTip *tip )
{
- if (m_toolTip)
- {
- m_toolTip->SetTip( (char*) NULL );
- delete m_toolTip;
- }
-
- m_toolTip = tip;
+ wxWindowBase::DoSetToolTip(tip);
- if (m_toolTip)
- m_toolTip->Apply( this );
+ if (m_tooltip)
+ m_tooltip->Apply( this );
}
void wxWindow::ApplyToolTip( GtkTooltips *tips, const wxChar *tip )
}
#endif // wxUSE_TOOLTIPS
-wxColour wxWindow::GetBackgroundColour() const
-{
- return m_backgroundColour;
-}
-
-void wxWindow::SetBackgroundColour( const wxColour &colour )
+bool wxWindow::SetBackgroundColour( const wxColour &colour )
{
- wxCHECK_RET( m_widget != NULL, _T("invalid window") );
-
- if (m_backgroundColour == colour) return;
-
- m_backgroundColour = colour;
- if (!m_backgroundColour.Ok()) return;
+ wxCHECK_MSG( m_widget != NULL, FALSE, _T("invalid window") );
- GtkWidget *connect_widget = GetConnectWidget();
- if (!connect_widget->window) return;
+ if ( !wxWindowBase::SetBackgroundColour(colour) )
+ return FALSE;
if (m_wxwindow && m_wxwindow->window)
{
- /* wxMSW doesn't clear the window here. I don't do that
- either to provide compatibility. call Clear() to do
- the job. */
+ // wxMSW doesn't clear the window here. I don't do that either to
+ // provide compatibility. call Clear() to do the job.
m_backgroundColour.CalcPixel( gdk_window_get_colormap( m_wxwindow->window ) );
gdk_window_set_background( m_wxwindow->window, m_backgroundColour.GetColor() );
wxColour sysbg = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE );
- if (sysbg.Red() == colour.Red() &&
- sysbg.Green() == colour.Green() &&
- sysbg.Blue() == colour.Blue())
+ if ( sysbg == m_backgroundColour )
{
m_backgroundColour = wxNullColour;
ApplyWidgetStyle();
{
ApplyWidgetStyle();
}
-}
-wxColour wxWindow::GetForegroundColour() const
-{
- return m_foregroundColour;
+ return TRUE;
}
-void wxWindow::SetForegroundColour( const wxColour &colour )
+bool wxWindow::SetForegroundColour( const wxColour &colour )
{
- wxCHECK_RET( m_widget != NULL, _T("invalid window") );
-
- if (m_foregroundColour == colour) return;
-
- m_foregroundColour = colour;
- if (!m_foregroundColour.Ok()) return;
+ wxCHECK_MSG( m_widget != NULL, FALSE, _T("invalid window") );
- if (!m_widget->window) return;
+ if ( !wxWindowBase::SetForegroundColour(colour) )
+ return FALSE;
wxColour sysbg = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE );
- if (sysbg.Red() == colour.Red() &&
- sysbg.Green() == colour.Green() &&
- sysbg.Blue() == colour.Blue())
+ if ( sysbg == m_foregroundColour )
{
m_backgroundColour = wxNullColour;
ApplyWidgetStyle();
{
ApplyWidgetStyle();
}
+
+ return TRUE;
}
GtkStyle *wxWindow::GetWidgetStyle()
{
if (m_widgetStyle) gtk_style_unref( m_widgetStyle );
- m_widgetStyle =
- gtk_style_copy(
- gtk_widget_get_style( m_widget ) );
+ m_widgetStyle = gtk_style_copy( gtk_widget_get_style( m_widget ) );
return m_widgetStyle;
}
{
}
-bool wxWindow::Validate()
-{
- wxCHECK_MSG( m_widget != NULL, FALSE, _T("invalid window") );
-
- wxNode *node = m_children.First();
- while (node)
- {
- wxWindow *child = (wxWindow *)node->Data();
- if (child->GetValidator() && /* child->GetValidator()->Ok() && */ !child->GetValidator()->Validate(this))
- {
- return FALSE;
- }
- node = node->Next();
- }
- return TRUE;
-}
-
-bool wxWindow::TransferDataToWindow()
-{
- wxCHECK_MSG( m_widget != NULL, FALSE, _T("invalid window") );
-
- wxNode *node = m_children.First();
- while (node)
- {
- wxWindow *child = (wxWindow *)node->Data();
- if (child->GetValidator() && /* child->GetValidator()->Ok() && */
- !child->GetValidator()->TransferToWindow() )
- {
- wxMessageBox( _("Application Error"), _("Could not transfer data to window"), wxOK|wxICON_EXCLAMATION );
- return FALSE;
- }
- node = node->Next();
- }
- return TRUE;
-}
-
-bool wxWindow::TransferDataFromWindow()
-{
- wxCHECK_MSG( m_widget != NULL, FALSE, _T("invalid window") );
-
- wxNode *node = m_children.First();
- while (node)
- {
- wxWindow *child = (wxWindow *)node->Data();
- if ( child->GetValidator() && /* child->GetValidator()->Ok() && */ !child->GetValidator()->TransferFromWindow() )
- {
- return FALSE;
- }
- node = node->Next();
- }
- return TRUE;
-}
-
-void wxWindow::SetAcceleratorTable( const wxAcceleratorTable& accel )
-{
- m_acceleratorTable = accel;
-}
-
-void wxWindow::OnInitDialog( wxInitDialogEvent &WXUNUSED(event) )
-{
- TransferDataToWindow();
-}
-
-void wxWindow::InitDialog()
-{
- wxCHECK_RET( m_widget != NULL, _T("invalid window") );
-
- wxInitDialogEvent event(GetId());
- event.SetEventObject( this );
- GetEventHandler()->ProcessEvent(event);
-}
-
static void SetInvokingWindow( wxMenu *menu, wxWindow *win )
{
menu->SetInvokingWindow( win );
if (m_dropTarget) m_dropTarget->RegisterWidget( dnd_widget );
}
-wxDropTarget *wxWindow::GetDropTarget() const
-{
- return m_dropTarget;
-}
-
-#endif
+#endif // wxUSE_DRAG_AND_DROP
GtkWidget* wxWindow::GetConnectWidget()
{
return (window == m_widget->window);
}
-void wxWindow::SetFont( const wxFont &font )
+bool wxWindow::SetFont( const wxFont &font )
{
- wxCHECK_RET( m_widget != NULL, _T("invalid window") );
-
- if (m_font == font) return;
-
- if (((wxFont*)&font)->Ok())
- m_font = font;
- else
- m_font = *wxSWISS_FONT;
+ wxCHECK_MSG( m_widget != NULL, FALSE, _T("invalid window") );
- if (!m_widget->window) return;
+ if ( !wxWindowBase::SetFont(font) )
+ {
+ // nothing to do
+ return FALSE;
+ }
wxColour sysbg = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE );
- if (sysbg.Red() == m_backgroundColour.Red() &&
- sysbg.Green() == m_backgroundColour.Green() &&
- sysbg.Blue() == m_backgroundColour.Blue())
+ if ( sysbg == m_backgroundColour )
{
m_backgroundColour = wxNullColour;
ApplyWidgetStyle();
{
ApplyWidgetStyle();
}
-}
-
-void wxWindow::SetWindowStyleFlag( long flag )
-{
- m_windowStyle = flag;
-}
-long wxWindow::GetWindowStyleFlag() const
-{
- return m_windowStyle;
+ return TRUE;
}
void wxWindow::CaptureMouse()
wxCHECK_RET( g_capturing == FALSE, _T("CaptureMouse called twice") );
- if (!m_widget->window) return;
-
GtkWidget *connect_widget = GetConnectWidget();
gtk_grab_add( connect_widget );
gdk_pointer_grab( connect_widget->window, FALSE,
wxCHECK_RET( g_capturing == TRUE, _T("ReleaseMouse called twice") );
- if (!m_widget->window) return;
-
GtkWidget *connect_widget = GetConnectWidget();
gtk_grab_remove( connect_widget );
gdk_pointer_ungrab ( GDK_CURRENT_TIME );
g_capturing = FALSE;
}
-void wxWindow::SetTitle( const wxString &WXUNUSED(title) )
-{
-}
-
-wxString wxWindow::GetTitle() const
-{
- return (wxString&)m_windowName;
-}
-
-wxString wxWindow::GetLabel() const
-{
- return GetTitle();
-}
-
-void wxWindow::SetName( const wxString &name )
-{
- m_windowName = name;
-}
-
-wxString wxWindow::GetName() const
-{
- return (wxString&)m_windowName;
-}
-
-bool wxWindow::IsShown() const
-{
- return m_isShown;
-}
-
-bool wxWindow::IsRetained()
+bool wxWindow::IsRetained() const
{
return FALSE;
}
-wxWindow *wxWindow::FindWindow( long id )
-{
- if (id == m_windowId) return this;
- wxNode *node = m_children.First();
- while (node)
- {
- wxWindow *child = (wxWindow*)node->Data();
- wxWindow *res = child->FindWindow( id );
- if (res) return res;
- node = node->Next();
- }
- return (wxWindow *) NULL;
-}
-
-wxWindow *wxWindow::FindWindow( const wxString& name )
-{
- if (name == m_windowName) return this;
- wxNode *node = m_children.First();
- while (node)
- {
- wxWindow *child = (wxWindow*)node->Data();
- wxWindow *res = child->FindWindow( name );
- if (res) return res;
- node = node->Next();
- }
- return (wxWindow *) NULL;
-}
-
void wxWindow::SetScrollbar( int orient, int pos, int thumbVisible,
int range, bool refresh )
{
m_vAdjust->page_size = fthumb;
}
- if (m_wxwindow)
+ if (m_wxwindow->window)
{
if (orient == wxHORIZONTAL)
gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "changed" );
wxCHECK_RET( m_wxwindow != NULL, _T("window needs client area for scrolling") );
- if (!m_scrollGC)
+ wxNode *node = m_children.First();
+ while (node)
{
- m_scrollGC = gdk_gc_new( m_wxwindow->window );
- gdk_gc_set_exposures( m_scrollGC, TRUE );
+ wxWindow *child = (wxWindow*) node->Data();
+ child->Move( child->GetX() + dx, child->GetY() + dy );
+ node = node->Next();
}
int cw = 0;
int ch = 0;
GetClientSize( &cw, &ch );
+
int w = cw - abs(dx);
int h = ch - abs(dy);
-
if ((h < 0) || (w < 0))
{
Refresh();
+ return;
}
- else
- {
- int s_x = 0;
- int s_y = 0;
- if (dx < 0) s_x = -dx;
- if (dy < 0) s_y = -dy;
- int d_x = 0;
- int d_y = 0;
- if (dx > 0) d_x = dx;
- if (dy > 0) d_y = dy;
-
- gdk_window_copy_area( m_wxwindow->window, m_scrollGC, d_x, d_y,
- m_wxwindow->window, s_x, s_y, w, h );
-
- wxRect rect;
- if (dx < 0) rect.x = cw+dx; else rect.x = 0;
- if (dy < 0) rect.y = ch+dy; else rect.y = 0;
- if (dy != 0) rect.width = cw; else rect.width = abs(dx);
- if (dx != 0) rect.height = ch; else rect.height = abs(dy);
-
- Refresh( TRUE, &rect );
- }
-
- wxNode *node = m_children.First();
- while (node)
- {
- wxWindow *child = (wxWindow*) node->Data();
- child->Move( child->m_x + dx, child->m_y + dy );
- node = node->Next();
- }
-
-}
-
-//-------------------------------------------------------------------------------------
-// Layout
-//-------------------------------------------------------------------------------------
-
-wxLayoutConstraints *wxWindow::GetConstraints() const
-{
- return m_constraints;
-}
-
-void wxWindow::SetConstraints( wxLayoutConstraints *constraints )
-{
- if (m_constraints)
- {
- UnsetConstraints(m_constraints);
- delete m_constraints;
- }
- m_constraints = constraints;
- if (m_constraints)
- {
- // Make sure other windows know they're part of a 'meaningful relationship'
- if (m_constraints->left.GetOtherWindow() && (m_constraints->left.GetOtherWindow() != this))
- m_constraints->left.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
- if (m_constraints->top.GetOtherWindow() && (m_constraints->top.GetOtherWindow() != this))
- m_constraints->top.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
- if (m_constraints->right.GetOtherWindow() && (m_constraints->right.GetOtherWindow() != this))
- m_constraints->right.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
- if (m_constraints->bottom.GetOtherWindow() && (m_constraints->bottom.GetOtherWindow() != this))
- m_constraints->bottom.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
- if (m_constraints->width.GetOtherWindow() && (m_constraints->width.GetOtherWindow() != this))
- m_constraints->width.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
- if (m_constraints->height.GetOtherWindow() && (m_constraints->height.GetOtherWindow() != this))
- m_constraints->height.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
- if (m_constraints->centreX.GetOtherWindow() && (m_constraints->centreX.GetOtherWindow() != this))
- m_constraints->centreX.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
- if (m_constraints->centreY.GetOtherWindow() && (m_constraints->centreY.GetOtherWindow() != this))
- m_constraints->centreY.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
- }
-;
-}
-;
-
-void wxWindow::SetAutoLayout( bool autoLayout )
-{
- m_autoLayout = autoLayout;
-}
-
-bool wxWindow::GetAutoLayout() const
-{
- return m_autoLayout;
-}
-
-wxSizer *wxWindow::GetSizer() const
-{
- return m_windowSizer;
-}
-
-void wxWindow::SetSizerParent( wxWindow *win )
-{
- m_sizerParent = win;
-}
-
-wxWindow *wxWindow::GetSizerParent() const
-{
- return m_sizerParent;
-}
-
-// This removes any dangling pointers to this window
-// in other windows' constraintsInvolvedIn lists.
-void wxWindow::UnsetConstraints(wxLayoutConstraints *c)
-{
- if (c)
- {
- if (c->left.GetOtherWindow() && (c->top.GetOtherWindow() != this))
- c->left.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
- if (c->top.GetOtherWindow() && (c->top.GetOtherWindow() != this))
- c->top.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
- if (c->right.GetOtherWindow() && (c->right.GetOtherWindow() != this))
- c->right.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
- if (c->bottom.GetOtherWindow() && (c->bottom.GetOtherWindow() != this))
- c->bottom.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
- if (c->width.GetOtherWindow() && (c->width.GetOtherWindow() != this))
- c->width.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
- if (c->height.GetOtherWindow() && (c->height.GetOtherWindow() != this))
- c->height.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
- if (c->centreX.GetOtherWindow() && (c->centreX.GetOtherWindow() != this))
- c->centreX.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
- if (c->centreY.GetOtherWindow() && (c->centreY.GetOtherWindow() != this))
- c->centreY.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
- }
-}
-
-// Back-pointer to other windows we're involved with, so if we delete
-// this window, we must delete any constraints we're involved with.
-void wxWindow::AddConstraintReference(wxWindow *otherWin)
-{
- if (!m_constraintsInvolvedIn)
- m_constraintsInvolvedIn = new wxList;
- if (!m_constraintsInvolvedIn->Member(otherWin))
- m_constraintsInvolvedIn->Append(otherWin);
-}
-
-// REMOVE back-pointer to other windows we're involved with.
-void wxWindow::RemoveConstraintReference(wxWindow *otherWin)
-{
- if (m_constraintsInvolvedIn)
- m_constraintsInvolvedIn->DeleteObject(otherWin);
-}
-
-// Reset any constraints that mention this window
-void wxWindow::DeleteRelatedConstraints()
-{
- if (m_constraintsInvolvedIn)
- {
- wxNode *node = m_constraintsInvolvedIn->First();
- while (node)
- {
- wxWindow *win = (wxWindow *)node->Data();
- wxNode *next = node->Next();
- wxLayoutConstraints *constr = win->GetConstraints();
-
- // Reset any constraints involving this window
- if (constr)
- {
- constr->left.ResetIfWin((wxWindow *)this);
- constr->top.ResetIfWin((wxWindow *)this);
- constr->right.ResetIfWin((wxWindow *)this);
- constr->bottom.ResetIfWin((wxWindow *)this);
- constr->width.ResetIfWin((wxWindow *)this);
- constr->height.ResetIfWin((wxWindow *)this);
- constr->centreX.ResetIfWin((wxWindow *)this);
- constr->centreY.ResetIfWin((wxWindow *)this);
- }
- delete node;
- node = next;
- }
- delete m_constraintsInvolvedIn;
- m_constraintsInvolvedIn = (wxList *) NULL;
- }
-}
-
-void wxWindow::SetSizer(wxSizer *sizer)
-{
- m_windowSizer = sizer;
- if (sizer)
- sizer->SetSizerParent((wxWindow *)this);
-}
-
-/*
- * New version
- */
-
-bool wxWindow::Layout()
-{
- if (GetConstraints())
- {
- int w, h;
- GetClientSize(&w, &h);
- GetConstraints()->width.SetValue(w);
- GetConstraints()->height.SetValue(h);
- }
-
- // If top level (one sizer), evaluate the sizer's constraints.
- if (GetSizer())
- {
- int noChanges;
- GetSizer()->ResetConstraints(); // Mark all constraints as unevaluated
- GetSizer()->LayoutPhase1(&noChanges);
- GetSizer()->LayoutPhase2(&noChanges);
- GetSizer()->SetConstraintSizes(); // Recursively set the real window sizes
-
- return TRUE;
- }
- else
- {
- // Otherwise, evaluate child constraints
- ResetConstraints(); // Mark all constraints as unevaluated
- DoPhase(1); // Just one phase need if no sizers involved
- DoPhase(2);
- SetConstraintSizes(); // Recursively set the real window sizes
- }
- return TRUE;
-}
-
-
-// Do a phase of evaluating constraints:
-// the default behaviour. wxSizers may do a similar
-// thing, but also impose their own 'constraints'
-// and order the evaluation differently.
-bool wxWindow::LayoutPhase1(int *noChanges)
-{
- wxLayoutConstraints *constr = GetConstraints();
- if (constr)
- {
- return constr->SatisfyConstraints((wxWindow *)this, noChanges);
- }
- else
- return TRUE;
-}
-
-bool wxWindow::LayoutPhase2(int *noChanges)
-{
- *noChanges = 0;
-
- // Layout children
- DoPhase(1);
- DoPhase(2);
- return TRUE;
-}
-
-// Do a phase of evaluating child constraints
-bool wxWindow::DoPhase(int phase)
-{
- int noIterations = 0;
- int maxIterations = 500;
- int noChanges = 1;
- int noFailures = 0;
- wxList succeeded;
- while ((noChanges > 0) && (noIterations < maxIterations))
- {
- noChanges = 0;
- noFailures = 0;
- wxNode *node = m_children.First();
- while (node)
- {
- wxWindow *child = (wxWindow *)node->Data();
- if (!child->IsKindOf(CLASSINFO(wxFrame)) && !child->IsKindOf(CLASSINFO(wxDialog)))
- {
- wxLayoutConstraints *constr = child->GetConstraints();
- if (constr)
- {
- if (succeeded.Member(child))
- {
- }
- else
- {
- int tempNoChanges = 0;
- bool success = ( (phase == 1) ? child->LayoutPhase1(&tempNoChanges) : child->LayoutPhase2(&tempNoChanges) ) ;
- noChanges += tempNoChanges;
- if (success)
- {
- succeeded.Append(child);
- }
- }
- }
- }
- node = node->Next();
- }
- noIterations ++;
- }
- return TRUE;
-}
-
-void wxWindow::ResetConstraints()
-{
- wxLayoutConstraints *constr = GetConstraints();
- if (constr)
- {
- constr->left.SetDone(FALSE);
- constr->top.SetDone(FALSE);
- constr->right.SetDone(FALSE);
- constr->bottom.SetDone(FALSE);
- constr->width.SetDone(FALSE);
- constr->height.SetDone(FALSE);
- constr->centreX.SetDone(FALSE);
- constr->centreY.SetDone(FALSE);
- }
- wxNode *node = m_children.First();
- while (node)
- {
- wxWindow *win = (wxWindow *)node->Data();
- if (!win->IsKindOf(CLASSINFO(wxFrame)) && !win->IsKindOf(CLASSINFO(wxDialog)))
- win->ResetConstraints();
- node = node->Next();
- }
-}
-
-// Need to distinguish between setting the 'fake' size for
-// windows and sizers, and setting the real values.
-void wxWindow::SetConstraintSizes(bool recurse)
-{
- wxLayoutConstraints *constr = GetConstraints();
- if (constr && constr->left.GetDone() && constr->right.GetDone() &&
- constr->width.GetDone() && constr->height.GetDone())
- {
- int x = constr->left.GetValue();
- int y = constr->top.GetValue();
- int w = constr->width.GetValue();
- int h = constr->height.GetValue();
-
- // If we don't want to resize this window, just move it...
- if ((constr->width.GetRelationship() != wxAsIs) ||
- (constr->height.GetRelationship() != wxAsIs))
- {
- // Calls Layout() recursively. AAAGH. How can we stop that.
- // Simply take Layout() out of non-top level OnSizes.
- SizerSetSize(x, y, w, h);
- }
- else
- {
- SizerMove(x, y);
- }
- }
- else if (constr)
- {
- wxChar *windowClass = this->GetClassInfo()->GetClassName();
-
- wxString winName;
- if (GetName() == _T(""))
- winName = _T("unnamed");
- else
- winName = GetName();
- wxLogDebug( _T("Constraint(s) not satisfied for window of type %s, name %s:\n"),
- (const wxChar *)windowClass,
- (const wxChar *)winName);
- if (!constr->left.GetDone()) wxLogDebug( _T(" unsatisfied 'left' constraint.\n") );
- if (!constr->right.GetDone()) wxLogDebug( _T(" unsatisfied 'right' constraint.\n") );
- if (!constr->width.GetDone()) wxLogDebug( _T(" unsatisfied 'width' constraint.\n") );
- if (!constr->height.GetDone()) wxLogDebug( _T(" unsatisfied 'height' constraint.\n") );
- wxLogDebug( _T("Please check constraints: try adding AsIs() constraints.\n") );
- }
-
- if (recurse)
- {
- wxNode *node = m_children.First();
- while (node)
- {
- wxWindow *win = (wxWindow *)node->Data();
- if (!win->IsKindOf(CLASSINFO(wxFrame)) && !win->IsKindOf(CLASSINFO(wxDialog)))
- win->SetConstraintSizes();
- node = node->Next();
- }
- }
-}
-
-// This assumes that all sizers are 'on' the same
-// window, i.e. the parent of this window.
-void wxWindow::TransformSizerToActual(int *x, int *y) const
-{
- if (!m_sizerParent || m_sizerParent->IsKindOf(CLASSINFO(wxDialog)) ||
- m_sizerParent->IsKindOf(CLASSINFO(wxFrame)) )
- return;
-
- int xp, yp;
- m_sizerParent->GetPosition(&xp, &yp);
- m_sizerParent->TransformSizerToActual(&xp, &yp);
- *x += xp;
- *y += yp;
-}
-
-void wxWindow::SizerSetSize(int x, int y, int w, int h)
-{
- int xx = x;
- int yy = y;
- TransformSizerToActual(&xx, &yy);
- SetSize(xx, yy, w, h);
-}
+ int s_x = 0;
+ int s_y = 0;
+ if (dx < 0) s_x = -dx;
+ if (dy < 0) s_y = -dy;
+ int d_x = 0;
+ int d_y = 0;
+ if (dx > 0) d_x = dx;
+ if (dy > 0) d_y = dy;
-void wxWindow::SizerMove(int x, int y)
-{
- int xx = x;
- int yy = y;
- TransformSizerToActual(&xx, &yy);
- Move(xx, yy);
-}
-
-// Only set the size/position of the constraint (if any)
-void wxWindow::SetSizeConstraint(int x, int y, int w, int h)
-{
- wxLayoutConstraints *constr = GetConstraints();
- if (constr)
- {
- if (x != -1)
- {
- constr->left.SetValue(x);
- constr->left.SetDone(TRUE);
- }
- if (y != -1)
- {
- constr->top.SetValue(y);
- constr->top.SetDone(TRUE);
- }
- if (w != -1)
- {
- constr->width.SetValue(w);
- constr->width.SetDone(TRUE);
- }
- if (h != -1)
+ if (!m_scrollGC)
{
- constr->height.SetValue(h);
- constr->height.SetDone(TRUE);
+ m_scrollGC = gdk_gc_new( m_wxwindow->window );
+ gdk_gc_set_exposures( m_scrollGC, TRUE );
}
- }
-}
-void wxWindow::MoveConstraint(int x, int y)
-{
- wxLayoutConstraints *constr = GetConstraints();
- if (constr)
- {
- if (x != -1)
- {
- constr->left.SetValue(x);
- constr->left.SetDone(TRUE);
- }
- if (y != -1)
- {
- constr->top.SetValue(y);
- constr->top.SetDone(TRUE);
- }
- }
-}
+ gdk_window_copy_area( m_wxwindow->window, m_scrollGC, d_x, d_y,
+ m_wxwindow->window, s_x, s_y, w, h );
-void wxWindow::GetSizeConstraint(int *w, int *h) const
-{
- wxLayoutConstraints *constr = GetConstraints();
- if (constr)
- {
- *w = constr->width.GetValue();
- *h = constr->height.GetValue();
- }
- else
- GetSize(w, h);
-}
+ wxRect rect;
+ if (dx < 0) rect.x = cw+dx; else rect.x = 0;
+ if (dy < 0) rect.y = ch+dy; else rect.y = 0;
+ if (dy != 0) rect.width = cw; else rect.width = abs(dx);
+ if (dx != 0) rect.height = ch; else rect.height = abs(dy);
-void wxWindow::GetClientSizeConstraint(int *w, int *h) const
-{
- wxLayoutConstraints *constr = GetConstraints();
- if (constr)
- {
- *w = constr->width.GetValue();
- *h = constr->height.GetValue();
- }
- else
- GetClientSize(w, h);
+ Refresh( TRUE, &rect );
}
-void wxWindow::GetPositionConstraint(int *x, int *y) const
+void wxWindow::SetScrolling(bool scroll)
{
- wxLayoutConstraints *constr = GetConstraints();
- if (constr)
- {
- *x = constr->left.GetValue();
- *y = constr->top.GetValue();
- }
- else
- GetPosition(x, y);
+ m_isScrolling = g_blockEventsOnScroll = scroll;
}
-
wxApp *wxTheApp = (wxApp *) NULL;
wxAppInitializerFunction wxApp::m_appInitFn = (wxAppInitializerFunction) NULL;
-extern wxList wxPendingDelete;
#if wxUSE_THREADS
extern wxList *wxPendingEvents;
extern wxCriticalSection *wxPendingEventsLocker;
m_colorCube = (unsigned char*)malloc(32 * 32 * 32);
- for (int r = 0; r < 32; r++)
- {
+ for (int r = 0; r < 32; r++)
+ {
for (int g = 0; g < 32; g++)
{
for (int b = 0; b < 32; b++)
int gg = (g << 3) | (g >> 2);
int bb = (b << 3) | (b >> 2);
+ int index = -1;
+
GdkColor *colors = cmap->colors;
- if(colors)
- {
- int max = 3 * 65536;
- int index = -1;
-
- for (int i = 0; i < cmap->size; i++)
- {
- int rdiff = ((rr << 8) - colors[i].red);
- int gdiff = ((gg << 8) - colors[i].green);
- int bdiff = ((bb << 8) - colors[i].blue);
- int sum = ABS (rdiff) + ABS (gdiff) + ABS (bdiff);
- if (sum < max) { index = i; max = sum; }
+ if(colors)
+ {
+ int max = 3 * 65536;
+
+ for (int i = 0; i < cmap->size; i++)
+ {
+ int rdiff = ((rr << 8) - colors[i].red);
+ int gdiff = ((gg << 8) - colors[i].green);
+ int bdiff = ((bb << 8) - colors[i].blue);
+ int sum = ABS (rdiff) + ABS (gdiff) + ABS (bdiff);
+ if (sum < max)
+ {
+ index = i; max = sum;
+ }
+ }
}
- }
+
m_colorCube[ (r*1024) + (g*32) + b ] = index;
}
}
delete obj;
- if (wxPendingDelete.Member(obj))
- delete node;
+ if (wxPendingDelete.Find(obj))
+ delete node;
node = wxPendingDelete.First();
}
m_parent->AddChild( this );
- (m_parent->m_insertCallback)( m_parent, this );
+ m_parent->InsertChild( this );
PostCreation();
SetBitmap();
}
-void wxBitmapButton::Enable( const bool enable )
+bool wxBitmapButton::Enable( bool enable )
{
- wxWindow::Enable(enable);
+ if ( !wxWindow::Enable(enable) )
+ return FALSE;
- SetBitmap();
+ SetBitmap();
+
+ return TRUE;
}
void wxBitmapButton::HasFocus()
gtk_signal_connect( GTK_OBJECT(m_widget), "clicked",
GTK_SIGNAL_FUNC(gtk_button_clicked_callback), (gpointer*)this );
- m_parent->AddChild( this );
-
- (m_parent->m_insertCallback)( m_parent, this );
+ m_parent->DoAddChild( this );
PostCreation();
gtk_label_set( GTK_LABEL( GTK_BUTTON(m_widget)->child ), GetLabel().mbc_str() );
}
-void wxButton::Enable( bool enable )
+bool wxButton::Enable( bool enable )
{
- wxCHECK_RET( m_widget != NULL, _T("invalid button") );
-
- wxControl::Enable( enable );
+ if ( !wxControl::Enable( enable ) )
+ return FALSE;
gtk_widget_set_sensitive( GTK_BUTTON(m_widget)->child, enable );
+
+ return TRUE;
}
void wxButton::ApplyWidgetStyle()
GTK_SIGNAL_FUNC(gtk_checkbox_clicked_callback),
(gpointer *)this );
- m_parent->AddChild( this );
-
- (m_parent->m_insertCallback)( m_parent, this );
+ m_parent->DoAddChild( this );
PostCreation();
gtk_label_set( GTK_LABEL(m_widgetLabel), GetLabel().mbc_str() );
}
-void wxCheckBox::Enable( bool enable )
+bool wxCheckBox::Enable( bool enable )
{
- wxCHECK_RET( m_widgetLabel != NULL, _T("invalid checkbox") );
-
- wxControl::Enable( enable );
+ if ( !wxControl::Enable( enable ) )
+ return FALSE;
gtk_widget_set_sensitive( m_widgetLabel, enable );
+
+ return TRUE;
}
void wxCheckBox::ApplyWidgetStyle()
}
gtk_option_menu_set_menu( GTK_OPTION_MENU(m_widget), menu );
- m_parent->AddChild( this );
-
- (m_parent->m_insertCallback)( m_parent, this );
+ m_parent->DoAddChild( this );
PostCreation();
gtk_widget_show( list_item );
}
- m_parent->AddChild( this );
-
- (m_parent->m_insertCallback)( m_parent, this );
+ m_parent->DoAddChild( this );
PostCreation();
void wxComboBox::OnSize( wxSizeEvent &event )
{
- wxControl::OnSize( event );
+ event.Skip();
return;
if (!window) return;
- GtkWidget *widget = window->m_wxwindow;
- if (!widget) return;
+ GtkWidget *widget = window->GetWxWindow();
+ if (!widget)
+ return;
m_window = widget->window;
/* still not realized ? */
if (!m_window) return;
- if (window->m_wxwindow)
- m_cmap = gtk_widget_get_colormap( window->m_wxwindow );
+ if (window->GetWxWindow())
+ m_cmap = gtk_widget_get_colormap( window->GetWxWindow() );
else
- m_cmap = gtk_widget_get_colormap( window->m_widget );
+ m_cmap = gtk_widget_get_colormap( window->GetHandle() );
m_isMemDC = FALSE;
printf( ".\n" );
*/
- if ((win->m_width != alloc->width) || (win->m_height != alloc->height))
+ if ((win->GetWidth() != alloc->width) || (win->GetHeight() != alloc->height))
{
- win->m_sizeSet = FALSE;
- win->m_width = alloc->width;
- win->m_height = alloc->height;
+ win->InternalSetSize( alloc->width, alloc->height );
}
}
if (!win->HasVMT()) return FALSE;
- win->m_x = event->x;
- win->m_y = event->y;
+ win->InternalSetPosition(event->x, event->y);
- wxMoveEvent mevent( wxPoint(win->m_x,win->m_y), win->GetId() );
+ wxMoveEvent mevent( wxPoint(win->GetX(),win->GetY()), win->GetId() );
mevent.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( mevent );
{
wxIcon icon( win->m_icon );
win->m_icon = wxNullIcon;
- win->SetIcon( icon );
+ win->SetIcon( icon );
}
return FALSE;
{
/* I haven''t been able to set the position of
the dialog before it is shown, so I do it here */
- gtk_widget_set_uposition( widget, win->m_x, win->m_y );
+ gtk_widget_set_uposition( widget, win->GetX(), win->GetY() );
/* all this is for Motif Window Manager "hints" and is supposed to be
recognized by other WM as well. not tested. */
long decor = (long) GDK_DECOR_BORDER;
long func = (long) GDK_FUNC_MOVE ;
- if ((win->m_windowStyle & wxCAPTION) != 0)
- decor |= GDK_DECOR_TITLE;
- if ((win->m_windowStyle & wxSYSTEM_MENU) != 0)
+ if ((win->GetWindowStyle() & wxCAPTION) != 0)
+ decor |= GDK_DECOR_TITLE;
+ if ((win->GetWindowStyle() & wxSYSTEM_MENU) != 0)
{
decor |= GDK_DECOR_MENU;
func |= GDK_FUNC_CLOSE;
}
- if ((win->m_windowStyle & wxMINIMIZE_BOX) != 0)
+ if ((win->GetWindowStyle() & wxMINIMIZE_BOX) != 0)
{
- func |= GDK_FUNC_MINIMIZE;
- decor |= GDK_DECOR_MINIMIZE;
+ func |= GDK_FUNC_MINIMIZE;
+ decor |= GDK_DECOR_MINIMIZE;
}
- if ((win->m_windowStyle & wxMAXIMIZE_BOX) != 0)
+ if ((win->GetWindowStyle() & wxMAXIMIZE_BOX) != 0)
{
- decor |= GDK_DECOR_MAXIMIZE;
- func |= GDK_FUNC_MAXIMIZE;
+ decor |= GDK_DECOR_MAXIMIZE;
+ func |= GDK_FUNC_MAXIMIZE;
}
- if ((win->m_windowStyle & wxRESIZE_BORDER) != 0)
+ if ((win->GetWindowStyle() & wxRESIZE_BORDER) != 0)
{
func |= GDK_FUNC_RESIZE;
decor |= GDK_DECOR_RESIZEH;
}
- gdk_window_set_decorations( win->m_widget->window, (GdkWMDecoration)decor);
- gdk_window_set_functions( win->m_widget->window, (GdkWMFunction)func);
+ gdk_window_set_decorations( win->GetHandle()->window, (GdkWMDecoration)decor);
+ gdk_window_set_functions( win->GetHandle()->window, (GdkWMFunction)func);
/* GTK's shrinking/growing policy */
- if ((win->m_windowStyle & wxRESIZE_BORDER) == 0)
- gtk_window_set_policy(GTK_WINDOW(win->m_widget), 0, 0, 1);
+ if ((win->GetWindowStyle() & wxRESIZE_BORDER) == 0)
+ gtk_window_set_policy(GTK_WINDOW(win->GetHandle()), 0, 0, 1);
else
- gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1);
+ gtk_window_set_policy(GTK_WINDOW(win->GetHandle()), 1, 1, 1);
return FALSE;
}
void wxDialog::Init()
{
+ m_returnCode = 0;
m_sizeSet = FALSE;
m_modalShowing = FALSE;
}
/* we cannot set MWM hints before the widget has
been realized, so we do this directly after realization */
gtk_signal_connect( GTK_OBJECT(m_widget), "realize",
- GTK_SIGNAL_FUNC(gtk_dialog_realized_callback), (gpointer) this );
+ GTK_SIGNAL_FUNC(gtk_dialog_realized_callback), (gpointer) this );
/* we set the position of the window after the map event. setting it
before has no effect (with KWM) */
gtk_signal_connect( GTK_OBJECT(m_widget), "map",
- GTK_SIGNAL_FUNC(gtk_dialog_map_callback), (gpointer) this );
+ GTK_SIGNAL_FUNC(gtk_dialog_map_callback), (gpointer) this );
/* the user resized the frame by dragging etc. */
gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
if ((m_x != -1) || (m_y != -1))
{
if ((m_x != old_x) || (m_y != old_y))
- {
- /* we set the position here and when showing the dialog
- for the first time in idle time */
+ {
+ /* we set the position here and when showing the dialog
+ for the first time in idle time */
gtk_widget_set_uposition( m_widget, m_x, m_y );
- }
+ }
}
if ((m_width != old_width) || (m_height != old_height))
{
/* actual resizing is deferred to GtkOnSize in idle time and
- when showing the dialog */
+ when showing the dialog */
m_sizeSet = FALSE;
}
if (show != m_isShown)
{
if (show)
- {
- gtk_widget_show( m_widget );
- }
+ {
+ gtk_widget_show( m_widget );
+ }
else
gtk_widget_hide( m_widget );
-
+
m_isShown = show;
}
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
-// Licence: wxWindows licence
+// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
/* XPM */
static char * gv_xpm[] = {
"40 34 3 1",
-" s None c None",
-". c black",
-"X c white",
+" s None c None",
+". c black",
+"X c white",
" ",
" ",
" ...... ",
" ",
" ",
" "};
-
+
/* XPM */
static char * page_xpm[] = {
/* width height ncolors chars_per_pixel */
"32 32 5 1",
/* colors */
-" s None c None",
-". c black",
-"X c wheat",
-"o c tan",
-"O c #6699FF",
+" s None c None",
+". c black",
+"X c wheat",
+"o c tan",
+"O c #6699FF",
/* pixels */
" ................... ",
" .XXXXXXXXXXXXXXXXX.. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" .XXXXXXXXXXXXXXXXXXXXXXX. ",
" ......................... "};
-
-
+
+
// ----------------------------------------------------------------------------
// "drag_leave"
// ----------------------------------------------------------------------------
static void target_drag_leave( GtkWidget *WXUNUSED(widget),
- GdkDragContext *context,
- guint WXUNUSED(time),
- wxDropTarget *drop_target )
+ GdkDragContext *context,
+ guint WXUNUSED(time),
+ wxDropTarget *drop_target )
{
if (g_isIdle) wxapp_install_idle_handler();
/* inform the wxDropTarget about the current GdkDragContext.
this is only valid for the duration of this call */
drop_target->SetDragContext( context );
-
+
/* we don't need return values. this event is just for
information */
drop_target->OnLeave();
-
+
/* this has to be done because GDK has no "drag_enter" event */
drop_target->m_firstMotion = TRUE;
-
+
/* after this, invalidate the drop_target's GdkDragContext */
drop_target->SetDragContext( (GdkDragContext*) NULL );
}
// ----------------------------------------------------------------------------
static gboolean target_drag_motion( GtkWidget *WXUNUSED(widget),
- GdkDragContext *context,
- gint x,
- gint y,
- guint time,
- wxDropTarget *drop_target )
+ GdkDragContext *context,
+ gint x,
+ gint y,
+ guint time,
+ wxDropTarget *drop_target )
{
if (g_isIdle) wxapp_install_idle_handler();
/* Owen Taylor: "if the coordinates not in a drop zone,
return FALSE, otherwise call gtk_drag_status() and
return TRUE" */
-
+
/* inform the wxDropTarget about the current GdkDragContext.
this is only valid for the duration of this call */
drop_target->SetDragContext( context );
-
+
if (drop_target->m_firstMotion)
{
/* the first "drag_motion" event substitutes a "drag_enter" event */
- drop_target->OnEnter();
+ drop_target->OnEnter();
}
-
+
/* give program a chance to react (i.e. to say no by returning FALSE) */
bool ret = drop_target->OnMove( x, y );
-
+
/* we don't yet handle which "actions" (i.e. copy or move)
the target accepts. so far we simply accept the
suggested action. TODO. */
if (ret)
gdk_drag_status( context, context->suggested_action, time );
-
+
/* after this, invalidate the drop_target's GdkDragContext */
drop_target->SetDragContext( (GdkDragContext*) NULL );
-
+
/* this has to be done because GDK has no "drag_enter" event */
drop_target->m_firstMotion = FALSE;
-
+
return ret;
}
// ----------------------------------------------------------------------------
static gboolean target_drag_drop( GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time,
- wxDropTarget *drop_target )
+ GdkDragContext *context,
+ gint x,
+ gint y,
+ guint time,
+ wxDropTarget *drop_target )
{
if (g_isIdle) wxapp_install_idle_handler();
otherwise call gtk_drag_data_get()" */
// printf( "drop.\n" );
-
+
/* this seems to make a difference between not accepting
due to wrong target area and due to wrong format. let
us hope that this is not required.. */
-
+
/* inform the wxDropTarget about the current GdkDragContext.
this is only valid for the duration of this call */
drop_target->SetDragContext( context );
-
+
/* inform the wxDropTarget about the current drag widget.
this is only valid for the duration of this call */
drop_target->SetDragWidget( widget );
-
+
/* inform the wxDropTarget about the current drag time.
this is only valid for the duration of this call */
drop_target->SetDragTime( time );
-
+
bool ret = drop_target->OnDrop( x, y );
-
+
if (!ret)
{
/* cancel the whole thing */
gtk_drag_finish( context,
- FALSE, /* no success */
- FALSE, /* don't delete data on dropping side */
- time );
+ FALSE, /* no success */
+ FALSE, /* don't delete data on dropping side */
+ time );
}
-
+
/* after this, invalidate the drop_target's GdkDragContext */
drop_target->SetDragContext( (GdkDragContext*) NULL );
-
+
/* after this, invalidate the drop_target's drag widget */
drop_target->SetDragWidget( (GtkWidget*) NULL );
-
+
/* this has to be done because GDK has no "drag_enter" event */
drop_target->m_firstMotion = TRUE;
-
+
return ret;
}
// ----------------------------------------------------------------------------
static void target_drag_data_received( GtkWidget *WXUNUSED(widget),
- GdkDragContext *context,
- gint x,
- gint y,
- GtkSelectionData *data,
- guint WXUNUSED(info),
- guint time,
- wxDropTarget *drop_target )
+ GdkDragContext *context,
+ gint x,
+ gint y,
+ GtkSelectionData *data,
+ guint WXUNUSED(info),
+ guint time,
+ wxDropTarget *drop_target )
{
if (g_isIdle) wxapp_install_idle_handler();
success == TRUE" */
// printf( "data received.\n" );
-
+
if ((data->length <= 0) || (data->format != 8))
{
/* negative data length and non 8-bit data format
qualifies for junk */
gtk_drag_finish (context, FALSE, FALSE, time);
-
-// printf( "no data.\n" );
-
- return;
+
+// printf( "no data.\n" );
+
+ return;
}
-
+
/* inform the wxDropTarget about the current GtkSelectionData.
this is only valid for the duration of this call */
drop_target->SetDragData( data );
-
+
if (drop_target->OnData( x, y ))
{
- /* tell GTK that data transfer was successfull */
+ /* tell GTK that data transfer was successfull */
gtk_drag_finish( context, TRUE, FALSE, time );
}
else
{
- /* tell GTK that data transfer was not successfull */
+ /* tell GTK that data transfer was not successfull */
gtk_drag_finish( context, FALSE, FALSE, time );
}
-
+
/* after this, invalidate the drop_target's drag data */
drop_target->SetDragData( (GtkSelectionData*) NULL );
}
{
if (!m_dragContext) return FALSE;
if (!m_dragWidget) return FALSE;
-
+
/*
wxPrintf( _T("format: %s.\n"), format.GetId().c_str() );
if (format.GetType() == wxDF_PRIVATE) wxPrintf( _T("private data.\n") );
*/
/* this should trigger an "drag_data_received" event */
- gtk_drag_get_data( m_dragWidget,
- m_dragContext,
- format.GetAtom(),
- m_dragTime );
-
+ gtk_drag_get_data( m_dragWidget,
+ m_dragContext,
+ format.GetAtom(),
+ m_dragTime );
+
return TRUE;
}
bool wxDropTarget::IsSupported( wxDataFormat format )
-{
+{
if (!m_dragContext) return FALSE;
-
+
GList *child = m_dragContext->targets;
while (child)
{
GdkAtom formatAtom = (GdkAtom) GPOINTER_TO_INT(child->data);
-
+
// char *name = gdk_atom_name( formatAtom );
// if (name) printf( "Format available: %s.\n", name );
-
+
if (formatAtom == format.GetAtom()) return TRUE;
child = child->next;
}
return FALSE;
}
-
+
bool wxDropTarget::GetData( wxDataObject *data_object )
{
if (!m_dragData) return FALSE;
-
+
if (m_dragData->target != data_object->GetFormat().GetAtom()) return FALSE;
-
+
if (data_object->GetFormat().GetType() == wxDF_TEXT)
{
wxTextDataObject *text_object = (wxTextDataObject*)data_object;
text_object->SetText( (const char*)m_dragData->data );
} else
-
+
if (data_object->GetFormat().GetType() == wxDF_FILENAME)
{
} else
-
+
if (data_object->GetFormat().GetType() == wxDF_PRIVATE)
{
- wxPrivateDataObject *priv_object = (wxPrivateDataObject*)data_object;
- priv_object->SetData( (const char*)m_dragData->data, (size_t)m_dragData->length );
+ wxPrivateDataObject *priv_object = (wxPrivateDataObject*)data_object;
+ priv_object->SetData( (const char*)m_dragData->data, (size_t)m_dragData->length );
}
-
+
return TRUE;
}
-
+
void wxDropTarget::UnregisterWidget( GtkWidget *widget )
{
wxCHECK_RET( widget != NULL, _T("unregister widget is NULL") );
-
+
gtk_drag_dest_unset( widget );
-
+
gtk_signal_disconnect_by_func( GTK_OBJECT(widget),
- GTK_SIGNAL_FUNC(target_drag_leave), (gpointer) this );
+ GTK_SIGNAL_FUNC(target_drag_leave), (gpointer) this );
gtk_signal_disconnect_by_func( GTK_OBJECT(widget),
- GTK_SIGNAL_FUNC(target_drag_motion), (gpointer) this );
+ GTK_SIGNAL_FUNC(target_drag_motion), (gpointer) this );
gtk_signal_disconnect_by_func( GTK_OBJECT(widget),
- GTK_SIGNAL_FUNC(target_drag_drop), (gpointer) this );
+ GTK_SIGNAL_FUNC(target_drag_drop), (gpointer) this );
gtk_signal_disconnect_by_func( GTK_OBJECT(widget),
- GTK_SIGNAL_FUNC(target_drag_data_received), (gpointer) this );
+ GTK_SIGNAL_FUNC(target_drag_data_received), (gpointer) this );
}
void wxDropTarget::RegisterWidget( GtkWidget *widget )
{
wxCHECK_RET( widget != NULL, _T("register widget is NULL") );
-
+
/* gtk_drag_dest_set() determines what default behaviour we'd like
GTK to supply. we don't want to specify out targets (=formats)
or actions in advance (i.e. not GTK_DEST_DEFAULT_MOTION and
not GTK_DEST_DEFAULT_DROP). instead we react individually to
"drag_motion" and "drag_drop" events. this makes it possible
- to allow dropping on only a small area. we should set
+ to allow dropping on only a small area. we should set
GTK_DEST_DEFAULT_HIGHLIGHT as this will switch on the nice
highlighting if dragging over standard controls, but this
seems to be broken without the other two. */
-
+
gtk_drag_dest_set( widget,
- (GtkDestDefaults) 0, /* no default behaviour */
- (GtkTargetEntry*) NULL, /* we don't supply any formats here */
- 0, /* number of targets = 0 */
- (GdkDragAction) 0 ); /* we don't supply any actions here */
-
+ (GtkDestDefaults) 0, /* no default behaviour */
+ (GtkTargetEntry*) NULL, /* we don't supply any formats here */
+ 0, /* number of targets = 0 */
+ (GdkDragAction) 0 ); /* we don't supply any actions here */
+
gtk_signal_connect( GTK_OBJECT(widget), "drag_leave",
- GTK_SIGNAL_FUNC(target_drag_leave), (gpointer) this );
+ GTK_SIGNAL_FUNC(target_drag_leave), (gpointer) this );
gtk_signal_connect( GTK_OBJECT(widget), "drag_motion",
- GTK_SIGNAL_FUNC(target_drag_motion), (gpointer) this );
+ GTK_SIGNAL_FUNC(target_drag_motion), (gpointer) this );
gtk_signal_connect( GTK_OBJECT(widget), "drag_drop",
- GTK_SIGNAL_FUNC(target_drag_drop), (gpointer) this );
+ GTK_SIGNAL_FUNC(target_drag_drop), (gpointer) this );
gtk_signal_connect( GTK_OBJECT(widget), "drag_data_received",
- GTK_SIGNAL_FUNC(target_drag_data_received), (gpointer) this );
+ GTK_SIGNAL_FUNC(target_drag_data_received), (gpointer) this );
}
//-------------------------------------------------------------------------
if (IsSupported( wxDF_TEXT ))
{
RequestData( wxDF_TEXT );
- return TRUE;
+ return TRUE;
}
-
+
return FALSE;
}
{
wxTextDataObject data;
if (!GetData( &data )) return FALSE;
-
+
OnDropText( x, y, data.GetText() );
-
+
return TRUE;
}
bool wxPrivateDropTarget::OnDrop( int WXUNUSED(x), int WXUNUSED(y) )
{
if (!IsSupported( m_id ))
- {
+ {
RequestData( m_id );
return FALSE;
}
-
+
return FALSE;
}
bool wxPrivateDropTarget::OnData( int x, int y )
{
if (!IsSupported( m_id )) return FALSE;
-
+
wxPrivateDataObject data;
if (!GetData( &data )) return FALSE;
-
+
OnDropData( x, y, data.GetData(), data.GetSize() );
-
+
return TRUE;
}
if (IsSupported( wxDF_FILENAME ))
{
RequestData( wxDF_FILENAME );
- return TRUE;
+ return TRUE;
}
-
+
return FALSE;
}
if (text[i] == 0) number++;
if (number == 0) return FALSE;
-
+
wxChar **files = new wxChar*[number];
-
+
text = WXSTRINGCAST data.GetFiles();
for (i = 0; i < number; i++)
{
text += len+1;
}
- OnDropFiles( x, y, number, files );
-
+ OnDropFiles( x, y, number, files );
+
free( files );
-
+
return TRUE;
}
// "drag_data_get"
//----------------------------------------------------------------------------
-static void
+static void
source_drag_data_get (GtkWidget *WXUNUSED(widget),
- GdkDragContext *context,
- GtkSelectionData *selection_data,
- guint WXUNUSED(info),
- guint WXUNUSED(time),
- wxDropSource *drop_source )
+ GdkDragContext *context,
+ GtkSelectionData *selection_data,
+ guint WXUNUSED(info),
+ guint WXUNUSED(time),
+ wxDropSource *drop_source )
{
if (g_isIdle) wxapp_install_idle_handler();
// char *name = gdk_atom_name( selection_data->target );
// if (name) printf( "Format requested: %s.\n", name );
-
+
wxNode *node = drop_source->m_data->m_dataObjects.First();
while (node)
{
wxDataObject *data_object = (wxDataObject*) node->Data();
- if (data_object->GetFormat().GetAtom() == selection_data->target)
- {
-// printf( "format found.\n" );
-
- size_t data_size = data_object->GetSize();
-
- if (data_size > 0)
- {
-// printf( "data size: %d.\n", (int)data_size );
-
- guchar *buffer = new guchar[data_size];
- data_object->WriteData( buffer );
-
+ if (data_object->GetFormat().GetAtom() == selection_data->target)
+ {
+// printf( "format found.\n" );
+
+ size_t data_size = data_object->GetSize();
+
+ if (data_size > 0)
+ {
+// printf( "data size: %d.\n", (int)data_size );
+
+ guchar *buffer = new guchar[data_size];
+ data_object->WriteData( buffer );
+
gtk_selection_data_set( selection_data,
- selection_data->target,
- 8, // 8-bit
- buffer,
- data_size );
-
- free( buffer );
-
- /* so far only copy, no moves. TODO. */
+ selection_data->target,
+ 8, // 8-bit
+ buffer,
+ data_size );
+
+ free( buffer );
+
+ /* so far only copy, no moves. TODO. */
drop_source->m_retValue = wxDragCopy;
-
- return;
- }
- }
-
+
+ return;
+ }
+ }
+
node = node->Next();
}
-
+
drop_source->m_retValue = wxDragCancel;
}
-
+
//----------------------------------------------------------------------------
// "drag_data_delete"
//----------------------------------------------------------------------------
static void source_drag_data_delete( GtkWidget *WXUNUSED(widget),
- GdkDragContext *WXUNUSED(context),
- wxDropSource *drop_source )
+ GdkDragContext *WXUNUSED(context),
+ wxDropSource *drop_source )
{
if (g_isIdle) wxapp_install_idle_handler();
drop_source->m_retValue = wxDragMove;
}
-
+
//----------------------------------------------------------------------------
// "drag_begin"
//----------------------------------------------------------------------------
static void source_drag_begin( GtkWidget *WXUNUSED(widget),
- GdkDragContext *WXUNUSED(context),
- wxDropSource *WXUNUSED(drop_source) )
+ GdkDragContext *WXUNUSED(context),
+ wxDropSource *WXUNUSED(drop_source) )
{
if (g_isIdle) wxapp_install_idle_handler();
// printf( "drag_begin.\n" );
}
-
+
//----------------------------------------------------------------------------
// "drag_end"
//----------------------------------------------------------------------------
static void source_drag_end( GtkWidget *WXUNUSED(widget),
- GdkDragContext *WXUNUSED(context),
- wxDropSource *drop_source )
+ GdkDragContext *WXUNUSED(context),
+ wxDropSource *drop_source )
{
if (g_isIdle) wxapp_install_idle_handler();
drop_source->m_waiting = FALSE;
}
-
+
//---------------------------------------------------------------------------
// wxDropSource
//---------------------------------------------------------------------------
{
g_blockEventsOnDrag = TRUE;
m_waiting = TRUE;
-
+
m_window = win;
- m_widget = win->m_widget;
- if (win->m_wxwindow) m_widget = win->m_wxwindow;
-
+ m_widget = win->GetWidget();
+ if (win->GetWxWindow()) m_widget = win->GetWxWindow();
+
m_data = (wxDataBroker*) NULL;
m_retValue = wxDragCancel;
m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
m_goaheadCursor = wxCursor( wxCURSOR_HAND );
-
+
m_goIcon = go;
if (wxNullIcon == go) m_goIcon = wxIcon( page_xpm );
m_stopIcon = stop;
wxDropSource::wxDropSource( wxDataObject *data, wxWindow *win, const wxIcon &go, const wxIcon &stop )
{
m_waiting = TRUE;
-
+
m_window = win;
- m_widget = win->m_widget;
- if (win->m_wxwindow) m_widget = win->m_wxwindow;
+ m_widget = win->GetWidget();
+ if (win->GetWxWindow()) m_widget = win->GetWxWindow();
m_retValue = wxDragCancel;
-
+
if (data)
{
m_data = new wxDataBroker();
- m_data->Add( data );
+ m_data->Add( data );
}
else
{
m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
m_goaheadCursor = wxCursor( wxCURSOR_HAND );
-
+
m_goIcon = go;
if (wxNullIcon == go) m_goIcon = wxIcon( page_xpm );
m_stopIcon = stop;
wxDropSource::wxDropSource( wxDataBroker *data, wxWindow *win )
{
m_window = win;
- m_widget = win->m_widget;
- if (win->m_wxwindow) m_widget = win->m_wxwindow;
+ m_widget = win->GetWidget();
+ if (win->GetWxWindow()) m_widget = win->GetWxWindow();
m_retValue = wxDragCancel;
-
+
m_data = data;
m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
void wxDropSource::SetData( wxDataObject *data )
{
if (m_data) delete m_data;
-
+
if (data)
{
m_data = new wxDataBroker();
- m_data->Add( data );
+ m_data->Add( data );
}
else
{
void wxDropSource::SetData( wxDataBroker *data )
{
if (m_data) delete m_data;
-
+
m_data = data;
}
g_blockEventsOnDrag = FALSE;
}
-
+
wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) )
{
wxASSERT_MSG( m_data, _T("wxDragSource: no data") );
-
+
if (!m_data) return (wxDragResult) wxDragNone;
-
+
g_blockEventsOnDrag = TRUE;
-
+
RegisterWindow();
-
+
m_waiting = TRUE;
GdkAtom atom = gdk_atom_intern( "STRING", FALSE );
GtkTargetList *target_list = gtk_target_list_new( (GtkTargetEntry*) NULL, 0 );
gtk_target_list_add( target_list, atom, 0, 0 );
-
+
GdkEventMotion event;
event.window = m_widget->window;
int x = 0;
event.y = y;
event.state = state;
event.time = GDK_CURRENT_TIME;
-
+
/* GTK wants to know which button was pressed which caused the dragging */
int button_number = 0;
if (event.state & GDK_BUTTON1_MASK) button_number = 1;
{
GdkDragContext *context = gtk_drag_begin( m_widget,
target_list,
- GDK_ACTION_COPY,
- button_number, /* number of mouse button which started drag */
- (GdkEvent*) &event );
-
+ GDK_ACTION_COPY,
+ button_number, /* number of mouse button which started drag */
+ (GdkEvent*) &event );
+
wxMask *mask = m_goIcon.GetMask();
GdkBitmap *bm = (GdkBitmap *) NULL;
if (mask) bm = mask->GetBitmap();
- GdkPixmap *pm = m_goIcon.GetPixmap();
-
+ GdkPixmap *pm = m_goIcon.GetPixmap();
+
gtk_drag_set_icon_pixmap( context,
- gtk_widget_get_colormap( m_widget ),
- pm,
- bm,
- 0,
- 0 );
-
+ gtk_widget_get_colormap( m_widget ),
+ pm,
+ bm,
+ 0,
+ 0 );
+
while (m_waiting) gtk_main_iteration();;
}
g_blockEventsOnDrag = FALSE;
-
+
UnregisterWindow();
return m_retValue;
void wxDropSource::RegisterWindow()
{
if (!m_widget) return;
-
+
gtk_signal_connect( GTK_OBJECT(m_widget), "drag_data_get",
- GTK_SIGNAL_FUNC (source_drag_data_get), (gpointer) this);
+ GTK_SIGNAL_FUNC (source_drag_data_get), (gpointer) this);
gtk_signal_connect (GTK_OBJECT(m_widget), "drag_data_delete",
- GTK_SIGNAL_FUNC (source_drag_data_delete), (gpointer) this );
+ GTK_SIGNAL_FUNC (source_drag_data_delete), (gpointer) this );
gtk_signal_connect (GTK_OBJECT(m_widget), "drag_begin",
- GTK_SIGNAL_FUNC (source_drag_begin), (gpointer) this );
+ GTK_SIGNAL_FUNC (source_drag_begin), (gpointer) this );
gtk_signal_connect (GTK_OBJECT(m_widget), "drag_end",
- GTK_SIGNAL_FUNC (source_drag_end), (gpointer) this );
+ GTK_SIGNAL_FUNC (source_drag_end), (gpointer) this );
}
void wxDropSource::UnregisterWindow()
{
if (!m_widget) return;
-
+
gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget),
- GTK_SIGNAL_FUNC(source_drag_data_get), (gpointer) this );
+ GTK_SIGNAL_FUNC(source_drag_data_get), (gpointer) this );
gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget),
- GTK_SIGNAL_FUNC(source_drag_data_delete), (gpointer) this );
+ GTK_SIGNAL_FUNC(source_drag_data_delete), (gpointer) this );
gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget),
- GTK_SIGNAL_FUNC(source_drag_begin), (gpointer) this );
+ GTK_SIGNAL_FUNC(source_drag_begin), (gpointer) this );
gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget),
- GTK_SIGNAL_FUNC(source_drag_end), (gpointer) this );
+ GTK_SIGNAL_FUNC(source_drag_end), (gpointer) this );
}
#endif
int style = dialog->GetStyle();
- GtkFileSelection *filedlg = GTK_FILE_SELECTION(dialog->m_widget);
+ GtkFileSelection *filedlg = GTK_FILE_SELECTION(dialog->GetHandle());
char *filename = gtk_file_selection_get_filename(filedlg);
if ( (style & wxSAVE) && ( style & wxOVERWRITE_PROMPT ) )
return *this;
}
-bool wxFont::operator == ( const wxFont& font )
+bool wxFont::operator == ( const wxFont& font ) const
{
return m_refData == font.m_refData;
}
-bool wxFont::operator != ( const wxFont& font )
+bool wxFont::operator != ( const wxFont& font ) const
{
return m_refData != font.m_refData;
}
printf( ".\n" );
*/
- if ((win->m_width != alloc->width) || (win->m_height != alloc->height))
+ if ((win->GetWidth() != alloc->width) || (win->GetHeight() != alloc->height))
{
- win->m_sizeSet = FALSE;
- win->m_width = alloc->width;
- win->m_height = alloc->height;
+ win->InternalSetSize( alloc->width, alloc->height );
}
}
if (!win->HasVMT()) return;
win->m_menuBarDetached = FALSE;
- win->m_sizeSet = FALSE;
+ win->UpdateSize();
}
//-----------------------------------------------------------------------------
if (!win->HasVMT()) return;
win->m_menuBarDetached = TRUE;
- win->m_sizeSet = FALSE;
+ win->UpdateSize();
}
//-----------------------------------------------------------------------------
if (!win->HasVMT()) return;
win->m_toolBarDetached = FALSE;
- win->m_sizeSet = FALSE;
+ win->UpdateSize();
}
//-----------------------------------------------------------------------------
if (!win->HasVMT()) return;
win->m_toolBarDetached = TRUE;
- win->m_sizeSet = FALSE;
+ win->UpdateSize();
}
//-----------------------------------------------------------------------------
if (!win->HasVMT()) return FALSE;
- win->m_x = event->x;
- win->m_y = event->y;
+ win->InternalSetPosition(event->x, event->y);
- wxMoveEvent mevent( wxPoint(win->m_x,win->m_y), win->GetId() );
+ wxMoveEvent mevent( wxPoint(win->GetX(),win->GetY()), win->GetId() );
mevent.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( mevent );
long decor = (long) GDK_DECOR_BORDER;
long func = (long) GDK_FUNC_MOVE;
- if ((win->m_windowStyle & wxCAPTION) != 0)
- decor |= GDK_DECOR_TITLE;
- if ((win->m_windowStyle & wxSYSTEM_MENU) != 0)
+ if ((win->GetWindowStyle() & wxCAPTION) != 0)
+ decor |= GDK_DECOR_TITLE;
+ if ((win->GetWindowStyle() & wxSYSTEM_MENU) != 0)
{
decor |= GDK_DECOR_MENU;
func |= GDK_FUNC_CLOSE;
}
- if ((win->m_windowStyle & wxMINIMIZE_BOX) != 0)
+ if ((win->GetWindowStyle() & wxMINIMIZE_BOX) != 0)
{
- func |= GDK_FUNC_MINIMIZE;
- decor |= GDK_DECOR_MINIMIZE;
+ func |= GDK_FUNC_MINIMIZE;
+ decor |= GDK_DECOR_MINIMIZE;
}
- if ((win->m_windowStyle & wxMAXIMIZE_BOX) != 0)
+ if ((win->GetWindowStyle() & wxMAXIMIZE_BOX) != 0)
{
- func |= GDK_FUNC_MAXIMIZE;
- decor |= GDK_DECOR_MAXIMIZE;
+ func |= GDK_FUNC_MAXIMIZE;
+ decor |= GDK_DECOR_MAXIMIZE;
}
- if ((win->m_windowStyle & wxRESIZE_BORDER) != 0)
+ if ((win->GetWindowStyle() & wxRESIZE_BORDER) != 0)
{
func |= GDK_FUNC_RESIZE;
decor |= GDK_DECOR_RESIZEH;
}
- gdk_window_set_decorations( win->m_widget->window, (GdkWMDecoration)decor);
- gdk_window_set_functions( win->m_widget->window, (GdkWMFunction)func);
+ gdk_window_set_decorations( win->GetHandle()->window, (GdkWMDecoration)decor);
+ gdk_window_set_functions( win->GetHandle()->window, (GdkWMFunction)func);
/* GTK's shrinking/growing policy */
- if ((win->m_windowStyle & wxRESIZE_BORDER) == 0)
- gtk_window_set_policy(GTK_WINDOW(win->m_widget), 0, 0, 1);
+ if ((win->GetWindowStyle() & wxRESIZE_BORDER) == 0)
+ gtk_window_set_policy(GTK_WINDOW(win->GetHandle()), 0, 0, 1);
else
- gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1);
+ gtk_window_set_policy(GTK_WINDOW(win->GetHandle()), 1, 1, 1);
/* reset the icon */
if (win->m_icon != wxNullIcon)
{
wxIcon icon( win->m_icon );
win->m_icon = wxNullIcon;
- win->SetIcon( icon );
+ win->SetIcon( icon );
}
/* we set the focus to the child that accepts the focus. this
doesn't really have to be done in "realize" but why not? */
- wxNode *node = win->m_children.First();
+ wxWindowList::Node *node = win->GetChildren().GetFirst();
while (node)
{
- wxWindow *child = (wxWindow*) node->Data();
- if (child->AcceptsFocus())
- {
- child->SetFocus();
- break;
- }
-
- node = node->Next();
+ wxWindow *child = node->GetData();
+ if (child->AcceptsFocus())
+ {
+ child->SetFocus();
+ break;
+ }
+
+ node = node->GetNext();
}
return FALSE;
if (wxIS_KIND_OF(child,wxToolBar) || wxIS_KIND_OF(child,wxMenuBar))
{
/* actually, menubars are never inserted here, but this
- may change one day */
+ may change one day */
/* these are outside the client area */
- wxFrame* frame = (wxFrame*) parent;
+ wxFrame* frame = (wxFrame*) parent;
gtk_myfixed_put( GTK_MYFIXED(frame->m_mainWidget),
- GTK_WIDGET(child->m_widget),
- child->m_x,
- child->m_y,
- child->m_width,
- child->m_height );
-
- /* we connect to these events for recalculating the client area
- space when the toolbar is floating */
- if (wxIS_KIND_OF(child,wxToolBar))
- {
- wxToolBar *toolBar = (wxToolBar*) child;
- if (toolBar->m_windowStyle & wxTB_DOCKABLE)
- {
- gtk_signal_connect( GTK_OBJECT(toolBar->m_widget), "child_attached",
+ GTK_WIDGET(child->GetHandle()),
+ child->GetX(),
+ child->GetY(),
+ child->GetWidth(),
+ child->GetHeight() );
+
+ /* we connect to these events for recalculating the client area
+ space when the toolbar is floating */
+ if (wxIS_KIND_OF(child,wxToolBar))
+ {
+ wxToolBar *toolBar = (wxToolBar*) child;
+ if (toolBar->GetWindowStyle() & wxTB_DOCKABLE)
+ {
+ gtk_signal_connect( GTK_OBJECT(toolBar->GetHandle()), "child_attached",
GTK_SIGNAL_FUNC(gtk_toolbar_attached_callback), (gpointer)parent );
-
- gtk_signal_connect( GTK_OBJECT(toolBar->m_widget), "child_detached",
+
+ gtk_signal_connect( GTK_OBJECT(toolBar->GetHandle()), "child_detached",
GTK_SIGNAL_FUNC(gtk_toolbar_detached_callback), (gpointer)parent );
- }
- }
+ }
+ }
}
else
{
/* these are inside the client area */
- gtk_myfixed_put( GTK_MYFIXED(parent->m_wxwindow),
- GTK_WIDGET(child->m_widget),
- child->m_x,
- child->m_y,
- child->m_width,
- child->m_height );
+ gtk_myfixed_put( GTK_MYFIXED(parent->GetWxWindow()),
+ GTK_WIDGET(child->GetHandle()),
+ child->GetX(),
+ child->GetY(),
+ child->GetWidth(),
+ child->GetHeight() );
}
/* resize on OnInternalIdle */
- parent->m_sizeSet = FALSE;
+ parent->UpdateSize();
}
//-----------------------------------------------------------------------------
/* we cannot set MWM hints and icons before the widget has
been realized, so we do this directly after realization */
gtk_signal_connect( GTK_OBJECT(m_widget), "realize",
- GTK_SIGNAL_FUNC(gtk_frame_realized_callback), (gpointer) this );
+ GTK_SIGNAL_FUNC(gtk_frame_realized_callback), (gpointer) this );
/* the user resized the frame by dragging etc. */
gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
if ((m_x != old_x) || (m_y != old_y))
{
/* we set the size here and in gtk_frame_map_callback */
- gtk_widget_set_uposition( m_widget, m_x, m_y );
+ gtk_widget_set_uposition( m_widget, m_x, m_y );
}
}
if ((m_width != old_width) || (m_height != old_height))
{
/* we set the size in GtkOnSize, i.e. mostly the actual resizing is
- done either directly before the frame is shown or in idle time
- so that different calls to SetSize() don't lead to flicker. */
+ done either directly before the frame is shown or in idle time
+ so that different calls to SetSize() don't lead to flicker. */
m_sizeSet = FALSE;
}
{
/* menu bar */
if (m_frameMenuBar)
- {
- if (!m_menuBarDetached)
- (*height) -= wxMENU_HEIGHT;
- else
- (*height) -= wxPLACE_HOLDER;
- }
-
- /* status bar */
+ {
+ if (!m_menuBarDetached)
+ (*height) -= wxMENU_HEIGHT;
+ else
+ (*height) -= wxPLACE_HOLDER;
+ }
+
+ /* status bar */
if (m_frameStatusBar) (*height) -= wxSTATUS_HEIGHT;
-
- /* tool bar */
+
+ /* tool bar */
if (m_frameToolBar)
{
- if (!m_toolBarDetached)
- {
+ if (!m_toolBarDetached)
+ {
int y = 0;
m_frameToolBar->GetSize( (int *) NULL, &y );
(*height) -= y;
- }
- else
+ }
+ else
(*height) -= wxPLACE_HOLDER;
}
-
- /* mini edge */
+
+ /* mini edge */
(*height) -= m_miniEdge*2 + m_miniTitle;
}
if (width)
/* menu bar */
if (m_frameMenuBar)
- {
- if (!m_menuBarDetached)
- height += wxMENU_HEIGHT;
- else
- height += wxPLACE_HOLDER;
- }
-
- /* status bar */
+ {
+ if (!m_menuBarDetached)
+ height += wxMENU_HEIGHT;
+ else
+ height += wxPLACE_HOLDER;
+ }
+
+ /* status bar */
if (m_frameStatusBar) height += wxSTATUS_HEIGHT;
-
- /* tool bar */
+
+ /* tool bar */
if (m_frameToolBar)
{
- if (!m_toolBarDetached)
- {
+ if (!m_toolBarDetached)
+ {
int y = 0;
m_frameToolBar->GetSize( (int *) NULL, &y );
height += y;
- }
- else
+ }
+ else
height += wxPLACE_HOLDER;
}
-
+
wxWindow::DoSetClientSize( width + m_miniEdge*2, height + m_miniEdge*2 + m_miniTitle );
}
int yy = m_miniEdge + m_miniTitle;
int ww = m_width - 2*m_miniEdge;
int hh = wxMENU_HEIGHT;
- if (m_menuBarDetached) hh = wxPLACE_HOLDER;
- m_frameMenuBar->m_x = xx;
- m_frameMenuBar->m_y = yy;
- m_frameMenuBar->m_width = ww;
- m_frameMenuBar->m_height = hh;
+ if (m_menuBarDetached) hh = wxPLACE_HOLDER;
+ m_frameMenuBar->InternalSetPosition(xx, yy);
+ m_frameMenuBar->InternalSetSize(ww, hh);
gtk_myfixed_set_size( GTK_MYFIXED(m_mainWidget),
- m_frameMenuBar->m_widget,
- xx, yy, ww, hh );
- client_area_y_offset += hh;
+ m_frameMenuBar->GetHandle(),
+ xx, yy, ww, hh );
+ client_area_y_offset += hh;
}
if (m_frameToolBar)
int xx = m_miniEdge;
int yy = m_miniEdge + m_miniTitle;
if (m_frameMenuBar)
- {
- if (!m_menuBarDetached)
- yy += wxMENU_HEIGHT;
- else
- yy += wxPLACE_HOLDER;
- }
+ {
+ if (!m_menuBarDetached)
+ yy += wxMENU_HEIGHT;
+ else
+ yy += wxPLACE_HOLDER;
+ }
int ww = m_width - 2*m_miniEdge;
- int hh = m_frameToolBar->m_height;
- if (m_toolBarDetached) hh = wxPLACE_HOLDER;
- m_frameToolBar->m_x = xx;
- m_frameToolBar->m_y = yy;
- /* m_frameToolBar->m_height = hh; don't change the toolbar's height */
- m_frameToolBar->m_width = ww;
+ int hh = m_frameToolBar->GetHeight();
+ // VZ: according to earlier comments in this file, the tbar height
+ // shouldn't be changed, so I comment out the next line
+ // (09.05.99)
+ //if (m_toolBarDetached) hh = wxPLACE_HOLDER;
+
+ m_frameToolBar->InternalSetPosition(xx, yy);
+ m_frameToolBar->InternalSetSize(ww, hh);
+
gtk_myfixed_set_size( GTK_MYFIXED(m_mainWidget),
- m_frameToolBar->m_widget,
- xx, yy, ww, hh );
- client_area_y_offset += hh;
+ m_frameToolBar->GetHandle(),
+ xx, yy, ww, hh );
+ client_area_y_offset += hh;
}
int client_x = m_miniEdge;
- int client_y = client_area_y_offset + m_miniEdge + m_miniTitle;
+ int client_y = client_area_y_offset + m_miniEdge + m_miniTitle;
int client_w = m_width - 2*m_miniEdge;
- int client_h = m_height - client_area_y_offset- 2*m_miniEdge - m_miniTitle;
+ int client_h = m_height - client_area_y_offset- 2*m_miniEdge - m_miniTitle;
gtk_myfixed_set_size( GTK_MYFIXED(m_mainWidget),
- m_wxwindow,
- client_x, client_y, client_w, client_h );
+ m_wxwindow,
+ client_x, client_y, client_w, client_h );
}
else
{
/* if there is no m_mainWidget between m_widget and m_wxwindow there
- is no need to set the size or position of m_wxwindow. */
+ is no need to set the size or position of m_wxwindow. */
}
if (m_frameStatusBar)
int yy = m_height - wxSTATUS_HEIGHT - m_miniEdge - client_area_y_offset;
int ww = m_width - 2*m_miniEdge;
int hh = wxSTATUS_HEIGHT;
- m_frameStatusBar->m_x = xx;
- m_frameStatusBar->m_y = yy;
- m_frameStatusBar->m_width = ww;
- m_frameStatusBar->m_height = hh;
+ m_frameStatusBar->InternalSetPosition(xx, yy);
+ m_frameStatusBar->InternalSetSize(ww, hh);
gtk_myfixed_set_size( GTK_MYFIXED(m_wxwindow),
- m_frameStatusBar->m_widget,
- xx, yy, ww, hh );
+ m_frameStatusBar->GetHandle(),
+ xx, yy, ww, hh );
}
/* we actually set the size of a frame here and no-where else */
/* send size event to status bar */
if (m_frameStatusBar)
{
- wxSizeEvent event2( wxSize(m_frameStatusBar->m_width,m_frameStatusBar->m_height), m_frameStatusBar->GetId() );
+ wxSizeEvent event2( wxSize(m_frameStatusBar->GetWidth(),m_frameStatusBar->GetHeight()), m_frameStatusBar->GetId() );
event2.SetEventObject( m_frameStatusBar );
m_frameStatusBar->GetEventHandler()->ProcessEvent( event2 );
}
#if (GTK_MINOR_VERSION > 0)
/* support for native hot keys */
- gtk_accel_group_attach( menu->m_accel, GTK_OBJECT(win->m_widget));
+ gtk_accel_group_attach( menu->m_accel, GTK_OBJECT(win->GetHandle()));
#endif
wxNode *node = menu->GetItems().First();
node = node->Next();
}
- if (m_frameMenuBar->m_parent != this)
+ if (m_frameMenuBar->GetParent() != this)
{
- m_frameMenuBar->m_parent = this;
+ m_frameMenuBar->SetParent(this);
gtk_myfixed_put( GTK_MYFIXED(m_mainWidget),
- m_frameMenuBar->m_widget,
- m_frameMenuBar->m_x,
- m_frameMenuBar->m_y,
- m_frameMenuBar->m_width,
- m_frameMenuBar->m_height );
-
- if (menuBar->m_windowStyle & wxMB_DOCKABLE)
- {
- gtk_signal_connect( GTK_OBJECT(menuBar->m_widget), "child_attached",
+ m_frameMenuBar->GetHandle(),
+ m_frameMenuBar->GetX(),
+ m_frameMenuBar->GetY(),
+ m_frameMenuBar->GetWidth(),
+ m_frameMenuBar->GetHeight() );
+
+ if (menuBar->GetWindowStyle() & wxMB_DOCKABLE)
+ {
+ gtk_signal_connect( GTK_OBJECT(menuBar->GetHandle()), "child_attached",
GTK_SIGNAL_FUNC(gtk_menu_attached_callback), (gpointer)this );
-
- gtk_signal_connect( GTK_OBJECT(menuBar->m_widget), "child_detached",
+
+ gtk_signal_connect( GTK_OBJECT(menuBar->GetHandle()), "child_detached",
GTK_SIGNAL_FUNC(gtk_menu_detached_callback), (gpointer)this );
- }
+ }
}
}
m_widget = gtk_progress_bar_new();
- m_parent->AddChild( this );
-
- (m_parent->m_insertCallback)( m_parent, this );
+ m_parent->DoAddChild( this );
PostCreation();
gtk_widget_show( list_item );
}
- m_parent->AddChild( this );
-
- (m_parent->m_insertCallback)( m_parent, this );
+ m_parent->DoAddChild( this );
PostCreation();
gtk_signal_connect( GTK_OBJECT(list_item), "select",
GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );
- if (GetWindowStyleFlag() & wxLB_MULTIPLE)
+ if (HasFlag(wxLB_MULTIPLE))
gtk_signal_connect( GTK_OBJECT(list_item), "deselect",
GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );
#endif
#if wxUSE_TOOLTIPS
- if (m_toolTip) m_toolTip->Apply( this );
+ if (m_tooltip) m_tooltip->Apply( this );
#endif
}
}
if (m_backgroundColour.Ok())
{
GdkWindow *window = GTK_WIDGET(m_list)->window;
- m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) );
- gdk_window_set_background( window, m_backgroundColour.GetColor() );
- gdk_window_clear( window );
+ if ( window )
+ {
+ m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) );
+ gdk_window_set_background( window, m_backgroundColour.GetColor() );
+ gdk_window_clear( window );
+ }
}
GList *child = m_list->children;
wxMenuBar *menu_bar = child_frame->m_menuBar;
if (!menu_bar) return;
- if (!menu_bar->m_widget) return;
+ if (!menu_bar->GetHandle()) return;
- menu_bar->m_x = 0;
- menu_bar->m_y = 0;
- menu_bar->m_width = m_width;
- menu_bar->m_height = wxMENU_HEIGHT;
+ menu_bar->InternalSetPosition(0, 0);
+ menu_bar->InternalSetSize(m_width, wxMENU_HEIGHT);
gtk_myfixed_set_size( GTK_MYFIXED(m_mainWidget),
- menu_bar->m_widget,
- 0, 0, m_width, wxMENU_HEIGHT );
+ menu_bar->GetHandle(),
+ 0, 0, m_width, wxMENU_HEIGHT );
}
void wxMDIParentFrame::OnInternalIdle()
if (m_justInserted)
{
- GtkNotebook *notebook = GTK_NOTEBOOK(m_clientWindow->m_widget);
+ GtkNotebook *notebook = GTK_NOTEBOOK(m_clientWindow->GetHandle());
gtk_notebook_set_page( notebook, g_list_length( notebook->children ) - 1 );
m_justInserted = FALSE;
wxMDIChildFrame *active_child_frame = GetActiveChild();
bool visible_child_menu = FALSE;
- wxNode *node = m_clientWindow->m_children.First();
+ wxNode *node = m_clientWindow->GetChildren().First();
while (node)
{
wxMDIChildFrame *child_frame = (wxMDIChildFrame *)node->Data();
if (child_frame->m_menuBar)
{
if (child_frame == active_child_frame)
- {
- gtk_widget_show( child_frame->m_menuBar->m_widget );
- visible_child_menu = TRUE;
- }
+ {
+ gtk_widget_show( child_frame->m_menuBar->GetHandle() );
+ visible_child_menu = TRUE;
+ }
else
- gtk_widget_hide( child_frame->m_menuBar->m_widget );
+ gtk_widget_hide( child_frame->m_menuBar->GetHandle() );
}
node = node->Next();
}
{
if (!m_clientWindow) return (wxMDIChildFrame*) NULL;
- GtkNotebook *notebook = GTK_NOTEBOOK(m_clientWindow->m_widget);
+ GtkNotebook *notebook = GTK_NOTEBOOK(m_clientWindow->GetHandle());
if (!notebook) return (wxMDIChildFrame*) NULL;
#if (GTK_MINOR_VERSION > 0)
GtkNotebookPage* page = (GtkNotebookPage*) (g_list_nth(notebook->children,i)->data);
if (!page) return (wxMDIChildFrame*) NULL;
- wxNode *node = m_clientWindow->m_children.First();
+ wxNode *node = m_clientWindow->GetChildren().First();
while (node)
{
wxMDIChildFrame *child_frame = (wxMDIChildFrame *)node->Data();
void wxMDIParentFrame::ActivateNext()
{
if (m_clientWindow)
- gtk_notebook_next_page( GTK_NOTEBOOK(m_clientWindow->m_widget) );
+ gtk_notebook_next_page( GTK_NOTEBOOK(m_clientWindow->GetHandle()) );
}
void wxMDIParentFrame::ActivatePrevious()
{
if (m_clientWindow)
- gtk_notebook_prev_page( GTK_NOTEBOOK(m_clientWindow->m_widget) );
+ gtk_notebook_prev_page( GTK_NOTEBOOK(m_clientWindow->GetHandle()) );
}
void wxMDIParentFrame::OnActivate( wxActivateEvent& WXUNUSED(event) )
if (m_menuBar)
{
- wxMDIParentFrame *mdi_frame = (wxMDIParentFrame*)m_parent->m_parent;
+ wxMDIParentFrame *mdi_frame = (wxMDIParentFrame*)m_parent->GetParent();
- if (m_menuBar->m_parent != this)
+ if (m_menuBar->GetParent() != this)
{
wxNode *node = m_menuBar->GetMenus().First();
while (node)
node = node->Next();
}
- m_menuBar->m_parent = mdi_frame;
+ m_menuBar->SetParent( mdi_frame );
}
/* the menu bar of the child window is shown in idle time as needed */
- gtk_widget_hide( m_menuBar->m_widget );
+ gtk_widget_hide( m_menuBar->GetHandle() );
/* insert the invisible menu bar into the _parent_ mdi frame */
gtk_myfixed_put( GTK_MYFIXED(mdi_frame->m_mainWidget),
- m_menuBar->m_widget,
- 0, 0, mdi_frame->m_width, wxMENU_HEIGHT );
+ m_menuBar->GetHandle(),
+ 0, 0, mdi_frame->GetWidth(), wxMENU_HEIGHT );
}
}
{
if (g_isIdle) wxapp_install_idle_handler();
- if ((win->m_x == alloc->x) &&
- (win->m_y == alloc->y) &&
- (win->m_width == alloc->width) &&
- (win->m_height == alloc->height) &&
- (win->m_sizeSet))
+ if ((win->GetX() == alloc->x) &&
+ (win->GetY() == alloc->y) &&
+ (win->GetWidth() == alloc->width) &&
+ (win->GetHeight() == alloc->height) &&
+ (win->IsSizeSet()))
{
return;
}
GtkWidget *label_widget = gtk_label_new( s.mbc_str() );
gtk_misc_set_alignment( GTK_MISC(label_widget), 0.0, 0.5 );
- gtk_signal_connect( GTK_OBJECT(child->m_widget), "size_allocate",
+ gtk_signal_connect( GTK_OBJECT(child->GetHandle()), "size_allocate",
GTK_SIGNAL_FUNC(gtk_page_size_callback), (gpointer)child );
- GtkNotebook *notebook = GTK_NOTEBOOK(parent->m_widget);
+ GtkNotebook *notebook = GTK_NOTEBOOK(parent->GetHandle());
- gtk_notebook_append_page( notebook, child->m_widget, label_widget );
+ gtk_notebook_append_page( notebook, child->GetHandle(), label_widget );
child->m_page = (GtkNotebookPage*) (g_list_last(notebook->children)->data);
- wxMDIParentFrame *parent_frame = (wxMDIParentFrame*) parent->m_parent;
+ wxMDIParentFrame *parent_frame = (wxMDIParentFrame*) parent->GetParent();
parent_frame->m_justInserted = TRUE;
}
gtk_notebook_set_scrollable( GTK_NOTEBOOK(m_widget), 1 );
- m_parent->AddChild( this );
-
- (m_parent->m_insertCallback)( m_parent, this );
+ m_parent->DoAddChild( this );
PostCreation();
return TRUE;
}
-
-
gtk_draw_shadow( widget->style,
widget->window,
- GTK_STATE_NORMAL,
- GTK_SHADOW_OUT,
- 0, 0,
- win->m_width, win->m_height );
+ GTK_STATE_NORMAL,
+ GTK_SHADOW_OUT,
+ 0, 0,
+ win->GetWidth(), win->GetHeight() );
if (!win->m_title.IsEmpty() &&
- ((win->m_windowStyle & wxCAPTION) ||
- (win->m_windowStyle & wxTINY_CAPTION_HORIZ) ||
- (win->m_windowStyle & wxTINY_CAPTION_VERT)))
+ ((win->GetWindowStyle() & wxCAPTION) ||
+ (win->GetWindowStyle() & wxTINY_CAPTION_HORIZ) ||
+ (win->GetWindowStyle() & wxTINY_CAPTION_VERT)))
{
GdkGC *gc = gdk_gc_new( widget->window );
- GdkFont *font = wxSMALL_FONT->GetInternalFont(1.0);
- int x = 2;
- if (win->m_windowStyle & wxSYSTEM_MENU) x = 18;
-
+ GdkFont *font = wxSMALL_FONT->GetInternalFont(1.0);
+ int x = 2;
+ if (win->GetWindowStyle() & wxSYSTEM_MENU) x = 18;
+
gdk_gc_set_foreground( gc, &widget->style->bg[GTK_STATE_SELECTED] );
- gdk_draw_rectangle( widget->window, gc, TRUE,
- x,
- 3,
- win->m_width - 4 - x,
- font->ascent + font->descent+1 );
-
+ gdk_draw_rectangle( widget->window, gc, TRUE,
+ x,
+ 3,
+ win->GetWidth() - 4 - x,
+ font->ascent + font->descent+1 );
+
gdk_gc_set_foreground( gc, &widget->style->white );
gdk_draw_string( widget->window, font, gc,
- x+2,
- 3+font->ascent,
- win->m_title.mb_str() );
-
+ x+2,
+ 3+font->ascent,
+ win->m_title.mb_str() );
+
gdk_gc_unref( gc );
}
}
gtk_draw_shadow( widget->style,
widget->window,
- GTK_STATE_NORMAL,
- GTK_SHADOW_OUT,
- 0, 0,
- win->m_width, win->m_height );
-
+ GTK_STATE_NORMAL,
+ GTK_SHADOW_OUT,
+ 0, 0,
+ win->GetWidth(), win->GetHeight() );
+
if (!win->m_title.IsEmpty() &&
- ((win->m_windowStyle & wxCAPTION) ||
- (win->m_windowStyle & wxTINY_CAPTION_HORIZ) ||
- (win->m_windowStyle & wxTINY_CAPTION_VERT)))
+ ((win->GetWindowStyle() & wxCAPTION) ||
+ (win->GetWindowStyle() & wxTINY_CAPTION_HORIZ) ||
+ (win->GetWindowStyle() & wxTINY_CAPTION_VERT)))
{
GdkGC *gc = gdk_gc_new( widget->window );
- GdkFont *font = wxSMALL_FONT->GetInternalFont(1.0);
- int x = 2;
- if (win->m_windowStyle & wxSYSTEM_MENU) x = 17;
-
+ GdkFont *font = wxSMALL_FONT->GetInternalFont(1.0);
+ int x = 2;
+ if (win->GetWindowStyle() & wxSYSTEM_MENU) x = 17;
+
gdk_gc_set_foreground( gc, &widget->style->bg[GTK_STATE_SELECTED] );
- gdk_draw_rectangle( widget->window, gc, TRUE,
- x,
- 3,
- win->m_width - 4 - x,
- font->ascent + font->descent+1 );
-
+ gdk_draw_rectangle( widget->window, gc, TRUE,
+ x,
+ 3,
+ win->GetWidth() - 4 - x,
+ font->ascent + font->descent+1 );
+
gdk_gc_set_foreground( gc, &widget->style->white );
gdk_draw_string( widget->window, font, gc,
- x+2,
- 3+font->ascent,
- win->m_title.mb_str() );
-
+ x+2,
+ 3+font->ascent,
+ win->m_title.mb_str() );
+
gdk_gc_unref( gc );
}
}
(GdkEventMask)
(GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
- GDK_POINTER_MOTION_MASK |
+ GDK_POINTER_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK |
- GDK_BUTTON_MOTION_MASK |
+ GDK_BUTTON_MOTION_MASK |
GDK_BUTTON1_MOTION_MASK),
(GdkWindow *) NULL,
(GdkCursor *) NULL,
GDK_CURRENT_TIME );
-
+
win->m_diffX = (int)gdk_event->x;
win->m_diffY = (int)gdk_event->y;
- DrawFrame( widget, 0, 0, win->m_width, win->m_height );
+ DrawFrame( widget, 0, 0, win->GetWidth(), win->GetHeight() );
win->m_oldX = 0;
win->m_oldY = 0;
int x = (int)gdk_event->x;
int y = (int)gdk_event->y;
- DrawFrame( widget, win->m_oldX, win->m_oldY, win->m_width, win->m_height );
+ DrawFrame( widget, win->m_oldX, win->m_oldY, win->GetWidth(), win->GetHeight() );
gdk_pointer_ungrab ( GDK_CURRENT_TIME );
int org_x = 0;
int org_y = 0;
gdk_window_get_origin( widget->window, &org_x, &org_y );
x += org_x - win->m_diffX;
y += org_y - win->m_diffY;
- win->m_x = x;
- win->m_y = y;
- gtk_widget_set_uposition( win->m_widget, x, y );
+ win->InternalSetPosition(x, y);
+ gtk_widget_set_uposition( win->GetWidget(), x, y );
return TRUE;
}
gdk_event->state = state;
}
- DrawFrame( widget, win->m_oldX, win->m_oldY, win->m_width, win->m_height );
+ DrawFrame( widget, win->m_oldX, win->m_oldY, win->GetWidth(), win->GetHeight() );
win->m_oldX = (int)gdk_event->x - win->m_diffX;
win->m_oldY = (int)gdk_event->y - win->m_diffY;
- DrawFrame( widget, win->m_oldX, win->m_oldY, win->m_width, win->m_height );
+ DrawFrame( widget, win->m_oldX, win->m_oldY, win->GetWidth(), win->GetHeight() );
return TRUE;
}
if ((style & wxCAPTION) || (style & wxTINY_CAPTION_HORIZ) || (style & wxTINY_CAPTION_VERT))
m_miniTitle = 13;
-
+
m_miniEdge = 3;
m_isDragging = FALSE;
m_oldX = -1;
GtkWidget *close_button = gtk_button_new_with_label( "x" );
gtk_myfixed_put( GTK_MYFIXED(m_mainWidget),
- close_button,
- 4, 4, 12, 11 );
+ close_button,
+ 4, 4, 12, 11 );
gtk_widget_show( close_button );
{
if (g_isIdle) wxapp_install_idle_handler();
- if ((win->m_x == alloc->x) &&
- (win->m_y == alloc->y) &&
- (win->m_width == alloc->width) &&
- (win->m_height == alloc->height))
+ if ((win->GetX() == alloc->x) &&
+ (win->GetY() == alloc->y) &&
+ (win->GetWidth() == alloc->width) &&
+ (win->GetHeight() == alloc->height))
{
return;
}
page->m_box = gtk_hbox_new (FALSE, 0);
gtk_container_border_width(GTK_CONTAINER(page->m_box), 2);
- GtkNotebook *notebook = GTK_NOTEBOOK(parent->m_widget);
+ GtkNotebook *notebook = GTK_NOTEBOOK(parent->GetWidget());
page->m_client = child;
- gtk_notebook_append_page( notebook, child->m_widget, page->m_box );
+ gtk_notebook_append_page( notebook, child->GetWidget(), page->m_box );
page->m_page = (GtkNotebookPage*) (g_list_last(notebook->children)->data);
page->m_parent = notebook;
- gtk_signal_connect( GTK_OBJECT(child->m_widget), "size_allocate",
+ gtk_signal_connect( GTK_OBJECT(child->GetWidget()), "size_allocate",
GTK_SIGNAL_FUNC(gtk_page_size_callback), (gpointer)child );
wxASSERT_MSG( page->m_page, _T("Notebook page creation error") );
GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback),
(gpointer)this );
- m_parent->AddChild( this );
-
- (m_parent->m_insertCallback)( m_parent, this );
+ m_parent->DoAddChild( this );
gtk_signal_connect( GTK_OBJECT(m_widget), "key_press_event",
GTK_SIGNAL_FUNC(gtk_notebook_key_press_callback), (gpointer)this );
EVT_SIZE(wxRadioBox::OnSize)
END_EVENT_TABLE()
-wxRadioBox::wxRadioBox(void)
+wxRadioBox::wxRadioBox()
{
}
gtk_signal_connect( GTK_OBJECT(m_radio), "clicked",
GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this );
- gtk_myfixed_put( GTK_MYFIXED(m_parent->m_wxwindow),
- GTK_WIDGET(m_radio),
- m_x+10, m_y+10+(i*24), 10, 10 );
+ gtk_myfixed_put( GTK_MYFIXED(m_parent->GetWxWindow()),
+ GTK_WIDGET(m_radio),
+ m_x+10, m_y+10+(i*24), 10, 10 );
}
wxSize ls = LayoutItems();
if (newSize.y == -1) newSize.y = ls.y;
SetSize( newSize.x, newSize.y );
- m_parent->AddChild( this );
-
- (m_parent->m_insertCallback)( m_parent, this );
+ m_parent->DoAddChild( this );
PostCreation();
return TRUE;
}
-wxRadioBox::~wxRadioBox(void)
+wxRadioBox::~wxRadioBox()
{
wxNode *node = m_boxes.First();
while (node)
void wxRadioBox::OnSize( wxSizeEvent &event )
{
- wxControl::OnSize( event );
-
LayoutItems();
+
+ event.Skip();
}
wxSize wxRadioBox::LayoutItems()
int len = 22+gdk_string_measure( font, label->label );
if (len > max_len) max_len = len;
- gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), button, m_x+x, m_y+y );
+ gtk_myfixed_move( GTK_MYFIXED(m_parent->GetWxWindow()), button, m_x+x, m_y+y );
y += 20;
node = node->Next();
{
GtkWidget *button = GTK_WIDGET( node->Data() );
- gtk_myfixed_resize( GTK_MYFIXED(m_parent->m_wxwindow), button, max_len, 20 );
+ gtk_myfixed_resize( GTK_MYFIXED(m_parent->GetWxWindow()), button, max_len, 20 );
node = node->Next();
if (!node) break;
{
GtkWidget *button = GTK_WIDGET( node->Data() );
- gtk_myfixed_set_size( GTK_MYFIXED(m_parent->m_wxwindow), button, m_x+x, m_y+y, max, 20 );
+ gtk_myfixed_set_size( GTK_MYFIXED(m_parent->GetWxWindow()), button, m_x+x, m_y+y, max, 20 );
x += max;
node = node->Next();
wxFAIL_MSG(_T("wxRadioBox::SetLabel not implemented."));
}
-void wxRadioBox::Enable( bool enable )
+bool wxRadioBox::Enable( bool enable )
{
- wxControl::Enable( enable );
+ if ( !wxControl::Enable( enable ) )
+ return FALSE;
wxNode *node = m_boxes.First();
while (node)
gtk_widget_set_sensitive( label, enable );
node = node->Next();
}
+
+ return TRUE;
}
void wxRadioBox::Enable( int item, bool enable )
gtk_signal_connect( GTK_OBJECT(m_widget), "clicked",
GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this );
- m_parent->AddChild( this );
-
- (m_parent->m_insertCallback)( m_parent, this );
+ m_parent->DoAddChild( this );
PostCreation();
return GTK_TOGGLE_BUTTON(m_widget)->active;
}
-void wxRadioButton::Enable( bool enable )
+bool wxRadioButton::Enable( bool enable )
{
- wxCHECK_RET( m_widget != NULL, _T("invalid radiobutton") );
-
- wxControl::Enable( enable );
+ if ( !wxControl::Enable( enable ) )
+ return FALSE;
gtk_widget_set_sensitive( GTK_BUTTON(m_widget)->child, enable );
+
+ return TRUE;
}
void wxRadioButton::ApplyWidgetStyle()
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
float line_step = win->m_adjust->step_increment;
float page_step = win->m_adjust->page_increment;
- if (win->m_isScrolling)
+ if (win->IsScrolling())
{
command = wxEVT_SCROLL_THUMBTRACK;
}
int value = (int)(win->m_adjust->value+0.5);
- int orient = wxHORIZONTAL;
- if (win->GetWindowStyleFlag() & wxSB_VERTICAL == wxSB_VERTICAL) orient = wxVERTICAL;
+ int orient = win->HasFlag(wxSB_VERTICAL) ? wxVERTICAL : wxHORIZONTAL;
wxScrollEvent event( command, win->GetId(), value, orient );
event.SetEventObject( win );
static gint gtk_scrollbar_button_press_callback( GtkRange *WXUNUSED(widget),
GdkEventButton *WXUNUSED(gdk_event),
- wxScrollBar *win )
+ wxScrollBar *win )
{
if (g_isIdle) wxapp_install_idle_handler();
- win->m_isScrolling = TRUE;
+ win->SetScrolling(TRUE);
// g_blockEventsOnScroll = TRUE; doesn't work in DialogEd
return FALSE;
static gint gtk_scrollbar_button_release_callback( GtkRange *WXUNUSED(widget),
GdkEventButton *WXUNUSED(gdk_event),
- wxScrollBar *win )
+ wxScrollBar *win )
{
if (g_isIdle) wxapp_install_idle_handler();
- win->m_isScrolling = FALSE;
+ win->SetScrolling(FALSE);
// g_blockEventsOnScroll = FALSE;
gtk_signal_emit_by_name( GTK_OBJECT(win->m_adjust), "value_changed" );
gtk_signal_connect( GTK_OBJECT(m_adjust),
"value_changed",
- (GtkSignalFunc) gtk_scrollbar_callback,
- (gpointer) this );
+ (GtkSignalFunc) gtk_scrollbar_callback,
+ (gpointer) this );
gtk_signal_connect( GTK_OBJECT(m_widget),
"button_press_event",
(GtkSignalFunc)gtk_scrollbar_button_press_callback,
- (gpointer) this );
+ (gpointer) this );
gtk_signal_connect( GTK_OBJECT(m_widget),
"button_release_event",
(GtkSignalFunc)gtk_scrollbar_button_release_callback,
- (gpointer) this );
+ (gpointer) this );
- m_parent->AddChild( this );
-
- (m_parent->m_insertCallback)( m_parent, this );
+ m_parent->DoAddChild( this );
PostCreation();
GtkRange *range = GTK_RANGE(m_widget);
return ( (window == GTK_WIDGET(range)->window) ||
(window == range->trough) ||
- (window == range->slider) ||
- (window == range->step_forw) ||
- (window == range->step_back) );
+ (window == range->slider) ||
+ (window == range->step_forw) ||
+ (window == range->step_back) );
}
void wxScrollBar::ApplyWidgetStyle()
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
if (style & wxSL_LABELS)
{
gtk_scale_set_draw_value( GTK_SCALE( m_widget ), TRUE );
-
- /* labels need more space and too small window will
- cause junk to appear on the dialog */
+
+ /* labels need more space and too small window will
+ cause junk to appear on the dialog */
if (style & wxSL_VERTICAL)
- {
- wxSize sz( size );
- if (sz.x < 35)
- {
- sz.x = 35;
- SetSize( sz );
- }
- }
+ {
+ wxSize sz( size );
+ if (sz.x < 35)
+ {
+ sz.x = 35;
+ SetSize( sz );
+ }
+ }
else
- {
- wxSize sz( size );
- if (sz.y < 35)
- {
- sz.y = 35;
- SetSize( sz );
- }
- }
+ {
+ wxSize sz( size );
+ if (sz.y < 35)
+ {
+ sz.y = 35;
+ SetSize( sz );
+ }
+ }
}
else
gtk_scale_set_draw_value( GTK_SCALE( m_widget ), FALSE );
gtk_signal_connect( GTK_OBJECT(m_adjust),
"value_changed",
- (GtkSignalFunc) gtk_slider_callback,
- (gpointer) this );
-
+ (GtkSignalFunc) gtk_slider_callback,
+ (gpointer) this );
+
SetRange( minValue, maxValue );
SetValue( value );
- m_parent->AddChild( this );
-
- (m_parent->m_insertCallback)( m_parent, this );
+ m_parent->DoAddChild( this );
PostCreation();
GtkRange *range = GTK_RANGE(m_widget);
return ( (window == GTK_WIDGET(range)->window) ||
(window == range->trough) ||
- (window == range->slider) ||
- (window == range->step_forw) ||
- (window == range->step_back) );
+ (window == range->slider) ||
+ (window == range->step_forw) ||
+ (window == range->step_back) );
}
void wxSlider::ApplyWidgetStyle()
(GtkSignalFunc) gtk_spinbutt_callback,
(gpointer) this );
- m_parent->AddChild( this );
-
- (m_parent->m_insertCallback)( m_parent, this );
+ m_parent->DoAddChild( this );
PostCreation();
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
m_widget = gtk_label_new( "Bitmap" );
}
- m_parent->AddChild( this );
-
- (m_parent->m_insertCallback)( m_parent, this );
+ m_parent->DoAddChild( this );
PostCreation();
m_widget = gtk_frame_new(m_label.mbc_str());
- m_parent->AddChild( this );
-
- (m_parent->m_insertCallback)( m_parent, this );
+ m_parent->DoAddChild( this );
PostCreation();
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
else
m_widget = gtk_hseparator_new();
- m_parent->AddChild( this );
-
- (m_parent->m_insertCallback)( m_parent, this );
+ m_parent->DoAddChild( this );
PostCreation();
SetSize( newSize.x, newSize.y );
- m_parent->AddChild( this );
-
- (m_parent->m_insertCallback)( m_parent, this );
+ m_parent->DoAddChild( this );
PostCreation();
if (tool->m_enabled)
{
if (tb->m_fg->red != 0)
- {
+ {
tb->m_fg->red = 0;
tb->m_fg->green = 0;
tb->m_fg->blue = 0;
gdk_color_alloc( gtk_widget_get_colormap( GTK_WIDGET(tb->m_toolbar) ), tb->m_fg );
-
+
#if (GTK_MINOR_VERSION > 0)
GtkStyle *g_style =
gtk_style_copy(
gtk_widget_get_style(
GTK_TOOLBAR(tb->m_toolbar)->tooltips->tip_window ) );
-
+
g_style->fg[GTK_STATE_NORMAL] = *tb->m_fg;
gtk_widget_set_style( GTK_TOOLBAR(tb->m_toolbar)->tooltips->tip_window, g_style );
#else
gtk_tooltips_set_colors( GTK_TOOLBAR(tb->m_toolbar)->tooltips, tb->m_bg, tb->m_fg );
#endif
- }
+ }
}
else
{
if (tb->m_fg->red == 0)
- {
+ {
tb->m_fg->red = 33000;
tb->m_fg->green = 33000;
tb->m_fg->blue = 33000;
gtk_style_copy(
gtk_widget_get_style(
GTK_TOOLBAR(tb->m_toolbar)->tooltips->tip_window ) );
-
+
g_style->fg[GTK_STATE_NORMAL] = *tb->m_fg;
gtk_widget_set_style( GTK_TOOLBAR(tb->m_toolbar)->tooltips->tip_window, g_style );
#else
gtk_tooltips_set_colors( GTK_TOOLBAR(tb->m_toolbar)->tooltips, tb->m_bg, tb->m_fg );
#endif
- }
+ }
}
/* emit the event */
if (style & wxTB_DOCKABLE)
{
m_widget = gtk_handle_box_new();
- gtk_container_add( GTK_CONTAINER(m_widget), GTK_WIDGET(m_toolbar) );
- gtk_widget_show( GTK_WIDGET(m_toolbar) );
-
+ gtk_container_add( GTK_CONTAINER(m_widget), GTK_WIDGET(m_toolbar) );
+ gtk_widget_show( GTK_WIDGET(m_toolbar) );
+
#if (GTK_MINOR_VERSION > 0)
- if (style & wxTB_FLAT)
+ if (style & wxTB_FLAT)
gtk_handle_box_set_shadow_type( GTK_HANDLE_BOX(m_widget), GTK_SHADOW_NONE );
#endif
}
{
m_widget = GTK_WIDGET(m_toolbar);
}
-
+
gtk_toolbar_set_tooltips( GTK_TOOLBAR(m_toolbar), TRUE );
#if (GTK_MINOR_VERSION > 0)
gtk_style_copy(
gtk_widget_get_style(
GTK_TOOLBAR(m_toolbar)->tooltips->tip_window ) );
-
+
g_style->bg[GTK_STATE_NORMAL] = *m_bg;
gtk_widget_set_style( GTK_TOOLBAR(m_toolbar)->tooltips->tip_window, g_style );
#else
m_xMargin = 0;
m_yMargin = 0;
- m_parent->AddChild( this );
-
- (m_parent->m_insertCallback)( m_parent, this );
+ m_parent->DoAddChild( this );
PostCreation();
wxToolBarTool *tool = new wxToolBarTool( this, toolIndex, bitmap, pushedBitmap,
toggle, clientData,
helpString1, helpString2,
- tool_pixmap );
+ tool_pixmap );
GtkToolbarChildType ctype = toggle ? GTK_TOOLBAR_CHILD_TOGGLEBUTTON
: GTK_TOOLBAR_CHILD_BUTTON;
if (tool->m_index == toolIndex)
{
tool->m_enabled = enable;
-
+
/* we don't disable the tools for now as the bitmaps don't get
greyed anyway and this also disables tooltips
- if (tool->m_item)
- gtk_widget_set_sensitive( tool->m_item, enable );
+ if (tool->m_item)
+ gtk_widget_set_sensitive( tool->m_item, enable );
*/
-
+
return;
}
node = node->Next();
if (tool->m_index == toolIndex)
{
tool->m_longHelpString = helpString;
- return;
+ return;
}
node = node->Next();
}
if (tool->m_index == toolIndex)
{
tool->m_shortHelpString = helpString;
- return;
+ return;
}
node = node->Next();
}
{
if (g_isIdle) wxapp_install_idle_handler();
- if (!win->m_hasVMT) return;
+ if (!win->HasVMT()) return;
win->SetModified();
- wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, win->m_windowId );
+ wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, win->GetId() );
event.SetString( win->GetValue() );
event.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( event );
if (g_isIdle) wxapp_install_idle_handler();
win->CalculateScrollbar();
-
- if (!win->m_hasVMT) return;
+
+ if (!win->HasVMT()) return;
}
//-----------------------------------------------------------------------------
/* ... and put into the upper left hand corner of the table */
m_widget = gtk_table_new(bHasHScrollbar ? 2 : 1, 2, FALSE);
GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
-
gtk_table_attach( GTK_TABLE(m_widget), m_text, 0, 1, 0, 1,
(GtkAttachOptions)(GTK_FILL | GTK_EXPAND | GTK_SHRINK),
(GtkAttachOptions)(GTK_FILL | GTK_EXPAND | GTK_SHRINK),
/* always wrap words */
gtk_text_set_word_wrap( GTK_TEXT(m_text), TRUE );
-
/* put the horizontal scrollbar in the lower left hand corner */
if (bHasHScrollbar)
{
GtkWidget *hscrollbar = gtk_hscrollbar_new(GTK_TEXT(m_text)->hadj);
GTK_WIDGET_UNSET_FLAGS( hscrollbar, GTK_CAN_FOCUS );
-
gtk_table_attach(GTK_TABLE(m_widget), hscrollbar, 0, 1, 1, 2,
(GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
GTK_FILL,
gtk_text_set_line_wrap( GTK_TEXT(m_text), FALSE );
#endif
}
-
/* finally, put the vertical scrollbar in the upper right corner */
m_vScrollbar = gtk_vscrollbar_new( GTK_TEXT(m_text)->vadj );
GTK_WIDGET_UNSET_FLAGS( m_vScrollbar, GTK_CAN_FOCUS );
-
gtk_table_attach(GTK_TABLE(m_widget), m_vScrollbar, 1, 2, 0, 1,
GTK_FILL,
(GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK),
if (newSize.y == -1) newSize.y = 26;
SetSize( newSize.x, newSize.y );
- m_parent->AddChild( this );
-
- (m_parent->m_insertCallback)( m_parent, this );
+ m_parent->DoAddChild( this );
PostCreation();
return (window == GTK_ENTRY(m_text)->text_area);
}
-void wxTextCtrl::SetFont( const wxFont &WXUNUSED(font) )
+bool wxTextCtrl::SetFont( const wxFont &WXUNUSED(font) )
{
- wxCHECK_RET( m_text != NULL, _T("invalid text ctrl") );
+ wxCHECK_MSG( m_text != NULL, FALSE, _T("invalid text ctrl") );
// doesn't work
+ return FALSE;
}
-void wxTextCtrl::SetForegroundColour( const wxColour &WXUNUSED(colour) )
+bool wxTextCtrl::SetForegroundColour( const wxColour &WXUNUSED(colour) )
{
- wxCHECK_RET( m_text != NULL, _T("invalid text ctrl") );
+ wxCHECK_MSG( m_text != NULL, FALSE, _T("invalid text ctrl") );
// doesn't work
+ return FALSE;
}
-void wxTextCtrl::SetBackgroundColour( const wxColour &colour )
+bool wxTextCtrl::SetBackgroundColour( const wxColour &colour )
{
- wxCHECK_RET( m_text != NULL, _T("invalid text ctrl") );
+ wxCHECK_MSG( m_text != NULL, FALSE, _T("invalid text ctrl") );
wxControl::SetBackgroundColour( colour );
- if (!m_widget->window) return;
+ if (!m_widget->window)
+ return FALSE;
wxColour sysbg = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE );
if (sysbg.Red() == colour.Red() &&
sysbg.Green() == colour.Green() &&
sysbg.Blue() == colour.Blue())
{
- return;
+ return FALSE; // FIXME or TRUE?
}
- if (!m_backgroundColour.Ok()) return;
+ if (!m_backgroundColour.Ok())
+ return FALSE;
if (m_windowStyle & wxTE_MULTILINE)
{
GdkWindow *window = GTK_TEXT(m_text)->text_area;
- if (!window) return;
+ if (!window)
+ return FALSE;
m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) );
gdk_window_set_background( window, m_backgroundColour.GetColor() );
gdk_window_clear( window );
}
+
+ return TRUE;
}
void wxTextCtrl::ApplyWidgetStyle()
SetValidator(validator);
printf("Robert's new insertion code :-)\n");
- m_parent->AddChild( this );
- (m_parent->m_insertCallback)( m_parent, this );
-
+ m_parent->DoAddChild( this );
printf("postcreate\n");
PostCreation();
*/
+//-----------------------------------------------------------------------------
+// data
+//-----------------------------------------------------------------------------
+
+extern wxList wxPendingDelete;
+extern bool g_blockEventsOnDrag;
+extern bool g_blockEventsOnScroll;
+static bool g_capturing = FALSE;
+static wxWindow *g_focusWindow = (wxWindow*) NULL;
+
+/* hack: we need something to pass to gtk_menu_popup, so we store the time of
+ the last click here */
+static guint32 gs_timeLastClick = 0;
+
//-----------------------------------------------------------------------------
// debug
//-----------------------------------------------------------------------------
GTK_SIGNAL_FUNC(gtk_debug_focus_in_callback), (gpointer)s );
}
-#endif
-
-//-----------------------------------------------------------------------------
-// data
-//-----------------------------------------------------------------------------
-
-extern wxList wxPendingDelete;
-extern bool g_blockEventsOnDrag;
-extern bool g_blockEventsOnScroll;
-extern bool g_isIdle;
-static bool g_capturing = FALSE;
-static wxWindow *g_focusWindow = (wxWindow*) NULL;
-
-/* hack: we need something to pass to gtk_menu_popup, so we store the time of
- the last click here */
-static guint32 gs_timeLastClick = 0;
+#endif // Debug
//-----------------------------------------------------------------------------
-// idle system
+// local code (see below)
//-----------------------------------------------------------------------------
-extern void wxapp_install_idle_handler();
-extern bool g_isIdle;
+static void InitAdjustment(GtkAdjustment *adjust)
+{
+ adjust->lower = 0.0;
+ adjust->upper = 1.0;
+ adjust->value = 0.0;
+ adjust->step_increment = 1.0;
+ adjust->page_increment = 1.0;
+ adjust->page_size = 5.0;
+ gtk_signal_emit_by_name( GTK_OBJECT(adjust), "changed" );
+}
#if (GTK_MINOR_VERSION > 0)
-//-----------------------------------------------------------------------------
-// local code (see below)
-//-----------------------------------------------------------------------------
-
static void draw_frame( GtkWidget *widget, wxWindow *win )
{
- if (!win->HasVMT()) return;
+ if (!win->HasVMT())
+ return;
int dw = 0;
int dh = 0;
- if (win->m_hasScrolling)
+ if (win->HasScrolling())
{
GtkScrolledWindow *scroll_window = GTK_SCROLLED_WINDOW(widget);
GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(widget)->klass );
GtkWidget *hscrollbar = scroll_window->hscrollbar;
GtkWidget *vscrollbar = scroll_window->vscrollbar;
- we use this instead: range.slider_width = 11 + 2*2pts edge
+ we use this instead: range.slider_width = 11 + 2*2pts edge
*/
if (scroll_window->vscrollbar_visible)
dy += widget->allocation.y;
}
- if (win->m_windowStyle & wxRAISED_BORDER)
+ if (win->HasFlag(wxRAISED_BORDER))
{
gtk_draw_shadow( widget->style,
widget->window,
- GTK_STATE_NORMAL,
- GTK_SHADOW_OUT,
- dx, dy,
- win->m_width-dw, win->m_height-dh );
- return;
+ GTK_STATE_NORMAL,
+ GTK_SHADOW_OUT,
+ dx, dy,
+ win->GetWidth()-dw, win->GetHeight()-dh );
+ return;
}
- if (win->m_windowStyle & wxSUNKEN_BORDER)
+ if (win->HasFlag(wxSUNKEN_BORDER))
{
gtk_draw_shadow( widget->style,
widget->window,
- GTK_STATE_NORMAL,
- GTK_SHADOW_IN,
- dx, dy,
- win->m_width-dw, win->m_height-dh );
- return;
+ GTK_STATE_NORMAL,
+ GTK_SHADOW_IN,
+ dx, dy,
+ win->GetWidth()-dw, win->GetHeight()-dh );
+ return;
}
}
draw_frame( widget, win );
}
-#endif
+#endif // GTK_MINOR_VERSION > 0
//-----------------------------------------------------------------------------
// "expose_event" of m_wxwindow
static void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExpose *gdk_event, wxWindow *win )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
- if (!win->HasVMT()) return;
+ if ( !win->HasVMT() )
+ return;
- win->m_updateRegion.Union( gdk_event->area.x,
- gdk_event->area.y,
- gdk_event->area.width,
- gdk_event->area.height );
+ win->GetUpdateRegion().Union( gdk_event->area.x,
+ gdk_event->area.y,
+ gdk_event->area.width,
+ gdk_event->area.height );
- if (gdk_event->count > 0) return;
+ if ( gdk_event->count > 0 )
+ return;
/*
printf( "OnExpose from " );
event.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( event );
- win->m_updateRegion.Clear();
+ win->GetUpdateRegion().Clear();
}
//-----------------------------------------------------------------------------
static void gtk_window_draw_callback( GtkWidget *WXUNUSED(widget), GdkRectangle *rect, wxWindow *win )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
- if (!win->HasVMT()) return;
+ if ( !win->HasVMT() )
+ return;
- win->m_updateRegion.Union( rect->x, rect->y, rect->width, rect->height );
+ win->GetUpdateRegion().Union( rect->x, rect->y,
+ rect->width, rect->height );
wxPaintEvent event( win->GetId() );
event.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( event );
- win->m_updateRegion.Clear();
+ win->GetUpdateRegion().Clear();
}
//-----------------------------------------------------------------------------
static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxWindow *win )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
/*
- wxPrintf( _T("OnKeyPress from ") );
+ printf( "OnKeyPress from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
- wxPrintf( win->GetClassInfo()->GetClassName() );
- wxPrintf( _T(".\n") );
-
- wxPrintf( _T("keyval: %d.\n"), (int) gdk_event->keyval );
+ printf( win->GetClassInfo()->GetClassName() );
+ printf( ".\n" );
*/
long key_code = 0;
switch (gdk_event->keyval)
{
case GDK_BackSpace: key_code = WXK_BACK; break;
- case GDK_ISO_Left_Tab:
+ case GDK_ISO_Left_Tab:
case GDK_KP_Tab:
case GDK_Tab: key_code = WXK_TAB; break;
case GDK_Linefeed: key_code = WXK_RETURN; break;
// win is a control: tab can be propagated up
if ( (!ret) &&
((gdk_event->keyval == GDK_Tab) || (gdk_event->keyval == GDK_ISO_Left_Tab)) &&
- ((win->m_windowStyle & wxTE_PROCESS_TAB) == 0))
+ (win->HasFlag(wxTE_PROCESS_TAB) == 0))
{
wxNavigationKeyEvent new_event;
- /* GDK reports GDK_ISO_Left_Tab for SHIFT-TAB */
+ /* GDK reports GDK_ISO_Left_Tab for SHIFT-TAB */
new_event.SetDirection( (gdk_event->keyval == GDK_Tab) );
- /* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
+ /* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
new_event.SetWindowChange( (gdk_event->state & GDK_CONTROL_MASK) );
new_event.SetCurrentFocus( win );
ret = win->GetEventHandler()->ProcessEvent( new_event );
Damn, I forgot why this didn't work, but it didn't work.
// win is a panel: up can be propagated to the panel
- if ((!ret) && (win->m_wxwindow) && (win->m_parent) && (win->m_parent->AcceptsFocus()) &&
+ if ((!ret) && (win->GetWxWindow()) && (win->m_parent) && (win->m_parent->AcceptsFocus()) &&
(gdk_event->keyval == GDK_Up))
{
win->m_parent->SetFocus();
}
// win is a panel: left/right can be propagated to the panel
- if ((!ret) && (win->m_wxwindow) &&
+ if ((!ret) && (win->GetWxWindow()) &&
((gdk_event->keyval == GDK_Right) || (gdk_event->keyval == GDK_Left) ||
(gdk_event->keyval == GDK_Up) || (gdk_event->keyval == GDK_Down)))
{
if (ret)
{
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_press_event" );
- return TRUE;
+ return TRUE;
}
return FALSE;
static gint gtk_window_key_release_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxWindow *win )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
switch (gdk_event->keyval)
{
case GDK_BackSpace: key_code = WXK_BACK; break;
- case GDK_ISO_Left_Tab:
+ case GDK_ISO_Left_Tab:
case GDK_KP_Tab:
case GDK_Tab: key_code = WXK_TAB; break;
case GDK_Linefeed: key_code = WXK_RETURN; break;
if (win->GetEventHandler()->ProcessEvent( event ))
{
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_release_event" );
- return TRUE;
+ return TRUE;
}
return FALSE;
static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
-/*
- wxPrintf( _T("1) OnButtonPress from ") );
- if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
- wxPrintf( win->GetClassInfo()->GetClassName() );
- wxPrintf( _T(".\n") );
-*/
-
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return TRUE;
if (g_blockEventsOnScroll) return TRUE;
if (!win->IsOwnGtkWindow( gdk_event->window )) return FALSE;
- if (win->m_wxwindow)
+ if (win->GetWxWindow())
{
- if (GTK_WIDGET_CAN_FOCUS(win->m_wxwindow) && !GTK_WIDGET_HAS_FOCUS (win->m_wxwindow) )
+ if (GTK_WIDGET_CAN_FOCUS(win->GetWxWindow()) && !GTK_WIDGET_HAS_FOCUS (win->GetWxWindow()) )
{
- gtk_widget_grab_focus (win->m_wxwindow);
+ gtk_widget_grab_focus (win->GetWxWindow());
/*
- wxPrintf( _T("GrabFocus from ") );
+ printf( "GrabFocus from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
- wxPrintf( win->GetClassInfo()->GetClassName() );
- wxPrintf( _T(".\n") );
+ printf( win->GetClassInfo()->GetClassName() );
+ printf( ".\n" );
*/
}
-/*
- else
- {
- wxPrintf( _T("No GrabFocus from ") );
- if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
- wxPrintf( win->GetClassInfo()->GetClassName() );
- if (GTK_WIDGET_CAN_FOCUS(win->m_wxwindow))
- wxPrintf( _T(" because it already has") );
- wxPrintf( _T(".\n") );
- }
-*/
}
/*
- wxPrintf( _T("2) OnButtonPress from ") );
+ printf( "OnButtonPress from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
- wxPrintf( win->GetClassInfo()->GetClassName() );
- wxPrintf( _T(".\n") );
+ printf( win->GetClassInfo()->GetClassName() );
+ printf( ".\n" );
*/
wxEventType event_type = wxEVT_LEFT_DOWN;
{
wxWindow *child = (wxWindow*)node->Data();
- if (child->m_isStaticBox)
+ if ( child->IsStaticBox() )
{
// wxStaticBox is transparent in the box itself
- int x = event.m_x;
- int y = event.m_y;
- int xx1 = child->m_x;
- int yy1 = child->m_y;
- int xx2 = child->m_x + child->m_width;
- int yy2 = child->m_x + child->m_height;
+ int x = event.m_x,
+ y = event.m_y;
+
+ wxRect rectChild(child->GetRect());
+ int xx1 = rectChild.GetLeft(),
+ yy1 = rectChild.GetTop(),
+ xx2 = rectChild.GetRight(),
+ yy2 = rectChild.GetBottom();
// left
if (((x >= xx1) && (x <= xx1+10) && (y >= yy1) && (y <= yy2)) ||
((x >= xx1) && (x <= xx2) && (y >= yy2-1) && (y <= yy2)))
{
win = child;
- event.m_x -= child->m_x;
- event.m_y -= child->m_y;
+ event.m_x -= child->GetX();
+ event.m_y -= child->GetY();
break;
}
}
else
{
- if ((child->m_wxwindow == (GtkWidget*) NULL) &&
- (child->m_x <= event.m_x) &&
- (child->m_y <= event.m_y) &&
- (child->m_x+child->m_width >= event.m_x) &&
- (child->m_y+child->m_height >= event.m_y))
+ if ((child->GetWxWindow() == (GtkWidget*) NULL) &&
+ (child->GetX() <= event.m_x) &&
+ (child->GetY() <= event.m_y) &&
+ (child->GetX()+child->GetWidth() >= event.m_x) &&
+ (child->GetY()+child->GetHeight() >= event.m_y))
{
win = child;
- event.m_x -= child->m_x;
- event.m_y -= child->m_y;
+ event.m_x -= child->GetX();
+ event.m_y -= child->GetY();
break;
}
}
if (win->GetEventHandler()->ProcessEvent( event ))
{
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "button_press_event" );
- return TRUE;
+ return TRUE;
}
return FALSE;
static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
if (g_blockEventsOnScroll) return FALSE;
{
wxWindow *child = (wxWindow*)node->Data();
- if (child->m_isStaticBox)
+ if (child->IsStaticBox() )
{
// wxStaticBox is transparent in the box itself
int x = event.m_x;
int y = event.m_y;
- int xx1 = child->m_x;
- int yy1 = child->m_y;
- int xx2 = child->m_x + child->m_width;
- int yy2 = child->m_x + child->m_height;
+ int xx1 = child->GetX();
+ int yy1 = child->GetY();
+ int xx2 = child->GetX() + child->GetWidth();
+ int yy2 = child->GetX() + child->GetHeight();
// left
if (((x >= xx1) && (x <= xx1+10) && (y >= yy1) && (y <= yy2)) ||
((x >= xx1) && (x <= xx2) && (y >= yy2-1) && (y <= yy2)))
{
win = child;
- event.m_x -= child->m_x;
- event.m_y -= child->m_y;
+ event.m_x -= child->GetX();
+ event.m_y -= child->GetY();
break;
}
}
else
{
- if ((child->m_wxwindow == (GtkWidget*) NULL) &&
- (child->m_x <= event.m_x) &&
- (child->m_y <= event.m_y) &&
- (child->m_x+child->m_width >= event.m_x) &&
- (child->m_y+child->m_height >= event.m_y))
+ if ((child->GetWxWindow() == (GtkWidget*) NULL) &&
+ (child->GetX() <= event.m_x) &&
+ (child->GetY() <= event.m_y) &&
+ (child->GetX()+child->GetWidth() >= event.m_x) &&
+ (child->GetY()+child->GetHeight() >= event.m_y))
{
win = child;
- event.m_x -= child->m_x;
- event.m_y -= child->m_y;
+ event.m_x -= child->GetX();
+ event.m_y -= child->GetY();
break;
}
}
if (win->GetEventHandler()->ProcessEvent( event ))
{
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "button_release_event" );
- return TRUE;
+ return TRUE;
}
return FALSE;
static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_event, wxWindow *win )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
if (g_blockEventsOnScroll) return FALSE;
{
wxWindow *child = (wxWindow*)node->Data();
- if (child->m_isStaticBox)
+ if ( child->IsStaticBox() )
{
// wxStaticBox is transparent in the box itself
int x = event.m_x;
int y = event.m_y;
- int xx1 = child->m_x;
- int yy1 = child->m_y;
- int xx2 = child->m_x + child->m_width;
- int yy2 = child->m_x + child->m_height;
+ int xx1 = child->GetX();
+ int yy1 = child->GetY();
+ int xx2 = child->GetX() + child->GetWidth();
+ int yy2 = child->GetX() + child->GetHeight();
// left
if (((x >= xx1) && (x <= xx1+10) && (y >= yy1) && (y <= yy2)) ||
((x >= xx1) && (x <= xx2) && (y >= yy2-1) && (y <= yy2)))
{
win = child;
- event.m_x -= child->m_x;
- event.m_y -= child->m_y;
+ event.m_x -= child->GetX();
+ event.m_y -= child->GetY();
break;
}
}
else
{
- if ((child->m_wxwindow == (GtkWidget*) NULL) &&
- (child->m_x <= event.m_x) &&
- (child->m_y <= event.m_y) &&
- (child->m_x+child->m_width >= event.m_x) &&
- (child->m_y+child->m_height >= event.m_y))
+ if ((child->GetWxWindow() == (GtkWidget*) NULL) &&
+ (child->GetX() <= event.m_x) &&
+ (child->GetY() <= event.m_y) &&
+ (child->GetX()+child->GetWidth() >= event.m_x) &&
+ (child->GetY()+child->GetHeight() >= event.m_y))
{
win = child;
- event.m_x -= child->m_x;
- event.m_y -= child->m_y;
+ event.m_x -= child->GetX();
+ event.m_y -= child->GetY();
break;
}
}
if (win->GetEventHandler()->ProcessEvent( event ))
{
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "motion_notify_event" );
- return TRUE;
+ return TRUE;
}
return FALSE;
static gint gtk_window_focus_in_callback( GtkWidget *widget, GdkEvent *WXUNUSED(event), wxWindow *win )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
g_focusWindow = win;
- if (win->m_wxwindow)
+ if (win->GetWxWindow())
{
- if (GTK_WIDGET_CAN_FOCUS(win->m_wxwindow))
+ if (GTK_WIDGET_CAN_FOCUS(win->GetWxWindow()))
{
- GTK_WIDGET_SET_FLAGS (win->m_wxwindow, GTK_HAS_FOCUS);
+ GTK_WIDGET_SET_FLAGS (win->GetWxWindow(), GTK_HAS_FOCUS);
/*
printf( "SetFocus flag from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
/*
- wxPrintf( _T("OnSetFocus from ") );
+ printf( "OnSetFocus from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
- wxPrintf( win->GetClassInfo()->GetClassName() );
- wxPrintf( _T(" ") );
- wxPrintf( win->GetLabel() );
- wxPrintf( _T(".\n") );
+ printf( win->GetClassInfo()->GetClassName() );
+ printf( " " );
+ printf( WXSTRINGCAST win->GetLabel() );
+ printf( ".\n" );
*/
wxFocusEvent event( wxEVT_SET_FOCUS, win->GetId() );
static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEvent *WXUNUSED(event), wxWindow *win )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
- if (win->m_wxwindow)
+ if (win->GetWxWindow())
{
- if (GTK_WIDGET_CAN_FOCUS(win->m_wxwindow))
- GTK_WIDGET_UNSET_FLAGS (win->m_wxwindow, GTK_HAS_FOCUS);
+ if (GTK_WIDGET_CAN_FOCUS(win->GetWxWindow()))
+ GTK_WIDGET_UNSET_FLAGS (win->GetWxWindow(), GTK_HAS_FOCUS);
}
/*
- wxPrintf( _T("OnKillFocus from ") );
+ printf( "OnKillFocus from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
- wxPrintf( win->GetClassInfo()->GetClassName() );
- wxPrintf( _T(" ") );
- wxPrintf( win->GetLabel() );
- wxPrintf( _T(".\n") );
+ printf( win->GetClassInfo()->GetClassName() );
+ printf( ".\n" );
*/
wxFocusEvent event( wxEVT_KILL_FOCUS, win->GetId() );
static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
- if (!win->HasVMT()) return FALSE;
- if (g_blockEventsOnDrag) return FALSE;
+ if ( !win->HasVMT() || g_blockEventsOnDrag )
+ return FALSE;
- if (!win->IsOwnGtkWindow( gdk_event->window )) return FALSE;
+ GdkWindow *window = widget->window;
+ if ( window != gdk_event->window )
+ return FALSE;
- if ((widget->window) && (win->m_cursor.Ok()))
- gdk_window_set_cursor( widget->window, win->m_cursor.GetCursor() );
+ if ( window && win->GetCursor().Ok() )
+ gdk_window_set_cursor( window, win->GetCursor().GetCursor() );
/*
printf( "OnEnter from " );
int y = 0;
GdkModifierType state = (GdkModifierType)0;
- gdk_window_get_pointer( widget->window, &x, &y, &state );
+ gdk_window_get_pointer( window, &x, &y, &state );
event.m_shiftDown = (state & GDK_SHIFT_MASK);
event.m_controlDown = (state & GDK_CONTROL_MASK);
static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win )
{
- if (g_isIdle) wxapp_install_idle_handler();
+ if ( !win->HasVMT() || g_blockEventsOnDrag )
+ return FALSE;
- if (!win->HasVMT()) return FALSE;
- if (g_blockEventsOnDrag) return FALSE;
-
- if (!win->IsOwnGtkWindow( gdk_event->window )) return FALSE;
+ GdkWindow *window = widget->window;
+ if ( window != gdk_event->window )
+ return FALSE;
- if (widget->window)
- gdk_window_set_cursor( widget->window, wxSTANDARD_CURSOR->GetCursor() );
+ if ( window && win->GetCursor().Ok() )
+ gdk_window_set_cursor( window, wxSTANDARD_CURSOR->GetCursor() );
/*
- wxPrintf( _T("OnLeave from ") );
+ printf( "OnLeave from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
- wxPrintf( win->GetClassInfo()->GetClassName() );
- wxPrintf( _T(".\n") );
+ printf( win->GetClassInfo()->GetClassName() );
+ printf( ".\n" );
*/
wxMouseEvent event( wxEVT_LEAVE_WINDOW );
static void gtk_window_vscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow *win )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
if (g_blockEventsOnDrag) return;
/*
if (!win->HasVMT()) return;
- float diff = win->m_vAdjust->value - win->m_oldVerticalPos;
+ float diff = win->GetVAdjust()->value - win->GetOldVerticalPos();
if (fabs(diff) < 0.2) return;
- win->m_oldVerticalPos = win->m_vAdjust->value;
+ win->SetOldVerticalPos(win->GetVAdjust()->value);
wxEventType command = wxEVT_NULL;
- float line_step = win->m_vAdjust->step_increment;
- float page_step = win->m_vAdjust->page_increment;
+ float line_step = win->GetVAdjust()->step_increment;
+ float page_step = win->GetVAdjust()->page_increment;
- if (win->m_isScrolling)
+ if (win->IsScrolling())
{
command = wxEVT_SCROLL_THUMBTRACK;
}
else
{
- if (fabs(win->m_vAdjust->value-win->m_vAdjust->lower) < 0.2) command = wxEVT_SCROLL_BOTTOM;
- else if (fabs(win->m_vAdjust->value-win->m_vAdjust->upper) < 0.2) command = wxEVT_SCROLL_TOP;
+ if (fabs(win->GetVAdjust()->value-win->GetVAdjust()->lower) < 0.2) command = wxEVT_SCROLL_BOTTOM;
+ else if (fabs(win->GetVAdjust()->value-win->GetVAdjust()->upper) < 0.2) command = wxEVT_SCROLL_TOP;
else if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLL_LINEDOWN;
else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLL_LINEUP;
else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLL_PAGEDOWN;
else command = wxEVT_SCROLL_THUMBTRACK;
}
- int value = (int)(win->m_vAdjust->value+0.5);
+ int value = (int)(win->GetVAdjust()->value+0.5);
wxScrollEvent event( command, win->GetId(), value, wxVERTICAL );
event.SetEventObject( win );
static void gtk_window_hscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow *win )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
if (g_blockEventsOnDrag) return;
/*
if (!win->HasVMT()) return;
- float diff = win->m_hAdjust->value - win->m_oldHorizontalPos;
+ float diff = win->GetHAdjust()->value - win->GetOldHorizontalPos();
if (fabs(diff) < 0.2) return;
- win->m_oldHorizontalPos = win->m_hAdjust->value;
+ win->SetOldHorizontalPos( win->GetHAdjust()->value );
wxEventType command = wxEVT_NULL;
- float line_step = win->m_hAdjust->step_increment;
- float page_step = win->m_hAdjust->page_increment;
+ float line_step = win->GetHAdjust()->step_increment;
+ float page_step = win->GetHAdjust()->page_increment;
- if (win->m_isScrolling)
+ if (win->IsScrolling())
{
command = wxEVT_SCROLL_THUMBTRACK;
}
else
{
- if (fabs(win->m_hAdjust->value-win->m_hAdjust->lower) < 0.2) command = wxEVT_SCROLL_BOTTOM;
- else if (fabs(win->m_hAdjust->value-win->m_hAdjust->upper) < 0.2) command = wxEVT_SCROLL_TOP;
+ if (fabs(win->GetHAdjust()->value-win->GetHAdjust()->lower) < 0.2) command = wxEVT_SCROLL_BOTTOM;
+ else if (fabs(win->GetHAdjust()->value-win->GetHAdjust()->upper) < 0.2) command = wxEVT_SCROLL_TOP;
else if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLL_LINEDOWN;
else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLL_LINEUP;
else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLL_PAGEDOWN;
else command = wxEVT_SCROLL_THUMBTRACK;
}
- int value = (int)(win->m_hAdjust->value+0.5);
+ int value = (int)(win->GetHAdjust()->value+0.5);
wxScrollEvent event( command, win->GetId(), value, wxHORIZONTAL );
event.SetEventObject( win );
static void gtk_window_vscroll_change_callback( GtkWidget *WXUNUSED(widget), wxWindow *win )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
if (g_blockEventsOnDrag) return;
/*
if (!win->HasVMT()) return;
wxEventType command = wxEVT_SCROLL_THUMBTRACK;
- int value = (int)(win->m_vAdjust->value+0.5);
+ int value = (int)(win->GetVAdjust()->value+0.5);
wxScrollEvent event( command, win->GetId(), value, wxVERTICAL );
event.SetEventObject( win );
static void gtk_window_hscroll_change_callback( GtkWidget *WXUNUSED(widget), wxWindow *win )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
if (g_blockEventsOnDrag) return;
/*
if (!win->HasVMT()) return;
wxEventType command = wxEVT_SCROLL_THUMBTRACK;
- int value = (int)(win->m_hAdjust->value+0.5);
+ int value = (int)(win->GetHAdjust()->value+0.5);
wxScrollEvent event( command, win->GetId(), value, wxHORIZONTAL );
event.SetEventObject( win );
GdkEventButton *WXUNUSED(gdk_event),
wxWindow *win )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
// don't test here as we can release the mouse while being over
// a different window then the slider
//
// if (gdk_event->window != widget->slider) return FALSE;
- win->m_isScrolling = TRUE;
- g_blockEventsOnScroll = TRUE;
+ win->SetScrolling( TRUE );
return FALSE;
}
GdkEventButton *WXUNUSED(gdk_event),
wxWindow *win )
{
- if (g_isIdle) wxapp_install_idle_handler();
// don't test here as we can release the mouse while being over
// a different window then the slider
//
// if (gdk_event->window != widget->slider) return FALSE;
- GtkScrolledWindow *s_window = GTK_SCROLLED_WINDOW(win->m_widget);
+ GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(win->GetHandle());
- if (widget == GTK_RANGE(s_window->vscrollbar))
- gtk_signal_emit_by_name( GTK_OBJECT(win->m_hAdjust), "value_changed" );
+ if (widget == GTK_RANGE(scrolledWindow->vscrollbar))
+ gtk_signal_emit_by_name( GTK_OBJECT(win->GetHAdjust()), "value_changed" );
else
- gtk_signal_emit_by_name( GTK_OBJECT(win->m_vAdjust), "value_changed" );
+ gtk_signal_emit_by_name( GTK_OBJECT(win->GetVAdjust()), "value_changed" );
- win->m_isScrolling = FALSE;
- g_blockEventsOnScroll = FALSE;
+ win->SetScrolling( FALSE );
return FALSE;
}
-//-----------------------------------------------------------------------------
-// "realize" from m_widget
-//-----------------------------------------------------------------------------
-
-/* we cannot set colours, fonts and cursors before the widget has
- been realized, so we do this directly after realization */
+// ----------------------------------------------------------------------------
+// this wxWindowBase function is implemented here (in platform-specific file)
+// because it is static and so couldn't be made virtual
+// ----------------------------------------------------------------------------
-static gint
-gtk_window_realized_callback( GtkWidget *widget, wxWindow *win )
+wxWindow *wxWindowBase::FindFocus()
{
- if (g_isIdle) wxapp_install_idle_handler();
-
- if (win->m_font != *wxSWISS_FONT)
- {
- wxFont font( win->m_font );
- win->m_font = wxNullFont;
- win->SetFont( font );
- }
-
- if (win->m_backgroundColour != wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE ))
- {
- wxColour bg( win->m_backgroundColour );
- win->m_backgroundColour = wxNullColour;
- win->SetBackgroundColour( bg );
- }
-
- if (win->m_foregroundColour != *wxBLACK)
- {
- wxColour fg( win->m_foregroundColour );
- win->m_foregroundColour = wxNullColour;
- win->SetForegroundColour( fg );
- }
-
- wxCursor cursor( win->m_cursor );
- win->m_cursor = wxNullCursor;
- win->SetCursor( cursor );
-
- return FALSE;
+ return g_focusWindow;
}
//-----------------------------------------------------------------------------
static void wxInsertChildInWindow( wxWindow* parent, wxWindow* child )
{
- gtk_myfixed_put( GTK_MYFIXED(parent->m_wxwindow),
- GTK_WIDGET(child->m_widget),
- child->m_x,
- child->m_y,
- child->m_width,
- child->m_height );
-
- if (parent->m_windowStyle & wxTAB_TRAVERSAL)
+ gtk_myfixed_put( GTK_MYFIXED(parent->GetWxWindow()),
+ GTK_WIDGET(child->GetHandle()),
+ child->GetX(),
+ child->GetY(),
+ child->GetWidth(),
+ child->GetHeight() );
+
+ gtk_widget_set_usize( GTK_WIDGET(child->GetHandle()),
+ child->GetWidth(),
+ child->GetHeight() );
+
+ if (parent->HasFlag(wxTAB_TRAVERSAL))
{
/* we now allow a window to get the focus as long as it
doesn't have any children. */
- GTK_WIDGET_UNSET_FLAGS( parent->m_wxwindow, GTK_CAN_FOCUS );
+ GTK_WIDGET_UNSET_FLAGS( parent->GetWxWindow(), GTK_CAN_FOCUS );
}
}
wxWindow* wxGetActiveWindow()
{
- return g_focusWindow;
+ return g_focusWindow;
}
//-----------------------------------------------------------------------------
// wxWindow
//-----------------------------------------------------------------------------
-IMPLEMENT_DYNAMIC_CLASS(wxWindow,wxEvtHandler)
+IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowBase)
-BEGIN_EVENT_TABLE(wxWindow, wxEvtHandler)
- EVT_SIZE(wxWindow::OnSize)
- EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged)
- EVT_INIT_DIALOG(wxWindow::OnInitDialog)
+BEGIN_EVENT_TABLE(wxWindow, wxWindowBase)
EVT_KEY_DOWN(wxWindow::OnKeyDown)
END_EVENT_TABLE()
void wxWindow::Init()
{
- m_isWindow = TRUE;
+ // common init
+ InitBase();
- m_widget = (GtkWidget *) NULL;
+ // GTK specific
m_wxwindow = (GtkWidget *) NULL;
- m_parent = (wxWindow *) NULL;
- m_children.DeleteContents( FALSE );
- m_x = 0;
- m_y = 0;
- m_width = 0;
+ // position/size
+ m_x =
+ m_y =
+ m_width =
m_height = 0;
- m_minWidth = -1;
- m_minHeight = -1;
- m_maxWidth = -1;
- m_maxHeight = -1;
-
- m_retCode = 0;
-
- m_eventHandler = this;
- m_windowValidator = (wxValidator *) NULL;
- m_windowId = -1;
-
- m_cursor = *wxSTANDARD_CURSOR;
m_font = *wxSWISS_FONT;
- m_windowStyle = 0;
m_windowName = "noname";
- m_constraints = (wxLayoutConstraints *) NULL;
- m_constraintsInvolvedIn = (wxList *) NULL;
- m_windowSizer = (wxSizer *) NULL;
- m_sizerParent = (wxWindow *) NULL;
- m_autoLayout = FALSE;
-
m_sizeSet = FALSE;
m_hasVMT = FALSE;
m_needParent = TRUE;
- m_hasScrolling = FALSE;
+ m_hasScrolling =
m_isScrolling = FALSE;
- m_hAdjust = (GtkAdjustment*) NULL;
+
+ m_hAdjust =
m_vAdjust = (GtkAdjustment*) NULL;
- m_oldHorizontalPos = 0.0;
+ m_oldHorizontalPos =
m_oldVerticalPos = 0.0;
- m_isShown = FALSE;
- m_isEnabled = TRUE;
-
-#if wxUSE_DRAG_AND_DROP
- m_dropTarget = (wxDropTarget*) NULL;
-#endif
m_resizing = FALSE;
m_scrollGC = (GdkGC*) NULL;
m_widgetStyle = (GtkStyle*) NULL;
m_insertCallback = wxInsertChildInWindow;
- m_clientObject = (wxClientData*) NULL;
- m_clientData = NULL;
-
m_isStaticBox = FALSE;
m_acceptsFocus = FALSE;
-
-#if wxUSE_TOOLTIPS
- m_toolTip = (wxToolTip*) NULL;
-#endif // wxUSE_TOOLTIPS
}
wxWindow::wxWindow()
const wxPoint &pos, const wxSize &size,
long style, const wxString &name )
{
- wxASSERT_MSG( m_isWindow, _T("Init() must have been called before!") );
-
PreCreation( parent, id, pos, size, style, name );
m_widget = gtk_scrolled_window_new( (GtkAdjustment *) NULL, (GtkAdjustment *) NULL );
debug_focus_in( m_widget, _T("wxWindow::m_widget"), name );
#endif
- GtkScrolledWindow *s_window = GTK_SCROLLED_WINDOW(m_widget);
+ GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(m_widget);
#ifdef __WXDEBUG__
- debug_focus_in( s_window->hscrollbar, _T("wxWindow::hsrcollbar"), name );
- debug_focus_in( s_window->vscrollbar, _T("wxWindow::vsrcollbar"), name );
+ debug_focus_in( scrolledWindow->hscrollbar, _T("wxWindow::hsrcollbar"), name );
+ debug_focus_in( scrolledWindow->vscrollbar, _T("wxWindow::vsrcollbar"), name );
#endif
GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(m_widget)->klass );
scroll_class->scrollbar_spacing = 0;
- gtk_scrolled_window_set_policy( s_window, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
-
- m_oldHorizontalPos = 0.0;
- m_oldVerticalPos = 0.0;
+ gtk_scrolled_window_set_policy( scrolledWindow, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
- m_hAdjust = gtk_range_get_adjustment( GTK_RANGE(s_window->hscrollbar) );
- m_vAdjust = gtk_range_get_adjustment( GTK_RANGE(s_window->vscrollbar) );
+ m_hAdjust = gtk_range_get_adjustment( GTK_RANGE(scrolledWindow->hscrollbar) );
+ m_vAdjust = gtk_range_get_adjustment( GTK_RANGE(scrolledWindow->vscrollbar) );
m_wxwindow = gtk_myfixed_new();
#if (GTK_MINOR_VERSION > 0)
GtkMyFixed *myfixed = GTK_MYFIXED(m_wxwindow);
- if (m_windowStyle & wxRAISED_BORDER)
+ if (HasFlag(wxRAISED_BORDER))
{
gtk_myfixed_set_shadow_type( myfixed, GTK_SHADOW_OUT );
}
- else if (m_windowStyle & wxSUNKEN_BORDER)
+ else if (HasFlag(wxSUNKEN_BORDER))
{
gtk_myfixed_set_shadow_type( myfixed, GTK_SHADOW_IN );
}
{
gtk_myfixed_set_shadow_type( myfixed, GTK_SHADOW_NONE );
}
-#else
- GtkViewport *viewport = GTK_VIEWPORT(s_window->viewport);
+#else // GTK_MINOR_VERSION == 0
+ GtkViewport *viewport = GTK_VIEWPORT(scrolledWindow->viewport);
- if (m_windowStyle & wxRAISED_BORDER)
+ if (HasFlag(wxRAISED_BORDER))
{
gtk_viewport_set_shadow_type( viewport, GTK_SHADOW_OUT );
}
- else if (m_windowStyle & wxSUNKEN_BORDER)
+ else if (HasFlag(wxSUNKEN_BORDER))
{
gtk_viewport_set_shadow_type( viewport, GTK_SHADOW_IN );
}
{
gtk_viewport_set_shadow_type( viewport, GTK_SHADOW_NONE );
}
-#endif
+#endif // GTK_MINOR_VERSION
- /* we always allow a window to get the focus as long as it
- doesn't have any children. */
- if (m_windowStyle & wxTAB_TRAVERSAL)
+ if (HasFlag(wxTAB_TRAVERSAL))
{
+ /* we now allow a window to get the focus as long as it
+ doesn't have any children. */
GTK_WIDGET_SET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
m_acceptsFocus = FALSE;
}
m_acceptsFocus = TRUE;
}
- /* grab the actual focus */
-// gtk_widget_grab_focus( m_wxwindow );
-
- gtk_widget_show( m_wxwindow );
-
-
#if (GTK_MINOR_VERSION == 0)
// shut the viewport up
gtk_viewport_set_hadjustment( viewport, (GtkAdjustment*) gtk_adjustment_new( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) );
gtk_viewport_set_vadjustment( viewport, (GtkAdjustment*) gtk_adjustment_new( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) );
-#endif
+#endif // GTK_MINOR_VERSION == 0
// I _really_ don't want scrollbars in the beginning
- m_vAdjust->lower = 0.0;
- m_vAdjust->upper = 1.0;
- m_vAdjust->value = 0.0;
- m_vAdjust->step_increment = 1.0;
- m_vAdjust->page_increment = 1.0;
- m_vAdjust->page_size = 5.0;
- gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust), "changed" );
- m_hAdjust->lower = 0.0;
- m_hAdjust->upper = 1.0;
- m_hAdjust->value = 0.0;
- m_hAdjust->step_increment = 1.0;
- m_hAdjust->page_increment = 1.0;
- m_hAdjust->page_size = 5.0;
- gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "changed" );
-
- // these handlers block mouse events to any window during scrolling
- // such as motion events and prevent GTK and wxWindows from fighting
- // over where the slider should be
-
- gtk_signal_connect( GTK_OBJECT(s_window->vscrollbar), "button_press_event",
+ InitAdjustment(m_vAdjust);
+ InitAdjustment(m_hAdjust);
+
+ // these handlers block mouse events to any window during scrolling such as
+ // motion events and prevent GTK and wxWindows from fighting over where the
+ // slider should be
+
+ gtk_signal_connect( GTK_OBJECT(scrolledWindow->vscrollbar), "button_press_event",
(GtkSignalFunc)gtk_scrollbar_button_press_callback, (gpointer) this );
- gtk_signal_connect( GTK_OBJECT(s_window->hscrollbar), "button_press_event",
+ gtk_signal_connect( GTK_OBJECT(scrolledWindow->hscrollbar), "button_press_event",
(GtkSignalFunc)gtk_scrollbar_button_press_callback, (gpointer) this );
- gtk_signal_connect( GTK_OBJECT(s_window->vscrollbar), "button_release_event",
+ gtk_signal_connect( GTK_OBJECT(scrolledWindow->vscrollbar), "button_release_event",
(GtkSignalFunc)gtk_scrollbar_button_release_callback, (gpointer) this );
- gtk_signal_connect( GTK_OBJECT(s_window->hscrollbar), "button_release_event",
+ gtk_signal_connect( GTK_OBJECT(scrolledWindow->hscrollbar), "button_release_event",
(GtkSignalFunc)gtk_scrollbar_button_release_callback, (gpointer) this );
// these handlers get notified when screen updates are required either when
gtk_signal_connect(GTK_OBJECT(m_vAdjust), "changed",
(GtkSignalFunc) gtk_window_vscroll_change_callback, (gpointer) this );
- if (m_parent) m_parent->AddChild( this );
+ gtk_widget_show( m_wxwindow );
- (m_parent->m_insertCallback)( m_parent, this );
+ if (m_parent)
+ m_parent->DoAddChild( this );
PostCreation();
{
m_hasVMT = FALSE;
-#if wxUSE_DRAG_AND_DROP
- if (m_dropTarget)
- {
- delete m_dropTarget;
- m_dropTarget = (wxDropTarget*) NULL;
- }
-#endif
-
-#if wxUSE_TOOLTIPS
- if (m_toolTip)
- {
- delete m_toolTip;
- m_toolTip = (wxToolTip*) NULL;
- }
-#endif // wxUSE_TOOLTIPS
-
- if (m_widget) Show( FALSE );
-
- DestroyChildren();
-
- if (m_parent) m_parent->RemoveChild( this );
-
- if (m_widgetStyle) gtk_style_unref( m_widgetStyle );
-
- if (m_scrollGC) gdk_gc_unref( m_scrollGC );
+ if (m_widget)
+ Show( FALSE );
- if (m_wxwindow) gtk_widget_destroy( m_wxwindow );
-
- if (m_widget) gtk_widget_destroy( m_widget );
-
- DeleteRelatedConstraints();
- if (m_constraints)
- {
- /* This removes any dangling pointers to this window
- * in other windows' constraintsInvolvedIn lists. */
- UnsetConstraints(m_constraints);
- delete m_constraints;
- m_constraints = (wxLayoutConstraints *) NULL;
- }
-
- if (m_windowSizer)
- {
- delete m_windowSizer;
- m_windowSizer = (wxSizer *) NULL;
- }
- /* If this is a child of a sizer, remove self from parent */
- if (m_sizerParent) m_sizerParent->RemoveChild((wxWindow *)this);
+ if (m_parent)
+ m_parent->RemoveChild( this );
- /* Just in case the window has been Closed, but
- * we're then deleting immediately: don't leave
- * dangling pointers. */
- wxPendingDelete.DeleteObject(this);
+ if (m_widgetStyle)
+ gtk_style_unref( m_widgetStyle );
- /* Just in case we've loaded a top-level window via
- * wxWindow::LoadNativeDialog but we weren't a dialog
- * class */
- wxTopLevelWindows.DeleteObject(this);
+ if (m_scrollGC)
+ gdk_gc_unref( m_scrollGC );
- if (m_windowValidator) delete m_windowValidator;
+ if (m_wxwindow)
+ gtk_widget_destroy( m_wxwindow );
- if (m_clientObject) delete m_clientObject;
+ if (m_widget)
+ gtk_widget_destroy( m_widget );
}
-void wxWindow::PreCreation( wxWindow *parent, wxWindowID id,
- const wxPoint &pos, const wxSize &size,
- long style, const wxString &name )
+void wxWindow::PreCreation( wxWindow *parent,
+ wxWindowID id,
+ const wxPoint &pos,
+ const wxSize &size,
+ long style,
+ const wxString &name )
{
- wxASSERT_MSG( (!m_needParent) || (parent), _T("Need complete parent.") );
+ wxASSERT_MSG( !m_needParent || parent, _T("Need complete parent.") );
- m_widget = (GtkWidget*) NULL;
- m_wxwindow = (GtkWidget*) NULL;
- m_hasVMT = FALSE;
- m_parent = parent;
- m_children.DeleteContents( FALSE );
+ if ( !CreateBase(parent, id, pos, size, style, name) )
+ {
+ wxFAIL_MSG(_T("window creation failed"));
+ }
- m_width = size.x;
- if (m_width == -1) m_width = 20;
- m_height = size.y;
- if (m_height == -1) m_height = 20;
+ m_width = WidthDefault(size.x);
+ m_height = HeightDefault(size.y);
m_x = (int)pos.x;
m_y = (int)pos.y;
- if (!m_needParent) /* some reasonable defaults */
+ if (!parent) /* some reasonable defaults */
{
if (m_x == -1)
{
if (m_y < 10) m_y = 10;
}
}
-
- m_minWidth = -1;
- m_minHeight = -1;
- m_maxWidth = -1;
- m_maxHeight = -1;
-
- m_retCode = 0;
-
- m_eventHandler = this;
-
- m_windowId = id == -1 ? wxNewId() : id;
-
- m_sizeSet = FALSE;
-
- m_cursor = *wxSTANDARD_CURSOR;
- m_font = *wxSWISS_FONT;
- m_backgroundColour = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE );
- m_foregroundColour = *wxBLACK;
- m_windowStyle = style;
- m_windowName = name;
-
- m_constraints = (wxLayoutConstraints *) NULL;
- m_constraintsInvolvedIn = (wxList *) NULL;
- m_windowSizer = (wxSizer *) NULL;
- m_sizerParent = (wxWindow *) NULL;
- m_autoLayout = FALSE;
-
- m_hasScrolling = FALSE;
- m_isScrolling = FALSE;
- m_hAdjust = (GtkAdjustment *) NULL;
- m_vAdjust = (GtkAdjustment *) NULL;
- m_oldHorizontalPos = 0.0;
- m_oldVerticalPos = 0.0;
-
- m_isShown = FALSE;
- m_isEnabled = TRUE;
-
-#if wxUSE_DRAG_AND_DROP
- m_dropTarget = (wxDropTarget *) NULL;
-#endif
- m_resizing = FALSE;
- m_windowValidator = (wxValidator *) NULL;
- m_scrollGC = (GdkGC*) NULL;
- m_widgetStyle = (GtkStyle*) NULL;
-
- m_clientObject = (wxClientData*)NULL;
- m_clientData = NULL;
-
- m_isStaticBox = FALSE;
-
-#if wxUSE_TOOLTIPS
- m_toolTip = (wxToolTip*) NULL;
-#endif // wxUSE_TOOLTIPS
}
void wxWindow::PostCreation()
GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this );
#if (GTK_MINOR_VERSION > 0)
- /* these are called when the "sunken" or "raised" borders are drawn */
+ /* these are called when the "sunken" or "raised" borders are drawn */
gtk_signal_connect( GTK_OBJECT(m_widget), "expose_event",
GTK_SIGNAL_FUNC(gtk_window_own_expose_callback), (gpointer)this );
#endif
}
- GtkWidget *connect_widget = GetConnectWidget();
+ ConnectWidget( GetConnectWidget() );
- ConnectWidget( connect_widget );
+ /* we force the creation of wxFrame and wxDialog in the respective code */
+ if (m_parent)
+ gtk_widget_realize( m_widget );
+
+ if (m_wxwindow)
+ gtk_widget_realize( m_wxwindow );
- /* we cannot set colours, fonts and cursors before the widget has
- been realized, so we do this directly after realization */
- gtk_signal_connect( GTK_OBJECT(connect_widget), "realize",
- GTK_SIGNAL_FUNC(gtk_window_realized_callback), (gpointer) this );
+ SetCursor( *wxSTANDARD_CURSOR );
m_hasVMT = TRUE;
}
GTK_SIGNAL_FUNC(gtk_window_leave_callback), (gpointer)this );
}
-bool wxWindow::HasVMT()
-{
- return m_hasVMT;
-}
-
-bool wxWindow::Close( bool force )
-{
- wxASSERT_MSG( (m_widget != NULL), _T("invalid window") );
-
- wxCloseEvent event(wxEVT_CLOSE_WINDOW, m_windowId);
- event.SetEventObject(this);
- event.SetCanVeto(!force);
-
- /* return FALSE if window wasn't closed because the application vetoed the
- * close event */
- return GetEventHandler()->ProcessEvent(event) && !event.GetVeto();
-}
-
bool wxWindow::Destroy()
{
wxASSERT_MSG( (m_widget != NULL), _T("invalid window") );
m_hasVMT = FALSE;
- delete this;
- return TRUE;
-}
-
-bool wxWindow::DestroyChildren()
-{
- wxNode *node;
- while ((node = m_children.First()) != (wxNode *)NULL)
- {
- wxWindow *child;
- if ((child = (wxWindow *)node->Data()) != (wxWindow *)NULL)
- {
- delete child;
- if (m_children.Member(child)) delete node;
- }
- }
- return TRUE;
-}
-void wxWindow::PrepareDC( wxDC &WXUNUSED(dc) )
-{
- // are we to set fonts here ?
+ return wxWindowBase::Destroy();
}
void wxWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags )
if (m_resizing) return; /* I don't like recursions */
m_resizing = TRUE;
- if (m_parent->m_wxwindow == NULL) /* i.e. wxNotebook page */
+ if (m_parent->GetWxWindow() == NULL) /* i.e. wxNotebook */
{
/* don't set the size for children of wxNotebook, just take the values. */
m_x = x;
}
else
{
+ int old_width = m_width;
+ int old_height = m_height;
+
if ((sizeFlags & wxSIZE_USE_EXISTING) == wxSIZE_USE_EXISTING)
{
if (x != -1) m_x = x;
if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth;
if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight;
- int border = 0;
-
if (GTK_WIDGET_HAS_DEFAULT(m_widget))
- {
- /* the default button has a border around it */
- border = 5;
- }
-
- /* this is the result of hours of debugging: the following code
- means that if we have a m_wxwindow and we set the size of
- m_widget, m_widget (which is a GtkScrolledWindow) does NOT
- automatically propagate its size down to its m_wxwindow,
- which is its client area. therefore, we have to tell the
- client area directly that it has to resize itself.
- this will lead to that m_widget (GtkScrolledWindow) will
- calculate how much size it needs for scrollbars etc and
- it will then call XXX_size_allocate of its child, which
- is m_wxwindow. m_wxwindow in turn will do the same with its
- children and so on. problems can arise if this happens
- before all the children have been realized as some widgets
- stupidy need to be realized during XXX_size_allocate (e.g.
- GtkNotebook) and they will segv if called otherwise. this
- emergency is tested in gtk_myfixed_size_allocate. Normally
- this shouldn't be needed and only gtk_widget_queue_resize()
- should be enough to provoke a resize at the next appropriate
- moment, but this seems to fail, e.g. when a wxNotebook contains
- a wxSplitterWindow: the splitter window's children won't
- show up properly resized then. */
-
- gtk_myfixed_set_size( GTK_MYFIXED(m_parent->m_wxwindow),
- m_widget,
- m_x-border,
- m_y-border,
- m_width+2*border,
- m_height+2*border );
-
+ {
+ /* the default button has a border around it */
+ int border = 5;
+
+ gtk_myfixed_move( GTK_MYFIXED(m_parent->GetWxWindow()), m_widget, m_x-border, m_y-border );
+
+ gtk_widget_set_usize( m_widget, m_width+2*border, m_height+2*border );
+ }
+ else
+ {
+ gtk_myfixed_move( GTK_MYFIXED(m_parent->GetWxWindow()), m_widget, m_x, m_y );
+
+ if ((old_width != m_width) || (old_height != m_height))
+ gtk_widget_set_usize( m_widget, m_width, m_height );
+ }
}
m_sizeSet = TRUE;
UpdateWindowUI();
}
-void wxWindow::GetSize( int *width, int *height ) const
+void wxWindow::DoGetSize( int *width, int *height ) const
{
wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
{
GtkStyleClass *window_class = m_wxwindow->style->klass;
- if ((m_windowStyle & wxRAISED_BORDER) ||
- (m_windowStyle & wxSUNKEN_BORDER))
+ if (HasFlag(wxRAISED_BORDER) || HasFlag(wxSUNKEN_BORDER))
{
dw += 2 * window_class->xthickness;
dh += 2 * window_class->ythickness;
GtkWidget *viewport = scroll_window->viewport;
GtkStyleClass *viewport_class = viewport->style->klass;
- if ((m_windowStyle & wxRAISED_BORDER) ||
- (m_windowStyle & wxSUNKEN_BORDER))
+ if (HasFlag(wxRAISED_BORDER) || HasFlag(wxSUNKEN_BORDER))
{
dw += 2 * viewport_class->xthickness;
dh += 2 * viewport_class->ythickness;
GtkWidget *hscrollbar = scroll_window->hscrollbar;
GtkWidget *vscrollbar = scroll_window->vscrollbar;
- we use this instead: range.slider_width = 11 + 2*2pts edge
+ we use this instead: range.slider_width = 11 + 2*2pts edge
*/
if (scroll_window->vscrollbar_visible)
}
}
-void wxWindow::GetClientSize( int *width, int *height ) const
+void wxWindow::DoGetClientSize( int *width, int *height ) const
{
wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
{
GtkStyleClass *window_class = m_wxwindow->style->klass;
- if ((m_windowStyle & wxRAISED_BORDER) ||
- (m_windowStyle & wxSUNKEN_BORDER))
+ if (HasFlag(wxRAISED_BORDER) || HasFlag(wxSUNKEN_BORDER))
{
dw += 2 * window_class->xthickness;
dh += 2 * window_class->ythickness;
GtkWidget *viewport = scroll_window->viewport;
GtkStyleClass *viewport_class = viewport->style->klass;
- if ((m_windowStyle & wxRAISED_BORDER) ||
- (m_windowStyle & wxSUNKEN_BORDER))
+ if ( HasFlag(wxRAISED_BORDER) || HasFlag(wxSUNKEN_BORDER) )
{
dw += 2 * viewport_class->xthickness;
dh += 2 * viewport_class->ythickness;
GtkWidget *hscrollbar = scroll_window->hscrollbar;
GtkWidget *vscrollbar = scroll_window->vscrollbar;
- we use this instead: range.slider_width = 11 + 2*2pts edge
+ we use this instead: range.slider_width = 11 + 2*2pts edge
*/
if (scroll_window->vscrollbar_visible)
}
}
-void wxWindow::GetPosition( int *x, int *y ) const
+void wxWindow::DoGetPosition( int *x, int *y ) const
{
wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
if (y) (*y) = m_y;
}
-void wxWindow::ClientToScreen( int *x, int *y )
+void wxWindow::ClientToScreen( int *x, int *y ) const
{
wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
- if (!m_widget->window) return;
-
GdkWindow *source = (GdkWindow *) NULL;
if (m_wxwindow)
source = m_wxwindow->window;
if (y) *y += org_y;
}
-void wxWindow::ScreenToClient( int *x, int *y )
+void wxWindow::ScreenToClient( int *x, int *y ) const
{
wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
- if (!m_widget->window) return;
-
GdkWindow *source = (GdkWindow *) NULL;
if (m_wxwindow)
source = m_wxwindow->window;
if (y) *y -= org_y;
}
-void wxWindow::Centre( int direction )
+bool wxWindow::Show( bool show )
{
- wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
+ wxCHECK_MSG( (m_widget != NULL), FALSE, _T("invalid window") );
- int x = m_x;
- int y = m_y;
+ if ( !wxWindowBase::Show(show) )
+ return FALSE;
- if (m_parent)
- {
- int p_w = 0;
- int p_h = 0;
- m_parent->GetSize( &p_w, &p_h );
- if (direction & wxHORIZONTAL == wxHORIZONTAL) x = (p_w - m_width) / 2;
- if (direction & wxVERTICAL == wxVERTICAL) y = (p_h - m_height) / 2;
- }
+ if (show)
+ gtk_widget_show( m_widget );
else
- {
- if (direction & wxHORIZONTAL == wxHORIZONTAL) x = (gdk_screen_width () - m_width) / 2;
- if (direction & wxVERTICAL == wxVERTICAL) y = (gdk_screen_height () - m_height) / 2;
- }
+ gtk_widget_hide( m_widget );
- Move( x, y );
+ return TRUE;
}
-void wxWindow::Fit()
+bool wxWindow::Enable( bool enable )
{
- wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
+ wxCHECK_MSG( (m_widget != NULL), FALSE, _T("invalid window") );
- int maxX = 0;
- int maxY = 0;
- wxNode *node = m_children.First();
- while (node)
- {
- wxWindow *win = (wxWindow *)node->Data();
- int wx, wy, ww, wh;
- win->GetPosition(&wx, &wy);
- win->GetSize(&ww, &wh);
- if (wx + ww > maxX) maxX = wx + ww;
- if (wy + wh > maxY) maxY = wy + wh;
+ if ( !wxWindowBase::Enable(enable) )
+ return FALSE;
- node = node->Next();
- }
+ gtk_widget_set_sensitive( m_widget, enable );
+ if ( m_wxwindow )
+ gtk_widget_set_sensitive( m_wxwindow, enable );
- SetClientSize(maxX + 7, maxY + 14);
+ return TRUE;
}
-void wxWindow::SetSizeHints( int minW, int minH, int maxW, int maxH, int WXUNUSED(incW), int WXUNUSED(incH) )
+int wxWindow::GetCharHeight() const
{
- wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
+ wxCHECK_MSG( (m_widget != NULL), 12, _T("invalid window") );
- m_minWidth = minW;
- m_minHeight = minH;
- m_maxWidth = maxW;
- m_maxHeight = maxH;
-}
+ wxCHECK_MSG( m_font.Ok(), 12, _T("invalid font") );
-void wxWindow::OnSize( wxSizeEvent &WXUNUSED(event) )
-{
- /* this is commented because it also is commented
- in wxMSW. before I get even more questions about
- this. */
-// if (GetAutoLayout()) Layout();
+ GdkFont *font = m_font.GetInternalFont( 1.0 );
+
+ return font->ascent + font->descent;
}
-bool wxWindow::Show( bool show )
-{
- wxCHECK_MSG( (m_widget != NULL), FALSE, _T("invalid window") );
-
- if (show == m_isShown) return TRUE;
-
- if (show)
- gtk_widget_show( m_widget );
- else
- gtk_widget_hide( m_widget );
-
- m_isShown = show;
-
- return TRUE;
-}
-
-void wxWindow::Enable( bool enable )
-{
- wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
-
- m_isEnabled = enable;
-
- gtk_widget_set_sensitive( m_widget, enable );
- if (m_wxwindow) gtk_widget_set_sensitive( m_wxwindow, enable );
-}
-
-int wxWindow::GetCharHeight() const
-{
- wxCHECK_MSG( (m_widget != NULL), 12, _T("invalid window") );
-
- wxCHECK_MSG( m_font.Ok(), 12, _T("invalid font") );
-
- GdkFont *font = m_font.GetInternalFont( 1.0 );
-
- return font->ascent + font->descent;
-}
-
-int wxWindow::GetCharWidth() const
+int wxWindow::GetCharWidth() const
{
wxCHECK_MSG( (m_widget != NULL), 8, _T("invalid window") );
return gdk_string_width( font, "H" );
}
-void wxWindow::GetTextExtent( const wxString& string, int *x, int *y,
- int *descent, int *externalLeading, const wxFont *theFont, bool WXUNUSED(use16) ) const
+void wxWindow::GetTextExtent( const wxString& string,
+ int *x,
+ int *y,
+ int *descent,
+ int *externalLeading,
+ const wxFont *theFont ) const
{
wxFont fontToUse = m_font;
if (theFont) fontToUse = *theFont;
if (externalLeading) (*externalLeading) = 0; // ??
}
-void wxWindow::MakeModal( bool modal )
-{
- return;
-
- // Disable all other windows
- if (this->IsKindOf(CLASSINFO(wxDialog)) || this->IsKindOf(CLASSINFO(wxFrame)))
- {
- wxNode *node = wxTopLevelWindows.First();
- while (node)
- {
- wxWindow *win = (wxWindow *)node->Data();
- if (win != this) win->Enable(!modal);
-
- node = node->Next();
- }
- }
-}
-
void wxWindow::OnKeyDown( wxKeyEvent &event )
{
event.SetEventType( wxEVT_CHAR );
}
}
-wxWindow *wxWindow::FindFocus()
-{
- return g_focusWindow;
-}
-
bool wxWindow::AcceptsFocus() const
{
- return IsEnabled() && IsShown() && m_acceptsFocus;
+ return m_acceptsFocus && wxWindowBase::AcceptsFocus();
}
-void wxWindow::AddChild( wxWindow *child )
-{
- wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
- wxCHECK_RET( (child != NULL), _T("invalid child") );
-
- m_children.Append( child );
-}
-
-wxWindow *wxWindow::ReParent( wxWindow *newParent )
+bool wxWindow::Reparent( wxWindow *newParent )
{
wxCHECK_MSG( (m_widget != NULL), (wxWindow*) NULL, _T("invalid window") );
- wxWindow *oldParent = GetParent();
-
- if (oldParent) oldParent->RemoveChild( this );
+ if ( !wxWindowBase::Reparent(newParent) )
+ return FALSE;
gtk_widget_unparent( m_widget );
- if (newParent)
- {
- newParent->AddChild( this );
- (newParent->m_insertCallback)( newParent, this );
- }
-
- return oldParent;
-}
-
-void wxWindow::RemoveChild( wxWindow *child )
-{
- m_children.DeleteObject( child );
- child->m_parent = (wxWindow *) NULL;
-}
-
-void wxWindow::SetReturnCode( int retCode )
-{
- m_retCode = retCode;
-}
-
-int wxWindow::GetReturnCode()
-{
- return m_retCode;
+ return TRUE;
}
void wxWindow::Raise()
{
wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
- if (!m_widget->window) return;
-
- if (m_widget) gdk_window_raise( m_widget->window );
+ gdk_window_raise( m_widget->window );
}
void wxWindow::Lower()
{
wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
- if (!m_widget->window) return;
-
- if (m_widget) gdk_window_lower( m_widget->window );
-}
-
-wxEvtHandler *wxWindow::GetEventHandler() const
-{
- return m_eventHandler;
-}
-
-void wxWindow::SetEventHandler( wxEvtHandler *handler )
-{
- m_eventHandler = handler;
+ gdk_window_lower( m_widget->window );
}
-void wxWindow::PushEventHandler(wxEvtHandler *handler)
+bool wxWindow::SetCursor( const wxCursor &cursor )
{
- handler->SetNextHandler(GetEventHandler());
- SetEventHandler(handler);
-}
+ wxCHECK_MSG( (m_widget != NULL), FALSE, _T("invalid window") );
-wxEvtHandler *wxWindow::PopEventHandler(bool deleteHandler)
-{
- if (GetEventHandler())
+ if ( wxWindowBase::SetCursor(cursor) )
{
- wxEvtHandler *handlerA = GetEventHandler();
- wxEvtHandler *handlerB = handlerA->GetNextHandler();
- handlerA->SetNextHandler((wxEvtHandler *) NULL);
- SetEventHandler(handlerB);
- if (deleteHandler)
- {
- delete handlerA;
- return (wxEvtHandler*) NULL;
- }
- else
- return handlerA;
- }
- else
- return (wxEvtHandler *) NULL;
-}
-
-wxValidator *wxWindow::GetValidator()
-{
- return m_windowValidator;
-}
-
-void wxWindow::SetValidator( const wxValidator& validator )
-{
- if (m_windowValidator) delete m_windowValidator;
- m_windowValidator = (wxValidator*)validator.Clone();
- if (m_windowValidator) m_windowValidator->SetWindow(this);
-}
-
-void wxWindow::SetClientObject( wxClientData *data )
-{
- if (m_clientObject) delete m_clientObject;
- m_clientObject = data;
-}
-
-wxClientData *wxWindow::GetClientObject()
-{
- return m_clientObject;
-}
-
-void wxWindow::SetClientData( void *data )
-{
- m_clientData = data;
-}
+ if ((m_widget) && (m_widget->window))
+ gdk_window_set_cursor( m_widget->window, GetCursor().GetCursor() );
-void *wxWindow::GetClientData()
-{
- return m_clientData;
-}
+ if ((m_wxwindow) && (m_wxwindow->window))
+ gdk_window_set_cursor( m_wxwindow->window, GetCursor().GetCursor() );
-bool wxWindow::IsBeingDeleted()
-{
- return FALSE;
-}
-
-void wxWindow::SetId( wxWindowID id )
-{
- m_windowId = id;
-}
-
-wxWindowID wxWindow::GetId() const
-{
- return m_windowId;
-}
-
-void wxWindow::SetCursor( const wxCursor &cursor )
-{
- wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
-
- if (cursor.Ok())
- {
- if (cursor == m_cursor) return;
- m_cursor = cursor;
+ // cursor was set
+ return TRUE;
}
else
{
- m_cursor = *wxSTANDARD_CURSOR;
+ // cursor hasn't been changed
+ return FALSE;
}
-
- if (!m_widget->window) return;
-
- gdk_window_set_cursor( m_widget->window, m_cursor.GetCursor() );
-
- if ((m_wxwindow) && (m_wxwindow->window))
- gdk_window_set_cursor( m_wxwindow->window, m_cursor.GetCursor() );
}
void wxWindow::WarpPointer( int WXUNUSED(x), int WXUNUSED(y) )
{
- // TODO
+ // TODO
}
void wxWindow::Refresh( bool eraseBackground, const wxRect *rect )
{
wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
- if (!m_widget->window) return;
-
if (eraseBackground && m_wxwindow && m_wxwindow->window)
{
if (rect)
}
}
-wxRegion wxWindow::GetUpdateRegion() const
-{
- return m_updateRegion;
-}
-
-bool wxWindow::IsExposed( int x, int y) const
-{
- return (m_updateRegion.Contains( x, y ) != wxOutRegion );
-}
-
-bool wxWindow::IsExposed( int x, int y, int w, int h ) const
-{
- return (m_updateRegion.Contains( x, y, w, h ) != wxOutRegion );
-}
-
-bool wxWindow::IsExposed( const wxPoint& pt ) const
-{
- return (m_updateRegion.Contains( pt.x, pt.y ) != wxOutRegion );
-}
-
-bool wxWindow::IsExposed( const wxRect& rect ) const
-{
- return (m_updateRegion.Contains( rect.x, rect.y, rect.width, rect.height ) != wxOutRegion );
-}
-
void wxWindow::Clear()
{
wxCHECK_RET( m_widget != NULL, _T("invalid window") );
- if (!m_widget->window) return;
-
if (m_wxwindow && m_wxwindow->window)
{
gdk_window_clear( m_wxwindow->window );
}
#if wxUSE_TOOLTIPS
-void wxWindow::SetToolTip( const wxString &tip )
-{
- if (m_toolTip)
- {
- m_toolTip->SetTip( tip );
- }
- else
- {
- SetToolTip( new wxToolTip( tip ) );
- }
-
- // setting empty tooltip text does not remove the tooltip any more for
- // wxMSW compatibility - use SetToolTip((wxToolTip *)NULL) for this
-}
-
-void wxWindow::SetToolTip( wxToolTip *tip )
+void wxWindow::DoSetToolTip( wxToolTip *tip )
{
- if (m_toolTip)
- {
- m_toolTip->SetTip( (char*) NULL );
- delete m_toolTip;
- }
-
- m_toolTip = tip;
+ wxWindowBase::DoSetToolTip(tip);
- if (m_toolTip)
- m_toolTip->Apply( this );
+ if (m_tooltip)
+ m_tooltip->Apply( this );
}
void wxWindow::ApplyToolTip( GtkTooltips *tips, const wxChar *tip )
}
#endif // wxUSE_TOOLTIPS
-wxColour wxWindow::GetBackgroundColour() const
-{
- return m_backgroundColour;
-}
-
-void wxWindow::SetBackgroundColour( const wxColour &colour )
+bool wxWindow::SetBackgroundColour( const wxColour &colour )
{
- wxCHECK_RET( m_widget != NULL, _T("invalid window") );
-
- if (m_backgroundColour == colour) return;
-
- m_backgroundColour = colour;
- if (!m_backgroundColour.Ok()) return;
+ wxCHECK_MSG( m_widget != NULL, FALSE, _T("invalid window") );
- GtkWidget *connect_widget = GetConnectWidget();
- if (!connect_widget->window) return;
+ if ( !wxWindowBase::SetBackgroundColour(colour) )
+ return FALSE;
if (m_wxwindow && m_wxwindow->window)
{
- /* wxMSW doesn't clear the window here. I don't do that
- either to provide compatibility. call Clear() to do
- the job. */
+ // wxMSW doesn't clear the window here. I don't do that either to
+ // provide compatibility. call Clear() to do the job.
m_backgroundColour.CalcPixel( gdk_window_get_colormap( m_wxwindow->window ) );
gdk_window_set_background( m_wxwindow->window, m_backgroundColour.GetColor() );
wxColour sysbg = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE );
- if (sysbg.Red() == colour.Red() &&
- sysbg.Green() == colour.Green() &&
- sysbg.Blue() == colour.Blue())
+ if ( sysbg == m_backgroundColour )
{
m_backgroundColour = wxNullColour;
ApplyWidgetStyle();
{
ApplyWidgetStyle();
}
-}
-wxColour wxWindow::GetForegroundColour() const
-{
- return m_foregroundColour;
+ return TRUE;
}
-void wxWindow::SetForegroundColour( const wxColour &colour )
+bool wxWindow::SetForegroundColour( const wxColour &colour )
{
- wxCHECK_RET( m_widget != NULL, _T("invalid window") );
-
- if (m_foregroundColour == colour) return;
-
- m_foregroundColour = colour;
- if (!m_foregroundColour.Ok()) return;
+ wxCHECK_MSG( m_widget != NULL, FALSE, _T("invalid window") );
- if (!m_widget->window) return;
+ if ( !wxWindowBase::SetForegroundColour(colour) )
+ return FALSE;
wxColour sysbg = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE );
- if (sysbg.Red() == colour.Red() &&
- sysbg.Green() == colour.Green() &&
- sysbg.Blue() == colour.Blue())
+ if ( sysbg == m_foregroundColour )
{
m_backgroundColour = wxNullColour;
ApplyWidgetStyle();
{
ApplyWidgetStyle();
}
+
+ return TRUE;
}
GtkStyle *wxWindow::GetWidgetStyle()
{
if (m_widgetStyle) gtk_style_unref( m_widgetStyle );
- m_widgetStyle =
- gtk_style_copy(
- gtk_widget_get_style( m_widget ) );
+ m_widgetStyle = gtk_style_copy( gtk_widget_get_style( m_widget ) );
return m_widgetStyle;
}
{
}
-bool wxWindow::Validate()
-{
- wxCHECK_MSG( m_widget != NULL, FALSE, _T("invalid window") );
-
- wxNode *node = m_children.First();
- while (node)
- {
- wxWindow *child = (wxWindow *)node->Data();
- if (child->GetValidator() && /* child->GetValidator()->Ok() && */ !child->GetValidator()->Validate(this))
- {
- return FALSE;
- }
- node = node->Next();
- }
- return TRUE;
-}
-
-bool wxWindow::TransferDataToWindow()
-{
- wxCHECK_MSG( m_widget != NULL, FALSE, _T("invalid window") );
-
- wxNode *node = m_children.First();
- while (node)
- {
- wxWindow *child = (wxWindow *)node->Data();
- if (child->GetValidator() && /* child->GetValidator()->Ok() && */
- !child->GetValidator()->TransferToWindow() )
- {
- wxMessageBox( _("Application Error"), _("Could not transfer data to window"), wxOK|wxICON_EXCLAMATION );
- return FALSE;
- }
- node = node->Next();
- }
- return TRUE;
-}
-
-bool wxWindow::TransferDataFromWindow()
-{
- wxCHECK_MSG( m_widget != NULL, FALSE, _T("invalid window") );
-
- wxNode *node = m_children.First();
- while (node)
- {
- wxWindow *child = (wxWindow *)node->Data();
- if ( child->GetValidator() && /* child->GetValidator()->Ok() && */ !child->GetValidator()->TransferFromWindow() )
- {
- return FALSE;
- }
- node = node->Next();
- }
- return TRUE;
-}
-
-void wxWindow::SetAcceleratorTable( const wxAcceleratorTable& accel )
-{
- m_acceleratorTable = accel;
-}
-
-void wxWindow::OnInitDialog( wxInitDialogEvent &WXUNUSED(event) )
-{
- TransferDataToWindow();
-}
-
-void wxWindow::InitDialog()
-{
- wxCHECK_RET( m_widget != NULL, _T("invalid window") );
-
- wxInitDialogEvent event(GetId());
- event.SetEventObject( this );
- GetEventHandler()->ProcessEvent(event);
-}
-
static void SetInvokingWindow( wxMenu *menu, wxWindow *win )
{
menu->SetInvokingWindow( win );
if (m_dropTarget) m_dropTarget->RegisterWidget( dnd_widget );
}
-wxDropTarget *wxWindow::GetDropTarget() const
-{
- return m_dropTarget;
-}
-
-#endif
+#endif // wxUSE_DRAG_AND_DROP
GtkWidget* wxWindow::GetConnectWidget()
{
return (window == m_widget->window);
}
-void wxWindow::SetFont( const wxFont &font )
+bool wxWindow::SetFont( const wxFont &font )
{
- wxCHECK_RET( m_widget != NULL, _T("invalid window") );
-
- if (m_font == font) return;
-
- if (((wxFont*)&font)->Ok())
- m_font = font;
- else
- m_font = *wxSWISS_FONT;
+ wxCHECK_MSG( m_widget != NULL, FALSE, _T("invalid window") );
- if (!m_widget->window) return;
+ if ( !wxWindowBase::SetFont(font) )
+ {
+ // nothing to do
+ return FALSE;
+ }
wxColour sysbg = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE );
- if (sysbg.Red() == m_backgroundColour.Red() &&
- sysbg.Green() == m_backgroundColour.Green() &&
- sysbg.Blue() == m_backgroundColour.Blue())
+ if ( sysbg == m_backgroundColour )
{
m_backgroundColour = wxNullColour;
ApplyWidgetStyle();
{
ApplyWidgetStyle();
}
-}
-
-void wxWindow::SetWindowStyleFlag( long flag )
-{
- m_windowStyle = flag;
-}
-long wxWindow::GetWindowStyleFlag() const
-{
- return m_windowStyle;
+ return TRUE;
}
void wxWindow::CaptureMouse()
wxCHECK_RET( g_capturing == FALSE, _T("CaptureMouse called twice") );
- if (!m_widget->window) return;
-
GtkWidget *connect_widget = GetConnectWidget();
gtk_grab_add( connect_widget );
gdk_pointer_grab( connect_widget->window, FALSE,
wxCHECK_RET( g_capturing == TRUE, _T("ReleaseMouse called twice") );
- if (!m_widget->window) return;
-
GtkWidget *connect_widget = GetConnectWidget();
gtk_grab_remove( connect_widget );
gdk_pointer_ungrab ( GDK_CURRENT_TIME );
g_capturing = FALSE;
}
-void wxWindow::SetTitle( const wxString &WXUNUSED(title) )
-{
-}
-
-wxString wxWindow::GetTitle() const
-{
- return (wxString&)m_windowName;
-}
-
-wxString wxWindow::GetLabel() const
-{
- return GetTitle();
-}
-
-void wxWindow::SetName( const wxString &name )
-{
- m_windowName = name;
-}
-
-wxString wxWindow::GetName() const
-{
- return (wxString&)m_windowName;
-}
-
-bool wxWindow::IsShown() const
-{
- return m_isShown;
-}
-
-bool wxWindow::IsRetained()
+bool wxWindow::IsRetained() const
{
return FALSE;
}
-wxWindow *wxWindow::FindWindow( long id )
-{
- if (id == m_windowId) return this;
- wxNode *node = m_children.First();
- while (node)
- {
- wxWindow *child = (wxWindow*)node->Data();
- wxWindow *res = child->FindWindow( id );
- if (res) return res;
- node = node->Next();
- }
- return (wxWindow *) NULL;
-}
-
-wxWindow *wxWindow::FindWindow( const wxString& name )
-{
- if (name == m_windowName) return this;
- wxNode *node = m_children.First();
- while (node)
- {
- wxWindow *child = (wxWindow*)node->Data();
- wxWindow *res = child->FindWindow( name );
- if (res) return res;
- node = node->Next();
- }
- return (wxWindow *) NULL;
-}
-
void wxWindow::SetScrollbar( int orient, int pos, int thumbVisible,
int range, bool refresh )
{
m_vAdjust->page_size = fthumb;
}
- if (m_wxwindow)
+ if (m_wxwindow->window)
{
if (orient == wxHORIZONTAL)
gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "changed" );
wxCHECK_RET( m_wxwindow != NULL, _T("window needs client area for scrolling") );
- if (!m_scrollGC)
+ wxNode *node = m_children.First();
+ while (node)
{
- m_scrollGC = gdk_gc_new( m_wxwindow->window );
- gdk_gc_set_exposures( m_scrollGC, TRUE );
+ wxWindow *child = (wxWindow*) node->Data();
+ child->Move( child->GetX() + dx, child->GetY() + dy );
+ node = node->Next();
}
int cw = 0;
int ch = 0;
GetClientSize( &cw, &ch );
+
int w = cw - abs(dx);
int h = ch - abs(dy);
-
if ((h < 0) || (w < 0))
{
Refresh();
+ return;
}
- else
- {
- int s_x = 0;
- int s_y = 0;
- if (dx < 0) s_x = -dx;
- if (dy < 0) s_y = -dy;
- int d_x = 0;
- int d_y = 0;
- if (dx > 0) d_x = dx;
- if (dy > 0) d_y = dy;
-
- gdk_window_copy_area( m_wxwindow->window, m_scrollGC, d_x, d_y,
- m_wxwindow->window, s_x, s_y, w, h );
-
- wxRect rect;
- if (dx < 0) rect.x = cw+dx; else rect.x = 0;
- if (dy < 0) rect.y = ch+dy; else rect.y = 0;
- if (dy != 0) rect.width = cw; else rect.width = abs(dx);
- if (dx != 0) rect.height = ch; else rect.height = abs(dy);
-
- Refresh( TRUE, &rect );
- }
-
- wxNode *node = m_children.First();
- while (node)
- {
- wxWindow *child = (wxWindow*) node->Data();
- child->Move( child->m_x + dx, child->m_y + dy );
- node = node->Next();
- }
-
-}
-
-//-------------------------------------------------------------------------------------
-// Layout
-//-------------------------------------------------------------------------------------
-
-wxLayoutConstraints *wxWindow::GetConstraints() const
-{
- return m_constraints;
-}
-
-void wxWindow::SetConstraints( wxLayoutConstraints *constraints )
-{
- if (m_constraints)
- {
- UnsetConstraints(m_constraints);
- delete m_constraints;
- }
- m_constraints = constraints;
- if (m_constraints)
- {
- // Make sure other windows know they're part of a 'meaningful relationship'
- if (m_constraints->left.GetOtherWindow() && (m_constraints->left.GetOtherWindow() != this))
- m_constraints->left.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
- if (m_constraints->top.GetOtherWindow() && (m_constraints->top.GetOtherWindow() != this))
- m_constraints->top.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
- if (m_constraints->right.GetOtherWindow() && (m_constraints->right.GetOtherWindow() != this))
- m_constraints->right.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
- if (m_constraints->bottom.GetOtherWindow() && (m_constraints->bottom.GetOtherWindow() != this))
- m_constraints->bottom.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
- if (m_constraints->width.GetOtherWindow() && (m_constraints->width.GetOtherWindow() != this))
- m_constraints->width.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
- if (m_constraints->height.GetOtherWindow() && (m_constraints->height.GetOtherWindow() != this))
- m_constraints->height.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
- if (m_constraints->centreX.GetOtherWindow() && (m_constraints->centreX.GetOtherWindow() != this))
- m_constraints->centreX.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
- if (m_constraints->centreY.GetOtherWindow() && (m_constraints->centreY.GetOtherWindow() != this))
- m_constraints->centreY.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
- }
-;
-}
-;
-
-void wxWindow::SetAutoLayout( bool autoLayout )
-{
- m_autoLayout = autoLayout;
-}
-
-bool wxWindow::GetAutoLayout() const
-{
- return m_autoLayout;
-}
-
-wxSizer *wxWindow::GetSizer() const
-{
- return m_windowSizer;
-}
-
-void wxWindow::SetSizerParent( wxWindow *win )
-{
- m_sizerParent = win;
-}
-
-wxWindow *wxWindow::GetSizerParent() const
-{
- return m_sizerParent;
-}
-
-// This removes any dangling pointers to this window
-// in other windows' constraintsInvolvedIn lists.
-void wxWindow::UnsetConstraints(wxLayoutConstraints *c)
-{
- if (c)
- {
- if (c->left.GetOtherWindow() && (c->top.GetOtherWindow() != this))
- c->left.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
- if (c->top.GetOtherWindow() && (c->top.GetOtherWindow() != this))
- c->top.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
- if (c->right.GetOtherWindow() && (c->right.GetOtherWindow() != this))
- c->right.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
- if (c->bottom.GetOtherWindow() && (c->bottom.GetOtherWindow() != this))
- c->bottom.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
- if (c->width.GetOtherWindow() && (c->width.GetOtherWindow() != this))
- c->width.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
- if (c->height.GetOtherWindow() && (c->height.GetOtherWindow() != this))
- c->height.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
- if (c->centreX.GetOtherWindow() && (c->centreX.GetOtherWindow() != this))
- c->centreX.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
- if (c->centreY.GetOtherWindow() && (c->centreY.GetOtherWindow() != this))
- c->centreY.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
- }
-}
-
-// Back-pointer to other windows we're involved with, so if we delete
-// this window, we must delete any constraints we're involved with.
-void wxWindow::AddConstraintReference(wxWindow *otherWin)
-{
- if (!m_constraintsInvolvedIn)
- m_constraintsInvolvedIn = new wxList;
- if (!m_constraintsInvolvedIn->Member(otherWin))
- m_constraintsInvolvedIn->Append(otherWin);
-}
-
-// REMOVE back-pointer to other windows we're involved with.
-void wxWindow::RemoveConstraintReference(wxWindow *otherWin)
-{
- if (m_constraintsInvolvedIn)
- m_constraintsInvolvedIn->DeleteObject(otherWin);
-}
-
-// Reset any constraints that mention this window
-void wxWindow::DeleteRelatedConstraints()
-{
- if (m_constraintsInvolvedIn)
- {
- wxNode *node = m_constraintsInvolvedIn->First();
- while (node)
- {
- wxWindow *win = (wxWindow *)node->Data();
- wxNode *next = node->Next();
- wxLayoutConstraints *constr = win->GetConstraints();
-
- // Reset any constraints involving this window
- if (constr)
- {
- constr->left.ResetIfWin((wxWindow *)this);
- constr->top.ResetIfWin((wxWindow *)this);
- constr->right.ResetIfWin((wxWindow *)this);
- constr->bottom.ResetIfWin((wxWindow *)this);
- constr->width.ResetIfWin((wxWindow *)this);
- constr->height.ResetIfWin((wxWindow *)this);
- constr->centreX.ResetIfWin((wxWindow *)this);
- constr->centreY.ResetIfWin((wxWindow *)this);
- }
- delete node;
- node = next;
- }
- delete m_constraintsInvolvedIn;
- m_constraintsInvolvedIn = (wxList *) NULL;
- }
-}
-
-void wxWindow::SetSizer(wxSizer *sizer)
-{
- m_windowSizer = sizer;
- if (sizer)
- sizer->SetSizerParent((wxWindow *)this);
-}
-
-/*
- * New version
- */
-
-bool wxWindow::Layout()
-{
- if (GetConstraints())
- {
- int w, h;
- GetClientSize(&w, &h);
- GetConstraints()->width.SetValue(w);
- GetConstraints()->height.SetValue(h);
- }
-
- // If top level (one sizer), evaluate the sizer's constraints.
- if (GetSizer())
- {
- int noChanges;
- GetSizer()->ResetConstraints(); // Mark all constraints as unevaluated
- GetSizer()->LayoutPhase1(&noChanges);
- GetSizer()->LayoutPhase2(&noChanges);
- GetSizer()->SetConstraintSizes(); // Recursively set the real window sizes
-
- return TRUE;
- }
- else
- {
- // Otherwise, evaluate child constraints
- ResetConstraints(); // Mark all constraints as unevaluated
- DoPhase(1); // Just one phase need if no sizers involved
- DoPhase(2);
- SetConstraintSizes(); // Recursively set the real window sizes
- }
- return TRUE;
-}
-
-
-// Do a phase of evaluating constraints:
-// the default behaviour. wxSizers may do a similar
-// thing, but also impose their own 'constraints'
-// and order the evaluation differently.
-bool wxWindow::LayoutPhase1(int *noChanges)
-{
- wxLayoutConstraints *constr = GetConstraints();
- if (constr)
- {
- return constr->SatisfyConstraints((wxWindow *)this, noChanges);
- }
- else
- return TRUE;
-}
-
-bool wxWindow::LayoutPhase2(int *noChanges)
-{
- *noChanges = 0;
-
- // Layout children
- DoPhase(1);
- DoPhase(2);
- return TRUE;
-}
-
-// Do a phase of evaluating child constraints
-bool wxWindow::DoPhase(int phase)
-{
- int noIterations = 0;
- int maxIterations = 500;
- int noChanges = 1;
- int noFailures = 0;
- wxList succeeded;
- while ((noChanges > 0) && (noIterations < maxIterations))
- {
- noChanges = 0;
- noFailures = 0;
- wxNode *node = m_children.First();
- while (node)
- {
- wxWindow *child = (wxWindow *)node->Data();
- if (!child->IsKindOf(CLASSINFO(wxFrame)) && !child->IsKindOf(CLASSINFO(wxDialog)))
- {
- wxLayoutConstraints *constr = child->GetConstraints();
- if (constr)
- {
- if (succeeded.Member(child))
- {
- }
- else
- {
- int tempNoChanges = 0;
- bool success = ( (phase == 1) ? child->LayoutPhase1(&tempNoChanges) : child->LayoutPhase2(&tempNoChanges) ) ;
- noChanges += tempNoChanges;
- if (success)
- {
- succeeded.Append(child);
- }
- }
- }
- }
- node = node->Next();
- }
- noIterations ++;
- }
- return TRUE;
-}
-
-void wxWindow::ResetConstraints()
-{
- wxLayoutConstraints *constr = GetConstraints();
- if (constr)
- {
- constr->left.SetDone(FALSE);
- constr->top.SetDone(FALSE);
- constr->right.SetDone(FALSE);
- constr->bottom.SetDone(FALSE);
- constr->width.SetDone(FALSE);
- constr->height.SetDone(FALSE);
- constr->centreX.SetDone(FALSE);
- constr->centreY.SetDone(FALSE);
- }
- wxNode *node = m_children.First();
- while (node)
- {
- wxWindow *win = (wxWindow *)node->Data();
- if (!win->IsKindOf(CLASSINFO(wxFrame)) && !win->IsKindOf(CLASSINFO(wxDialog)))
- win->ResetConstraints();
- node = node->Next();
- }
-}
-
-// Need to distinguish between setting the 'fake' size for
-// windows and sizers, and setting the real values.
-void wxWindow::SetConstraintSizes(bool recurse)
-{
- wxLayoutConstraints *constr = GetConstraints();
- if (constr && constr->left.GetDone() && constr->right.GetDone() &&
- constr->width.GetDone() && constr->height.GetDone())
- {
- int x = constr->left.GetValue();
- int y = constr->top.GetValue();
- int w = constr->width.GetValue();
- int h = constr->height.GetValue();
-
- // If we don't want to resize this window, just move it...
- if ((constr->width.GetRelationship() != wxAsIs) ||
- (constr->height.GetRelationship() != wxAsIs))
- {
- // Calls Layout() recursively. AAAGH. How can we stop that.
- // Simply take Layout() out of non-top level OnSizes.
- SizerSetSize(x, y, w, h);
- }
- else
- {
- SizerMove(x, y);
- }
- }
- else if (constr)
- {
- wxChar *windowClass = this->GetClassInfo()->GetClassName();
-
- wxString winName;
- if (GetName() == _T(""))
- winName = _T("unnamed");
- else
- winName = GetName();
- wxLogDebug( _T("Constraint(s) not satisfied for window of type %s, name %s:\n"),
- (const wxChar *)windowClass,
- (const wxChar *)winName);
- if (!constr->left.GetDone()) wxLogDebug( _T(" unsatisfied 'left' constraint.\n") );
- if (!constr->right.GetDone()) wxLogDebug( _T(" unsatisfied 'right' constraint.\n") );
- if (!constr->width.GetDone()) wxLogDebug( _T(" unsatisfied 'width' constraint.\n") );
- if (!constr->height.GetDone()) wxLogDebug( _T(" unsatisfied 'height' constraint.\n") );
- wxLogDebug( _T("Please check constraints: try adding AsIs() constraints.\n") );
- }
-
- if (recurse)
- {
- wxNode *node = m_children.First();
- while (node)
- {
- wxWindow *win = (wxWindow *)node->Data();
- if (!win->IsKindOf(CLASSINFO(wxFrame)) && !win->IsKindOf(CLASSINFO(wxDialog)))
- win->SetConstraintSizes();
- node = node->Next();
- }
- }
-}
-
-// This assumes that all sizers are 'on' the same
-// window, i.e. the parent of this window.
-void wxWindow::TransformSizerToActual(int *x, int *y) const
-{
- if (!m_sizerParent || m_sizerParent->IsKindOf(CLASSINFO(wxDialog)) ||
- m_sizerParent->IsKindOf(CLASSINFO(wxFrame)) )
- return;
-
- int xp, yp;
- m_sizerParent->GetPosition(&xp, &yp);
- m_sizerParent->TransformSizerToActual(&xp, &yp);
- *x += xp;
- *y += yp;
-}
-
-void wxWindow::SizerSetSize(int x, int y, int w, int h)
-{
- int xx = x;
- int yy = y;
- TransformSizerToActual(&xx, &yy);
- SetSize(xx, yy, w, h);
-}
+ int s_x = 0;
+ int s_y = 0;
+ if (dx < 0) s_x = -dx;
+ if (dy < 0) s_y = -dy;
+ int d_x = 0;
+ int d_y = 0;
+ if (dx > 0) d_x = dx;
+ if (dy > 0) d_y = dy;
-void wxWindow::SizerMove(int x, int y)
-{
- int xx = x;
- int yy = y;
- TransformSizerToActual(&xx, &yy);
- Move(xx, yy);
-}
-
-// Only set the size/position of the constraint (if any)
-void wxWindow::SetSizeConstraint(int x, int y, int w, int h)
-{
- wxLayoutConstraints *constr = GetConstraints();
- if (constr)
- {
- if (x != -1)
- {
- constr->left.SetValue(x);
- constr->left.SetDone(TRUE);
- }
- if (y != -1)
- {
- constr->top.SetValue(y);
- constr->top.SetDone(TRUE);
- }
- if (w != -1)
- {
- constr->width.SetValue(w);
- constr->width.SetDone(TRUE);
- }
- if (h != -1)
+ if (!m_scrollGC)
{
- constr->height.SetValue(h);
- constr->height.SetDone(TRUE);
+ m_scrollGC = gdk_gc_new( m_wxwindow->window );
+ gdk_gc_set_exposures( m_scrollGC, TRUE );
}
- }
-}
-void wxWindow::MoveConstraint(int x, int y)
-{
- wxLayoutConstraints *constr = GetConstraints();
- if (constr)
- {
- if (x != -1)
- {
- constr->left.SetValue(x);
- constr->left.SetDone(TRUE);
- }
- if (y != -1)
- {
- constr->top.SetValue(y);
- constr->top.SetDone(TRUE);
- }
- }
-}
+ gdk_window_copy_area( m_wxwindow->window, m_scrollGC, d_x, d_y,
+ m_wxwindow->window, s_x, s_y, w, h );
-void wxWindow::GetSizeConstraint(int *w, int *h) const
-{
- wxLayoutConstraints *constr = GetConstraints();
- if (constr)
- {
- *w = constr->width.GetValue();
- *h = constr->height.GetValue();
- }
- else
- GetSize(w, h);
-}
+ wxRect rect;
+ if (dx < 0) rect.x = cw+dx; else rect.x = 0;
+ if (dy < 0) rect.y = ch+dy; else rect.y = 0;
+ if (dy != 0) rect.width = cw; else rect.width = abs(dx);
+ if (dx != 0) rect.height = ch; else rect.height = abs(dy);
-void wxWindow::GetClientSizeConstraint(int *w, int *h) const
-{
- wxLayoutConstraints *constr = GetConstraints();
- if (constr)
- {
- *w = constr->width.GetValue();
- *h = constr->height.GetValue();
- }
- else
- GetClientSize(w, h);
+ Refresh( TRUE, &rect );
}
-void wxWindow::GetPositionConstraint(int *x, int *y) const
+void wxWindow::SetScrolling(bool scroll)
{
- wxLayoutConstraints *constr = GetConstraints();
- if (constr)
- {
- *x = constr->left.GetValue();
- *y = constr->top.GetValue();
- }
- else
- GetPosition(x, y);
+ m_isScrolling = g_blockEventsOnScroll = scroll;
}
-