From 8bbe427f8e5a2078b266e282453595b5a634d35c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 9 Dec 1998 17:30:17 +0000 Subject: [PATCH] "wxGDIObject * => &" related changes (see mail to the list) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1142 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/confbase.h | 6 +- include/wx/gtk/bitmap.h | 11 +- include/wx/gtk/brush.h | 25 +- include/wx/gtk/colour.h | 5 +- include/wx/gtk/cursor.h | 30 +- include/wx/gtk/dc.h | 240 +++++----- include/wx/gtk/dcclient.h | 30 +- include/wx/gtk/dcmemory.h | 6 +- include/wx/gtk/dcps.h | 12 +- include/wx/gtk/font.h | 56 ++- include/wx/gtk/icon.h | 5 +- include/wx/gtk/menuitem.h | 6 +- include/wx/gtk/palette.h | 13 +- include/wx/gtk/pen.h | 29 +- include/wx/gtk/window.h | 51 +- include/wx/gtk1/bitmap.h | 11 +- include/wx/gtk1/brush.h | 25 +- include/wx/gtk1/colour.h | 5 +- include/wx/gtk1/cursor.h | 30 +- include/wx/gtk1/dc.h | 240 +++++----- include/wx/gtk1/dcclient.h | 30 +- include/wx/gtk1/dcmemory.h | 6 +- include/wx/gtk1/dcps.h | 12 +- include/wx/gtk1/font.h | 56 ++- include/wx/gtk1/icon.h | 5 +- include/wx/gtk1/menuitem.h | 6 +- include/wx/gtk1/palette.h | 13 +- include/wx/gtk1/pen.h | 29 +- include/wx/gtk1/window.h | 51 +- samples/dnd/dnd.cpp | 62 +-- samples/toolbar/test.cpp | 18 +- samples/toolbar/test.h | 13 + src/common/cmndata.cpp | 33 +- src/common/config.cpp | 19 +- src/common/fileconf.cpp | 10 +- src/common/gdicmn.cpp | 109 +++-- src/common/resource.cpp | 112 ++--- src/gtk/app.cpp | 26 +- src/gtk/bitmap.cpp | 223 +++++---- src/gtk/brush.cpp | 51 +- src/gtk/colour.cpp | 65 ++- src/gtk/cursor.cpp | 56 +-- src/gtk/font.cpp | 950 ++++++++++++++++++------------------- src/gtk/frame.cpp | 164 +++---- src/gtk/icon.cpp | 33 +- src/gtk/menu.cpp | 36 +- src/gtk/palette.cpp | 28 +- src/gtk/pen.cpp | 38 +- src/gtk/textctrl.cpp | 84 ++-- src/gtk/utilsres.cpp | 4 +- src/gtk/window.cpp | 203 ++++---- src/gtk1/app.cpp | 26 +- src/gtk1/bitmap.cpp | 223 +++++---- src/gtk1/brush.cpp | 51 +- src/gtk1/colour.cpp | 65 ++- src/gtk1/cursor.cpp | 56 +-- src/gtk1/font.cpp | 950 ++++++++++++++++++------------------- src/gtk1/frame.cpp | 164 +++---- src/gtk1/icon.cpp | 33 +- src/gtk1/menu.cpp | 36 +- src/gtk1/palette.cpp | 28 +- src/gtk1/pen.cpp | 38 +- src/gtk1/textctrl.cpp | 84 ++-- src/gtk1/utilsres.cpp | 4 +- src/gtk1/window.cpp | 203 ++++---- src/make.env | 3 +- 66 files changed, 2599 insertions(+), 2746 deletions(-) diff --git a/include/wx/confbase.h b/include/wx/confbase.h index 1b51cae526..604e78fe36 100644 --- a/include/wx/confbase.h +++ b/include/wx/confbase.h @@ -76,7 +76,7 @@ extern wxString wxExpandEnvVars(const wxString &sz); extern void wxSplitPath(wxArrayString& aParts, const char *sz); // ---------------------------------------------------------------------------- -// abstract base class wxConfigBase which defines the interface for derived +// abstract base class wxConfigBase which defines the interface for derived // classes // // wxConfig organizes the items in a tree-like structure (modeled after the @@ -222,14 +222,14 @@ public: protected: static bool IsImmutable(const wxString& key) - { return key[0u] == wxCONFIG_IMMUTABLE_PREFIX; } + { return !key.IsEmpty() && key[0u] == wxCONFIG_IMMUTABLE_PREFIX; } private: // are we doing automatic environment variable expansion? bool m_bExpandEnvVars; // do we record default values? bool m_bRecordDefaults; - + // static variables static wxConfigBase *ms_pConfig; static bool ms_bAutoCreate; diff --git a/include/wx/gtk/bitmap.h b/include/wx/gtk/bitmap.h index 45258f067b..ee381bac8d 100644 --- a/include/wx/gtk/bitmap.h +++ b/include/wx/gtk/bitmap.h @@ -55,7 +55,7 @@ public: ~wxMask(); // implementation - + GdkBitmap *m_bitmap; GdkBitmap *GetBitmap() const; }; @@ -75,14 +75,13 @@ public: wxBitmap( const char **bits ); wxBitmap( char **bits ); wxBitmap( const wxBitmap& bmp ); - wxBitmap( const wxBitmap* bmp ); wxBitmap( const wxString &filename, int type = wxBITMAP_TYPE_XPM ); ~wxBitmap(); wxBitmap& operator = ( const wxBitmap& bmp ); bool operator == ( const wxBitmap& bmp ); bool operator != ( const wxBitmap& bmp ); bool Ok() const; - + int GetHeight() const; int GetWidth() const; int GetDepth() const; @@ -96,14 +95,14 @@ public: wxPalette *GetPalette() const; wxPalette *GetColourMap() const { return GetPalette(); }; - -// implementation + +// implementation void SetHeight( int height ); void SetWidth( int width ); void SetDepth( int depth ); void SetPixmap( GdkPixmap *pixmap ); - + GdkPixmap *GetPixmap() const; GdkBitmap *GetBitmap() const; diff --git a/include/wx/gtk/brush.h b/include/wx/gtk/brush.h index bd3eeeba5f..43213033b0 100644 --- a/include/wx/gtk/brush.h +++ b/include/wx/gtk/brush.h @@ -4,7 +4,7 @@ // Author: Robert Roebling // Id: $Id$ // Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -37,29 +37,28 @@ class wxBrush: public wxGDIObject public: - wxBrush(void); + wxBrush(); wxBrush( const wxColour &colour, int style ); wxBrush( const wxBitmap &stippleBitmap ); wxBrush( const wxBrush &brush ); - wxBrush( const wxBrush *brush ); - ~wxBrush(void); + ~wxBrush(); wxBrush& operator = ( const wxBrush& brush ); bool operator == ( const wxBrush& brush ); bool operator != ( const wxBrush& brush ); - bool Ok(void) const; + bool Ok() const; + + int GetStyle() const; + wxColour &GetColour() const; + wxBitmap *GetStipple() const; + - int GetStyle(void) const; - wxColour &GetColour(void) const; - wxBitmap *GetStipple(void) const; - - void SetColour( const wxColour& col ); void SetColour( unsigned char r, unsigned char g, unsigned char b ); void SetStyle( int style ); void SetStipple( const wxBitmap& stipple ); - - void Unshare(void); - + + void Unshare(); + // no data :-) }; diff --git a/include/wx/gtk/colour.h b/include/wx/gtk/colour.h index 72d724cab1..ff686d2e06 100644 --- a/include/wx/gtk/colour.h +++ b/include/wx/gtk/colour.h @@ -4,7 +4,7 @@ // Author: Robert Roebling // Id: $Id$ // Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -50,7 +50,6 @@ public: // copy ctors and assignment operators wxColour( const wxColour& col ); - wxColour( const wxColour* col ); wxColour& operator = ( const wxColour& col ); // dtor @@ -59,7 +58,7 @@ public: // comparison bool operator == ( const wxColour& col ); bool operator != ( const wxColour& col ); - + // accessors void Set( unsigned char red, unsigned char green, unsigned char blue ); unsigned char Red() const; diff --git a/include/wx/gtk/cursor.h b/include/wx/gtk/cursor.h index f0391af65b..d274b6be95 100644 --- a/include/wx/gtk/cursor.h +++ b/include/wx/gtk/cursor.h @@ -4,7 +4,7 @@ // Author: Robert Roebling // Id: $Id$ // Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -19,14 +19,6 @@ #include "wx/object.h" #include "wx/gdicmn.h" -//----------------------------------------------------------------------------- -// classes -//----------------------------------------------------------------------------- - -class wxWindow; - -class wxCursor; - //----------------------------------------------------------------------------- // wxCursor //----------------------------------------------------------------------------- @@ -37,22 +29,16 @@ class wxCursor: public wxObject public: - wxCursor(void); + wxCursor(); wxCursor( int cursorId ); wxCursor( const wxCursor &cursor ); - wxCursor( const wxCursor *cursor ); - ~wxCursor(void); + ~wxCursor(); wxCursor& operator = ( const wxCursor& cursor ); - bool operator == ( const wxCursor& cursor ); - bool operator != ( const wxCursor& cursor ); - bool Ok(void) const; - - private: - public: - - friend wxWindow; - - GdkCursor *GetCursor(void) const; + bool operator == ( const wxCursor& cursor ) const; + bool operator != ( const wxCursor& cursor ) const; + bool Ok() const; + + GdkCursor *GetCursor() const; // no data :-) }; diff --git a/include/wx/gtk/dc.h b/include/wx/gtk/dc.h index e1ca5b0b91..09fef31960 100644 --- a/include/wx/gtk/dc.h +++ b/include/wx/gtk/dc.h @@ -4,7 +4,7 @@ // Author: Robert Roebling // Id: $Id$ // Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -34,14 +34,14 @@ class wxDC; // constants //----------------------------------------------------------------------------- -#define MM_TEXT 0 -#define MM_ISOTROPIC 1 -#define MM_ANISOTROPIC 2 -#define MM_LOMETRIC 3 -#define MM_HIMETRIC 4 -#define MM_TWIPS 5 -#define MM_POINTS 6 -#define MM_METRIC 7 +#define MM_TEXT 0 +#define MM_ISOTROPIC 1 +#define MM_ANISOTROPIC 2 +#define MM_LOMETRIC 3 +#define MM_HIMETRIC 4 +#define MM_TWIPS 5 +#define MM_POINTS 6 +#define MM_METRIC 7 //----------------------------------------------------------------------------- // global variables @@ -61,10 +61,10 @@ public: wxDC(); ~wxDC(); - + virtual void BeginDrawing() {} virtual void EndDrawing() {} - + virtual bool Ok() const; virtual void FloodFill( long x, long y, const wxColour& col, int style=wxFLOOD_SURFACE ) = 0; @@ -104,14 +104,14 @@ public: DrawPoint(pt.x, pt.y); } virtual void DrawPoint( wxPoint& point ); - + virtual void DrawLines( int n, wxPoint points[], long xoffset = 0, long yoffset = 0 ) = 0; virtual void DrawLines( wxList *points, long xoffset = 0, long yoffset = 0 ); - virtual void DrawPolygon( int n, wxPoint points[], long xoffset = 0, long yoffset = 0, + virtual void DrawPolygon( int n, wxPoint points[], long xoffset = 0, long yoffset = 0, int fillStyle=wxODDEVEN_RULE ) = 0; - virtual void DrawPolygon( wxList *lines, long xoffset = 0, long yoffset = 0, + virtual void DrawPolygon( wxList *lines, long xoffset = 0, long yoffset = 0, int fillStyle=wxODDEVEN_RULE ); - + virtual void DrawRectangle( long x, long y, long width, long height ) = 0; inline void DrawRectangle(const wxPoint& pt, const wxSize& sz) { @@ -139,11 +139,11 @@ public: { DrawEllipse(rect.x, rect.y, rect.width, rect.height); } - + virtual void DrawSpline( long x1, long y1, long x2, long y2, long x3, long y3 ); virtual void DrawSpline( wxList *points ) = 0; virtual void DrawSpline( int n, wxPoint points[] ); - + virtual bool CanDrawBitmap(void) const = 0; virtual void DrawIcon( const wxIcon &icon, long x, long y ) = 0; inline void DrawIcon( const wxIcon& icon, const wxPoint& pt ) @@ -155,18 +155,18 @@ public: { DrawBitmap(bitmap, pt.x, pt.y, useMask ); } - virtual bool Blit( long xdest, long ydest, + virtual bool Blit( long xdest, long ydest, long width, long height, - wxDC *source, - long xsrc, long ysrc, - int logical_func=wxCOPY, - bool useMask=FALSE ) = 0; - inline bool Blit( const wxPoint& destPt, + wxDC *source, + long xsrc, long ysrc, + int logical_func=wxCOPY, + bool useMask=FALSE ) = 0; + inline bool Blit( const wxPoint& destPt, const wxSize& sz, - wxDC *source, - const wxPoint& srcPt, - int rop = wxCOPY, - bool useMask=FALSE) + wxDC *source, + const wxPoint& srcPt, + int rop = wxCOPY, + bool useMask=FALSE) { return Blit(destPt.x, destPt.y, sz.x, sz.y, source, srcPt.x, srcPt.y, rop, useMask); } @@ -177,49 +177,49 @@ public: DrawText(text, pt.x, pt.y, use16bit); } virtual bool CanGetTextExtent(void) const = 0; - virtual void GetTextExtent( const wxString &string, + virtual void GetTextExtent( const wxString &string, long *width, long *height, - long *descent = (long *) NULL, - long *externalLeading = (long *) NULL, - wxFont *theFont = (wxFont *) NULL, - bool use16 = FALSE ) = 0; + long *descent = (long *) NULL, + long *externalLeading = (long *) NULL, + wxFont *theFont = (wxFont *) NULL, + bool use16 = FALSE ) = 0; virtual long GetCharWidth(void) = 0; virtual long GetCharHeight(void) = 0; - + virtual void Clear() = 0; - + virtual void SetFont( const wxFont &font ) = 0; - virtual wxFont *GetFont() { return &m_font; }; - + virtual const wxFont& GetFont() const { return m_font; }; + virtual void SetPen( const wxPen &pen ) = 0; - virtual wxPen *GetPen() { return &m_pen; }; - + virtual const wxPen& GetPen() const { return m_pen; }; + virtual void SetBrush( const wxBrush &brush ) = 0; - virtual wxBrush *GetBrush() { return &m_brush; }; + virtual const wxBrush& GetBrush() const { return m_brush; }; virtual void SetBackground( const wxBrush &brush ) = 0; - virtual wxBrush *GetBackground() { return &m_backgroundBrush; }; + virtual const wxBrush& GetBackground() const { return m_backgroundBrush; }; virtual void SetLogicalFunction( int function ) = 0; virtual int GetLogicalFunction() { return m_logicalFunction; }; - + virtual void SetTextForeground( const wxColour &col ); virtual void SetTextBackground( const wxColour &col ); virtual wxColour& GetTextBackground() const { return (wxColour&)m_textBackgroundColour; }; virtual wxColour& GetTextForeground() const { return (wxColour&)m_textForegroundColour; }; - + virtual void SetBackgroundMode( int mode ) = 0; virtual int GetBackgroundMode() { return m_backgroundMode; }; - + virtual void SetPalette( const wxPalette& palette ) = 0; void SetColourMap( const wxPalette& palette ) { SetPalette(palette); }; - + // the first two must be overridden and called virtual void DestroyClippingRegion(void); virtual void SetClippingRegion( long x, long y, long width, long height ); virtual void GetClippingBox( long *x, long *y, long *width, long *height ) const; virtual void SetClippingRegion( const wxRegion ®ion ) = 0; - + virtual long MinX() const { return m_minX; } virtual long MaxX() const { return m_maxX; } virtual long MinY() const { return m_minY; } @@ -228,30 +228,30 @@ public: virtual void GetSize( int* width, int* height ) const; inline wxSize GetSize(void) const { int w, h; GetSize(&w, &h); return wxSize(w, h); } virtual void GetSizeMM( long* width, long* height ) const; - + virtual bool StartDoc( const wxString& WXUNUSED(message) ) { return TRUE; } virtual void EndDoc() {} virtual void StartPage() {} virtual void EndPage() {} - + virtual void SetMapMode( int mode ); virtual int GetMapMode(void) const { return m_mappingMode; }; - + virtual void SetUserScale( double x, double y ); virtual void GetUserScale( double *x, double *y ); virtual void SetLogicalScale( double x, double y ); virtual void GetLogicalScale( double *x, double *y ); - + virtual void SetLogicalOrigin( long x, long y ); virtual void GetLogicalOrigin( long *x, long *y ); virtual void SetDeviceOrigin( long x, long y ); virtual void GetDeviceOrigin( long *x, long *y ); virtual void SetAxisOrientation( bool xLeftRight, bool yBottomUp ); - + virtual void SetOptimization( bool WXUNUSED(optimize) ) {} virtual bool GetOptimization() { return m_optimize; } - + virtual long DeviceToLogicalX(long x) const; virtual long DeviceToLogicalY(long y) const; virtual long DeviceToLogicalXRel(long x) const; @@ -262,77 +262,77 @@ public: virtual long LogicalToDeviceYRel(long y) const; // implementation - + void CalcBoundingBox( long x, long y ); void ComputeScaleAndOrigin(); - + long XDEV2LOG(long x) const - { - long new_x = x - m_deviceOriginX; - if (new_x > 0) - return (long)((double)(new_x) / m_scaleX + 0.5) * m_signX + m_logicalOriginX; - else - return (long)((double)(new_x) / m_scaleX - 0.5) * m_signX + m_logicalOriginX; - } + { + long new_x = x - m_deviceOriginX; + if (new_x > 0) + return (long)((double)(new_x) / m_scaleX + 0.5) * m_signX + m_logicalOriginX; + else + return (long)((double)(new_x) / m_scaleX - 0.5) * m_signX + m_logicalOriginX; + } long XDEV2LOGREL(long x) const - { - if (x > 0) - return (long)((double)(x) / m_scaleX + 0.5); - else - return (long)((double)(x) / m_scaleX - 0.5); - } + { + if (x > 0) + return (long)((double)(x) / m_scaleX + 0.5); + else + return (long)((double)(x) / m_scaleX - 0.5); + } long YDEV2LOG(long y) const - { - long new_y = y - m_deviceOriginY; - if (new_y > 0) - return (long)((double)(new_y) / m_scaleY + 0.5) * m_signY + m_logicalOriginY; - else - return (long)((double)(new_y) / m_scaleY - 0.5) * m_signY + m_logicalOriginY; - } + { + long new_y = y - m_deviceOriginY; + if (new_y > 0) + return (long)((double)(new_y) / m_scaleY + 0.5) * m_signY + m_logicalOriginY; + else + return (long)((double)(new_y) / m_scaleY - 0.5) * m_signY + m_logicalOriginY; + } long YDEV2LOGREL(long y) const - { - if (y > 0) - return (long)((double)(y) / m_scaleY + 0.5); - else - return (long)((double)(y) / m_scaleY - 0.5); - } + { + if (y > 0) + return (long)((double)(y) / m_scaleY + 0.5); + else + return (long)((double)(y) / m_scaleY - 0.5); + } long XLOG2DEV(long x) const - { - long new_x = x - m_logicalOriginX; - if (new_x > 0) - return (long)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX; - else - return (long)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX; - } + { + long new_x = x - m_logicalOriginX; + if (new_x > 0) + return (long)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX; + else + return (long)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX; + } long XLOG2DEVREL(long x) const - { - if (x > 0) - return (long)((double)(x) * m_scaleX + 0.5); - else - return (long)((double)(x) * m_scaleX - 0.5); - } + { + if (x > 0) + return (long)((double)(x) * m_scaleX + 0.5); + else + return (long)((double)(x) * m_scaleX - 0.5); + } long YLOG2DEV(long y) const - { - long new_y = y - m_logicalOriginY; - if (new_y > 0) - return (long)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY; - else - return (long)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY; - } + { + long new_y = y - m_logicalOriginY; + if (new_y > 0) + return (long)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY; + else + return (long)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY; + } long YLOG2DEVREL(long y) const - { - if (y > 0) - return (long)((double)(y) * m_scaleY + 0.5); - else - return (long)((double)(y) * m_scaleY - 0.5); - } - - + { + if (y > 0) + return (long)((double)(y) * m_scaleY + 0.5); + else + return (long)((double)(y) * m_scaleY - 0.5); + } + + public: - + bool m_ok; bool m_colour; - + // not sure, what these mean bool m_clipping; // Is clipping on right now ? bool m_isInteractive; // Is GetPixel possible ? @@ -340,36 +340,36 @@ public: bool m_dontDelete; // wxMSW only ? bool m_optimize; // wxMSW only ? wxString m_filename; // Not sure where this belongs. - + wxPen m_pen; wxBrush m_brush; wxBrush m_backgroundBrush; wxColour m_textForegroundColour; wxColour m_textBackgroundColour; wxFont m_font; - + int m_logicalFunction; int m_backgroundMode; int m_textAlignment; // gone in wxWin 2.0 ? - + int m_mappingMode; - + // not sure what for, but what is a mm on a screen you don't know the size of? - double m_mm_to_pix_x,m_mm_to_pix_y; - - long m_deviceOriginX,m_deviceOriginY; - + double m_mm_to_pix_x,m_mm_to_pix_y; + + long m_deviceOriginX,m_deviceOriginY; + long m_logicalOriginX,m_logicalOriginY; // User defined. double m_scaleX,m_scaleY; double m_logicalScaleX,m_logicalScaleY; double m_userScaleX,m_userScaleY; long m_signX,m_signY; - + bool m_needComputeScaleX,m_needComputeScaleY; // not yet used - + float m_scaleFactor; // wxPSDC wants to have this. Will disappear. - + long m_clipX1,m_clipY1,m_clipX2,m_clipY2; long m_minX,m_maxX,m_minY,m_maxY; }; diff --git a/include/wx/gtk/dcclient.h b/include/wx/gtk/dcclient.h index 9a46663029..4f4999affb 100644 --- a/include/wx/gtk/dcclient.h +++ b/include/wx/gtk/dcclient.h @@ -4,7 +4,7 @@ // Author: Robert Roebling // Id: $Id$ // Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -37,9 +37,9 @@ class wxWindowDC: public wxDC public: wxWindowDC(); wxWindowDC( wxWindow *win ); - + ~wxWindowDC(); - + virtual void FloodFill( long x, long y, const wxColour& col, int style=wxFLOOD_SURFACE ); virtual bool GetPixel( long x1, long y1, wxColour *col ) const; @@ -48,18 +48,18 @@ public: virtual void DrawArc( long x1, long y1, long x2, long y2, double xc, double yc ); virtual void DrawEllipticArc( long x, long y, long width, long height, double sa, double ea ); virtual void DrawPoint( long x, long y ); - + virtual void DrawLines( int n, wxPoint points[], long xoffset = 0, long yoffset = 0 ); virtual void DrawLines( wxList *points, long xoffset = 0, long yoffset = 0 ); - virtual void DrawPolygon( int n, wxPoint points[], long xoffset = 0, long yoffset = 0, + virtual void DrawPolygon( int n, wxPoint points[], long xoffset = 0, long yoffset = 0, int fillStyle=wxODDEVEN_RULE ); - virtual void DrawPolygon( wxList *lines, long xoffset = 0, long yoffset = 0, + virtual void DrawPolygon( wxList *lines, long xoffset = 0, long yoffset = 0, int fillStyle=wxODDEVEN_RULE ); - + virtual void DrawRectangle( long x, long y, long width, long height ); virtual void DrawRoundedRectangle( long x, long y, long width, long height, double radius = 20.0 ); virtual void DrawEllipse( long x, long y, long width, long height ); - + virtual bool CanDrawBitmap() const; virtual void DrawIcon( const wxIcon &icon, long x, long y ); virtual void DrawBitmap( const wxBitmap &bitmap, long x, long y, bool useMask=FALSE ); @@ -73,9 +73,9 @@ public: wxFont *theFont = (wxFont *) NULL, bool use16 = FALSE ); virtual long GetCharWidth(); virtual long GetCharHeight(); - + virtual void Clear(); - + virtual void SetFont( const wxFont &font ); virtual void SetPen( const wxPen &pen ); virtual void SetBrush( const wxBrush &brush ); @@ -85,15 +85,15 @@ public: virtual void SetTextBackground( const wxColour &col ); virtual void SetBackgroundMode( int mode ); virtual void SetPalette( const wxPalette& palette ); - + virtual void SetClippingRegion( long x, long y, long width, long height ); virtual void DestroyClippingRegion(); virtual void SetClippingRegion( const wxRegion ®ion ); - + virtual void DrawSpline( wxList *points ); - + // implementation - + GdkWindow *m_window; GdkGC *m_penGC; GdkGC *m_brushGC; @@ -101,7 +101,7 @@ public: GdkGC *m_bgGC; GdkColormap *m_cmap; bool m_isMemDC; - + void SetUpDC(); void Destroy(); GdkWindow *GetWindow(); diff --git a/include/wx/gtk/dcmemory.h b/include/wx/gtk/dcmemory.h index 10d0f2905f..ea4a1f1571 100644 --- a/include/wx/gtk/dcmemory.h +++ b/include/wx/gtk/dcmemory.h @@ -4,7 +4,7 @@ // Author: Robert Roebling // RCS-ID: $Id$ // Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -39,8 +39,8 @@ public: virtual void SelectObject( const wxBitmap& bitmap ); void GetSize( int *width, int *height ) const; - // implementation - + // implementation + wxBitmap m_selected; }; diff --git a/include/wx/gtk/dcps.h b/include/wx/gtk/dcps.h index 8d0ccedc11..f996001cb8 100644 --- a/include/wx/gtk/dcps.h +++ b/include/wx/gtk/dcps.h @@ -82,7 +82,7 @@ public: void DrawIcon( const wxIcon& icon, long x, long y ); void DrawBitmap( const wxBitmap& bitmap, long x, long y, bool useMask=FALSE ); - + void DrawText(const wxString& text, long x, long y, bool use16 = FALSE); void Clear(); @@ -91,7 +91,7 @@ public: void SetBrush( const wxBrush& brush ); void SetLogicalFunction( int function ); void SetBackground( const wxBrush& brush ); - + void SetClippingRegion(long x, long y, long width, long height); void SetClippingRegion( const wxRegion ®ion ); void DestroyClippingRegion(); @@ -108,16 +108,16 @@ public: long *descent = (long *) NULL, long *externalLeading = (long *) NULL, wxFont *theFont = (wxFont *) NULL, bool use16 = FALSE); - + void GetSize(int* width, int* height) const; void GetSizeMM(long *width, long *height) const; void SetAxisOrientation( bool xLeftRight, bool yBottomUp ); void SetDeviceOrigin( long x, long y ); - + inline void SetBackgroundMode(int WXUNUSED(mode)) {} inline void SetPalette(const wxPalette& WXUNUSED(palette)) {} - + inline ofstream *GetStream(void) const { return m_pstream; } protected: @@ -133,7 +133,7 @@ protected: double m_underlineThickness; }; -#endif +#endif // wxUSE_POSTSCRIPT #endif diff --git a/include/wx/gtk/font.h b/include/wx/gtk/font.h index bd34c91791..becbfb1eeb 100644 --- a/include/wx/gtk/font.h +++ b/include/wx/gtk/font.h @@ -4,7 +4,7 @@ // Author: Robert Roebling // Id: $Id$ // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -42,40 +42,39 @@ class wxFontNameDirectory; // wxFont //----------------------------------------------------------------------------- -class wxFont: public wxGDIObject +class wxFont: public wxGDIObject { DECLARE_DYNAMIC_CLASS(wxFont) - + public: - wxFont(void); + wxFont(); wxFont( int PointSize, int FontIdOrFamily, int Style, int Weight, - bool underlined = FALSE, const char *Face= ( const char *) NULL ); - wxFont( int PointSize, const char *Face, int Family, int Style, int Weight, - bool underlined = FALSE ); + bool underlined = FALSE, const char *Face = ( const char *) NULL ); + wxFont( int PointSize, const char *Face, int Family, + int Style, int Weight, bool underlined = FALSE ); wxFont( const wxFont& font ); - wxFont( const wxFont* font ); - ~wxFont(void); + ~wxFont(); wxFont& operator = ( const wxFont& font ); bool operator == ( const wxFont& font ); bool operator != ( const wxFont& font ); bool Ok() const; - int GetPointSize(void) const; - wxString GetFaceName(void) const; - int GetFamily(void) const; - wxString GetFamilyString(void) const; - int GetFontId(void) const; - wxString GetFaceString(void) const; - int GetStyle(void) const; - wxString GetStyleString(void) const; - int GetWeight(void) const; - wxString GetWeightString(void) const; - bool GetUnderlined(void) const; + int GetPointSize() const; + wxString GetFaceName() const; + int GetFamily() const; + wxString GetFamilyString() const; + int GetFontId() const; + wxString GetFaceString() const; + int GetStyle() const; + wxString GetStyleString() const; + int GetWeight() const; + wxString GetWeightString() const; + bool GetUnderlined() const; wxFont( char *xFontName ); - // implementation - + // implementation + GdkFont* GetInternalFont(float scale = 1.0) const; // no data :-) @@ -85,15 +84,15 @@ class wxFont: public wxGDIObject // wxFontDirectory //----------------------------------------------------------------------------- -class wxFontNameDirectory: public wxObject +class wxFontNameDirectory: public wxObject { DECLARE_DYNAMIC_CLASS(wxFontNameDirectory) - + public: - wxFontNameDirectory(void); + wxFontNameDirectory(); ~wxFontNameDirectory(); - void Initialize(void); + void Initialize(); void Initialize(int fontid, int family, const char *name); int FindOrCreateFontId(const char *name, int family); @@ -101,11 +100,10 @@ class wxFontNameDirectory: public wxObject int GetFamily(int fontid); int GetFontId(const char *name); char* GetFontName(int fontid); - int GetNewFontId(void); + int GetNewFontId(); char* GetPostScriptName(int fontid, int weight, int style); char* GetScreenName(int fontid, int weight, int style); - - + class wxHashTable *table; int nextFontId; }; diff --git a/include/wx/gtk/icon.h b/include/wx/gtk/icon.h index 2b54f60c05..4f0a9b5324 100644 --- a/include/wx/gtk/icon.h +++ b/include/wx/gtk/icon.h @@ -4,7 +4,7 @@ // Author: Robert Roebling // Id: $Id$ // Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -35,9 +35,8 @@ class wxIcon: public wxBitmap public: - wxIcon(void); + wxIcon(); wxIcon( const wxIcon& icon); - wxIcon( const wxIcon* icon); wxIcon( const char **bits, int width=-1, int height=-1 ); wxIcon( char **bits, int width=-1, int height=-1 ); diff --git a/include/wx/gtk/menuitem.h b/include/wx/gtk/menuitem.h index 99c0a659d6..77f08d493e 100644 --- a/include/wx/gtk/menuitem.h +++ b/include/wx/gtk/menuitem.h @@ -50,7 +50,9 @@ public: // the item's text = name void SetName(const wxString& str); + void SetText(const wxString& str) { SetName(str); } // compatibility const wxString& GetName() const { return m_text; } + const wxString& GetText() const { return GetName(); } // what kind of menu item we are void SetCheckable(bool checkable) { m_isCheckMenu = checkable; } @@ -60,7 +62,7 @@ public: bool IsSubMenu() const { return m_subMenu != NULL; } // state - void Enable( bool enable = TRUE ); + void Enable( bool enable = TRUE ); bool IsEnabled() const { return m_isEnabled; } void Check( bool check = TRUE ); bool IsChecked() const; @@ -86,5 +88,5 @@ private: }; -#endif +#endif //__GTKMENUITEMH__ diff --git a/include/wx/gtk/palette.h b/include/wx/gtk/palette.h index d6b7bbb64b..8574526cb3 100644 --- a/include/wx/gtk/palette.h +++ b/include/wx/gtk/palette.h @@ -5,7 +5,7 @@ // Created: 01/02/97 // Id: // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -36,17 +36,16 @@ class wxPalette: public wxGDIObject DECLARE_DYNAMIC_CLASS(wxPalette) public: - - wxPalette(void); + + wxPalette(); wxPalette( int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue ); wxPalette( const wxPalette& palette ); - wxPalette( const wxPalette* palette ); - ~wxPalette(void); + ~wxPalette(); wxPalette& operator = ( const wxPalette& palette ); bool operator == ( const wxPalette& palette ); bool operator != ( const wxPalette& palette ); - bool Ok(void) const; - + bool Ok() const; + bool Create( int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue); int GetPixel( const unsigned char red, const unsigned char green, const unsigned char blue ) const; bool GetRGB( int pixel, unsigned char *red, unsigned char *green, unsigned char *blue ) const; diff --git a/include/wx/gtk/pen.h b/include/wx/gtk/pen.h index 10ccf5e962..fb37103370 100644 --- a/include/wx/gtk/pen.h +++ b/include/wx/gtk/pen.h @@ -4,7 +4,7 @@ // Author: Robert Roebling // Id: $Id$ // Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -36,31 +36,30 @@ class wxPen: public wxGDIObject DECLARE_DYNAMIC_CLASS(wxPen) public: - - wxPen(void); + + wxPen(); wxPen( const wxColour &colour, int width, int style ); wxPen( const wxPen& pen ); - wxPen( const wxPen* pen ); - ~wxPen(void); + ~wxPen(); wxPen& operator = ( const wxPen& pen ); bool operator == ( const wxPen& pen ); bool operator != ( const wxPen& pen ); - + void SetColour( const wxColour &colour ); void SetColour( int red, int green, int blue ); void SetCap( int capStyle ); void SetJoin( int joinStyle ); void SetStyle( int style ); void SetWidth( int width ); - wxColour &GetColour(void) const; - int GetCap(void) const; - int GetJoin(void) const; - int GetStyle(void) const; - int GetWidth(void) const; - bool Ok(void) const; - - void Unshare(void); - + wxColour &GetColour() const; + int GetCap() const; + int GetJoin() const; + int GetStyle() const; + int GetWidth() const; + bool Ok() const; + + void Unshare(); + // no data :-) }; diff --git a/include/wx/gtk/window.h b/include/wx/gtk/window.h index 21a177b91d..bfa2607235 100644 --- a/include/wx/gtk/window.h +++ b/include/wx/gtk/window.h @@ -83,7 +83,7 @@ public: wxStringClientData( wxString &data ) { m_data = data; } void SetData( wxString &data ) { m_data = data; } wxString GetData() const { return m_data; } - + private: wxString m_data; }; @@ -95,7 +95,7 @@ private: class wxWindow: public wxEvtHandler { DECLARE_DYNAMIC_CLASS(wxWindow) - + public: wxWindow(); wxWindow(wxWindow *parent, wxWindowID id, @@ -110,7 +110,7 @@ public: const wxString& name = wxPanelNameStr); virtual ~wxWindow(); - virtual bool LoadFromResource( wxWindow *parent, const wxString& resourceName, + 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); @@ -155,7 +155,8 @@ public: virtual bool OnClose(); virtual void AddChild( wxWindow *child ); - wxList& GetChildren() const; + wxList& GetChildren() { return m_children; } + virtual void RemoveChild( wxWindow *child ); void SetReturnCode( int retCode ); int GetReturnCode(); @@ -167,7 +168,7 @@ public: { m_parent = p; } virtual wxWindow *ReParent( wxWindow *newParent ); - wxEvtHandler *GetEventHandler(); + wxEvtHandler *GetEventHandler() const; void SetEventHandler( wxEvtHandler *handler ); void PushEventHandler( wxEvtHandler *handler ); wxEvtHandler *PopEventHandler( bool deleteHandler = FALSE ); @@ -177,23 +178,23 @@ public: virtual void SetClientObject( wxClientData *data ); virtual wxClientData *GetClientObject(); - + virtual void SetClientData( void *data ); virtual void *GetClientData(); - + virtual void SetAcceleratorTable( const wxAcceleratorTable& accel ); virtual wxAcceleratorTable *GetAcceleratorTable() { return &m_acceleratorTable; } - + bool IsBeingDeleted(); void SetId( wxWindowID id ); - wxWindowID GetId(); + wxWindowID GetId() const; void SetCursor( const wxCursor &cursor ); 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; @@ -213,20 +214,20 @@ public: const wxFont *theFont = (const wxFont *) NULL, bool use16 = FALSE) const; virtual void SetFont( const wxFont &font ); - virtual wxFont *GetFont(); - + virtual const wxFont& GetFont() { return m_font; } + // For backward compatibility inline virtual void SetButtonFont(const wxFont& font) { SetFont(font); } inline virtual void SetLabelFont(const wxFont& font) { SetFont(font); } - inline virtual wxFont *GetLabelFont() { return GetFont(); }; - inline virtual wxFont *GetButtonFont() { return GetFont(); }; - + inline virtual const wxFont& GetLabelFont() { return GetFont(); }; + inline virtual const wxFont& GetButtonFont() { return GetFont(); }; + virtual void SetWindowStyleFlag( long flag ); virtual long GetWindowStyleFlag() const; - + virtual void CaptureMouse(); virtual void ReleaseMouse(); - + virtual void SetTitle( const wxString &title ); virtual wxString GetTitle() const; virtual void SetName( const wxString &name ); @@ -243,10 +244,10 @@ public: virtual bool IsRetained(); virtual wxWindow *FindWindow( long id ); virtual wxWindow *FindWindow( const wxString& name ); - + void AllowDoubleClick( bool WXUNUSED(allow) ) {}; void SetDoubleClick( bool WXUNUSED(allow) ) {}; - + virtual void ClientToScreen( int *x, int *y ); virtual void ScreenToClient( int *x, int *y ); @@ -270,27 +271,27 @@ public: virtual void ScrollWindow( int dx, int dy, const wxRect* rect = (wxRect *) NULL ); virtual bool AcceptsFocus() const; - + void UpdateWindowUI(); // implementation - + void PreCreation( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style, const wxString &name ); void PostCreation(); virtual GtkWidget *GetConnectWidget(); virtual bool IsOwnGtkWindow( GdkWindow *window ); void ConnectWidget( GtkWidget *widget ); - + bool HasVMT(); - + virtual wxPoint GetClientAreaOrigin() const; virtual void AdjustForParentClientOrigin( int& x, int& y, int sizeFlags ); GtkStyle *GetWidgetStyle(); void SetWidgetStyle(); virtual void ApplyWidgetStyle(); - + wxWindow *m_parent; wxList m_children; @@ -329,7 +330,7 @@ public: bool m_resizing; GdkGC *m_scrollGC; GtkStyle *m_widgetStyle; - + wxInsertChildFunction m_insertCallback; public: diff --git a/include/wx/gtk1/bitmap.h b/include/wx/gtk1/bitmap.h index 45258f067b..ee381bac8d 100644 --- a/include/wx/gtk1/bitmap.h +++ b/include/wx/gtk1/bitmap.h @@ -55,7 +55,7 @@ public: ~wxMask(); // implementation - + GdkBitmap *m_bitmap; GdkBitmap *GetBitmap() const; }; @@ -75,14 +75,13 @@ public: wxBitmap( const char **bits ); wxBitmap( char **bits ); wxBitmap( const wxBitmap& bmp ); - wxBitmap( const wxBitmap* bmp ); wxBitmap( const wxString &filename, int type = wxBITMAP_TYPE_XPM ); ~wxBitmap(); wxBitmap& operator = ( const wxBitmap& bmp ); bool operator == ( const wxBitmap& bmp ); bool operator != ( const wxBitmap& bmp ); bool Ok() const; - + int GetHeight() const; int GetWidth() const; int GetDepth() const; @@ -96,14 +95,14 @@ public: wxPalette *GetPalette() const; wxPalette *GetColourMap() const { return GetPalette(); }; - -// implementation + +// implementation void SetHeight( int height ); void SetWidth( int width ); void SetDepth( int depth ); void SetPixmap( GdkPixmap *pixmap ); - + GdkPixmap *GetPixmap() const; GdkBitmap *GetBitmap() const; diff --git a/include/wx/gtk1/brush.h b/include/wx/gtk1/brush.h index bd3eeeba5f..43213033b0 100644 --- a/include/wx/gtk1/brush.h +++ b/include/wx/gtk1/brush.h @@ -4,7 +4,7 @@ // Author: Robert Roebling // Id: $Id$ // Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -37,29 +37,28 @@ class wxBrush: public wxGDIObject public: - wxBrush(void); + wxBrush(); wxBrush( const wxColour &colour, int style ); wxBrush( const wxBitmap &stippleBitmap ); wxBrush( const wxBrush &brush ); - wxBrush( const wxBrush *brush ); - ~wxBrush(void); + ~wxBrush(); wxBrush& operator = ( const wxBrush& brush ); bool operator == ( const wxBrush& brush ); bool operator != ( const wxBrush& brush ); - bool Ok(void) const; + bool Ok() const; + + int GetStyle() const; + wxColour &GetColour() const; + wxBitmap *GetStipple() const; + - int GetStyle(void) const; - wxColour &GetColour(void) const; - wxBitmap *GetStipple(void) const; - - void SetColour( const wxColour& col ); void SetColour( unsigned char r, unsigned char g, unsigned char b ); void SetStyle( int style ); void SetStipple( const wxBitmap& stipple ); - - void Unshare(void); - + + void Unshare(); + // no data :-) }; diff --git a/include/wx/gtk1/colour.h b/include/wx/gtk1/colour.h index 72d724cab1..ff686d2e06 100644 --- a/include/wx/gtk1/colour.h +++ b/include/wx/gtk1/colour.h @@ -4,7 +4,7 @@ // Author: Robert Roebling // Id: $Id$ // Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -50,7 +50,6 @@ public: // copy ctors and assignment operators wxColour( const wxColour& col ); - wxColour( const wxColour* col ); wxColour& operator = ( const wxColour& col ); // dtor @@ -59,7 +58,7 @@ public: // comparison bool operator == ( const wxColour& col ); bool operator != ( const wxColour& col ); - + // accessors void Set( unsigned char red, unsigned char green, unsigned char blue ); unsigned char Red() const; diff --git a/include/wx/gtk1/cursor.h b/include/wx/gtk1/cursor.h index f0391af65b..d274b6be95 100644 --- a/include/wx/gtk1/cursor.h +++ b/include/wx/gtk1/cursor.h @@ -4,7 +4,7 @@ // Author: Robert Roebling // Id: $Id$ // Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -19,14 +19,6 @@ #include "wx/object.h" #include "wx/gdicmn.h" -//----------------------------------------------------------------------------- -// classes -//----------------------------------------------------------------------------- - -class wxWindow; - -class wxCursor; - //----------------------------------------------------------------------------- // wxCursor //----------------------------------------------------------------------------- @@ -37,22 +29,16 @@ class wxCursor: public wxObject public: - wxCursor(void); + wxCursor(); wxCursor( int cursorId ); wxCursor( const wxCursor &cursor ); - wxCursor( const wxCursor *cursor ); - ~wxCursor(void); + ~wxCursor(); wxCursor& operator = ( const wxCursor& cursor ); - bool operator == ( const wxCursor& cursor ); - bool operator != ( const wxCursor& cursor ); - bool Ok(void) const; - - private: - public: - - friend wxWindow; - - GdkCursor *GetCursor(void) const; + bool operator == ( const wxCursor& cursor ) const; + bool operator != ( const wxCursor& cursor ) const; + bool Ok() const; + + GdkCursor *GetCursor() const; // no data :-) }; diff --git a/include/wx/gtk1/dc.h b/include/wx/gtk1/dc.h index e1ca5b0b91..09fef31960 100644 --- a/include/wx/gtk1/dc.h +++ b/include/wx/gtk1/dc.h @@ -4,7 +4,7 @@ // Author: Robert Roebling // Id: $Id$ // Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -34,14 +34,14 @@ class wxDC; // constants //----------------------------------------------------------------------------- -#define MM_TEXT 0 -#define MM_ISOTROPIC 1 -#define MM_ANISOTROPIC 2 -#define MM_LOMETRIC 3 -#define MM_HIMETRIC 4 -#define MM_TWIPS 5 -#define MM_POINTS 6 -#define MM_METRIC 7 +#define MM_TEXT 0 +#define MM_ISOTROPIC 1 +#define MM_ANISOTROPIC 2 +#define MM_LOMETRIC 3 +#define MM_HIMETRIC 4 +#define MM_TWIPS 5 +#define MM_POINTS 6 +#define MM_METRIC 7 //----------------------------------------------------------------------------- // global variables @@ -61,10 +61,10 @@ public: wxDC(); ~wxDC(); - + virtual void BeginDrawing() {} virtual void EndDrawing() {} - + virtual bool Ok() const; virtual void FloodFill( long x, long y, const wxColour& col, int style=wxFLOOD_SURFACE ) = 0; @@ -104,14 +104,14 @@ public: DrawPoint(pt.x, pt.y); } virtual void DrawPoint( wxPoint& point ); - + virtual void DrawLines( int n, wxPoint points[], long xoffset = 0, long yoffset = 0 ) = 0; virtual void DrawLines( wxList *points, long xoffset = 0, long yoffset = 0 ); - virtual void DrawPolygon( int n, wxPoint points[], long xoffset = 0, long yoffset = 0, + virtual void DrawPolygon( int n, wxPoint points[], long xoffset = 0, long yoffset = 0, int fillStyle=wxODDEVEN_RULE ) = 0; - virtual void DrawPolygon( wxList *lines, long xoffset = 0, long yoffset = 0, + virtual void DrawPolygon( wxList *lines, long xoffset = 0, long yoffset = 0, int fillStyle=wxODDEVEN_RULE ); - + virtual void DrawRectangle( long x, long y, long width, long height ) = 0; inline void DrawRectangle(const wxPoint& pt, const wxSize& sz) { @@ -139,11 +139,11 @@ public: { DrawEllipse(rect.x, rect.y, rect.width, rect.height); } - + virtual void DrawSpline( long x1, long y1, long x2, long y2, long x3, long y3 ); virtual void DrawSpline( wxList *points ) = 0; virtual void DrawSpline( int n, wxPoint points[] ); - + virtual bool CanDrawBitmap(void) const = 0; virtual void DrawIcon( const wxIcon &icon, long x, long y ) = 0; inline void DrawIcon( const wxIcon& icon, const wxPoint& pt ) @@ -155,18 +155,18 @@ public: { DrawBitmap(bitmap, pt.x, pt.y, useMask ); } - virtual bool Blit( long xdest, long ydest, + virtual bool Blit( long xdest, long ydest, long width, long height, - wxDC *source, - long xsrc, long ysrc, - int logical_func=wxCOPY, - bool useMask=FALSE ) = 0; - inline bool Blit( const wxPoint& destPt, + wxDC *source, + long xsrc, long ysrc, + int logical_func=wxCOPY, + bool useMask=FALSE ) = 0; + inline bool Blit( const wxPoint& destPt, const wxSize& sz, - wxDC *source, - const wxPoint& srcPt, - int rop = wxCOPY, - bool useMask=FALSE) + wxDC *source, + const wxPoint& srcPt, + int rop = wxCOPY, + bool useMask=FALSE) { return Blit(destPt.x, destPt.y, sz.x, sz.y, source, srcPt.x, srcPt.y, rop, useMask); } @@ -177,49 +177,49 @@ public: DrawText(text, pt.x, pt.y, use16bit); } virtual bool CanGetTextExtent(void) const = 0; - virtual void GetTextExtent( const wxString &string, + virtual void GetTextExtent( const wxString &string, long *width, long *height, - long *descent = (long *) NULL, - long *externalLeading = (long *) NULL, - wxFont *theFont = (wxFont *) NULL, - bool use16 = FALSE ) = 0; + long *descent = (long *) NULL, + long *externalLeading = (long *) NULL, + wxFont *theFont = (wxFont *) NULL, + bool use16 = FALSE ) = 0; virtual long GetCharWidth(void) = 0; virtual long GetCharHeight(void) = 0; - + virtual void Clear() = 0; - + virtual void SetFont( const wxFont &font ) = 0; - virtual wxFont *GetFont() { return &m_font; }; - + virtual const wxFont& GetFont() const { return m_font; }; + virtual void SetPen( const wxPen &pen ) = 0; - virtual wxPen *GetPen() { return &m_pen; }; - + virtual const wxPen& GetPen() const { return m_pen; }; + virtual void SetBrush( const wxBrush &brush ) = 0; - virtual wxBrush *GetBrush() { return &m_brush; }; + virtual const wxBrush& GetBrush() const { return m_brush; }; virtual void SetBackground( const wxBrush &brush ) = 0; - virtual wxBrush *GetBackground() { return &m_backgroundBrush; }; + virtual const wxBrush& GetBackground() const { return m_backgroundBrush; }; virtual void SetLogicalFunction( int function ) = 0; virtual int GetLogicalFunction() { return m_logicalFunction; }; - + virtual void SetTextForeground( const wxColour &col ); virtual void SetTextBackground( const wxColour &col ); virtual wxColour& GetTextBackground() const { return (wxColour&)m_textBackgroundColour; }; virtual wxColour& GetTextForeground() const { return (wxColour&)m_textForegroundColour; }; - + virtual void SetBackgroundMode( int mode ) = 0; virtual int GetBackgroundMode() { return m_backgroundMode; }; - + virtual void SetPalette( const wxPalette& palette ) = 0; void SetColourMap( const wxPalette& palette ) { SetPalette(palette); }; - + // the first two must be overridden and called virtual void DestroyClippingRegion(void); virtual void SetClippingRegion( long x, long y, long width, long height ); virtual void GetClippingBox( long *x, long *y, long *width, long *height ) const; virtual void SetClippingRegion( const wxRegion ®ion ) = 0; - + virtual long MinX() const { return m_minX; } virtual long MaxX() const { return m_maxX; } virtual long MinY() const { return m_minY; } @@ -228,30 +228,30 @@ public: virtual void GetSize( int* width, int* height ) const; inline wxSize GetSize(void) const { int w, h; GetSize(&w, &h); return wxSize(w, h); } virtual void GetSizeMM( long* width, long* height ) const; - + virtual bool StartDoc( const wxString& WXUNUSED(message) ) { return TRUE; } virtual void EndDoc() {} virtual void StartPage() {} virtual void EndPage() {} - + virtual void SetMapMode( int mode ); virtual int GetMapMode(void) const { return m_mappingMode; }; - + virtual void SetUserScale( double x, double y ); virtual void GetUserScale( double *x, double *y ); virtual void SetLogicalScale( double x, double y ); virtual void GetLogicalScale( double *x, double *y ); - + virtual void SetLogicalOrigin( long x, long y ); virtual void GetLogicalOrigin( long *x, long *y ); virtual void SetDeviceOrigin( long x, long y ); virtual void GetDeviceOrigin( long *x, long *y ); virtual void SetAxisOrientation( bool xLeftRight, bool yBottomUp ); - + virtual void SetOptimization( bool WXUNUSED(optimize) ) {} virtual bool GetOptimization() { return m_optimize; } - + virtual long DeviceToLogicalX(long x) const; virtual long DeviceToLogicalY(long y) const; virtual long DeviceToLogicalXRel(long x) const; @@ -262,77 +262,77 @@ public: virtual long LogicalToDeviceYRel(long y) const; // implementation - + void CalcBoundingBox( long x, long y ); void ComputeScaleAndOrigin(); - + long XDEV2LOG(long x) const - { - long new_x = x - m_deviceOriginX; - if (new_x > 0) - return (long)((double)(new_x) / m_scaleX + 0.5) * m_signX + m_logicalOriginX; - else - return (long)((double)(new_x) / m_scaleX - 0.5) * m_signX + m_logicalOriginX; - } + { + long new_x = x - m_deviceOriginX; + if (new_x > 0) + return (long)((double)(new_x) / m_scaleX + 0.5) * m_signX + m_logicalOriginX; + else + return (long)((double)(new_x) / m_scaleX - 0.5) * m_signX + m_logicalOriginX; + } long XDEV2LOGREL(long x) const - { - if (x > 0) - return (long)((double)(x) / m_scaleX + 0.5); - else - return (long)((double)(x) / m_scaleX - 0.5); - } + { + if (x > 0) + return (long)((double)(x) / m_scaleX + 0.5); + else + return (long)((double)(x) / m_scaleX - 0.5); + } long YDEV2LOG(long y) const - { - long new_y = y - m_deviceOriginY; - if (new_y > 0) - return (long)((double)(new_y) / m_scaleY + 0.5) * m_signY + m_logicalOriginY; - else - return (long)((double)(new_y) / m_scaleY - 0.5) * m_signY + m_logicalOriginY; - } + { + long new_y = y - m_deviceOriginY; + if (new_y > 0) + return (long)((double)(new_y) / m_scaleY + 0.5) * m_signY + m_logicalOriginY; + else + return (long)((double)(new_y) / m_scaleY - 0.5) * m_signY + m_logicalOriginY; + } long YDEV2LOGREL(long y) const - { - if (y > 0) - return (long)((double)(y) / m_scaleY + 0.5); - else - return (long)((double)(y) / m_scaleY - 0.5); - } + { + if (y > 0) + return (long)((double)(y) / m_scaleY + 0.5); + else + return (long)((double)(y) / m_scaleY - 0.5); + } long XLOG2DEV(long x) const - { - long new_x = x - m_logicalOriginX; - if (new_x > 0) - return (long)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX; - else - return (long)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX; - } + { + long new_x = x - m_logicalOriginX; + if (new_x > 0) + return (long)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX; + else + return (long)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX; + } long XLOG2DEVREL(long x) const - { - if (x > 0) - return (long)((double)(x) * m_scaleX + 0.5); - else - return (long)((double)(x) * m_scaleX - 0.5); - } + { + if (x > 0) + return (long)((double)(x) * m_scaleX + 0.5); + else + return (long)((double)(x) * m_scaleX - 0.5); + } long YLOG2DEV(long y) const - { - long new_y = y - m_logicalOriginY; - if (new_y > 0) - return (long)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY; - else - return (long)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY; - } + { + long new_y = y - m_logicalOriginY; + if (new_y > 0) + return (long)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY; + else + return (long)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY; + } long YLOG2DEVREL(long y) const - { - if (y > 0) - return (long)((double)(y) * m_scaleY + 0.5); - else - return (long)((double)(y) * m_scaleY - 0.5); - } - - + { + if (y > 0) + return (long)((double)(y) * m_scaleY + 0.5); + else + return (long)((double)(y) * m_scaleY - 0.5); + } + + public: - + bool m_ok; bool m_colour; - + // not sure, what these mean bool m_clipping; // Is clipping on right now ? bool m_isInteractive; // Is GetPixel possible ? @@ -340,36 +340,36 @@ public: bool m_dontDelete; // wxMSW only ? bool m_optimize; // wxMSW only ? wxString m_filename; // Not sure where this belongs. - + wxPen m_pen; wxBrush m_brush; wxBrush m_backgroundBrush; wxColour m_textForegroundColour; wxColour m_textBackgroundColour; wxFont m_font; - + int m_logicalFunction; int m_backgroundMode; int m_textAlignment; // gone in wxWin 2.0 ? - + int m_mappingMode; - + // not sure what for, but what is a mm on a screen you don't know the size of? - double m_mm_to_pix_x,m_mm_to_pix_y; - - long m_deviceOriginX,m_deviceOriginY; - + double m_mm_to_pix_x,m_mm_to_pix_y; + + long m_deviceOriginX,m_deviceOriginY; + long m_logicalOriginX,m_logicalOriginY; // User defined. double m_scaleX,m_scaleY; double m_logicalScaleX,m_logicalScaleY; double m_userScaleX,m_userScaleY; long m_signX,m_signY; - + bool m_needComputeScaleX,m_needComputeScaleY; // not yet used - + float m_scaleFactor; // wxPSDC wants to have this. Will disappear. - + long m_clipX1,m_clipY1,m_clipX2,m_clipY2; long m_minX,m_maxX,m_minY,m_maxY; }; diff --git a/include/wx/gtk1/dcclient.h b/include/wx/gtk1/dcclient.h index 9a46663029..4f4999affb 100644 --- a/include/wx/gtk1/dcclient.h +++ b/include/wx/gtk1/dcclient.h @@ -4,7 +4,7 @@ // Author: Robert Roebling // Id: $Id$ // Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -37,9 +37,9 @@ class wxWindowDC: public wxDC public: wxWindowDC(); wxWindowDC( wxWindow *win ); - + ~wxWindowDC(); - + virtual void FloodFill( long x, long y, const wxColour& col, int style=wxFLOOD_SURFACE ); virtual bool GetPixel( long x1, long y1, wxColour *col ) const; @@ -48,18 +48,18 @@ public: virtual void DrawArc( long x1, long y1, long x2, long y2, double xc, double yc ); virtual void DrawEllipticArc( long x, long y, long width, long height, double sa, double ea ); virtual void DrawPoint( long x, long y ); - + virtual void DrawLines( int n, wxPoint points[], long xoffset = 0, long yoffset = 0 ); virtual void DrawLines( wxList *points, long xoffset = 0, long yoffset = 0 ); - virtual void DrawPolygon( int n, wxPoint points[], long xoffset = 0, long yoffset = 0, + virtual void DrawPolygon( int n, wxPoint points[], long xoffset = 0, long yoffset = 0, int fillStyle=wxODDEVEN_RULE ); - virtual void DrawPolygon( wxList *lines, long xoffset = 0, long yoffset = 0, + virtual void DrawPolygon( wxList *lines, long xoffset = 0, long yoffset = 0, int fillStyle=wxODDEVEN_RULE ); - + virtual void DrawRectangle( long x, long y, long width, long height ); virtual void DrawRoundedRectangle( long x, long y, long width, long height, double radius = 20.0 ); virtual void DrawEllipse( long x, long y, long width, long height ); - + virtual bool CanDrawBitmap() const; virtual void DrawIcon( const wxIcon &icon, long x, long y ); virtual void DrawBitmap( const wxBitmap &bitmap, long x, long y, bool useMask=FALSE ); @@ -73,9 +73,9 @@ public: wxFont *theFont = (wxFont *) NULL, bool use16 = FALSE ); virtual long GetCharWidth(); virtual long GetCharHeight(); - + virtual void Clear(); - + virtual void SetFont( const wxFont &font ); virtual void SetPen( const wxPen &pen ); virtual void SetBrush( const wxBrush &brush ); @@ -85,15 +85,15 @@ public: virtual void SetTextBackground( const wxColour &col ); virtual void SetBackgroundMode( int mode ); virtual void SetPalette( const wxPalette& palette ); - + virtual void SetClippingRegion( long x, long y, long width, long height ); virtual void DestroyClippingRegion(); virtual void SetClippingRegion( const wxRegion ®ion ); - + virtual void DrawSpline( wxList *points ); - + // implementation - + GdkWindow *m_window; GdkGC *m_penGC; GdkGC *m_brushGC; @@ -101,7 +101,7 @@ public: GdkGC *m_bgGC; GdkColormap *m_cmap; bool m_isMemDC; - + void SetUpDC(); void Destroy(); GdkWindow *GetWindow(); diff --git a/include/wx/gtk1/dcmemory.h b/include/wx/gtk1/dcmemory.h index 10d0f2905f..ea4a1f1571 100644 --- a/include/wx/gtk1/dcmemory.h +++ b/include/wx/gtk1/dcmemory.h @@ -4,7 +4,7 @@ // Author: Robert Roebling // RCS-ID: $Id$ // Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -39,8 +39,8 @@ public: virtual void SelectObject( const wxBitmap& bitmap ); void GetSize( int *width, int *height ) const; - // implementation - + // implementation + wxBitmap m_selected; }; diff --git a/include/wx/gtk1/dcps.h b/include/wx/gtk1/dcps.h index 8d0ccedc11..f996001cb8 100644 --- a/include/wx/gtk1/dcps.h +++ b/include/wx/gtk1/dcps.h @@ -82,7 +82,7 @@ public: void DrawIcon( const wxIcon& icon, long x, long y ); void DrawBitmap( const wxBitmap& bitmap, long x, long y, bool useMask=FALSE ); - + void DrawText(const wxString& text, long x, long y, bool use16 = FALSE); void Clear(); @@ -91,7 +91,7 @@ public: void SetBrush( const wxBrush& brush ); void SetLogicalFunction( int function ); void SetBackground( const wxBrush& brush ); - + void SetClippingRegion(long x, long y, long width, long height); void SetClippingRegion( const wxRegion ®ion ); void DestroyClippingRegion(); @@ -108,16 +108,16 @@ public: long *descent = (long *) NULL, long *externalLeading = (long *) NULL, wxFont *theFont = (wxFont *) NULL, bool use16 = FALSE); - + void GetSize(int* width, int* height) const; void GetSizeMM(long *width, long *height) const; void SetAxisOrientation( bool xLeftRight, bool yBottomUp ); void SetDeviceOrigin( long x, long y ); - + inline void SetBackgroundMode(int WXUNUSED(mode)) {} inline void SetPalette(const wxPalette& WXUNUSED(palette)) {} - + inline ofstream *GetStream(void) const { return m_pstream; } protected: @@ -133,7 +133,7 @@ protected: double m_underlineThickness; }; -#endif +#endif // wxUSE_POSTSCRIPT #endif diff --git a/include/wx/gtk1/font.h b/include/wx/gtk1/font.h index bd34c91791..becbfb1eeb 100644 --- a/include/wx/gtk1/font.h +++ b/include/wx/gtk1/font.h @@ -4,7 +4,7 @@ // Author: Robert Roebling // Id: $Id$ // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -42,40 +42,39 @@ class wxFontNameDirectory; // wxFont //----------------------------------------------------------------------------- -class wxFont: public wxGDIObject +class wxFont: public wxGDIObject { DECLARE_DYNAMIC_CLASS(wxFont) - + public: - wxFont(void); + wxFont(); wxFont( int PointSize, int FontIdOrFamily, int Style, int Weight, - bool underlined = FALSE, const char *Face= ( const char *) NULL ); - wxFont( int PointSize, const char *Face, int Family, int Style, int Weight, - bool underlined = FALSE ); + bool underlined = FALSE, const char *Face = ( const char *) NULL ); + wxFont( int PointSize, const char *Face, int Family, + int Style, int Weight, bool underlined = FALSE ); wxFont( const wxFont& font ); - wxFont( const wxFont* font ); - ~wxFont(void); + ~wxFont(); wxFont& operator = ( const wxFont& font ); bool operator == ( const wxFont& font ); bool operator != ( const wxFont& font ); bool Ok() const; - int GetPointSize(void) const; - wxString GetFaceName(void) const; - int GetFamily(void) const; - wxString GetFamilyString(void) const; - int GetFontId(void) const; - wxString GetFaceString(void) const; - int GetStyle(void) const; - wxString GetStyleString(void) const; - int GetWeight(void) const; - wxString GetWeightString(void) const; - bool GetUnderlined(void) const; + int GetPointSize() const; + wxString GetFaceName() const; + int GetFamily() const; + wxString GetFamilyString() const; + int GetFontId() const; + wxString GetFaceString() const; + int GetStyle() const; + wxString GetStyleString() const; + int GetWeight() const; + wxString GetWeightString() const; + bool GetUnderlined() const; wxFont( char *xFontName ); - // implementation - + // implementation + GdkFont* GetInternalFont(float scale = 1.0) const; // no data :-) @@ -85,15 +84,15 @@ class wxFont: public wxGDIObject // wxFontDirectory //----------------------------------------------------------------------------- -class wxFontNameDirectory: public wxObject +class wxFontNameDirectory: public wxObject { DECLARE_DYNAMIC_CLASS(wxFontNameDirectory) - + public: - wxFontNameDirectory(void); + wxFontNameDirectory(); ~wxFontNameDirectory(); - void Initialize(void); + void Initialize(); void Initialize(int fontid, int family, const char *name); int FindOrCreateFontId(const char *name, int family); @@ -101,11 +100,10 @@ class wxFontNameDirectory: public wxObject int GetFamily(int fontid); int GetFontId(const char *name); char* GetFontName(int fontid); - int GetNewFontId(void); + int GetNewFontId(); char* GetPostScriptName(int fontid, int weight, int style); char* GetScreenName(int fontid, int weight, int style); - - + class wxHashTable *table; int nextFontId; }; diff --git a/include/wx/gtk1/icon.h b/include/wx/gtk1/icon.h index 2b54f60c05..4f0a9b5324 100644 --- a/include/wx/gtk1/icon.h +++ b/include/wx/gtk1/icon.h @@ -4,7 +4,7 @@ // Author: Robert Roebling // Id: $Id$ // Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -35,9 +35,8 @@ class wxIcon: public wxBitmap public: - wxIcon(void); + wxIcon(); wxIcon( const wxIcon& icon); - wxIcon( const wxIcon* icon); wxIcon( const char **bits, int width=-1, int height=-1 ); wxIcon( char **bits, int width=-1, int height=-1 ); diff --git a/include/wx/gtk1/menuitem.h b/include/wx/gtk1/menuitem.h index 99c0a659d6..77f08d493e 100644 --- a/include/wx/gtk1/menuitem.h +++ b/include/wx/gtk1/menuitem.h @@ -50,7 +50,9 @@ public: // the item's text = name void SetName(const wxString& str); + void SetText(const wxString& str) { SetName(str); } // compatibility const wxString& GetName() const { return m_text; } + const wxString& GetText() const { return GetName(); } // what kind of menu item we are void SetCheckable(bool checkable) { m_isCheckMenu = checkable; } @@ -60,7 +62,7 @@ public: bool IsSubMenu() const { return m_subMenu != NULL; } // state - void Enable( bool enable = TRUE ); + void Enable( bool enable = TRUE ); bool IsEnabled() const { return m_isEnabled; } void Check( bool check = TRUE ); bool IsChecked() const; @@ -86,5 +88,5 @@ private: }; -#endif +#endif //__GTKMENUITEMH__ diff --git a/include/wx/gtk1/palette.h b/include/wx/gtk1/palette.h index d6b7bbb64b..8574526cb3 100644 --- a/include/wx/gtk1/palette.h +++ b/include/wx/gtk1/palette.h @@ -5,7 +5,7 @@ // Created: 01/02/97 // Id: // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -36,17 +36,16 @@ class wxPalette: public wxGDIObject DECLARE_DYNAMIC_CLASS(wxPalette) public: - - wxPalette(void); + + wxPalette(); wxPalette( int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue ); wxPalette( const wxPalette& palette ); - wxPalette( const wxPalette* palette ); - ~wxPalette(void); + ~wxPalette(); wxPalette& operator = ( const wxPalette& palette ); bool operator == ( const wxPalette& palette ); bool operator != ( const wxPalette& palette ); - bool Ok(void) const; - + bool Ok() const; + bool Create( int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue); int GetPixel( const unsigned char red, const unsigned char green, const unsigned char blue ) const; bool GetRGB( int pixel, unsigned char *red, unsigned char *green, unsigned char *blue ) const; diff --git a/include/wx/gtk1/pen.h b/include/wx/gtk1/pen.h index 10ccf5e962..fb37103370 100644 --- a/include/wx/gtk1/pen.h +++ b/include/wx/gtk1/pen.h @@ -4,7 +4,7 @@ // Author: Robert Roebling // Id: $Id$ // Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -36,31 +36,30 @@ class wxPen: public wxGDIObject DECLARE_DYNAMIC_CLASS(wxPen) public: - - wxPen(void); + + wxPen(); wxPen( const wxColour &colour, int width, int style ); wxPen( const wxPen& pen ); - wxPen( const wxPen* pen ); - ~wxPen(void); + ~wxPen(); wxPen& operator = ( const wxPen& pen ); bool operator == ( const wxPen& pen ); bool operator != ( const wxPen& pen ); - + void SetColour( const wxColour &colour ); void SetColour( int red, int green, int blue ); void SetCap( int capStyle ); void SetJoin( int joinStyle ); void SetStyle( int style ); void SetWidth( int width ); - wxColour &GetColour(void) const; - int GetCap(void) const; - int GetJoin(void) const; - int GetStyle(void) const; - int GetWidth(void) const; - bool Ok(void) const; - - void Unshare(void); - + wxColour &GetColour() const; + int GetCap() const; + int GetJoin() const; + int GetStyle() const; + int GetWidth() const; + bool Ok() const; + + void Unshare(); + // no data :-) }; diff --git a/include/wx/gtk1/window.h b/include/wx/gtk1/window.h index 21a177b91d..bfa2607235 100644 --- a/include/wx/gtk1/window.h +++ b/include/wx/gtk1/window.h @@ -83,7 +83,7 @@ public: wxStringClientData( wxString &data ) { m_data = data; } void SetData( wxString &data ) { m_data = data; } wxString GetData() const { return m_data; } - + private: wxString m_data; }; @@ -95,7 +95,7 @@ private: class wxWindow: public wxEvtHandler { DECLARE_DYNAMIC_CLASS(wxWindow) - + public: wxWindow(); wxWindow(wxWindow *parent, wxWindowID id, @@ -110,7 +110,7 @@ public: const wxString& name = wxPanelNameStr); virtual ~wxWindow(); - virtual bool LoadFromResource( wxWindow *parent, const wxString& resourceName, + 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); @@ -155,7 +155,8 @@ public: virtual bool OnClose(); virtual void AddChild( wxWindow *child ); - wxList& GetChildren() const; + wxList& GetChildren() { return m_children; } + virtual void RemoveChild( wxWindow *child ); void SetReturnCode( int retCode ); int GetReturnCode(); @@ -167,7 +168,7 @@ public: { m_parent = p; } virtual wxWindow *ReParent( wxWindow *newParent ); - wxEvtHandler *GetEventHandler(); + wxEvtHandler *GetEventHandler() const; void SetEventHandler( wxEvtHandler *handler ); void PushEventHandler( wxEvtHandler *handler ); wxEvtHandler *PopEventHandler( bool deleteHandler = FALSE ); @@ -177,23 +178,23 @@ public: virtual void SetClientObject( wxClientData *data ); virtual wxClientData *GetClientObject(); - + virtual void SetClientData( void *data ); virtual void *GetClientData(); - + virtual void SetAcceleratorTable( const wxAcceleratorTable& accel ); virtual wxAcceleratorTable *GetAcceleratorTable() { return &m_acceleratorTable; } - + bool IsBeingDeleted(); void SetId( wxWindowID id ); - wxWindowID GetId(); + wxWindowID GetId() const; void SetCursor( const wxCursor &cursor ); 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; @@ -213,20 +214,20 @@ public: const wxFont *theFont = (const wxFont *) NULL, bool use16 = FALSE) const; virtual void SetFont( const wxFont &font ); - virtual wxFont *GetFont(); - + virtual const wxFont& GetFont() { return m_font; } + // For backward compatibility inline virtual void SetButtonFont(const wxFont& font) { SetFont(font); } inline virtual void SetLabelFont(const wxFont& font) { SetFont(font); } - inline virtual wxFont *GetLabelFont() { return GetFont(); }; - inline virtual wxFont *GetButtonFont() { return GetFont(); }; - + inline virtual const wxFont& GetLabelFont() { return GetFont(); }; + inline virtual const wxFont& GetButtonFont() { return GetFont(); }; + virtual void SetWindowStyleFlag( long flag ); virtual long GetWindowStyleFlag() const; - + virtual void CaptureMouse(); virtual void ReleaseMouse(); - + virtual void SetTitle( const wxString &title ); virtual wxString GetTitle() const; virtual void SetName( const wxString &name ); @@ -243,10 +244,10 @@ public: virtual bool IsRetained(); virtual wxWindow *FindWindow( long id ); virtual wxWindow *FindWindow( const wxString& name ); - + void AllowDoubleClick( bool WXUNUSED(allow) ) {}; void SetDoubleClick( bool WXUNUSED(allow) ) {}; - + virtual void ClientToScreen( int *x, int *y ); virtual void ScreenToClient( int *x, int *y ); @@ -270,27 +271,27 @@ public: virtual void ScrollWindow( int dx, int dy, const wxRect* rect = (wxRect *) NULL ); virtual bool AcceptsFocus() const; - + void UpdateWindowUI(); // implementation - + void PreCreation( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style, const wxString &name ); void PostCreation(); virtual GtkWidget *GetConnectWidget(); virtual bool IsOwnGtkWindow( GdkWindow *window ); void ConnectWidget( GtkWidget *widget ); - + bool HasVMT(); - + virtual wxPoint GetClientAreaOrigin() const; virtual void AdjustForParentClientOrigin( int& x, int& y, int sizeFlags ); GtkStyle *GetWidgetStyle(); void SetWidgetStyle(); virtual void ApplyWidgetStyle(); - + wxWindow *m_parent; wxList m_children; @@ -329,7 +330,7 @@ public: bool m_resizing; GdkGC *m_scrollGC; GtkStyle *m_widgetStyle; - + wxInsertChildFunction m_insertCallback; public: diff --git a/samples/dnd/dnd.cpp b/samples/dnd/dnd.cpp index e3900dffe3..9b6bd0cec9 100644 --- a/samples/dnd/dnd.cpp +++ b/samples/dnd/dnd.cpp @@ -4,9 +4,9 @@ // Author: Vadim Zeitlin // Modified by: // Created: 04/01/98 -// RCS-ID: +// RCS-ID: $Id$ // Copyright: -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #include "wx/wxprec.h" @@ -59,7 +59,7 @@ private: // Define a new application type // ---------------------------------------------------------------------------- class DnDApp : public wxApp -{ +{ public: bool OnInit(); }; @@ -70,7 +70,7 @@ IMPLEMENT_APP(DnDApp); // Define a new frame type // ---------------------------------------------------------------------------- class DnDFrame : public wxFrame -{ +{ public: DnDFrame(wxFrame *frame, char *title, int x, int y, int w, int h); ~DnDFrame(); @@ -84,9 +84,9 @@ public: void OnLeftDown(wxMouseEvent& event); void OnRightDown(wxMouseEvent& event); - + bool OnClose(); - + DECLARE_EVENT_TABLE() private: @@ -123,10 +123,10 @@ BEGIN_EVENT_TABLE(DnDFrame, wxFrame) END_EVENT_TABLE() // `Main program' equivalent, creating windows and returning main app frame -bool DnDApp::OnInit(void) +bool DnDApp::OnInit() { // create the main frame window - DnDFrame *frame = new DnDFrame((wxFrame *) NULL, "Drag & Drop wxWindows App", + DnDFrame *frame = new DnDFrame((wxFrame *) NULL, "Drag & Drop wxWindows App", 50, 50, 450, 340); // activate it @@ -145,7 +145,7 @@ DnDFrame::DnDFrame(wxFrame *frame, char *title, int x, int y, int w, int h) // frame icon and status bar SetIcon(wxICON(mondrian)); - + // const int widths[] = { -1 }; CreateStatusBar(); @@ -169,7 +169,7 @@ DnDFrame::DnDFrame(wxFrame *frame, char *title, int x, int y, int w, int h) menu_bar->Append(help_menu, "&Help"); SetMenuBar(menu_bar); - + // make a panel with 3 subwindows wxPoint pos(0, 0); wxSize size(400, 200); @@ -179,8 +179,8 @@ DnDFrame::DnDFrame(wxFrame *frame, char *title, int x, int y, int w, int h) m_ctrlFile = new wxListBox(this, -1, pos, size, 1, &strFile, wxLB_HSCROLL); m_ctrlText = new wxListBox(this, -1, pos, size, 1, &strText, wxLB_HSCROLL); - m_ctrlLog = new wxTextCtrl(this, -1, "", pos, size, - wxTE_MULTILINE | wxTE_READONLY | + m_ctrlLog = new wxTextCtrl(this, -1, "", pos, size, + wxTE_MULTILINE | wxTE_READONLY | wxSUNKEN_BORDER| wxHSCROLL); // redirect log messages to the text window (don't forget to delete it!) @@ -189,14 +189,14 @@ DnDFrame::DnDFrame(wxFrame *frame, char *title, int x, int y, int w, int h) // associate drop targets with 2 text controls m_ctrlFile->SetDropTarget(new DnDFile(m_ctrlFile)); - m_ctrlText->SetDropTarget(new DnDText(m_ctrlText)); + m_ctrlText->SetDropTarget(new DnDText(m_ctrlText)); wxLayoutConstraints *c; // Top-left listbox c = new wxLayoutConstraints; - c->left.SameAs (this, wxLeft); - c->top.SameAs (this, wxTop); + c->left.SameAs(this, wxLeft); + c->top.SameAs(this, wxTop); c->right.PercentOf(this, wxRight, 50); c->height.PercentOf(this, wxHeight, 40); m_ctrlFile->SetConstraints(c); @@ -230,7 +230,7 @@ void DnDFrame::OnPaint(wxPaintEvent& /*event*/) int w = 0; int h = 0; GetClientSize( &w, &h ); - + wxPaintDC dc(this); dc.SetFont( wxFont( 24, wxDECORATIVE, wxNORMAL, wxNORMAL ) ); dc.DrawText( "Drag text from here!", 20, h-20 ); @@ -252,7 +252,7 @@ void DnDFrame::OnDrag(wxCommandEvent& /* event */) void DnDFrame::OnAbout(wxCommandEvent& /* event */) { - wxMessageDialog dialog(this, + wxMessageDialog dialog(this, "Drag-&-Drop Demo\n" "Please see \"Help|Help...\" for details\n" "Copyright (c) 1998 Vadim Zeitlin", @@ -263,22 +263,22 @@ void DnDFrame::OnAbout(wxCommandEvent& /* event */) void DnDFrame::OnHelp(wxCommandEvent& /* event */) { - wxMessageDialog dialog(this, + wxMessageDialog dialog(this, "This small program demonstrates drag & drop support in wxWindows. The program window\n" "consists of 3 parts: the bottom pane is for debug messages, so that you can see what's\n" -"going on inside. The top part is split into 2 listboxes, the left one accepts files\n" +"going on inside. The top part is split into 2 listboxes, the left one accepts files\n" "and the right one accepts text.\n" "\n" -"To test wxDropTarget: open wordpad (write.exe), select some text in it and drag it to\n" -"the right listbox (you'll notice the usual visual feedback, i.e. the cursor will change).\n" +"To test wxDropTarget: open wordpad (write.exe), select some text in it and drag it to\n" +"the right listbox (you'll notice the usual visual feedback, i.e. the cursor will change).\n" "Also, try dragging some files (you can select several at once) from Windows Explorer (or \n" "File Manager) to the left pane. Hold down Ctrl/Shift keys when you drop text (doesn't \n" "work with files) and see what changes.\n" "\n" -"To test wxDropSource: just press any mouse button on the empty zone of the window and drag\n" +"To test wxDropSource: just press any mouse button on the empty zone of the window and drag\n" "it to wordpad or any other droptarget accepting text (and of course you can just drag it\n" "to the right pane). Due to a lot of trace messages, the cursor might take some time to \n" -"change, don't release the mouse button until it does. You can change the string being\n" +"change, don't release the mouse button until it does. You can change the string being\n" "dragged in in \"File|Test drag...\" dialog.\n" "\n" "\n" @@ -291,19 +291,19 @@ void DnDFrame::OnHelp(wxCommandEvent& /* event */) void DnDFrame::OnLogClear(wxCommandEvent& /* event */ ) { -// m_ctrlLog->Clear(); + m_ctrlLog->Clear(); } -bool DnDFrame::OnClose() -{ - return TRUE; +bool DnDFrame::OnClose() +{ + return TRUE; } void DnDFrame::OnLeftDown(wxMouseEvent &WXUNUSED(event) ) { if ( !m_strText.IsEmpty() ) { // start drag operation - + wxTextDataObject data(m_strText); wxDropSource dragSource(data, this); const char *pc; @@ -324,11 +324,11 @@ void DnDFrame::OnLeftDown(wxMouseEvent &WXUNUSED(event) ) void DnDFrame::OnRightDown(wxMouseEvent &event ) { wxMenu *menu = new wxMenu; - + menu->Append(Menu_Drag, "&Test drag..."); menu->Append(Menu_About, "&About"); menu->Append(Menu_Quit, "E&xit"); - + PopupMenu( menu, event.GetX(), event.GetY() ); } @@ -350,7 +350,7 @@ bool DnDText::OnDropText(long, long, const char *psz) return TRUE; } -bool DnDFile::OnDropFiles(long, long, size_t nFiles, +bool DnDFile::OnDropFiles(long, long, size_t nFiles, const char * const aszFiles[]) { wxString str; diff --git a/samples/toolbar/test.cpp b/samples/toolbar/test.cpp index 9b4b9434e2..69bbfe4173 100644 --- a/samples/toolbar/test.cpp +++ b/samples/toolbar/test.cpp @@ -21,6 +21,8 @@ #endif #include "wx/toolbar.h" +#include + #include "test.h" #if defined(__WXGTK__) || defined(__WXMOTIF__) @@ -38,7 +40,6 @@ IMPLEMENT_APP(MyApp) - // The `main program' equivalent, creating the windows and returning the // main frame bool MyApp::OnInit(void) @@ -51,11 +52,7 @@ bool MyApp::OnInit(void) frame->CreateStatusBar(); // Give it an icon -#ifdef __WXMSW__ - frame->SetIcon(wxIcon("mondrian")); -#else - frame->SetIcon( wxIcon(mondrian_xpm) ); -#endif + frame->SetIcon(wxICON(mondrian)); // Make a menubar wxMenu *fileMenu = new wxMenu; @@ -92,8 +89,6 @@ bool MyApp::OnInit(void) bool MyApp::InitToolbar(wxToolBar* toolBar) { - toolBar->SetMargins(5, 5); - // Set up toolbar wxBitmap* toolBarBitmaps[8]; @@ -167,7 +162,7 @@ END_EVENT_TABLE() // Define my frame constructor MyFrame::MyFrame(wxFrame* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style): - wxFrame(parent, id, title, pos, size, style) + wxFrame(parent, id, title, pos, size, style), m_timer(this) { m_textWindow = new wxTextCtrl(this, -1, "", wxPoint(0, 0), wxSize(-1, -1), wxTE_MULTILINE); } @@ -179,7 +174,10 @@ void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) { - (void)wxMessageBox("wxWindows wxToolBar demo\n", "About wxToolBar"); +// (void)wxMessageBox("wxWindows wxToolBar demo\n", "About wxToolBar"); + wxLogStatus("Started timer."); + + m_timer.Start(500, TRUE); } // Define the behaviour for the frame closing diff --git a/samples/toolbar/test.h b/samples/toolbar/test.h index 4f2a12bb79..dcea766cb8 100644 --- a/samples/toolbar/test.h +++ b/samples/toolbar/test.h @@ -17,6 +17,17 @@ class MyApp: public wxApp bool InitToolbar(wxToolBar* toolBar); }; +class MyTimer : public wxTimer +{ +public: + MyTimer(wxFrame *frame) { m_frame = frame; } + + virtual void Notify() { wxLogStatus(m_frame, "Timer arrived!"); } + +private: + wxFrame *m_frame; +}; + // Define a new frame class MyFrame: public wxFrame { @@ -34,6 +45,8 @@ public: private: wxTextCtrl* m_textWindow; + MyTimer m_timer; + DECLARE_EVENT_TABLE() }; diff --git a/src/common/cmndata.cpp b/src/common/cmndata.cpp index e32e8a0b31..61cf2f3a54 100644 --- a/src/common/cmndata.cpp +++ b/src/common/cmndata.cpp @@ -6,7 +6,7 @@ // Created: 01/02/97 // RCS-ID: $Id$ // Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -50,7 +50,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxColourData, wxObject) * wxColourData */ -wxColourData::wxColourData(void) +wxColourData::wxColourData() { int i; for (i = 0; i < 16; i++) @@ -58,9 +58,9 @@ wxColourData::wxColourData(void) chooseFull = FALSE; dataColour.Set(0,0,0); -} +} -wxColourData::~wxColourData(void) +wxColourData::~wxColourData() { } @@ -94,7 +94,7 @@ void wxColourData::operator=(const wxColourData& data) * Font data */ -wxFontData::wxFontData(void) +wxFontData::wxFontData() { // Intialize colour to black. fontColour.Set(0, 0, 0); @@ -106,7 +106,7 @@ wxFontData::wxFontData(void) maxSize = 0; } -wxFontData::~wxFontData(void) +wxFontData::~wxFontData() { } @@ -126,7 +126,7 @@ void wxFontData::operator=(const wxFontData& data) * Print data */ -wxPrintData::wxPrintData(void) +wxPrintData::wxPrintData() { #ifdef __WXMSW__ printData = NULL; @@ -147,7 +147,7 @@ wxPrintData::wxPrintData(void) printSetupDialog = FALSE; } -wxPrintData::~wxPrintData(void) +wxPrintData::~wxPrintData() { #ifdef __WXMSW__ PRINTDLG *pd = (PRINTDLG *)printData; @@ -159,7 +159,7 @@ wxPrintData::~wxPrintData(void) } #ifdef __WXMSW__ -void wxPrintData::ConvertToNative(void) +void wxPrintData::ConvertToNative() { PRINTDLG *pd = (PRINTDLG*) printData; if ( pd == NULL ) @@ -174,8 +174,6 @@ void wxPrintData::ConvertToNative(void) pd->hDevMode = NULL; // Will be created by PrintDlg pd->hDevNames = NULL; // Ditto - // Why had I put this #ifdef in?? Seems fine to me. -#if 1 pd->Flags = PD_RETURNDEFAULT; pd->nCopies = 1; @@ -196,7 +194,6 @@ void wxPrintData::ConvertToNative(void) GlobalFree(pd->hDevNames); pd->hDevNames = NULL; } -#endif } if ( pd->hDevMode ) @@ -245,7 +242,7 @@ void wxPrintData::ConvertToNative(void) pd->Flags |= PD_PRINTSETUP; } -void wxPrintData::ConvertFromNative(void) +void wxPrintData::ConvertFromNative() { PRINTDLG *pd = (PRINTDLG*) printData; if ( pd == NULL ) @@ -308,7 +305,7 @@ void wxPrintData::operator=(const wxPrintData& data) * wxPageSetupData */ -wxPageSetupData::wxPageSetupData(void) +wxPageSetupData::wxPageSetupData() { #if defined(__WIN95__) m_pageSetupData = NULL; @@ -330,7 +327,7 @@ wxPageSetupData::wxPageSetupData(void) m_getDefaultInfo = FALSE; } -wxPageSetupData::~wxPageSetupData(void) +wxPageSetupData::~wxPageSetupData() { #if defined(__WIN95__) && defined(__WXMSW__) PAGESETUPDLG *pd = (PAGESETUPDLG *)m_pageSetupData; @@ -360,7 +357,7 @@ void wxPageSetupData::operator=(const wxPageSetupData& data) } #if defined(__WXMSW__) && defined(__WIN95__) -void wxPageSetupData::ConvertToNative(void) +void wxPageSetupData::ConvertToNative() { PAGESETUPDLG *pd = (PAGESETUPDLG*) m_pageSetupData; if ( m_pageSetupData == NULL ) @@ -369,7 +366,7 @@ void wxPageSetupData::ConvertToNative(void) pd->hDevMode = GlobalAlloc(GMEM_MOVEABLE, sizeof(DEVMODE)); m_pageSetupData = (void *)pd; } - + pd->Flags = PSD_MARGINS|PSD_MINMARGINS; if ( m_defaultMinMargins ) @@ -422,7 +419,7 @@ void wxPageSetupData::ConvertToNative(void) } } -void wxPageSetupData::ConvertFromNative(void) +void wxPageSetupData::ConvertFromNative() { PAGESETUPDLG *pd = (PAGESETUPDLG *) m_pageSetupData ; if ( !pd ) diff --git a/src/common/config.cpp b/src/common/config.cpp index 6a4eff0b33..1510e939a7 100644 --- a/src/common/config.cpp +++ b/src/common/config.cpp @@ -211,15 +211,14 @@ bool wxConfigBase::Write(const wxString& key, bool value) } wxString wxConfigBase::ExpandEnvVars(const wxString& str) const - { - wxString tmp; // Required for BC++ - if (IsExpandingEnvVars()) - tmp = wxExpandEnvVars(str); - else - tmp = str; - return tmp; - } - +{ + wxString tmp; // Required for BC++ + if (IsExpandingEnvVars()) + tmp = wxExpandEnvVars(str); + else + tmp = str; + return tmp; +} // ---------------------------------------------------------------------------- // wxConfigPathChanger @@ -410,5 +409,3 @@ void wxSplitPath(wxArrayString& aParts, const char *sz) pc++; } } - - diff --git a/src/common/fileconf.cpp b/src/common/fileconf.cpp index 79394e5f9b..92ca337641 100644 --- a/src/common/fileconf.cpp +++ b/src/common/fileconf.cpp @@ -111,9 +111,9 @@ wxString wxFileConfig::GetGlobalDir() wxString wxFileConfig::GetLocalDir() { wxString strDir; - + wxGetHomeDir(&strDir); - + #ifdef __UNIX__ if (strDir.Last() != '/') strDir << '/'; #else @@ -152,7 +152,7 @@ wxString wxFileConfig::GetLocalFileName(const char *szFile) if ( strchr(szFile, '.') == NULL ) str << ".ini"; #endif - + return str; } @@ -762,7 +762,7 @@ void wxFileConfig::LineListRemove(LineList *pLine) // last entry? if ( pNext == NULL ) m_linesTail = pPrev; - else + else pNext->SetPrev(pPrev); delete pLine; @@ -1328,7 +1328,7 @@ wxString FilterOut(const wxString& str) { if(str.IsEmpty()) return str; - + wxString strResult; strResult.Alloc(str.Len()); diff --git a/src/common/gdicmn.cpp b/src/common/gdicmn.cpp index 642c03c3ea..34df0496ce 100644 --- a/src/common/gdicmn.cpp +++ b/src/common/gdicmn.cpp @@ -6,7 +6,7 @@ // Created: 01/02/97 // RCS-ID: $Id$ // Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -72,13 +72,13 @@ wxRect::wxRect(const wxPoint& topLeft, const wxPoint& bottomRight) y = topLeft.y; width = bottomRight.x - topLeft.x; height = bottomRight.y - topLeft.y; - + if (width < 0) { width = -width; x -= width; } - + if (height < 0) { height = -height; @@ -94,9 +94,9 @@ wxRect::wxRect(const wxPoint& point, const wxSize& size) wxRect::wxRect(const wxRect& rect) { - x = rect.x; - y = rect.y; - width = rect.width; + x = rect.x; + y = rect.y; + width = rect.width; height = rect.height; } @@ -146,14 +146,14 @@ void wxColourDatabase::Initialize () // Don't initialize for X: colours are found // in FindColour below. // Added: Not all - + struct cdef { char *name; int r,g,b; }; cdef cc; static cdef table[]={ - + // #ifdef __WXMSW__ {"AQUAMARINE",112, 219, 147}, {"BLACK",0, 0, 0}, @@ -234,7 +234,7 @@ void wxColourDatabase::Initialize () {"LIGHT MAGENTA", 255, 0, 255}, {"MEDIUM GREY", 100, 100, 100}, #endif - + {0,0,0,0} }; int i; @@ -263,7 +263,7 @@ wxColour *wxColourDatabase::FindColour(const wxString& colour) wxNode *node = Find(str); if (node) return (wxColour *)node->Data(); - + #ifdef __WXMSW__ else return NULL; #endif @@ -277,7 +277,7 @@ wxColour *wxColourDatabase::FindColour(const wxString& colour) #ifdef __WXGTK__ else { wxColour *col = new wxColour( colour ); - + if (!(col->Ok())) { delete col; return (wxColour *) NULL; @@ -321,19 +321,19 @@ wxString wxColourDatabase::FindName (const wxColour& colour) const unsigned char red = colour.Red (); unsigned char green = colour.Green (); unsigned char blue = colour.Blue (); - + for (wxNode * node = First (); node; node = node->Next ()) { wxColour *col = (wxColour *) node->Data (); - + if (col->Red () == red && col->Green () == green && col->Blue () == blue) - { - const char *found = node->GetKeyString(); - if (found) - return wxString(found); - } + { + const char *found = node->GetKeyString(); + if (found) + return wxString(found); + } } - return wxString(""); // Not Found + return wxString(""); // Not Found } @@ -393,8 +393,7 @@ void wxInitializeStockObjects () wxCROSS_CURSOR = new wxCursor (wxCURSOR_CROSS); } -void -wxDeleteStockObjects () +void wxDeleteStockObjects () { wxDELETE(wxNORMAL_FONT); wxDELETE(wxSMALL_FONT); @@ -494,12 +493,12 @@ wxPen *wxPenList::FindOrCreatePen (const wxColour& colour, int width, int style) { wxPen *each_pen = (wxPen *) node->Data (); if (each_pen && each_pen->GetVisible() && - each_pen->GetWidth () == width && - each_pen->GetStyle () == style && - each_pen->GetColour ().Red () == colour.Red () && - each_pen->GetColour ().Green () == colour.Green () && - each_pen->GetColour ().Blue () == colour.Blue ()) - return each_pen; + each_pen->GetWidth () == width && + each_pen->GetStyle () == style && + each_pen->GetColour ().Red () == colour.Red () && + each_pen->GetColour ().Green () == colour.Green () && + each_pen->GetColour ().Blue () == colour.Blue ()) + return each_pen; } wxPen *pen = new wxPen (colour, width, style); @@ -537,11 +536,11 @@ wxBrush *wxBrushList::FindOrCreateBrush (const wxColour& colour, int style) { wxBrush *each_brush = (wxBrush *) node->Data (); if (each_brush && each_brush->GetVisible() && - each_brush->GetStyle () == style && - each_brush->GetColour ().Red () == colour.Red () && - each_brush->GetColour ().Green () == colour.Green () && - each_brush->GetColour ().Blue () == colour.Blue ()) - return each_brush; + each_brush->GetStyle () == style && + each_brush->GetColour ().Red () == colour.Red () && + each_brush->GetColour ().Green () == colour.Green () && + each_brush->GetColour ().Blue () == colour.Blue ()) + return each_brush; } // Yes, we can return a pointer to this in a later FindOrCreateBrush call, // because we created it within FindOrCreateBrush. Safeguards against @@ -562,14 +561,14 @@ wxFontList::~wxFontList () wxNode *node = First (); while (node) { - // Only delete objects that are 'visible', i.e. - // that have been created using FindOrCreate..., - // where the pointers are expected to be shared - // (and therefore not deleted by any one part of an app). + // Only delete objects that are 'visible', i.e. + // that have been created using FindOrCreate..., + // where the pointers are expected to be shared + // (and therefore not deleted by any one part of an app). wxFont *font = (wxFont *) node->Data (); wxNode *next = node->Next (); - if (font->GetVisible()) - delete font; + if (font->GetVisible()) + delete font; node = next; } } @@ -585,23 +584,23 @@ void wxFontList::RemoveFont (wxFont * font) } wxFont *wxFontList:: - FindOrCreateFont (int PointSize, int FamilyOrFontId, int Style, int Weight, bool underline, const wxString& Face) + FindOrCreateFont (int PointSize, int FamilyOrFontId, int Style, int Weight, bool underline, const wxString& Face) { for (wxNode * node = First (); node; node = node->Next ()) { wxFont *each_font = (wxFont *) node->Data (); if (each_font && each_font->GetVisible() && each_font->Ok() && - each_font->GetPointSize () == PointSize && - each_font->GetStyle () == Style && - each_font->GetWeight () == Weight && - each_font->GetUnderlined () == underline && - //#if defined(__X__) - // each_font->GetFontId () == FamilyOrFontId) /* New font system */ - //#else - each_font->GetFamily () == FamilyOrFontId && + each_font->GetPointSize () == PointSize && + each_font->GetStyle () == Style && + each_font->GetWeight () == Weight && + each_font->GetUnderlined () == underline && + //#if defined(__X__) + // each_font->GetFontId () == FamilyOrFontId) /* New font system */ + //#else + each_font->GetFamily () == FamilyOrFontId && (!each_font->GetFaceName() || each_font->GetFaceName() == Face)) - //#endif - return each_font; + //#endif + return each_font; } wxFont *font = new wxFont (PointSize, FamilyOrFontId, Style, Weight, underline, Face); font->SetVisible(TRUE); @@ -609,9 +608,14 @@ wxFont *wxFontList:: } void wxBitmapList::AddBitmap(wxBitmap *bitmap) -{ Append(bitmap); } +{ + Append(bitmap); +} + void wxBitmapList::RemoveBitmap(wxBitmap *bitmap) -{ DeleteObject(bitmap); } +{ + DeleteObject(bitmap); +} wxSize wxGetDisplaySize() { @@ -620,7 +624,8 @@ wxSize wxGetDisplaySize() return wxSize(x, y); } -wxResourceCache::~wxResourceCache () { +wxResourceCache::~wxResourceCache () +{ wxNode *node = First (); while (node) { wxGDIObject *item = (wxGDIObject *)node->Data(); diff --git a/src/common/resource.cpp b/src/common/resource.cpp index 21c1c97190..f31d3ae392 100644 --- a/src/common/resource.cpp +++ b/src/common/resource.cpp @@ -148,7 +148,7 @@ wxItemResource::~wxItemResource() /* * Resource table */ - + wxResourceTable::wxResourceTable():wxHashTable(wxKEY_STRING), identifiers(wxKEY_STRING) { } @@ -157,7 +157,7 @@ wxResourceTable::~wxResourceTable() { ClearTable(); } - + wxItemResource *wxResourceTable::FindResource(const wxString& name) const { wxItemResource *item = (wxItemResource *)Get((char *)(const char *)name); @@ -196,7 +196,7 @@ bool wxResourceTable::DeleteResource(const wxString& name) break; } } - + delete item; return TRUE; } @@ -588,7 +588,7 @@ wxItemResource *wxResourceInterpretDialog(wxResourceTable& table, wxExpr *expr, long windowStyle = wxDEFAULT_DIALOG_STYLE; if (isPanel) windowStyle = 0; - + int x = 0; int y = 0; int width = -1; int height = -1; int isModal = 0; wxExpr *labelFontExpr = (wxExpr *) NULL; @@ -632,7 +632,7 @@ wxItemResource *wxResourceInterpretDialog(wxResourceTable& table, wxExpr *expr, dialogItem->SetName(name); dialogItem->SetTitle(title); dialogItem->SetSize(x, y, width, height); - + if (backColourHex != "") { int r = 0; @@ -1033,7 +1033,7 @@ wxItemResource *wxResourceInterpretControl(wxResourceTable& table, wxExpr *expr) controlItem->SetValue4(str); count ++; - + wxExpr *valueList = (wxExpr *) NULL; // Check for default value list if ((valueList = expr->Nth(count)) && (valueList->Type() == PrologList)) @@ -1106,7 +1106,7 @@ wxItemResource *wxResourceInterpretControl(wxResourceTable& table, wxExpr *expr) return controlItem; } -// Forward declaration +// Forward declaration wxItemResource *wxResourceInterpretMenu1(wxResourceTable& table, wxExpr *expr); /* @@ -1116,7 +1116,7 @@ wxItemResource *wxResourceInterpretMenu1(wxResourceTable& table, wxExpr *expr); wxItemResource *wxResourceInterpretMenuItem(wxResourceTable& table, wxExpr *expr) { wxItemResource *item = new wxItemResource; - + wxExpr *labelExpr = expr->Nth(0); wxExpr *idExpr = expr->Nth(1); wxExpr *helpExpr = expr->Nth(2); @@ -1170,7 +1170,7 @@ wxItemResource *wxResourceInterpretMenuItem(wxResourceTable& table, wxExpr *expr wxExpr *subMenuExpr = expr->GetFirst(); while (subMenuExpr && (subMenuExpr->Type() != PrologList)) subMenuExpr = subMenuExpr->GetNext(); - + while (subMenuExpr) { wxItemResource *child = wxResourceInterpretMenuItem(table, subMenuExpr); @@ -1208,7 +1208,7 @@ wxItemResource *wxResourceInterpretMenu(wxResourceTable& table, wxExpr *expr) expr->GetAttributeValue("menu", &listExpr); if (!listExpr) return (wxItemResource *) NULL; - + wxItemResource *menuResource = wxResourceInterpretMenuItem(table, listExpr); if (!menuResource) @@ -1219,7 +1219,7 @@ wxItemResource *wxResourceInterpretMenu(wxResourceTable& table, wxExpr *expr) { menuResource->SetName(name); } - + return menuResource; } @@ -1233,7 +1233,7 @@ wxItemResource *wxResourceInterpretMenuBar(wxResourceTable& table, wxExpr *expr) wxItemResource *resource = new wxItemResource; resource->SetType("wxMenu"); // resource->SetType(wxTYPE_MENU); - + wxExpr *element = listExpr->GetFirst(); while (element) { @@ -1247,7 +1247,7 @@ wxItemResource *wxResourceInterpretMenuBar(wxResourceTable& table, wxExpr *expr) { resource->SetName(name); } - + return resource; } @@ -1301,7 +1301,7 @@ wxItemResource *wxResourceInterpretBitmap(wxResourceTable& WXUNUSED(table), wxEx } else bitmapSpec->SetValue1(0); - + if (platformExpr && platformExpr->StringValue()) { wxString plat(platformExpr->StringValue()); @@ -1326,14 +1326,14 @@ wxItemResource *wxResourceInterpretBitmap(wxResourceTable& WXUNUSED(table), wxEx if (yresExpr) yres = (int)yresExpr->IntegerValue(); bitmapSpec->SetSize(0, 0, xres, yres); - + bitmapItem->GetChildren().Append(bitmapSpec); } } } bitmapExpr = bitmapExpr->GetNext(); } - + return bitmapItem; } @@ -1362,7 +1362,7 @@ wxFont wxResourceInterpretFontSpec(wxExpr *expr) int weight = wxNORMAL; int underline = 0; wxString faceName(""); - + wxExpr *pointExpr = expr->Nth(0); wxExpr *familyExpr = expr->Nth(1); wxExpr *styleExpr = expr->Nth(2); @@ -1518,7 +1518,7 @@ bool wxGetResourceToken(FILE *fd) wxReallocateResourceBuffer(); wxResourceBuffer[wxResourceBufferCount] = (char)ch; wxResourceBufferCount ++; - + ch = getc(fd); } wxResourceBuffer[wxResourceBufferCount] = 0; @@ -1533,12 +1533,12 @@ bool wxGetResourceToken(FILE *fd) static char *name = "...."; with possible comments. */ - + bool wxResourceReadOneResource(FILE *fd, wxExprDatabase& db, bool *eof, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; - + // static or #define if (!wxGetResourceToken(fd)) { @@ -1566,7 +1566,7 @@ bool wxResourceReadOneResource(FILE *fd, wxExprDatabase& db, bool *eof, wxResour } delete[] name; delete[] value; - + return TRUE; } else if (strcmp(wxResourceBuffer, "#include") == 0) @@ -1609,7 +1609,7 @@ bool wxResourceReadOneResource(FILE *fd, wxExprDatabase& db, bool *eof, wxResour wxLogWarning(_("Expected 'char' whilst parsing resource.")); return FALSE; } - + // *name if (!wxGetResourceToken(fd)) { @@ -1625,7 +1625,7 @@ bool wxResourceReadOneResource(FILE *fd, wxExprDatabase& db, bool *eof, wxResour } char nameBuf[100]; strncpy(nameBuf, wxResourceBuffer+1, 99); - + // = if (!wxGetResourceToken(fd)) { @@ -1666,7 +1666,7 @@ bool wxResourceReadOneResource(FILE *fd, wxExprDatabase& db, bool *eof, wxResour /* * Parses string window style into integer window style */ - + /* * Style flag parsing, e.g. * "wxSYSTEM_MENU | wxBORDER" -> integer @@ -1722,13 +1722,13 @@ static wxResourceBitListStruct wxResourceBitListTable[] = { "wxLB_SORT", wxLB_SORT }, { "wxLB_OWNERDRAW", wxLB_OWNERDRAW }, { "wxLB_HSCROLL", wxLB_HSCROLL }, - + /* wxComboxBox */ { "wxCB_SIMPLE", wxCB_SIMPLE }, { "wxCB_DROPDOWN", wxCB_DROPDOWN }, { "wxCB_READONLY", wxCB_READONLY }, { "wxCB_SORT", wxCB_SORT }, - + /* wxGauge */ { "wxGA_PROGRESSBAR", wxGA_PROGRESSBAR }, { "wxGA_HORIZONTAL", wxGA_HORIZONTAL }, @@ -1815,7 +1815,7 @@ static wxResourceBitListStruct wxResourceBitListTable[] = { "wxALIGN_CENTRE", wxALIGN_CENTRE}, { "wxALIGN_RIGHT", wxALIGN_RIGHT}, { "wxCOLOURED", wxCOLOURED}, - + /* wxToolBar */ { "wxTB_3DBUTTONS", wxTB_3DBUTTONS}, { "wxTB_HORIZONTAL", wxTB_HORIZONTAL}, @@ -1990,12 +1990,12 @@ long wxParseWindowStyle(const wxString& bitListString) * Load a bitmap from a wxWindows resource, choosing an optimum * depth and appropriate type. */ - + wxBitmap wxResourceCreateBitmap(const wxString& resource, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; - + wxItemResource *item = table->FindResource(resource); if (item) { @@ -2008,7 +2008,7 @@ wxBitmap wxResourceCreateBitmap(const wxString& resource, wxResourceTable *table long thisNoColours = (long)pow(2.0, (double)thisDepth); wxItemResource *optResource = (wxItemResource *) NULL; - + // Try to find optimum bitmap for this platform/colour depth wxNode *node = item->GetChildren().First(); while (node) @@ -2102,7 +2102,7 @@ wxBitmap wxResourceCreateBitmap(const wxString& resource, wxResourceTable *table { wxLogWarning(_("Failed to find XBM resource %s.\n" "Forgot to use wxResourceLoadBitmapData?"), (const char*) name); - return (wxBitmap *) NULL; + return wxNullBitmap; } return wxBitmap(item->GetValue1(), (int)item->GetValue2(), (int)item->GetValue3()) ; #else @@ -2118,7 +2118,7 @@ wxBitmap wxResourceCreateBitmap(const wxString& resource, wxResourceTable *table { wxLogWarning(_("Failed to find XPM resource %s.\n" "Forgot to use wxResourceLoadBitmapData?"), (const char*) name); - return (wxBitmap *) NULL; + return wxNullBitmap; } return wxBitmap(item->GetValue1()); #else @@ -2145,12 +2145,12 @@ wxBitmap wxResourceCreateBitmap(const wxString& resource, wxResourceTable *table * Load an icon from a wxWindows resource, choosing an optimum * depth and appropriate type. */ - + wxIcon wxResourceCreateIcon(const wxString& resource, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; - + wxItemResource *item = table->FindResource(resource); if (item) { @@ -2163,7 +2163,7 @@ wxIcon wxResourceCreateIcon(const wxString& resource, wxResourceTable *table) long thisNoColours = (long)pow(2.0, (double)thisDepth); wxItemResource *optResource = (wxItemResource *) NULL; - + // Try to find optimum icon for this platform/colour depth wxNode *node = item->GetChildren().First(); while (node) @@ -2257,7 +2257,7 @@ wxIcon wxResourceCreateIcon(const wxString& resource, wxResourceTable *table) { wxLogWarning(_("Failed to find XBM resource %s.\n" "Forgot to use wxResourceLoadIconData?"), (const char*) name); - return (wxIcon *) NULL; + return wxNullIcon; } return wxIcon((const char **)item->GetValue1(), (int)item->GetValue2(), (int)item->GetValue3()); #else @@ -2333,7 +2333,7 @@ wxMenuBar *wxResourceCreateMenuBar(const wxString& resource, wxResourceTable *ta { if (!table) table = wxDefaultResourceTable; - + wxItemResource *menuResource = table->FindResource(resource); if (menuResource && (menuResource->GetType() != "") && (menuResource->GetType() == "wxMenu")) { @@ -2357,7 +2357,7 @@ wxMenu *wxResourceCreateMenu(const wxString& resource, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; - + wxItemResource *menuResource = table->FindResource(resource); if (menuResource && (menuResource->GetType() != "") && (menuResource->GetType() == "wxMenu")) // if (menuResource && (menuResource->GetType() == wxTYPE_MENU)) @@ -2370,7 +2370,7 @@ bool wxResourceParseData(const wxString& resource, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; - + return table->ParseResourceData(resource); } @@ -2378,7 +2378,7 @@ bool wxResourceParseFile(const wxString& filename, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; - + return table->ParseResourceFile(filename); } @@ -2387,7 +2387,7 @@ bool wxResourceRegisterBitmapData(const wxString& name, char bits[], int width, { if (!table) table = wxDefaultResourceTable; - + return table->RegisterResourceBitmapData(name, bits, width, height); } @@ -2415,7 +2415,7 @@ bool wxResourceAddIdentifier(const wxString& name, int value, wxResourceTable *t { if (!table) table = wxDefaultResourceTable; - + table->identifiers.Put(name, (wxObject *)value); return TRUE; } @@ -2424,7 +2424,7 @@ int wxResourceGetIdentifier(const wxString& name, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; - + return (int)table->identifiers.Get(name); } @@ -2436,7 +2436,7 @@ bool wxResourceParseIncludeFile(const wxString& f, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; - + FILE *fd = fopen(f, "r"); if (!fd) { @@ -2490,7 +2490,7 @@ bool wxEatWhiteSpaceString(char *s) int ch = getc_string(s); if (ch == EOF) return TRUE; - + if ((ch != ' ') && (ch != '/') && (ch != ' ') && (ch != 10) && (ch != 13) && (ch != 9)) { ungetc_string(); @@ -2585,7 +2585,7 @@ bool wxGetResourceTokenString(char *s) wxReallocateResourceBuffer(); wxResourceBuffer[wxResourceBufferCount] = (char)ch; wxResourceBufferCount ++; - + ch = getc_string(s); } wxResourceBuffer[wxResourceBufferCount] = 0; @@ -2600,12 +2600,12 @@ bool wxGetResourceTokenString(char *s) static char *name = "...."; with possible comments. */ - + bool wxResourceReadOneResourceString(char *s, wxExprDatabase& db, bool *eof, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; - + // static or #define if (!wxGetResourceTokenString(s)) { @@ -2633,7 +2633,7 @@ bool wxResourceReadOneResourceString(char *s, wxExprDatabase& db, bool *eof, wxR } delete[] name; delete[] value; - + return TRUE; } /* @@ -2680,7 +2680,7 @@ bool wxResourceReadOneResourceString(char *s, wxExprDatabase& db, bool *eof, wxR wxLogWarning(_("Expected 'char' whilst parsing resource.")); return FALSE; } - + // *name if (!wxGetResourceTokenString(s)) { @@ -2696,7 +2696,7 @@ bool wxResourceReadOneResourceString(char *s, wxExprDatabase& db, bool *eof, wxR } char nameBuf[100]; strncpy(nameBuf, wxResourceBuffer+1, 99); - + // = if (!wxGetResourceTokenString(s)) { @@ -2738,11 +2738,11 @@ bool wxResourceParseString(char *s, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; - + if (!s) return FALSE; - - // Turn backslashes into spaces + + // Turn backslashes into spaces if (s) { int len = strlen(s); @@ -2774,7 +2774,7 @@ bool wxWindow::LoadFromResource(wxWindow *parent, const wxString& resourceName, { if (!table) table = wxDefaultResourceTable; - + wxItemResource *resource = table->FindResource((const char *)resourceName); // if (!resource || (resource->GetType() != wxTYPE_DIALOG_BOX)) if (!resource || !resource->GetType() || @@ -2848,7 +2848,7 @@ bool wxWindow::LoadFromResource(wxWindow *parent, const wxString& resourceName, while (node) { wxItemResource *childResource = (wxItemResource *)node->Data(); - + (void) CreateItem(childResource, resource, table); node = node->Next(); diff --git a/src/gtk/app.cpp b/src/gtk/app.cpp index 0e7eec9b1b..630733a3ae 100644 --- a/src/gtk/app.cpp +++ b/src/gtk/app.cpp @@ -4,7 +4,7 @@ // Author: Robert Roebling // Id: $Id$ // Copyright: (c) 1998 Robert Roebling, Julian Smart -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -213,8 +213,8 @@ bool wxApp::SendIdleEvents(void) wxNode* node = wxTopLevelWindows.First(); while (node) { - wxWindow* win = (wxWindow*) node->Data(); - if (SendIdleEvents(win)) + wxWindow* win = (wxWindow*) node->Data(); + if (SendIdleEvents(win)) needMore = TRUE; node = node->Next(); } @@ -225,22 +225,22 @@ bool wxApp::SendIdleEvents( wxWindow* win ) { bool needMore = FALSE; - wxIdleEvent event; - event.SetEventObject(win); - win->ProcessEvent(event); + wxIdleEvent event; + event.SetEventObject(win); + win->ProcessEvent(event); if (event.MoreRequested()) needMore = TRUE; - wxNode* node = win->GetChildren()->First(); - while (node) - { - wxWindow* win = (wxWindow*) node->Data(); - if (SendIdleEvents(win)) + wxNode* node = win->GetChildren().First(); + while (node) + { + wxWindow* win = (wxWindow*) node->Data(); + if (SendIdleEvents(win)) needMore = TRUE; - node = node->Next(); - } + node = node->Next(); + } return needMore ; } diff --git a/src/gtk/bitmap.cpp b/src/gtk/bitmap.cpp index f92b146377..000c58e5ad 100644 --- a/src/gtk/bitmap.cpp +++ b/src/gtk/bitmap.cpp @@ -4,7 +4,7 @@ // Author: Robert Roebling // RCS-ID: $Id$ // Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -24,7 +24,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxMask,wxObject) -wxMask::wxMask(void) +wxMask::wxMask() { m_bitmap = (GdkBitmap *) NULL; } @@ -41,7 +41,7 @@ wxMask::wxMask( const wxBitmap& WXUNUSED(bitmap) ) { } -wxMask::~wxMask(void) +wxMask::~wxMask() { if (m_bitmap) gdk_bitmap_unref( m_bitmap ); } @@ -50,7 +50,7 @@ GdkBitmap *wxMask::GetBitmap(void) const { return m_bitmap; } - + //----------------------------------------------------------------------------- // wxBitmap //----------------------------------------------------------------------------- @@ -60,7 +60,7 @@ class wxBitmapRefData: public wxObjectRefData public: wxBitmapRefData(void); ~wxBitmapRefData(void); - + GdkPixmap *m_pixmap; GdkBitmap *m_bitmap; wxMask *m_mask; @@ -70,7 +70,7 @@ public: wxPalette *m_palette; }; -wxBitmapRefData::wxBitmapRefData(void) +wxBitmapRefData::wxBitmapRefData() { m_pixmap = (GdkPixmap *) NULL; m_bitmap = (GdkBitmap *) NULL; @@ -81,7 +81,7 @@ wxBitmapRefData::wxBitmapRefData(void) m_palette = (wxPalette *) NULL; } -wxBitmapRefData::~wxBitmapRefData(void) +wxBitmapRefData::~wxBitmapRefData() { if (m_pixmap) gdk_pixmap_unref( m_pixmap ); if (m_bitmap) gdk_bitmap_unref( m_bitmap ); @@ -95,95 +95,88 @@ wxBitmapRefData::~wxBitmapRefData(void) IMPLEMENT_DYNAMIC_CLASS(wxBitmap,wxGDIObject) -wxBitmap::wxBitmap(void) +wxBitmap::wxBitmap() { if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this); } - + wxBitmap::wxBitmap( int width, int height, int depth ) { wxCHECK_RET( (width > 0) && (height > 0), "invalid bitmap size" ) wxCHECK_RET( (depth > 0) || (depth == -1), "invalid bitmap depth" ) m_refData = new wxBitmapRefData(); - + GdkWindow *parent = (GdkWindow*) &gdk_root_parent; - + M_BMPDATA->m_mask = (wxMask *) NULL; M_BMPDATA->m_pixmap = gdk_pixmap_new( parent, width, height, depth ); M_BMPDATA->m_width = width; M_BMPDATA->m_height = height; M_BMPDATA->m_bpp = gdk_window_get_visual( parent )->depth; - + if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this); } wxBitmap::wxBitmap( const char **bits ) { wxCHECK_RET( bits != NULL, "invalid bitmap data" ) - + m_refData = new wxBitmapRefData(); GdkBitmap *mask = (GdkBitmap*) NULL; GdkWindow *parent = (GdkWindow*) &gdk_root_parent; - + M_BMPDATA->m_pixmap = gdk_pixmap_create_from_xpm_d( parent, &mask, NULL, (gchar **) bits ); - + if (mask) { M_BMPDATA->m_mask = new wxMask(); M_BMPDATA->m_mask->m_bitmap = mask; } - + gdk_window_get_size( M_BMPDATA->m_pixmap, &(M_BMPDATA->m_width), &(M_BMPDATA->m_height) ); - + M_BMPDATA->m_bpp = gdk_window_get_visual( parent )->depth; // ? if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this); } - + wxBitmap::wxBitmap( char **bits ) { wxCHECK_RET( bits != NULL, "invalid bitmap data" ) - + m_refData = new wxBitmapRefData(); GdkBitmap *mask = (GdkBitmap*) NULL; GdkWindow *parent = (GdkWindow*) &gdk_root_parent; - + M_BMPDATA->m_pixmap = gdk_pixmap_create_from_xpm_d( parent, &mask, NULL, (gchar **) bits ); - + wxCHECK_RET( M_BMPDATA->m_pixmap, "couldn't create pixmap" ); - + if (mask) { M_BMPDATA->m_mask = new wxMask(); M_BMPDATA->m_mask->m_bitmap = mask; } - + gdk_window_get_size( M_BMPDATA->m_pixmap, &(M_BMPDATA->m_width), &(M_BMPDATA->m_height) ); - + M_BMPDATA->m_bpp = gdk_window_get_visual( parent )->depth; // ? if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this); } - + wxBitmap::wxBitmap( const wxBitmap& bmp ) { Ref( bmp ); - - if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this); -} - -wxBitmap::wxBitmap( const wxBitmap* bmp ) -{ - if (bmp) Ref( *bmp ); - + if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this); } wxBitmap::wxBitmap( const wxString &filename, int type ) { LoadFile( filename, type ); - + if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this); } @@ -192,44 +185,44 @@ wxBitmap::wxBitmap( const char bits[], int width, int height, int WXUNUSED(depth m_refData = new wxBitmapRefData(); M_BMPDATA->m_mask = (wxMask *) NULL; - M_BMPDATA->m_bitmap = + M_BMPDATA->m_bitmap = gdk_bitmap_create_from_data( (GdkWindow*) &gdk_root_parent, (gchar *) bits, width, height ); M_BMPDATA->m_width = width; M_BMPDATA->m_height = height; M_BMPDATA->m_bpp = 1; wxCHECK_RET( M_BMPDATA->m_bitmap, "couldn't create bitmap" ); - + if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this); } - -wxBitmap::~wxBitmap(void) + +wxBitmap::~wxBitmap() { if (wxTheBitmapList) wxTheBitmapList->DeleteObject(this); } - + wxBitmap& wxBitmap::operator = ( const wxBitmap& bmp ) { - if (*this == bmp) return (*this); - Ref( bmp ); - return *this; + if (*this == bmp) return (*this); + Ref( bmp ); + return *this; } - + bool wxBitmap::operator == ( const wxBitmap& bmp ) { - return m_refData == bmp.m_refData; + return m_refData == bmp.m_refData; } - + bool wxBitmap::operator != ( const wxBitmap& bmp ) { - return m_refData != bmp.m_refData; + return m_refData != bmp.m_refData; } - + bool wxBitmap::Ok(void) const { return (m_refData != NULL); } - + int wxBitmap::GetHeight(void) const { wxCHECK_MSG( Ok(), -1, "invalid bitmap" ); @@ -240,69 +233,69 @@ int wxBitmap::GetHeight(void) const int wxBitmap::GetWidth(void) const { wxCHECK_MSG( Ok(), -1, "invalid bitmap" ); - + return M_BMPDATA->m_width; } int wxBitmap::GetDepth(void) const { wxCHECK_MSG( Ok(), -1, "invalid bitmap" ); - + return M_BMPDATA->m_bpp; } wxMask *wxBitmap::GetMask(void) const { wxCHECK_MSG( Ok(), (wxMask *) NULL, "invalid bitmap" ); - + return M_BMPDATA->m_mask; } void wxBitmap::SetMask( wxMask *mask ) { wxCHECK_RET( Ok(), "invalid bitmap" ); - + if (M_BMPDATA->m_mask) delete M_BMPDATA->m_mask; - + M_BMPDATA->m_mask = mask; } bool wxBitmap::SaveFile( const wxString &name, int type, wxPalette *WXUNUSED(palette) ) { wxCHECK_MSG( Ok(), FALSE, "invalid bitmap" ); - + if (type == wxBITMAP_TYPE_PNG) { wxImage image( *this ); if (image.Ok()) return image.SaveFile( name, type ); } - + return FALSE; } bool wxBitmap::LoadFile( const wxString &name, int type ) { UnRef(); - + if (!wxFileExists(name)) return FALSE; - + if (type == wxBITMAP_TYPE_XPM) { m_refData = new wxBitmapRefData(); - + GdkBitmap *mask = (GdkBitmap*) NULL; GdkWindow *parent = (GdkWindow*) &gdk_root_parent; - + M_BMPDATA->m_pixmap = gdk_pixmap_create_from_xpm( parent, &mask, NULL, name ); - + if (mask) { M_BMPDATA->m_mask = new wxMask(); M_BMPDATA->m_mask->m_bitmap = mask; } - + gdk_window_get_size( M_BMPDATA->m_pixmap, &(M_BMPDATA->m_width), &(M_BMPDATA->m_height) ); - M_BMPDATA->m_bpp = gdk_window_get_visual( parent )->depth; + M_BMPDATA->m_bpp = gdk_window_get_visual( parent )->depth; } else if (type == wxBITMAP_TYPE_PNG) { @@ -316,16 +309,16 @@ bool wxBitmap::LoadFile( const wxString &name, int type ) image.LoadFile( name, type ); if (image.Ok()) *this = image.ConvertToBitmap(); } - else + else return FALSE; - + return TRUE; } - + wxPalette *wxBitmap::GetPalette(void) const { if (!Ok()) return (wxPalette *) NULL; - + return M_BMPDATA->m_palette; } @@ -360,17 +353,17 @@ void wxBitmap::SetPixmap( GdkPixmap *pixmap ) GdkPixmap *wxBitmap::GetPixmap(void) const { wxCHECK_MSG( Ok(), (GdkPixmap *) NULL, "invalid bitmap" ); - + return M_BMPDATA->m_pixmap; } - + GdkBitmap *wxBitmap::GetBitmap(void) const { wxCHECK_MSG( Ok(), (GdkBitmap *) NULL, "invalid bitmap" ); - + return M_BMPDATA->m_bitmap; } - + //----------------------------------------------------------------------------- // wxImage //----------------------------------------------------------------------------- @@ -383,46 +376,46 @@ wxBitmap wxImage::ConvertToBitmap() const int width = GetWidth(); int height = GetHeight(); - + bitmap.SetHeight( height ); bitmap.SetWidth( width ); - + // Create picture - - GdkImage *data_image = + + GdkImage *data_image = gdk_image_new( GDK_IMAGE_FASTEST, gdk_visual_get_system(), width, height ); - + bitmap.SetPixmap( gdk_pixmap_new( (GdkWindow*)&gdk_root_parent, width, height, -1 ) ); // Create mask - + GdkImage *mask_image = (GdkImage*) NULL; - + if (HasMask()) { unsigned char *mask_data = (unsigned char*)malloc( ((width >> 3)+8) * height ); - + mask_image = gdk_image_new_bitmap( gdk_visual_get_system(), mask_data, width, height ); - + wxMask *mask = new wxMask(); mask->m_bitmap = gdk_pixmap_new( (GdkWindow*)&gdk_root_parent, width, height, 1 ); - + bitmap.SetMask( mask ); } - - // Retrieve depth - + + // Retrieve depth + GdkVisual *visual = gdk_window_get_visual( bitmap.GetPixmap() ); if (visual == NULL) visual = gdk_window_get_visual( (GdkWindow*) &gdk_root_parent ); int bpp = visual->depth; if ((bpp == 16) && (visual->red_mask != 0xf800)) bpp = 15; if (bpp < 8) bpp = 8; - + // Render enum byte_order { RGB, RBG, BRG, BGR, GRB, GBR }; byte_order b_o = RGB; - + if (bpp >= 24) { GdkVisual *visual = gdk_visual_get_system(); @@ -433,13 +426,13 @@ wxBitmap wxImage::ConvertToBitmap() const else if ((visual->green_mask > visual->red_mask) && (visual->red_mask > visual->blue_mask)) b_o = GRB; else if ((visual->green_mask > visual->blue_mask) && (visual->blue_mask > visual->red_mask)) b_o = GBR; } - + int r_mask = GetMaskRed(); int g_mask = GetMaskGreen(); int b_mask = GetMaskBlue(); - + unsigned char* data = GetData(); - + int index = 0; for (int y = 0; y < height; y++) { @@ -451,7 +444,7 @@ wxBitmap wxImage::ConvertToBitmap() const index++; int b = data[index]; index++; - + if (HasMask()) { if ((r == r_mask) && (b == b_mask) && (g == g_mask)) @@ -459,7 +452,7 @@ wxBitmap wxImage::ConvertToBitmap() const else gdk_image_put_pixel( mask_image, x, y, 0 ); } - + switch (bpp) { case 8: @@ -477,9 +470,9 @@ wxBitmap wxImage::ConvertToBitmap() const int sum = ABS (rdiff) + ABS (gdiff) + ABS (bdiff); if (sum < max) { index = i; max = sum; } } - + gdk_image_put_pixel( data_image, x, y, index ); - + break; } case 15: @@ -513,68 +506,68 @@ wxBitmap wxImage::ConvertToBitmap() const } } // for } // for - + // Blit picture - + GdkGC *data_gc = gdk_gc_new( bitmap.GetPixmap() ); - + gdk_draw_image( bitmap.GetPixmap(), data_gc, data_image, 0, 0, 0, 0, width, height ); - + gdk_image_destroy( data_image ); gdk_gc_unref( data_gc ); - + // Blit mask - + if (HasMask()) { GdkGC *mask_gc = gdk_gc_new( bitmap.GetMask()->GetBitmap() ); - + gdk_draw_image( bitmap.GetMask()->GetBitmap(), mask_gc, mask_image, 0, 0, 0, 0, width, height ); - + gdk_image_destroy( mask_image ); gdk_gc_unref( mask_gc ); } - + return bitmap; } wxImage::wxImage( const wxBitmap &bitmap ) { wxCHECK_RET( bitmap.Ok(), "invalid bitmap" ); - - GdkImage *gdk_image = gdk_image_get( bitmap.GetPixmap(), - 0, 0, + + GdkImage *gdk_image = gdk_image_get( bitmap.GetPixmap(), + 0, 0, bitmap.GetWidth(), bitmap.GetHeight() ); - + wxCHECK_RET( gdk_image, "couldn't create image" ); - + Create( bitmap.GetWidth(), bitmap.GetHeight() ); char unsigned *data = GetData(); - + if (!data) { gdk_image_destroy( gdk_image ); wxFAIL_MSG( "couldn't create image" ); return; } - + GdkImage *gdk_image_mask = (GdkImage*) NULL; if (bitmap.GetMask()) { - gdk_image_mask = gdk_image_get( bitmap.GetMask()->GetBitmap(), - 0, 0, + gdk_image_mask = gdk_image_get( bitmap.GetMask()->GetBitmap(), + 0, 0, bitmap.GetWidth(), bitmap.GetHeight() ); SetMaskColour( 16, 16, 16 ); // anything unlikely and dividable } - + GdkVisual *visual = gdk_window_get_visual( bitmap.GetPixmap() ); if (visual == NULL) visual = gdk_window_get_visual( (GdkWindow*) &gdk_root_parent ); int bpp = visual->depth; if ((bpp == 16) && (visual->red_mask != 0xf800)) bpp = 15; GdkColormap *cmap = gtk_widget_get_default_colormap(); - + long pos = 0; for (int j = 0; j < bitmap.GetHeight(); j++) { @@ -602,7 +595,7 @@ wxImage::wxImage( const wxBitmap &bitmap ) data[pos+1] = (pixel >> 8) & 0xff; data[pos+2] = pixel & 0xff; } - + if (gdk_image_mask) { int mask_pixel = gdk_image_get_pixel( gdk_image_mask, i, j ); @@ -613,11 +606,11 @@ wxImage::wxImage( const wxBitmap &bitmap ) data[pos+2] = 16; } } - + pos += 3; } } - + gdk_image_destroy( gdk_image ); if (gdk_image_mask) gdk_image_destroy( gdk_image_mask ); } diff --git a/src/gtk/brush.cpp b/src/gtk/brush.cpp index 698c499596..146a4d0d88 100644 --- a/src/gtk/brush.cpp +++ b/src/gtk/brush.cpp @@ -20,16 +20,16 @@ class wxBrushRefData: public wxObjectRefData { public: - - wxBrushRefData(void); + + wxBrushRefData(); wxBrushRefData( const wxBrushRefData& data ); - + int m_style; wxBitmap m_stipple; wxColour m_colour; }; -wxBrushRefData::wxBrushRefData(void) +wxBrushRefData::wxBrushRefData() { m_style = 0; } @@ -47,7 +47,7 @@ wxBrushRefData::wxBrushRefData( const wxBrushRefData& data ) IMPLEMENT_DYNAMIC_CLASS(wxBrush,wxGDIObject) -wxBrush::wxBrush(void) +wxBrush::wxBrush() { if (wxTheBrushList) wxTheBrushList->AddBrush( this ); } @@ -57,7 +57,7 @@ wxBrush::wxBrush( const wxColour &colour, int style ) m_refData = new wxBrushRefData(); M_BRUSHDATA->m_style = style; M_BRUSHDATA->m_colour = colour; - + if (wxTheBrushList) wxTheBrushList->AddBrush( this ); } @@ -67,52 +67,45 @@ wxBrush::wxBrush( const wxBitmap &stippleBitmap ) M_BRUSHDATA->m_style = wxSTIPPLE; M_BRUSHDATA->m_colour = *wxBLACK; M_BRUSHDATA->m_stipple = stippleBitmap; - + if (wxTheBrushList) wxTheBrushList->AddBrush( this ); } wxBrush::wxBrush( const wxBrush &brush ) { Ref( brush ); - - if (wxTheBrushList) wxTheBrushList->AddBrush( this ); -} -wxBrush::wxBrush( const wxBrush *brush ) -{ - if (brush) Ref( *brush ); - - if (wxTheBrushList) wxTheBrushList->Append( this ); + if (wxTheBrushList) wxTheBrushList->AddBrush( this ); } -wxBrush::~wxBrush(void) +wxBrush::~wxBrush() { if (wxTheBrushList) wxTheBrushList->RemoveBrush( this ); } wxBrush& wxBrush::operator = ( const wxBrush& brush ) { - if (*this == brush) return (*this); - Ref( brush ); - return *this; + if (*this == brush) return (*this); + Ref( brush ); + return *this; } - + bool wxBrush::operator == ( const wxBrush& brush ) { - return m_refData == brush.m_refData; + return m_refData == brush.m_refData; } bool wxBrush::operator != ( const wxBrush& brush ) { - return m_refData != brush.m_refData; + return m_refData != brush.m_refData; } -bool wxBrush::Ok(void) const +bool wxBrush::Ok() const { return ((m_refData) && M_BRUSHDATA->m_colour.Ok()); } -int wxBrush::GetStyle(void) const +int wxBrush::GetStyle() const { if (m_refData == NULL) { @@ -123,25 +116,25 @@ int wxBrush::GetStyle(void) const return M_BRUSHDATA->m_style; } -wxColour &wxBrush::GetColour(void) const +wxColour &wxBrush::GetColour() const { if (m_refData == NULL) { wxFAIL_MSG( "invalid brush" ); return wxNullColour; } - + return M_BRUSHDATA->m_colour; } -wxBitmap *wxBrush::GetStipple(void) const +wxBitmap *wxBrush::GetStipple() const { if (m_refData == NULL) { wxFAIL_MSG( "invalid brush" ); return &wxNullBitmap; } - + return &M_BRUSHDATA->m_stipple; } @@ -169,7 +162,7 @@ void wxBrush::SetStipple( const wxBitmap& stipple ) M_BRUSHDATA->m_stipple = stipple; } -void wxBrush::Unshare(void) +void wxBrush::Unshare() { if (!m_refData) { diff --git a/src/gtk/colour.cpp b/src/gtk/colour.cpp index 09479c1230..526ef17636 100644 --- a/src/gtk/colour.cpp +++ b/src/gtk/colour.cpp @@ -4,7 +4,7 @@ // Author: Robert Roebling // Id: $Id$ // Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -23,15 +23,15 @@ class wxColourRefData: public wxObjectRefData { public: - + wxColourRefData(); ~wxColourRefData(); void FreeColour(); - + GdkColor m_color; GdkColormap *m_colormap; bool m_hasPixel; - + friend wxColour; }; @@ -75,17 +75,17 @@ wxColour::wxColour( unsigned char red, unsigned char green, unsigned char blue ) M_COLDATA->m_color.blue = ((unsigned short)blue) << SHIFT; M_COLDATA->m_color.pixel = 0; } - + void wxColour::InitFromName( const wxString &colourName ) { wxNode *node = (wxNode *) NULL; - if ( (wxTheColourDatabase) && (node = wxTheColourDatabase->Find(colourName)) ) + if ( (wxTheColourDatabase) && (node = wxTheColourDatabase->Find(colourName)) ) { wxColour *col = (wxColour*)node->Data(); UnRef(); if (col) Ref( *col ); - } - else + } + else { m_refData = new wxColourRefData(); if (!gdk_color_parse( colourName, &M_COLDATA->m_color )) @@ -98,34 +98,29 @@ void wxColour::InitFromName( const wxString &colourName ) } wxColour::wxColour( const wxColour& col ) -{ - Ref( col ); -} - -wxColour::wxColour( const wxColour* col ) -{ - if (col) Ref( *col ); +{ + Ref( col ); } wxColour::~wxColour() { } -wxColour& wxColour::operator = ( const wxColour& col ) -{ - if (*this == col) return (*this); - Ref( col ); - return *this; +wxColour& wxColour::operator = ( const wxColour& col ) +{ + if (*this == col) return (*this); + Ref( col ); + return *this; } -bool wxColour::operator == ( const wxColour& col ) -{ - return m_refData == col.m_refData; +bool wxColour::operator == ( const wxColour& col ) +{ + return m_refData == col.m_refData; } -bool wxColour::operator != ( const wxColour& col) -{ - return m_refData != col.m_refData; +bool wxColour::operator != ( const wxColour& col) +{ + return m_refData != col.m_refData; } void wxColour::Set( unsigned char red, unsigned char green, unsigned char blue ) @@ -145,7 +140,7 @@ unsigned char wxColour::Red() const wxFAIL_MSG( "invalid colour" ); return 0; } - + return (unsigned char)(M_COLDATA->m_color.red >> SHIFT); } @@ -156,7 +151,7 @@ unsigned char wxColour::Green() const wxFAIL_MSG( "invalid colour" ); return 0; } - + return (unsigned char)(M_COLDATA->m_color.green >> SHIFT); } @@ -167,7 +162,7 @@ unsigned char wxColour::Blue() const wxFAIL_MSG( "invalid colour" ); return 0; } - + return (unsigned char)(M_COLDATA->m_color.blue >> SHIFT); } @@ -179,10 +174,10 @@ bool wxColour::Ok() const void wxColour::CalcPixel( GdkColormap *cmap ) { if (!Ok()) return; - + if ((M_COLDATA->m_hasPixel) && (M_COLDATA->m_colormap == cmap)) return; M_COLDATA->FreeColour(); - + GdkColormapPrivate *private_colormap = (GdkColormapPrivate*) cmap; if ((private_colormap->visual->type == GDK_VISUAL_GRAYSCALE) || (private_colormap->visual->type == GDK_VISUAL_PSEUDO_COLOR)) @@ -199,7 +194,7 @@ void wxColour::CalcPixel( GdkColormap *cmap ) int sum = ABS (rdiff) + ABS (gdiff) + ABS (bdiff); if (sum < max) { index = i; max = sum; } } - + M_COLDATA->m_hasPixel = TRUE; M_COLDATA->m_color.pixel = index; } @@ -207,21 +202,21 @@ void wxColour::CalcPixel( GdkColormap *cmap ) { M_COLDATA->m_hasPixel = gdk_color_alloc( cmap, &M_COLDATA->m_color ); } - + M_COLDATA->m_colormap = cmap; } int wxColour::GetPixel() const { if (!Ok()) return 0; - + return M_COLDATA->m_color.pixel; } GdkColor *wxColour::GetColor() const { if (!Ok()) return (GdkColor *) NULL; - + return &M_COLDATA->m_color; } diff --git a/src/gtk/cursor.cpp b/src/gtk/cursor.cpp index 01a469f84f..73babdfb05 100644 --- a/src/gtk/cursor.cpp +++ b/src/gtk/cursor.cpp @@ -4,7 +4,7 @@ // Author: Robert Roebling // Id: $Id$ // Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -21,19 +21,19 @@ class wxCursorRefData: public wxObjectRefData { public: - - wxCursorRefData(void); - ~wxCursorRefData(void); - + + wxCursorRefData(); + ~wxCursorRefData(); + GdkCursor *m_cursor; }; -wxCursorRefData::wxCursorRefData(void) +wxCursorRefData::wxCursorRefData() { m_cursor = (GdkCursor *) NULL; } -wxCursorRefData::~wxCursorRefData(void) +wxCursorRefData::~wxCursorRefData() { if (m_cursor) gdk_cursor_destroy( m_cursor ); } @@ -44,14 +44,14 @@ wxCursorRefData::~wxCursorRefData(void) IMPLEMENT_DYNAMIC_CLASS(wxCursor,wxObject) -wxCursor::wxCursor(void) +wxCursor::wxCursor() { } wxCursor::wxCursor( int cursorId ) { m_refData = new wxCursorRefData(); - + GdkCursorType gdk_cur = GDK_LEFT_PTR; switch (cursorId) { @@ -67,12 +67,12 @@ wxCursor::wxCursor( int cursorId ) case wxCURSOR_PENCIL: gdk_cur = GDK_PENCIL; break; case wxCURSOR_NO_ENTRY: gdk_cur = GDK_PIRATE; break; } - + M_CURSORDATA->m_cursor = gdk_cursor_new( gdk_cur ); - + /* do that yourself - + wxCURSOR_BULLSEYE, wxCURSOR_CHAR, wxCURSOR_LEFT_BUTTON, @@ -95,7 +95,7 @@ wxCursor::wxCursor( int cursorId ) wxCURSOR_BASED_ARROW_UP, wxCURSOR_BASED_ARROW_DOWN */ - + } wxCursor::wxCursor( const wxCursor &cursor ) @@ -103,39 +103,33 @@ wxCursor::wxCursor( const wxCursor &cursor ) Ref( cursor ); } -wxCursor::wxCursor( const wxCursor *cursor ) -{ - UnRef(); - if (cursor) Ref( *cursor ); -} - -wxCursor::~wxCursor(void) +wxCursor::~wxCursor() { } wxCursor& wxCursor::operator = ( const wxCursor& cursor ) { - if (*this == cursor) return (*this); - Ref( cursor ); - return *this; + if (*this == cursor) return (*this); + Ref( cursor ); + return *this; } -bool wxCursor::operator == ( const wxCursor& cursor ) +bool wxCursor::operator == ( const wxCursor& cursor ) const { - return m_refData == cursor.m_refData; + return m_refData == cursor.m_refData; } -bool wxCursor::operator != ( const wxCursor& cursor ) +bool wxCursor::operator != ( const wxCursor& cursor ) const { - return m_refData != cursor.m_refData; + return m_refData != cursor.m_refData; } -bool wxCursor::Ok(void) const +bool wxCursor::Ok() const { return (m_refData != NULL); } -GdkCursor *wxCursor::GetCursor(void) const +GdkCursor *wxCursor::GetCursor() const { return M_CURSORDATA->m_cursor; } @@ -146,7 +140,7 @@ GdkCursor *wxCursor::GetCursor(void) const bool g_isBusy = FALSE; -void wxEndBusyCursor(void) +void wxEndBusyCursor() { g_isBusy = FALSE; } @@ -156,7 +150,7 @@ void wxBeginBusyCursor( wxCursor *WXUNUSED(cursor) ) g_isBusy = TRUE; } -bool wxIsBusy(void) +bool wxIsBusy() { return g_isBusy; } diff --git a/src/gtk/font.cpp b/src/gtk/font.cpp index 6a2d12c7af..c1f43fcf7f 100644 --- a/src/gtk/font.cpp +++ b/src/gtk/font.cpp @@ -4,7 +4,7 @@ // Author: Robert Roebling // Id: $Id$ // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -27,53 +27,53 @@ extern wxFontNameDirectory *wxTheFontNameDirectory; class wxFontRefData: public wxObjectRefData { - public: - - wxFontRefData(void); - ~wxFontRefData(void); - +public: + + wxFontRefData(); + ~wxFontRefData(); + wxList m_scaled_xfonts; int m_pointSize; int m_family, m_style, m_weight; bool m_underlined; int m_fontId; char* m_faceName; - + bool m_byXFontName; GdkFont *m_font; - + friend wxFont; }; -wxFontRefData::wxFontRefData(void) : m_scaled_xfonts(wxKEY_INTEGER) -{ - m_byXFontName = FALSE; - m_pointSize = 12; - m_family = wxSWISS; - m_style = wxNORMAL; - m_weight = wxNORMAL; - m_underlined = FALSE; - m_fontId = 0; - m_faceName = (char *) NULL; - m_font = (GdkFont *) NULL; -} - -wxFontRefData::~wxFontRefData(void) -{ - wxNode *node = m_scaled_xfonts.First(); - while (node) - { - GdkFont *font = (GdkFont*)node->Data(); - wxNode *next = node->Next(); - gdk_font_unref( font ); - node = next; - } - if (m_faceName) - { - delete m_faceName; +wxFontRefData::wxFontRefData() : m_scaled_xfonts(wxKEY_INTEGER) +{ + m_byXFontName = FALSE; + m_pointSize = 12; + m_family = wxSWISS; + m_style = wxNORMAL; + m_weight = wxNORMAL; + m_underlined = FALSE; + m_fontId = 0; m_faceName = (char *) NULL; - } - if (m_font) gdk_font_unref( m_font ); + m_font = (GdkFont *) NULL; +} + +wxFontRefData::~wxFontRefData() +{ + wxNode *node = m_scaled_xfonts.First(); + while (node) + { + GdkFont *font = (GdkFont*)node->Data(); + wxNode *next = node->Next(); + gdk_font_unref( font ); + node = next; + } + if (m_faceName) + { + delete m_faceName; + m_faceName = (char *) NULL; + } + if (m_font) gdk_font_unref( m_font ); } //----------------------------------------------------------------------------- @@ -82,257 +82,249 @@ wxFontRefData::~wxFontRefData(void) IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject) -wxFont::wxFont(void) +wxFont::wxFont() { - if (wxTheFontList) wxTheFontList->Append( this ); + if (wxTheFontList) wxTheFontList->Append( this ); } wxFont::wxFont( char *xFontName ) { - if (!xFontName) return; - - m_refData = new wxFontRefData(); - - M_FONTDATA->m_byXFontName = TRUE; - M_FONTDATA->m_font = gdk_font_load( xFontName ); + if (!xFontName) return; + + m_refData = new wxFontRefData(); + + M_FONTDATA->m_byXFontName = TRUE; + M_FONTDATA->m_font = gdk_font_load( xFontName ); } wxFont::wxFont(int PointSize, int FontIdOrFamily, int Style, int Weight, - bool Underlined, const char* Face) -{ - m_refData = new wxFontRefData(); - - if (FontIdOrFamily == wxDEFAULT) FontIdOrFamily = wxSWISS; - M_FONTDATA->m_family = FontIdOrFamily; - - if ((M_FONTDATA->m_faceName = (Face) ? copystring(Face) : (char*)NULL) ) - { - M_FONTDATA->m_fontId = wxTheFontNameDirectory->FindOrCreateFontId( Face, FontIdOrFamily ); - M_FONTDATA->m_family = wxTheFontNameDirectory->GetFamily( FontIdOrFamily ); - } - else - { - M_FONTDATA->m_fontId = FontIdOrFamily; - M_FONTDATA->m_family = wxTheFontNameDirectory->GetFamily( FontIdOrFamily ); - } - - if (Style == wxDEFAULT) Style = wxNORMAL; - M_FONTDATA->m_style = Style; - if (Weight == wxDEFAULT) Weight = wxNORMAL; - M_FONTDATA->m_weight = Weight; - if (PointSize == wxDEFAULT) PointSize = 12; - M_FONTDATA->m_pointSize = PointSize; - M_FONTDATA->m_underlined = Underlined; - - if (wxTheFontList) wxTheFontList->Append( this ); -} - -wxFont::wxFont(int PointSize, const char *Face, int Family, int Style, - int Weight, bool Underlined) -{ - m_refData = new wxFontRefData(); - - M_FONTDATA->m_fontId = wxTheFontNameDirectory->FindOrCreateFontId( Face, Family ); - M_FONTDATA->m_faceName = (Face) ? copystring(Face) : (char*)NULL; - M_FONTDATA->m_family = wxTheFontNameDirectory->GetFamily( M_FONTDATA->m_fontId ); - M_FONTDATA->m_style = Style; - M_FONTDATA->m_weight = Weight; - M_FONTDATA->m_pointSize = PointSize; - M_FONTDATA->m_underlined = Underlined; - - if (wxTheFontList) wxTheFontList->Append( this ); + bool Underlined, const char* Face) +{ + m_refData = new wxFontRefData(); + + if (FontIdOrFamily == wxDEFAULT) FontIdOrFamily = wxSWISS; + M_FONTDATA->m_family = FontIdOrFamily; + + if ((M_FONTDATA->m_faceName = (Face) ? copystring(Face) : (char*)NULL) ) + { + M_FONTDATA->m_fontId = wxTheFontNameDirectory->FindOrCreateFontId( Face, FontIdOrFamily ); + M_FONTDATA->m_family = wxTheFontNameDirectory->GetFamily( FontIdOrFamily ); + } + else + { + M_FONTDATA->m_fontId = FontIdOrFamily; + M_FONTDATA->m_family = wxTheFontNameDirectory->GetFamily( FontIdOrFamily ); + } + + if (Style == wxDEFAULT) Style = wxNORMAL; + M_FONTDATA->m_style = Style; + if (Weight == wxDEFAULT) Weight = wxNORMAL; + M_FONTDATA->m_weight = Weight; + if (PointSize == wxDEFAULT) PointSize = 12; + M_FONTDATA->m_pointSize = PointSize; + M_FONTDATA->m_underlined = Underlined; + + if (wxTheFontList) wxTheFontList->Append( this ); } -wxFont::wxFont( const wxFont& font ) -{ - Ref( font ); - - if (wxTheFontList) wxTheFontList->Append( this ); +wxFont::wxFont(int PointSize, const char *Face, int Family, int Style, + int Weight, bool Underlined) +{ + m_refData = new wxFontRefData(); + + M_FONTDATA->m_fontId = wxTheFontNameDirectory->FindOrCreateFontId( Face, Family ); + M_FONTDATA->m_faceName = (Face) ? copystring(Face) : (char*)NULL; + M_FONTDATA->m_family = wxTheFontNameDirectory->GetFamily( M_FONTDATA->m_fontId ); + M_FONTDATA->m_style = Style; + M_FONTDATA->m_weight = Weight; + M_FONTDATA->m_pointSize = PointSize; + M_FONTDATA->m_underlined = Underlined; + + if (wxTheFontList) wxTheFontList->Append( this ); } -wxFont::wxFont( const wxFont* font ) -{ - UnRef(); - if (font) Ref( *font ); - - if (wxTheFontList) wxTheFontList->Append( this ); +wxFont::wxFont( const wxFont& font ) +{ + Ref( font ); + + if (wxTheFontList) wxTheFontList->Append( this ); } -wxFont::~wxFont(void) +wxFont::~wxFont() { - if (wxTheFontList) wxTheFontList->DeleteObject( this ); + if (wxTheFontList) wxTheFontList->DeleteObject( this ); } -wxFont& wxFont::operator = ( const wxFont& font ) -{ - if (*this == font) return (*this); - Ref( font ); - return *this; +wxFont& wxFont::operator = ( const wxFont& font ) +{ + if (*this == font) return (*this); + Ref( font ); + return *this; } -bool wxFont::operator == ( const wxFont& font ) -{ - return m_refData == font.m_refData; +bool wxFont::operator == ( const wxFont& font ) +{ + return m_refData == font.m_refData; } -bool wxFont::operator != ( const wxFont& font ) -{ - return m_refData != font.m_refData; +bool wxFont::operator != ( const wxFont& font ) +{ + return m_refData != font.m_refData; } bool wxFont::Ok() const { - return (m_refData != NULL); + return (m_refData != NULL); } -int wxFont::GetPointSize(void) const +int wxFont::GetPointSize() const { - if (!Ok()) - { - wxFAIL_MSG( "invalid font" ); - return 0; - } - - return M_FONTDATA->m_pointSize; + if (!Ok()) + { + wxFAIL_MSG( "invalid font" ); + return 0; + } + + return M_FONTDATA->m_pointSize; } -wxString wxFont::GetFaceString(void) const +wxString wxFont::GetFaceString() const { - if (!Ok()) - { - wxFAIL_MSG( "invalid font" ); - return ""; - } - - wxString s = wxTheFontNameDirectory->GetFontName( M_FONTDATA->m_fontId ); - return s; + if (!Ok()) + { + wxFAIL_MSG( "invalid font" ); + return ""; + } + + wxString s = wxTheFontNameDirectory->GetFontName( M_FONTDATA->m_fontId ); + return s; } -wxString wxFont::GetFaceName(void) const +wxString wxFont::GetFaceName() const { - if (!Ok()) - { - wxFAIL_MSG( "invalid font" ); - return ""; - } - - wxString s = wxTheFontNameDirectory->GetFontName( M_FONTDATA->m_fontId ); - return s; + if (!Ok()) + { + wxFAIL_MSG( "invalid font" ); + return ""; + } + + wxString s = wxTheFontNameDirectory->GetFontName( M_FONTDATA->m_fontId ); + return s; } -int wxFont::GetFamily(void) const +int wxFont::GetFamily() const { - if (!Ok()) - { - wxFAIL_MSG( "invalid font" ); - return 0; - } - - return M_FONTDATA->m_family; + if (!Ok()) + { + wxFAIL_MSG( "invalid font" ); + return 0; + } + + return M_FONTDATA->m_family; } -wxString wxFont::GetFamilyString(void) const +wxString wxFont::GetFamilyString() const { - if (!Ok()) - { - wxFAIL_MSG( "invalid font" ); + if (!Ok()) + { + wxFAIL_MSG( "invalid font" ); + return "wxDEFAULT"; + } + + switch (M_FONTDATA->m_family) + { + case wxDECORATIVE: return wxString("wxDECORATIVE"); + case wxROMAN: return wxString("wxROMAN"); + case wxSCRIPT: return wxString("wxSCRIPT"); + case wxSWISS: return wxString("wxSWISS"); + case wxMODERN: return wxString("wxMODERN"); + case wxTELETYPE: return wxString("wxTELETYPE"); + default: return "wxDEFAULT"; + } + return "wxDEFAULT"; - } - - switch (M_FONTDATA->m_family) - { - case wxDECORATIVE: return wxString("wxDECORATIVE"); - case wxROMAN: return wxString("wxROMAN"); - case wxSCRIPT: return wxString("wxSCRIPT"); - case wxSWISS: return wxString("wxSWISS"); - case wxMODERN: return wxString("wxMODERN"); - case wxTELETYPE: return wxString("wxTELETYPE"); - default: return "wxDEFAULT"; - } - - return "wxDEFAULT"; -} - -int wxFont::GetFontId(void) const -{ - if (!Ok()) - { - wxFAIL_MSG( "invalid font" ); - return 0; - } - - return M_FONTDATA->m_fontId; // stub } -int wxFont::GetStyle(void) const +int wxFont::GetFontId() const { - if (!Ok()) - { - wxFAIL_MSG( "invalid font" ); - return 0; - } - - return M_FONTDATA->m_style; + if (!Ok()) + { + wxFAIL_MSG( "invalid font" ); + return 0; + } + + return M_FONTDATA->m_fontId; // stub } -wxString wxFont::GetStyleString(void) const +int wxFont::GetStyle() const { - if (!Ok()) - { - wxFAIL_MSG( "invalid font" ); - return "wxDEFAULT"; - } - - switch (M_FONTDATA->m_style) - { - case wxNORMAL: return wxString("wxNORMAL"); - case wxSLANT: return wxString("wxSLANT"); - case wxITALIC: return wxString("wxITALIC"); - default: return wxString("wxDEFAULT"); - } - - return wxString("wxDEFAULT"); -} - -int wxFont::GetWeight(void) const -{ - if (!Ok()) - { - wxFAIL_MSG( "invalid font" ); - return 0; - } + if (!Ok()) + { + wxFAIL_MSG( "invalid font" ); + return 0; + } - return M_FONTDATA->m_weight; + return M_FONTDATA->m_style; } -wxString wxFont::GetWeightString(void) const +wxString wxFont::GetStyleString() const { - if (!Ok()) - { - wxFAIL_MSG( "invalid font" ); - return "wxDEFAULT"; - } + if (!Ok()) + { + wxFAIL_MSG( "invalid font" ); + return "wxDEFAULT"; + } + + switch (M_FONTDATA->m_style) + { + case wxNORMAL: return wxString("wxNORMAL"); + case wxSLANT: return wxString("wxSLANT"); + case wxITALIC: return wxString("wxITALIC"); + default: return wxString("wxDEFAULT"); + } - switch (M_FONTDATA->m_weight) - { - case wxNORMAL: return wxString("wxNORMAL"); - case wxBOLD: return wxString("wxBOLD"); - case wxLIGHT: return wxString("wxLIGHT"); - default: return wxString("wxDEFAULT"); - } - - return wxString("wxDEFAULT"); + return wxString("wxDEFAULT"); } -bool wxFont::GetUnderlined(void) const +int wxFont::GetWeight() const { - if (!Ok()) - { - wxFAIL_MSG( "invalid font" ); - return FALSE; - } - - return M_FONTDATA->m_underlined; + if (!Ok()) + { + wxFAIL_MSG( "invalid font" ); + return 0; + } + + return M_FONTDATA->m_weight; +} + +wxString wxFont::GetWeightString() const +{ + if (!Ok()) + { + wxFAIL_MSG( "invalid font" ); + return "wxDEFAULT"; + } + + switch (M_FONTDATA->m_weight) + { + case wxNORMAL: return wxString("wxNORMAL"); + case wxBOLD: return wxString("wxBOLD"); + case wxLIGHT: return wxString("wxLIGHT"); + default: return wxString("wxDEFAULT"); + } + + return wxString("wxDEFAULT"); +} + +bool wxFont::GetUnderlined() const +{ + if (!Ok()) + { + wxFAIL_MSG( "invalid font" ); + return FALSE; + } + + return M_FONTDATA->m_underlined; } //----------------------------------------------------------------------------- @@ -341,57 +333,57 @@ bool wxFont::GetUnderlined(void) const // local help function static GdkFont *wxLoadQueryNearestFont(int point_size, int fontid, - int style, int weight, - bool underlined); + int style, int weight, + bool underlined); GdkFont *wxFont::GetInternalFont(float scale) const { - if (!Ok()) - { - wxFAIL_MSG( "invalid font" ); - return (GdkFont*) NULL; - } - - if (M_FONTDATA->m_byXFontName) return M_FONTDATA->m_font; - - long int_scale = long(scale * 100.0 + 0.5); // key for fontlist - int point_scale = (M_FONTDATA->m_pointSize * 10 * int_scale) / 100; - GdkFont *font = (GdkFont *) NULL; - - wxNode *node = M_FONTDATA->m_scaled_xfonts.Find(int_scale); - if (node) - { - font = (GdkFont*)node->Data(); - } - else - { -/* - if (int_scale == 100) printf( "int_scale.\n" ); - if (M_FONTDATA->m_style == wxSWISS) printf( "swiss.\n" ); - if (M_FONTDATA->m_pointSize == 12) printf( "12.\n" ); - if (M_FONTDATA->m_weight == wxNORMAL) printf( "normal.\n" ); - if (M_FONTDATA->m_underlined == FALSE) printf( "false.\n" ); -*/ - if ((int_scale == 100) && - (M_FONTDATA->m_family == wxSWISS) && - (M_FONTDATA->m_style == wxNORMAL) && - (M_FONTDATA->m_pointSize == 12) && - (M_FONTDATA->m_weight == wxNORMAL) && - (M_FONTDATA->m_underlined == FALSE)) - { - font = gdk_font_load( "-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*" ); - } - else - { - font = wxLoadQueryNearestFont( point_scale, M_FONTDATA->m_fontId, M_FONTDATA->m_style, - M_FONTDATA->m_weight, M_FONTDATA->m_underlined ); - } - M_FONTDATA->m_scaled_xfonts.Append( int_scale, (wxObject*)font ); - } - if (!font) - printf("could not load any font"); -// wxError("could not load any font", "wxFont"); - return font; + if (!Ok()) + { + wxFAIL_MSG( "invalid font" ); + return (GdkFont*) NULL; + } + + if (M_FONTDATA->m_byXFontName) return M_FONTDATA->m_font; + + long int_scale = long(scale * 100.0 + 0.5); // key for fontlist + int point_scale = (M_FONTDATA->m_pointSize * 10 * int_scale) / 100; + GdkFont *font = (GdkFont *) NULL; + + wxNode *node = M_FONTDATA->m_scaled_xfonts.Find(int_scale); + if (node) + { + font = (GdkFont*)node->Data(); + } + else + { + /* + if (int_scale == 100) printf( "int_scale.\n" ); + if (M_FONTDATA->m_style == wxSWISS) printf( "swiss.\n" ); + if (M_FONTDATA->m_pointSize == 12) printf( "12.\n" ); + if (M_FONTDATA->m_weight == wxNORMAL) printf( "normal.\n" ); + if (M_FONTDATA->m_underlined == FALSE) printf( "false.\n" ); + */ + if ((int_scale == 100) && + (M_FONTDATA->m_family == wxSWISS) && + (M_FONTDATA->m_style == wxNORMAL) && + (M_FONTDATA->m_pointSize == 12) && + (M_FONTDATA->m_weight == wxNORMAL) && + (M_FONTDATA->m_underlined == FALSE)) + { + font = gdk_font_load( "-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*" ); + } + else + { + font = wxLoadQueryNearestFont( point_scale, M_FONTDATA->m_fontId, M_FONTDATA->m_style, + M_FONTDATA->m_weight, M_FONTDATA->m_underlined ); + } + M_FONTDATA->m_scaled_xfonts.Append( int_scale, (wxObject*)font ); + } + if (!font) + printf("could not load any font"); + // wxError("could not load any font", "wxFont"); + return font; } //----------------------------------------------------------------------------- @@ -399,46 +391,46 @@ GdkFont *wxFont::GetInternalFont(float scale) const //----------------------------------------------------------------------------- static GdkFont *wxLoadQueryFont(int point_size, int fontid, int style, - int weight, bool WXUNUSED(underlined)) + int weight, bool WXUNUSED(underlined)) { char buffer[512]; char *name = wxTheFontNameDirectory->GetScreenName( fontid, weight, style ); if (!name) - name = "-*-*-*-*-*-*-*-%d-*-*-*-*-*-*"; + name = "-*-*-*-*-*-*-*-%d-*-*-*-*-*-*"; sprintf(buffer, name, point_size); return gdk_font_load( buffer ); } static GdkFont *wxLoadQueryNearestFont(int point_size, int fontid, - int style, int weight, - bool underlined) + int style, int weight, + bool underlined) { GdkFont *font; font = wxLoadQueryFont( point_size, fontid, style, weight, underlined ); if (!font) { - // search up and down by stepsize 10 - int max_size = point_size + 20 * (1 + (point_size/180)); - int min_size = point_size - 20 * (1 + (point_size/180)); - int i; - - // Search for smaller size (approx.) - for (i=point_size-10; !font && i >= 10 && i >= min_size; i -= 10) - font = wxLoadQueryFont(i, fontid, style, weight, underlined); - // Search for larger size (approx.) - for (i=point_size+10; !font && i <= max_size; i += 10) - font = wxLoadQueryFont(i, fontid, style, weight, underlined); - // Try default family - if (!font && fontid != wxDEFAULT) - font = wxLoadQueryFont(point_size, wxDEFAULT, style, - weight, underlined); - // Bogus font - if (!font) - font = wxLoadQueryFont(120, wxDEFAULT, wxNORMAL, wxNORMAL, - underlined); + // search up and down by stepsize 10 + int max_size = point_size + 20 * (1 + (point_size/180)); + int min_size = point_size - 20 * (1 + (point_size/180)); + int i; + + // Search for smaller size (approx.) + for (i=point_size-10; !font && i >= 10 && i >= min_size; i -= 10) + font = wxLoadQueryFont(i, fontid, style, weight, underlined); + // Search for larger size (approx.) + for (i=point_size+10; !font && i <= max_size; i += 10) + font = wxLoadQueryFont(i, fontid, style, weight, underlined); + // Try default family + if (!font && fontid != wxDEFAULT) + font = wxLoadQueryFont(point_size, wxDEFAULT, style, + weight, underlined); + // Bogus font + if (!font) + font = wxLoadQueryFont(120, wxDEFAULT, wxNORMAL, wxNORMAL, + underlined); } return font; } @@ -466,7 +458,7 @@ static char *font_defaults[] = { "AfmTimes", "Times", "AfmHelvetica", "Helv", "AfmCourier", "Cour", - + "Afm___", "${AfmTimes,$[weight],$[style]}", "AfmTimes__", "${AfmTimes}${Afm$[weight]}${Afm$[style]}", @@ -489,7 +481,7 @@ static char *font_defaults[] = { "PostScriptBoldStraight", "-Bold", "PostScriptBoldItalic", "-BoldOblique", "PostScriptBoldSlant", "-BoldOblique", - + #if WX_NORMALIZED_PS_FONTS "PostScript___", "${PostScriptTimes,$[weight],$[style]}", #else @@ -532,7 +524,7 @@ static char *font_defaults[] = { "ScreenScriptBase", "*-zapfchancery", "ScreenStdSuffix", "-${Screen$[weight]}-${Screen$[style]}" - "-normal-*-*-%d-*-*-*-*-*-*", + "-normal-*-*-%d-*-*-*-*-*-*", "Screen___", "-${ScreenDefaultBase}${ScreenStdSuffix}", @@ -557,20 +549,20 @@ enum {wxSTYLE_NORMAL, wxSTYLE_ITALIC, wxSTYLE_SLANT, wxNUM_STYLES}; static int WCoordinate(int w) { switch (w) { - case wxBOLD: return wxWEIGHT_BOLD; - case wxLIGHT: return wxWEIGHT_LIGHT; - case wxNORMAL: - default: return wxWEIGHT_NORMAL; + case wxBOLD: return wxWEIGHT_BOLD; + case wxLIGHT: return wxWEIGHT_LIGHT; + case wxNORMAL: + default: return wxWEIGHT_NORMAL; } }; static int SCoordinate(int s) { switch (s) { - case wxITALIC: return wxSTYLE_ITALIC; - case wxSLANT: return wxSTYLE_SLANT; - case wxNORMAL: - default: return wxSTYLE_NORMAL; + case wxITALIC: return wxSTYLE_ITALIC; + case wxSLANT: return wxSTYLE_SLANT; + case wxNORMAL: + default: return wxSTYLE_NORMAL; } }; @@ -580,11 +572,11 @@ static int SCoordinate(int s) class wxSuffixMap { public: - ~wxSuffixMap(void); + ~wxSuffixMap(); inline char *GetName(int weight, int style) { - return ( map [WCoordinate(weight)] [SCoordinate(style)] ); + return ( map [WCoordinate(weight)] [SCoordinate(style)] ); } char *map[wxNUM_WEIGHTS][wxNUM_STYLES]; @@ -601,45 +593,45 @@ static void SearchResource(const char *prefix, const char **names, int count, ch char resource[1024], **defaults, *internal; k = 1 << count; - + *v = (char *) NULL; internal = (char *) NULL; for (i = 0; i < k; i++) { - strcpy(resource, prefix); - for (j = 0; j < count; j++) { - if (!(i & (1 << j))) - strcat(resource, names[j]); - else - strcat(resource, "_"); - } - if (wxGetResource(wxAPP_CLASS, (char *)resource, v)) - return; - if (!internal) { - defaults = font_defaults; - while (*defaults) { - if (!strcmp(*defaults, resource)) { - internal = defaults[1]; - break; - } - defaults += 2; - } - } + strcpy(resource, prefix); + for (j = 0; j < count; j++) { + if (!(i & (1 << j))) + strcat(resource, names[j]); + else + strcat(resource, "_"); + } + if (wxGetResource(wxAPP_CLASS, (char *)resource, v)) + return; + if (!internal) { + defaults = font_defaults; + while (*defaults) { + if (!strcmp(*defaults, resource)) { + internal = defaults[1]; + break; + } + defaults += 2; + } + } } if (internal) - *v = copystring(internal); + *v = copystring(internal); } -wxSuffixMap::~wxSuffixMap(void) +wxSuffixMap::~wxSuffixMap() { int k, j; for (k = 0; k < wxNUM_WEIGHTS; ++k) - for (j = 0; j < wxNUM_STYLES; ++j) - if (map[k][j]) { - delete[] map[k][j]; - map[k][j] = (char *) NULL; - } + for (j = 0; j < wxNUM_STYLES; ++j) + if (map[k][j]) { + delete[] map[k][j]; + map[k][j] = (char *) NULL; + } } void wxSuffixMap::Initialize(const char *resname, const char *devresname) @@ -650,100 +642,100 @@ void wxSuffixMap::Initialize(const char *resname, const char *devresname) const char *names[3]; for (k = 0; k < wxNUM_WEIGHTS; k++) { - switch (k) { - case wxWEIGHT_NORMAL: weight = "Medium"; break; - case wxWEIGHT_LIGHT: weight = "Light"; break; - case wxWEIGHT_BOLD: - default: weight = "Bold"; - } - for (j = 0; j < wxNUM_STYLES; j++) { - switch (j) { - case wxSTYLE_NORMAL: style = "Straight"; break; - case wxSTYLE_ITALIC: style = "Italic"; break; - case wxSTYLE_SLANT: - default: style = "Slant"; - } - names[0] = resname; - names[1] = weight; - names[2] = style; - - SearchResource(devresname, names, 3, &v); - - /* Expand macros in the found string: */ - found: - int len, closer = 0, startpos = 0; - - len = (v ? strlen(v) : 0); - for (i = 0; i < len; i++) { - if (v[i] == '$' && ((v[i+1] == '[') || (v[i+1] == '{'))) { - startpos = i; - closer = (v[i+1] == '[') ? ']' : '}'; - ++i; - } else if (v[i] == closer) { - int newstrlen; - const char *r = (char *) NULL; bool delete_r = FALSE; - char *name; - - name = v + startpos + 2; - v[i] = 0; - - if (closer == '}') { - int i, count, len; - char **names; - - for (i = 0, count = 1; name[i]; i++) - if (name[i] == ',') - count++; - - len = i; - - names = new char*[count]; - names[0] = name; - for (i = 0, count = 1; i < len; i++) - if (name[i] == ',') { - names[count++] = name + i + 1; - name[i] = 0; - } - - SearchResource("", (const char **)names, count, (char **)&r); - delete_r = (r != 0); - delete[] names; - - if (!r) { - for (i = 0; i < len; i++) - if (!name[i]) - name[i] = ','; - r = ""; - printf("Bad resource name \"%s\" in font lookup\n", name); - } - } else if (!strcmp(name, "weight")) { - r = weight; - } else if (!strcmp(name, "style")) { - r = style; - } else if (!strcmp(name, "family")) { - r = resname; - } else { - r = ""; - printf("Bad font macro name \"%s\"\n", name); - } - - // add r to v - newstrlen = strlen(r); - char *naya = new char[startpos + newstrlen + len - i]; - memcpy(naya, v, startpos); - memcpy(naya + startpos, r, newstrlen); - memcpy(naya + startpos + newstrlen, v + i + 1, len - i); - if (delete_r) - delete[] (char*)r; - delete[] v; - v = naya; - - goto found; - } - } - /* We have a final value: */ - map[k][j] = v; - } + switch (k) { + case wxWEIGHT_NORMAL: weight = "Medium"; break; + case wxWEIGHT_LIGHT: weight = "Light"; break; + case wxWEIGHT_BOLD: + default: weight = "Bold"; + } + for (j = 0; j < wxNUM_STYLES; j++) { + switch (j) { + case wxSTYLE_NORMAL: style = "Straight"; break; + case wxSTYLE_ITALIC: style = "Italic"; break; + case wxSTYLE_SLANT: + default: style = "Slant"; + } + names[0] = resname; + names[1] = weight; + names[2] = style; + + SearchResource(devresname, names, 3, &v); + + /* Expand macros in the found string: */ +found: + int len, closer = 0, startpos = 0; + + len = (v ? strlen(v) : 0); + for (i = 0; i < len; i++) { + if (v[i] == '$' && ((v[i+1] == '[') || (v[i+1] == '{'))) { + startpos = i; + closer = (v[i+1] == '[') ? ']' : '}'; + ++i; + } else if (v[i] == closer) { + int newstrlen; + const char *r = (char *) NULL; bool delete_r = FALSE; + char *name; + + name = v + startpos + 2; + v[i] = 0; + + if (closer == '}') { + int i, count, len; + char **names; + + for (i = 0, count = 1; name[i]; i++) + if (name[i] == ',') + count++; + + len = i; + + names = new char*[count]; + names[0] = name; + for (i = 0, count = 1; i < len; i++) + if (name[i] == ',') { + names[count++] = name + i + 1; + name[i] = 0; + } + + SearchResource("", (const char **)names, count, (char **)&r); + delete_r = (r != 0); + delete[] names; + + if (!r) { + for (i = 0; i < len; i++) + if (!name[i]) + name[i] = ','; + r = ""; + printf("Bad resource name \"%s\" in font lookup\n", name); + } + } else if (!strcmp(name, "weight")) { + r = weight; + } else if (!strcmp(name, "style")) { + r = style; + } else if (!strcmp(name, "family")) { + r = resname; + } else { + r = ""; + printf("Bad font macro name \"%s\"\n", name); + } + + // add r to v + newstrlen = strlen(r); + char *naya = new char[startpos + newstrlen + len - i]; + memcpy(naya, v, startpos); + memcpy(naya + startpos, r, newstrlen); + memcpy(naya + startpos + newstrlen, v + i + 1, len - i); + if (delete_r) + delete[] (char*)r; + delete[] v; + v = naya; + + goto found; + } + } + /* We have a final value: */ + map[k][j] = v; + } } } @@ -752,27 +744,27 @@ void wxSuffixMap::Initialize(const char *resname, const char *devresname) //----------------------------------------------------------------------------- class wxFontNameItem : public wxObject { -DECLARE_DYNAMIC_CLASS(wxFontNameItem) + DECLARE_DYNAMIC_CLASS(wxFontNameItem) public: - wxFontNameItem(const char *name, int id, int family); - ~wxFontNameItem(); - - inline char* GetScreenName(int w, int s) {return screen.GetName(w, s);} - inline char* GetPostScriptName(int w, int s) {return printing.GetName(w, s);} - inline char* GetAFMName(int w, int s) {return afm.GetName(w, s);} - inline char* GetName(void) {return name;} - inline int GetFamily(void) {return family;} - inline int GetId(void) {return id;} - inline bool IsRoman(void) {return isroman;} + wxFontNameItem(const char *name, int id, int family); + ~wxFontNameItem(); + + inline char* GetScreenName(int w, int s) {return screen.GetName(w, s);} + inline char* GetPostScriptName(int w, int s) {return printing.GetName(w, s);} + inline char* GetAFMName(int w, int s) {return afm.GetName(w, s);} + inline char* GetName() {return name;} + inline int GetFamily() {return family;} + inline int GetId() {return id;} + inline bool IsRoman() {return isroman;} #if defined(__WXDEBUG__) - void Dump(ostream& str); + void Dump(ostream& str); #endif - int id; - int family; - char *name; - wxSuffixMap screen, printing, afm; - bool isroman; + int id; + int family; + char *name; + wxSuffixMap screen, printing, afm; + bool isroman; }; IMPLEMENT_ABSTRACT_CLASS(wxFontNameItem, wxObject) @@ -788,10 +780,10 @@ wxFontNameItem::wxFontNameItem(const char *Name, int Id, int Family) afm. Initialize(name, "Afm"); } -wxFontNameItem::~wxFontNameItem(void) +wxFontNameItem::~wxFontNameItem() { if (name) - delete[] name; + delete[] name; name = (char *) NULL; } @@ -808,7 +800,7 @@ void wxFontNameItem::Dump(ostream& str) IMPLEMENT_DYNAMIC_CLASS(wxFontNameDirectory, wxObject) -wxFontNameDirectory::wxFontNameDirectory(void) +wxFontNameDirectory::wxFontNameDirectory() { table = new wxHashTable(wxKEY_INTEGER, 20); nextFontId = -1; @@ -820,14 +812,14 @@ wxFontNameDirectory::~wxFontNameDirectory() table->BeginFind(); wxNode *node = table->Next(); while (node) { - wxFontNameItem *item = (wxFontNameItem*)node->Data(); - delete item; - node = table->Next(); + wxFontNameItem *item = (wxFontNameItem*)node->Data(); + delete item; + node = table->Next(); } delete table; } -int wxFontNameDirectory::GetNewFontId(void) +int wxFontNameDirectory::GetNewFontId() { return (nextFontId--); } @@ -846,18 +838,18 @@ void wxFontNameDirectory::Initialize() void wxFontNameDirectory::Initialize(int fontid, int family, const char *resname) { char *fam, resource[256]; - + sprintf(resource, "Family%s", resname); SearchResource((const char *)resource, (const char **) NULL, 0, (char **)&fam); if (fam) { - if (!strcmp(fam, "Default")) family = wxDEFAULT; - else if (!strcmp(fam, "Roman")) family = wxROMAN; - else if (!strcmp(fam, "Decorative")) family = wxDECORATIVE; - else if (!strcmp(fam, "Modern")) family = wxMODERN; - else if (!strcmp(fam, "Teletype")) family = wxTELETYPE; - else if (!strcmp(fam, "Swiss")) family = wxSWISS; - else if (!strcmp(fam, "Script")) family = wxSCRIPT; - delete[] fam; // free resource + if (!strcmp(fam, "Default")) family = wxDEFAULT; + else if (!strcmp(fam, "Roman")) family = wxROMAN; + else if (!strcmp(fam, "Decorative")) family = wxDECORATIVE; + else if (!strcmp(fam, "Modern")) family = wxMODERN; + else if (!strcmp(fam, "Teletype")) family = wxTELETYPE; + else if (!strcmp(fam, "Swiss")) family = wxSWISS; + else if (!strcmp(fam, "Script")) family = wxSCRIPT; + delete[] fam; // free resource } table->Put(fontid, new wxFontNameItem(resname, fontid, family)); } @@ -877,7 +869,7 @@ char *wxFontNameDirectory::GetScreenName(int fontid, int weight, int style) { wxFontNameItem *item = (wxFontNameItem*)table->Get(fontid); // find font if (item) - return item->GetScreenName(weight, style); + return item->GetScreenName(weight, style); // font does not exist return (char *) NULL; } @@ -886,7 +878,7 @@ char *wxFontNameDirectory::GetPostScriptName(int fontid, int weight, int style) { wxFontNameItem *item = (wxFontNameItem*)table->Get(fontid); // find font if (item) - return item->GetPostScriptName(weight, style); + return item->GetPostScriptName(weight, style); // font does not exist return (char *) NULL; } @@ -895,7 +887,7 @@ char *wxFontNameDirectory::GetAFMName(int fontid, int weight, int style) { wxFontNameItem *item = (wxFontNameItem *)table->Get(fontid); // find font if (item) - return item->GetAFMName(weight, style); + return item->GetAFMName(weight, style); // font does not exist return (char *) NULL; } @@ -904,7 +896,7 @@ char *wxFontNameDirectory::GetFontName(int fontid) { wxFontNameItem *item = (wxFontNameItem *)table->Get(fontid); // find font if (item) - return item->GetName(); + return item->GetName(); // font does not exist return (char *) NULL; } @@ -916,9 +908,9 @@ int wxFontNameDirectory::GetFontId(const char *name) table->BeginFind(); while ( (node = table->Next()) ) { - wxFontNameItem *item = (wxFontNameItem*)node->Data(); - if (!strcmp(name, item->name)) - return item->id; + wxFontNameItem *item = (wxFontNameItem*)node->Data(); + if (!strcmp(name, item->name)) + return item->id; } // font does not exist return 0; @@ -927,9 +919,9 @@ int wxFontNameDirectory::GetFontId(const char *name) int wxFontNameDirectory::GetFamily(int fontid) { wxFontNameItem *item = (wxFontNameItem *)table->Get(fontid); - + if (item) - return item->family; + return item->family; // font does not exist return wxDEFAULT; } diff --git a/src/gtk/frame.cpp b/src/gtk/frame.cpp index 1dfee32d43..4e9104c7a9 100644 --- a/src/gtk/frame.cpp +++ b/src/gtk/frame.cpp @@ -42,14 +42,14 @@ extern wxList wxPendingDelete; static void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxFrame *win ) { if (!win->HasVMT()) return; - + /* printf( "OnFrameResize from " ); if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) printf( win->GetClassInfo()->GetClassName() ); printf( ".\n" ); */ - + if ((win->m_width != alloc->width) || (win->m_height != alloc->height)) { win->m_sizeSet = FALSE; @@ -83,10 +83,10 @@ static gint gtk_frame_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WX static gint gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *event, wxFrame *win ) { if (!win->HasVMT()) return FALSE; - + win->m_x = event->x; win->m_y = event->y; - + return FALSE; } @@ -130,7 +130,7 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title, long style, const wxString &name ) { wxTopLevelWindows.Append( this ); - + m_needParent = FALSE; PreCreation( parent, id, pos, size, style, name ); @@ -139,9 +139,9 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title, GtkWindowType win_type = GTK_WINDOW_TOPLEVEL; if (style & wxSIMPLE_BORDER) win_type = GTK_WINDOW_POPUP; - + m_widget = gtk_window_new( win_type ); - + if ((size.x != -1) && (size.y != -1)) gtk_widget_set_usize( m_widget, m_width, m_height ); if ((pos.x != -1) && (pos.y != -1)) @@ -166,11 +166,11 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title, gtk_signal_connect( GTK_OBJECT(m_widget), "configure_event", GTK_SIGNAL_FUNC(gtk_frame_configure_callback), (gpointer)this ); - + if (m_parent) m_parent->AddChild( this ); - + PostCreation(); - + return TRUE; } @@ -187,17 +187,17 @@ wxFrame::~wxFrame() bool wxFrame::Show( bool show ) { wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); - + if (show && !m_sizeSet) { - // by calling GtkOnSize here, we don't have to call - // either after showing the frame, which would entail - // much ugly flicker nor from within the size_allocate - // handler, because GTK 1.1.X forbids that. - + // by calling GtkOnSize here, we don't have to call + // either after showing the frame, which would entail + // much ugly flicker nor from within the size_allocate + // handler, because GTK 1.1.X forbids that. + GtkOnSize( m_x, m_y, m_width, m_height ); } - + return wxWindow::Show( show ); } @@ -209,7 +209,7 @@ void wxFrame::OnCloseWindow( wxCloseEvent &event ) bool wxFrame::Destroy() { wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); - + if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this); return TRUE; @@ -236,7 +236,7 @@ wxPoint wxFrame::GetClientAreaOrigin() const void wxFrame::SetSize( int x, int y, int width, int height, int sizeFlags ) { wxASSERT_MSG( (m_widget != NULL), "invalid window" ); - + // Don't do anything for children of wxMDIChildFrame if (!m_wxwindow) return; @@ -247,7 +247,7 @@ void wxFrame::SetSize( int x, int y, int width, int height, int sizeFlags ) int old_y = m_y; int old_width = m_width; int old_height = m_height; - + if ((sizeFlags & wxSIZE_USE_EXISTING) == wxSIZE_USE_EXISTING) { if (x != -1) m_x = x; @@ -272,7 +272,7 @@ void wxFrame::SetSize( int x, int y, int width, int height, int sizeFlags ) { if (height == -1) m_height = 26; } - + if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth; if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight; if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_minWidth; @@ -280,15 +280,15 @@ void wxFrame::SetSize( int x, int y, int width, int height, int sizeFlags ) if ((m_x != -1) || (m_y != -1)) { - if ((m_x != old_x) || (m_y != old_y)) + if ((m_x != old_x) || (m_y != old_y)) gtk_widget_set_uposition( m_widget, m_x, m_y ); } - + if ((m_width != old_width) || (m_height != old_height)) { gtk_widget_set_usize( m_widget, m_width, m_height ); } - + wxSizeEvent event( wxSize(m_width,m_height), GetId() ); event.SetEventObject( this ); GetEventHandler()->ProcessEvent( event ); @@ -304,20 +304,20 @@ void wxFrame::SetSize( int width, int height ) void wxFrame::Centre( int direction ) { wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); - + int x = 0; int y = 0; - + if (direction & wxHORIZONTAL == wxHORIZONTAL) x = (gdk_screen_width () - m_width) / 2; if (direction & wxVERTICAL == wxVERTICAL) y = (gdk_screen_height () - m_height) / 2; - + Move( x, y ); } void wxFrame::GetClientSize( int *width, int *height ) const { wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); - + wxWindow::GetClientSize( width, height ); if (height) { @@ -340,7 +340,7 @@ void wxFrame::GetClientSize( int *width, int *height ) const void wxFrame::SetClientSize( int const width, int const height ) { wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); - + int h = height; if (m_frameMenuBar) h += wxMENU_HEIGHT; if (m_frameStatusBar) h += wxSTATUS_HEIGHT; @@ -361,35 +361,35 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height if (m_resizing) return; m_resizing = TRUE; - + if (!m_wxwindow) return; - + m_width = width; m_height = height; - + if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth; if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight; if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_minWidth; if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_minHeight; gtk_widget_set_usize( m_widget, m_width, m_height ); - + // this emulates the new wxMSW behaviour of placing all // frame-subwindows (menu, toolbar..) on one native window // OK, this hurts in the eye, but I don't want to call SetSize() // because I don't want to call any non-native functions here. - + if (m_frameMenuBar) { int xx = m_miniEdge; - int yy = m_miniEdge + m_miniTitle; - int ww = m_width - 2*m_miniEdge; - int hh = wxMENU_HEIGHT; + int yy = m_miniEdge + m_miniTitle; + int ww = m_width - 2*m_miniEdge; + int hh = wxMENU_HEIGHT; m_frameMenuBar->m_x = xx; m_frameMenuBar->m_y = yy; m_frameMenuBar->m_width = ww; m_frameMenuBar->m_height = hh; - + gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_frameMenuBar->m_widget, xx, yy ); gtk_widget_set_usize( m_frameMenuBar->m_widget, ww, hh ); } @@ -397,42 +397,42 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height if (m_frameToolBar) { int xx = m_miniEdge; - int yy = m_miniEdge + m_miniTitle; + int yy = m_miniEdge + m_miniTitle; if (m_frameMenuBar) yy += wxMENU_HEIGHT; - int ww = m_width - 2*m_miniEdge; + int ww = m_width - 2*m_miniEdge; int hh = m_frameToolBar->m_height; - - m_frameToolBar->m_x = xx; + + m_frameToolBar->m_x = xx; m_frameToolBar->m_y = yy; m_frameToolBar->m_height = hh; m_frameToolBar->m_width = ww; - + gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_frameToolBar->m_widget, xx, yy ); gtk_widget_set_usize( m_frameToolBar->m_widget, ww, hh ); } - + if (m_frameStatusBar) { int xx = 0 + m_miniEdge; - int yy = m_height - wxSTATUS_HEIGHT - m_miniEdge; - int ww = m_width - 2*m_miniEdge; - int hh = wxSTATUS_HEIGHT; - + int yy = m_height - wxSTATUS_HEIGHT - m_miniEdge; + 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; - + gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_frameStatusBar->m_widget, xx, yy ); gtk_widget_set_usize( m_frameStatusBar->m_widget, ww, hh ); } - + m_sizeSet = TRUE; - + wxSizeEvent event( wxSize(m_width,m_height), GetId() ); event.SetEventObject( this ); GetEventHandler()->ProcessEvent( event ); - + m_resizing = FALSE; } @@ -440,23 +440,23 @@ void wxFrame::OnIdle(wxIdleEvent& WXUNUSED(event) ) { if (!m_sizeSet) GtkOnSize( m_x, m_y, m_width, m_height ); - + DoMenuUpdates(); } void wxFrame::OnSize( wxSizeEvent &WXUNUSED(event) ) { wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); - + if (GetAutoLayout()) { Layout(); } - else + else { // no child: go out ! if (!GetChildren().First()) return; - + // do we have exactly one child? wxWindow *child = (wxWindow *) NULL; for(wxNode *node = GetChildren().First(); node; node = node->Next()) @@ -470,7 +470,7 @@ void wxFrame::OnSize( wxSizeEvent &WXUNUSED(event) ) #endif ) { - // it's the second one: do nothing + // it's the second one: do nothing if (child) return; child = win; } @@ -500,9 +500,9 @@ void wxFrame::SetMenuBar( wxMenuBar *menuBar ) { wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); wxASSERT_MSG( (m_wxwindow != NULL), "invalid frame" ); - + m_frameMenuBar = menuBar; - + if (m_frameMenuBar) { wxNode *node = m_frameMenuBar->m_menus.First(); @@ -512,7 +512,7 @@ void wxFrame::SetMenuBar( wxMenuBar *menuBar ) SetInvokingWindow( menu, this ); node = node->Next(); } - + if (m_frameMenuBar->m_parent != this) { m_frameMenuBar->m_parent = this; @@ -520,11 +520,11 @@ void wxFrame::SetMenuBar( wxMenuBar *menuBar ) m_frameMenuBar->m_widget, m_frameMenuBar->m_x, m_frameMenuBar->m_y ); } } - + if (m_sizeSet) GtkOnSize( m_x, m_y, m_width, m_height ); } -wxMenuBar *wxFrame::GetMenuBar(void) const +wxMenuBar *wxFrame::GetMenuBar() const { return m_frameMenuBar; } @@ -532,15 +532,15 @@ wxMenuBar *wxFrame::GetMenuBar(void) const wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name) { wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); - + wxCHECK_MSG( m_frameToolBar == NULL, FALSE, "recreating toolbar in wxFrame" ); m_frameToolBar = OnCreateToolBar( style, id, name ); - + GetChildren().DeleteObject( m_frameToolBar ); - + if (m_sizeSet) GtkOnSize( m_x, m_y, m_width, m_height ); - + return m_frameToolBar; } @@ -549,33 +549,33 @@ wxToolBar* wxFrame::OnCreateToolBar( long style, wxWindowID id, const wxString& return new wxToolBar( this, id, wxDefaultPosition, wxDefaultSize, style, name ); } -wxToolBar *wxFrame::GetToolBar(void) const -{ - return m_frameToolBar; +wxToolBar *wxFrame::GetToolBar() const +{ + return m_frameToolBar; } wxStatusBar* wxFrame::CreateStatusBar( int number, long style, wxWindowID id, const wxString& name ) { wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); - + wxCHECK_MSG( m_frameStatusBar == NULL, FALSE, "recreating status bar in wxFrame" ); m_frameStatusBar = OnCreateStatusBar( number, style, id, name ); - + if (m_sizeSet) GtkOnSize( m_x, m_y, m_width, m_height ); - + return m_frameStatusBar; } wxStatusBar *wxFrame::OnCreateStatusBar( int number, long style, wxWindowID id, const wxString& name ) { wxStatusBar *statusBar = (wxStatusBar *) NULL; - + statusBar = new wxStatusBar(this, id, wxPoint(0, 0), wxSize(100, 20), style, name); - + // Set the height according to the font and the border size wxClientDC dc(statusBar); - dc.SetFont( *statusBar->GetFont() ); + dc.SetFont( statusBar->GetFont() ); long x, y; dc.GetTextExtent( "X", &x, &y ); @@ -591,7 +591,7 @@ wxStatusBar *wxFrame::OnCreateStatusBar( int number, long style, wxWindowID id, void wxFrame::SetStatusText(const wxString& text, int number) { wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); - + wxCHECK_RET( m_frameStatusBar != NULL, "no statusbar to set text for" ); m_frameStatusBar->SetStatusText(text, number); @@ -600,13 +600,13 @@ void wxFrame::SetStatusText(const wxString& text, int number) void wxFrame::SetStatusWidths(int n, const int widths_field[] ) { wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); - + wxCHECK_RET( m_frameStatusBar != NULL, "no statusbar to set widths for" ); m_frameStatusBar->SetStatusWidths(n, widths_field); } -wxStatusBar *wxFrame::GetStatusBar(void) const +wxStatusBar *wxFrame::GetStatusBar() const { return m_frameStatusBar; } @@ -614,7 +614,7 @@ wxStatusBar *wxFrame::GetStatusBar(void) const void wxFrame::SetTitle( const wxString &title ) { wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); - + m_title = title; if (m_title.IsNull()) m_title = ""; gtk_window_set_title( GTK_WINDOW(m_widget), title ); @@ -623,14 +623,14 @@ void wxFrame::SetTitle( const wxString &title ) void wxFrame::SetIcon( const wxIcon &icon ) { wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); - + m_icon = icon; if (!icon.Ok()) return; - + wxMask *mask = icon.GetMask(); GdkBitmap *bm = (GdkBitmap *) NULL; if (mask) bm = mask->GetBitmap(); - + gdk_window_set_icon( m_widget->window, (GdkWindow *) NULL, icon.GetPixmap(), bm ); } diff --git a/src/gtk/icon.cpp b/src/gtk/icon.cpp index 37ce52b757..a372cb9869 100644 --- a/src/gtk/icon.cpp +++ b/src/gtk/icon.cpp @@ -19,34 +19,29 @@ IMPLEMENT_DYNAMIC_CLASS(wxIcon,wxBitmap) -wxIcon::wxIcon( const char **bits, int WXUNUSED(width), int WXUNUSED(height) ) : - wxBitmap( bits ) +wxIcon::wxIcon( const char **bits, int WXUNUSED(width), int WXUNUSED(height) ) : + wxBitmap( bits ) { } - -wxIcon::wxIcon( char **bits, int WXUNUSED(width), int WXUNUSED(height) ) : - wxBitmap( bits ) + +wxIcon::wxIcon( char **bits, int WXUNUSED(width), int WXUNUSED(height) ) : + wxBitmap( bits ) { } - -wxIcon::wxIcon() : wxBitmap() -{ -} -wxIcon::wxIcon( const wxIcon& icon ) : wxBitmap() -{ - Ref(icon); +wxIcon::wxIcon() : wxBitmap() +{ } -wxIcon::wxIcon( const wxIcon* icon ) : wxBitmap() -{ - if (icon) Ref(*icon); +wxIcon::wxIcon( const wxIcon& icon ) : wxBitmap() +{ + Ref(icon); } wxIcon& wxIcon::operator = ( const wxIcon& icon ) -{ - if (*this == icon) return (*this); - Ref(icon); - return *this; +{ + if (*this == icon) return (*this); + Ref(icon); + return *this; } diff --git a/src/gtk/menu.cpp b/src/gtk/menu.cpp index 7d8900886e..09c77c3479 100644 --- a/src/gtk/menu.cpp +++ b/src/gtk/menu.cpp @@ -31,7 +31,7 @@ wxMenuBar::wxMenuBar() m_menus.DeleteContents( TRUE ); m_menubar = gtk_menu_bar_new(); - + m_widget = GTK_WIDGET(m_menubar); PostCreation(); @@ -159,7 +159,7 @@ static void gtk_menu_clicked_callback( GtkWidget *widget, wxMenu *menu ) wxCommandEvent event( wxEVT_COMMAND_MENU_SELECTED, id ); event.SetEventObject( menu ); event.SetInt(id ); - + if (menu->m_callback) { (void) (*(menu->m_callback)) (*menu, event); @@ -187,7 +187,7 @@ static void gtk_menu_hilight_callback( GtkWidget *widget, wxMenu *menu ) wxCommandEvent event( wxEVT_MENU_HIGHLIGHT, id ); event.SetEventObject( menu ); event.SetInt(id ); - + /* wxMSW doesn't call callback here either if (menu->m_callback) { @@ -218,22 +218,24 @@ wxMenuItem::wxMenuItem() m_menuItem = (GtkWidget *) NULL; } +// it's valid for this function to be called even if m_menuItem == NULL void wxMenuItem::SetName(const wxString& str) { - wxCHECK_RET( m_menuItem, "invalid menu item" ); - m_text = ""; - for ( const char *pc = str; *pc != '\0'; pc++ ) + for ( const char *pc = str; *pc != '\0'; pc++ ) { if ( *pc == '&' ) pc++; // skip it m_text << *pc; } - - GtkLabel *label = GTK_LABEL( GTK_BIN(m_menuItem)->child ); - - gtk_label_set( label, m_text.c_str()); + + if ( m_menuItem ) + { + GtkLabel *label = GTK_LABEL( GTK_BIN(m_menuItem)->child ); + + gtk_label_set( label, m_text.c_str()); + } } void wxMenuItem::Check( bool check ) @@ -246,12 +248,12 @@ void wxMenuItem::Check( bool check ) gtk_check_menu_item_set_state( (GtkCheckMenuItem*)m_menuItem, (gint)check ); } -void wxMenuItem::Enable( bool enable ) -{ +void wxMenuItem::Enable( bool enable ) +{ wxCHECK_RET( m_menuItem, "invalid menu item" ); gtk_widget_set_sensitive( m_menuItem, enable ); - m_isEnabled = enable; + m_isEnabled = enable; } bool wxMenuItem::IsChecked() const @@ -279,11 +281,11 @@ wxMenu::wxMenu( const wxString& title, const wxFunction func ) m_items.DeleteContents( TRUE ); m_invokingWindow = (wxWindow *) NULL; m_menu = gtk_menu_new(); // Do not show! - + m_callback = func; m_eventHandler = this; m_clientData = (void*) NULL; - + if (m_title.IsNull()) m_title = ""; if (m_title != "") { @@ -325,7 +327,7 @@ void wxMenu::Append( int id, const wxString &item, const wxString &helpStr, bool const char *text = mitem->GetText(); GtkWidget *menuItem = checkable ? gtk_check_menu_item_new_with_label(text) : gtk_menu_item_new_with_label(text); - + mitem->SetMenuItem(menuItem); gtk_signal_connect( GTK_OBJECT(menuItem), "activate", @@ -466,7 +468,7 @@ wxMenuItem *wxMenu::FindItem(int id) const // Not finding anything here can be correct // when search the entire menu system for // an entry -> no error message. - + return (wxMenuItem *) NULL; } diff --git a/src/gtk/palette.cpp b/src/gtk/palette.cpp index 9f49402c61..07d99dc13c 100644 --- a/src/gtk/palette.cpp +++ b/src/gtk/palette.cpp @@ -22,19 +22,19 @@ class wxPaletteRefData: public wxObjectRefData { public: - + wxPaletteRefData(void); ~wxPaletteRefData(void); - + GdkColormap *m_colormap; }; -wxPaletteRefData::wxPaletteRefData(void) +wxPaletteRefData::wxPaletteRefData() { m_colormap = (GdkColormap *) NULL; }; -wxPaletteRefData::~wxPaletteRefData(void) +wxPaletteRefData::~wxPaletteRefData() { if (m_colormap) gdk_colormap_unref( m_colormap ); }; @@ -45,7 +45,7 @@ wxPaletteRefData::~wxPaletteRefData(void) IMPLEMENT_DYNAMIC_CLASS(wxPalette,wxGDIObject) -wxPalette::wxPalette(void) +wxPalette::wxPalette() { }; @@ -60,31 +60,25 @@ wxPalette::wxPalette( const wxPalette& palette ) Ref( palette ); }; -wxPalette::wxPalette( const wxPalette* palette ) -{ - UnRef(); - if (palette) Ref( *palette ); -}; - -wxPalette::~wxPalette(void) +wxPalette::~wxPalette() { }; wxPalette& wxPalette::operator = ( const wxPalette& palette ) { - if (*this == palette) return (*this); - Ref( palette ); - return *this; + if (*this == palette) return (*this); + Ref( palette ); + return *this; }; bool wxPalette::operator == ( const wxPalette& palette ) { - return m_refData == palette.m_refData; + return m_refData == palette.m_refData; }; bool wxPalette::operator != ( const wxPalette& palette ) { - return m_refData != palette.m_refData; + return m_refData != palette.m_refData; }; bool wxPalette::Ok(void) const diff --git a/src/gtk/pen.cpp b/src/gtk/pen.cpp index dc2fec60a0..8402796a46 100644 --- a/src/gtk/pen.cpp +++ b/src/gtk/pen.cpp @@ -4,7 +4,7 @@ // Author: Robert Roebling // Id: $Id$ // Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -21,10 +21,10 @@ class wxPenRefData: public wxObjectRefData { public: - + wxPenRefData(void); wxPenRefData(const wxPenRefData& data); - + int m_width; int m_style; int m_joinStyle; @@ -55,7 +55,7 @@ wxPenRefData::wxPenRefData( const wxPenRefData& data ) IMPLEMENT_DYNAMIC_CLASS(wxPen,wxGDIObject) -wxPen::wxPen(void) +wxPen::wxPen() { if (wxThePenList) wxThePenList->AddPen( this ); } @@ -66,7 +66,7 @@ wxPen::wxPen( const wxColour &colour, int width, int style ) M_PENDATA->m_width = width; M_PENDATA->m_style = style; M_PENDATA->m_colour = colour; - + if (wxThePenList) wxThePenList->AddPen( this ); } @@ -76,14 +76,6 @@ wxPen::wxPen( const wxPen& pen ) if (wxThePenList) wxThePenList->AddPen( this ); } -wxPen::wxPen( const wxPen* pen ) -{ - UnRef(); - if (pen) Ref( *pen ); - - if (wxThePenList) wxThePenList->AddPen( this ); -} - wxPen::~wxPen() { if (wxThePenList) wxThePenList->RemovePen( this ); @@ -91,19 +83,19 @@ wxPen::~wxPen() wxPen& wxPen::operator = ( const wxPen& pen ) { - if (*this == pen) return (*this); - Ref( pen ); - return *this; + if (*this == pen) return (*this); + Ref( pen ); + return *this; } bool wxPen::operator == ( const wxPen& pen ) { - return m_refData == pen.m_refData; + return m_refData == pen.m_refData; } bool wxPen::operator != ( const wxPen& pen ) { - return m_refData != pen.m_refData; + return m_refData != pen.m_refData; } void wxPen::SetColour( const wxColour &colour ) @@ -145,35 +137,35 @@ void wxPen::SetWidth( int width ) int wxPen::GetCap() const { wxCHECK_MSG( Ok(), -1, "invalid pen" ); - + return M_PENDATA->m_capStyle; } int wxPen::GetJoin() const { wxCHECK_MSG( Ok(), -1, "invalid pen" ); - + return M_PENDATA->m_joinStyle; } int wxPen::GetStyle() const { wxCHECK_MSG( Ok(), -1, "invalid pen" ); - + return M_PENDATA->m_style; } int wxPen::GetWidth() const { wxCHECK_MSG( Ok(), -1, "invalid pen" ); - + return M_PENDATA->m_width; } wxColour &wxPen::GetColour() const { wxCHECK_MSG( Ok(), wxNullColour, "invalid pen" ); - + return M_PENDATA->m_colour; } diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index e99ff0e8b7..c2fb43427b 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -26,7 +26,7 @@ static void gtk_text_changed_callback( GtkWidget *WXUNUSED(widget), wxTextCtrl *win ) { win->SetModified(); - + wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, win->m_windowId ); wxString val( win->GetValue() ); if (!val.IsNull()) event.m_commandString = WXSTRINGCAST val; @@ -89,7 +89,7 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value, 0, 0); // put the horizontal scrollbar in the lower left hand corner - if (bHasHScrollbar) + if (bHasHScrollbar) { GtkWidget *hscrollbar = gtk_hscrollbar_new(GTK_TEXT(m_text)->hadj); gtk_table_attach(GTK_TABLE(m_widget), hscrollbar, 0, 1, 1, 2, @@ -107,7 +107,7 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value, 0, 0); gtk_widget_show( vscrollbar ); } - else + else { // a single-line text control: no need for scrollbars m_widget = @@ -122,10 +122,10 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value, m_parent->AddChild( this ); (m_parent->m_insertCallback)( m_parent, this ); - + PostCreation(); - if (multi_line) + if (multi_line) { gtk_widget_realize(m_text); gtk_widget_show(m_text); @@ -148,9 +148,9 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value, if (!multi_line) gtk_entry_set_visibility( GTK_ENTRY(m_text), FALSE ); } - + if (style & wxTE_READONLY) - { + { if (!multi_line) gtk_entry_set_editable( GTK_ENTRY(m_text), FALSE ); } @@ -171,7 +171,7 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value, wxString wxTextCtrl::GetValue() const { wxCHECK_MSG( m_text != NULL, "", "invalid text ctrl" ); - + wxString tmp; if (m_windowStyle & wxTE_MULTILINE) { @@ -190,7 +190,7 @@ wxString wxTextCtrl::GetValue() const void wxTextCtrl::SetValue( const wxString &value ) { wxCHECK_RET( m_text != NULL, "invalid text ctrl" ); - + wxString tmp = ""; if (!value.IsNull()) tmp = value; if (m_windowStyle & wxTE_MULTILINE) @@ -209,7 +209,7 @@ void wxTextCtrl::SetValue( const wxString &value ) void wxTextCtrl::WriteText( const wxString &text ) { wxCHECK_RET( m_text != NULL, "invalid text ctrl" ); - + if (text.IsNull()) return; if (m_windowStyle & wxTE_MULTILINE) @@ -226,14 +226,14 @@ void wxTextCtrl::WriteText( const wxString &text ) bool wxTextCtrl::LoadFile( const wxString &file ) { wxCHECK_MSG( m_text != NULL, FALSE, "invalid text ctrl" ); - + if (!wxFileExists(file)) return FALSE; Clear(); FILE *fp = NULL; struct stat statb; - + if ((stat ((char*) (const char*) file, &statb) == -1) || (statb.st_mode & S_IFMT) != S_IFREG || !(fp = fopen ((char*) (const char*) file, "r"))) { @@ -254,7 +254,7 @@ bool wxTextCtrl::LoadFile( const wxString &file ) fclose (fp); text[len] = 0; - + if (m_windowStyle & wxTE_MULTILINE) { gtk_editable_insert_text( GTK_EDITABLE(m_text), text, 0, &len ); @@ -263,7 +263,7 @@ bool wxTextCtrl::LoadFile( const wxString &file ) { gtk_entry_set_text( GTK_ENTRY(m_text), text ); } - + free (text); m_modified = FALSE; return TRUE; @@ -274,9 +274,9 @@ bool wxTextCtrl::LoadFile( const wxString &file ) bool wxTextCtrl::SaveFile( const wxString &file ) { wxCHECK_MSG( m_text != NULL, FALSE, "invalid text ctrl" ); - + if (file == "") return FALSE; - + FILE *fp; if (!(fp = fopen ((char*) (const char*) file, "w"))) @@ -287,7 +287,7 @@ bool wxTextCtrl::SaveFile( const wxString &file ) { char *text = NULL; gint len = 0; - + if (m_windowStyle & wxTE_MULTILINE) { len = gtk_text_get_length( GTK_TEXT(m_text) ); @@ -297,20 +297,20 @@ bool wxTextCtrl::SaveFile( const wxString &file ) { text = gtk_entry_get_text( GTK_ENTRY(m_text) ); } - + if (fwrite (text, sizeof (char), len, fp) != (size_t) len) { // Did not write whole file } - + // Make sure newline terminates the file if (text[len - 1] != '\n') fputc ('\n', fp); fclose (fp); - + if (m_windowStyle & wxTE_MULTILINE) g_free( text ); - + m_modified = FALSE; return TRUE; } @@ -337,7 +337,7 @@ wxString wxTextCtrl::GetLineText( long lineNo ) const int j; for (j = 0; text[i] && text[i] != '\n'; i++, j++ ) buf += text[i]; - + g_free( text ); return buf; } @@ -366,7 +366,7 @@ long wxTextCtrl::PositionToXY(long pos, long *x, long *y ) const return 0; if( pos >= len) return pos=len-1; - + *x=1; // Col 1 *y=1; // Line 1 for (int i = 0; i < pos; i++ ) @@ -378,7 +378,7 @@ long wxTextCtrl::PositionToXY(long pos, long *x, long *y ) const } else (*x)++; - } + } g_free( text ); return 1; } @@ -388,7 +388,7 @@ long wxTextCtrl::XYToPosition(long x, long y ) const if (!(m_windowStyle & wxTE_MULTILINE)) return 0; long pos=0; - + for(int i=1;icurrent_pos; } long wxTextCtrl::GetLastPosition() const { wxCHECK_MSG( m_text != NULL, 0, "invalid text ctrl" ); - + int pos = 0; if (m_windowStyle & wxTE_MULTILINE) pos = gtk_text_get_length( GTK_TEXT(m_text) ); @@ -494,14 +494,14 @@ long wxTextCtrl::GetLastPosition() const void wxTextCtrl::Remove( long from, long to ) { wxCHECK_RET( m_text != NULL, "invalid text ctrl" ); - + gtk_editable_delete_text( GTK_EDITABLE(m_text), (gint)from, (gint)to ); } void wxTextCtrl::Replace( long from, long to, const wxString &value ) { wxCHECK_RET( m_text != NULL, "invalid text ctrl" ); - + gtk_editable_delete_text( GTK_EDITABLE(m_text), (gint)from, (gint)to ); if (value.IsNull()) return; gint pos = (gint)to; @@ -511,7 +511,7 @@ void wxTextCtrl::Replace( long from, long to, const wxString &value ) void wxTextCtrl::Cut() { wxCHECK_RET( m_text != NULL, "invalid text ctrl" ); - + #if (GTK_MINOR_VERSION == 1) gtk_editable_cut_clipboard( GTK_EDITABLE(m_text) ); #else @@ -522,7 +522,7 @@ void wxTextCtrl::Cut() void wxTextCtrl::Copy() { wxCHECK_RET( m_text != NULL, "invalid text ctrl" ); - + #if (GTK_MINOR_VERSION == 1) gtk_editable_copy_clipboard( GTK_EDITABLE(m_text) ); #else @@ -533,7 +533,7 @@ void wxTextCtrl::Copy() void wxTextCtrl::Paste() { wxCHECK_RET( m_text != NULL, "invalid text ctrl" ); - + #if (GTK_MINOR_VERSION == 1) gtk_editable_paste_clipboard( GTK_EDITABLE(m_text) ); #else @@ -554,7 +554,7 @@ void wxTextCtrl::OnChar( wxKeyEvent &key_event ) event.SetEventObject(this); if (GetEventHandler()->ProcessEvent(event)) return; } - else if (key_event.KeyCode() == WXK_TAB) + else if (key_event.KeyCode() == WXK_TAB) { wxNavigationKeyEvent event; event.SetDirection( key_event.m_shiftDown ); @@ -659,14 +659,14 @@ bool wxTextCtrl::IsOwnGtkWindow( GdkWindow *window ) void wxTextCtrl::SetFont( const wxFont &WXUNUSED(font) ) { wxCHECK_RET( m_text != NULL, "invalid text ctrl" ); - + // doesn't work } void wxTextCtrl::SetForegroundColour( const wxColour &WXUNUSED(colour) ) { wxCHECK_RET( m_text != NULL, "invalid text ctrl" ); - + // doesn't work } @@ -675,9 +675,9 @@ void wxTextCtrl::SetBackgroundColour( const wxColour &colour ) wxCHECK_RET( m_text != NULL, "invalid text ctrl" ); wxControl::SetBackgroundColour( colour ); - + if (!m_backgroundColour.Ok()) return; - + if (m_windowStyle & wxTE_MULTILINE) { GdkWindow *window = GTK_TEXT(m_text)->text_area; diff --git a/src/gtk/utilsres.cpp b/src/gtk/utilsres.cpp index d743ad554e..748d845d37 100644 --- a/src/gtk/utilsres.cpp +++ b/src/gtk/utilsres.cpp @@ -109,7 +109,7 @@ static char *GetIniFile(char *dest, const char *filename) return dest; } -static void wxXMergeDatabases(void) +static void wxXMergeDatabases() { XrmDatabase homeDB, serverDB, applicationDB; char filenamebuf[1024]; @@ -159,7 +159,7 @@ static void wxXMergeDatabases(void) // called on application exit //----------------------------------------------------------------------------- -void wxFlushResources(void) +void wxFlushResources() { char nameBuffer[512]; diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index c3eba590fa..0a7b3f3bc5 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -86,14 +86,14 @@ this is (in most cases) the only GTK widget the class manages. E.g. the wxStatitText class handles only a GtkLabel widget a pointer to which you can find in m_widget (defined in wxWindow) - + When the class has a client area for drawing into and for containing children - it has to handle the client area widget (of the type GtkMyFixed, defined in - win_gtk.c), but there could be any number of widgets, handled by a class - The common rule for all windows is only, that the widget that interacts with - the rest of GTK must be referenced in m_widget and all other widgets must be - children of this widget on the GTK level. The top-most widget, which also - represents the client area, must be in the m_wxwindow field and must be of + it has to handle the client area widget (of the type GtkMyFixed, defined in + win_gtk.c), but there could be any number of widgets, handled by a class + The common rule for all windows is only, that the widget that interacts with + the rest of GTK must be referenced in m_widget and all other widgets must be + children of this widget on the GTK level. The top-most widget, which also + represents the client area, must be in the m_wxwindow field and must be of the type GtkMyFixed. As I said, the window classes that display a GTK native widget only have @@ -504,7 +504,7 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion if (g_blockEventsOnDrag) return TRUE; if (g_blockEventsOnScroll) return TRUE; - + if (!win->HasVMT()) return TRUE; /* @@ -762,7 +762,7 @@ static void gtk_window_hscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow * float line_step = win->m_hAdjust->step_increment; float page_step = win->m_hAdjust->page_increment; - + if (win->m_isScrolling) { command = wxEVT_SCROLL_THUMBTRACK; @@ -839,12 +839,12 @@ static void gtk_window_hscroll_change_callback( GtkWidget *WXUNUSED(widget), wxW // "button_press_event" from scrollbar //----------------------------------------------------------------------------- -static gint gtk_scrollbar_button_press_callback( GtkRange *WXUNUSED(widget), - GdkEventButton *WXUNUSED(gdk_event), +static gint gtk_scrollbar_button_press_callback( GtkRange *WXUNUSED(widget), + GdkEventButton *WXUNUSED(gdk_event), wxWindow *win ) { // if (gdk_event->window != widget->slider) return FALSE; - + win->m_isScrolling = TRUE; g_blockEventsOnScroll = TRUE; @@ -855,8 +855,8 @@ static gint gtk_scrollbar_button_press_callback( GtkRange *WXUNUSED(widget), // "button_release_event" from scrollbar //----------------------------------------------------------------------------- -static gint gtk_scrollbar_button_release_callback( GtkRange *widget, - GdkEventButton *WXUNUSED(gdk_event), +static gint gtk_scrollbar_button_release_callback( GtkRange *widget, + GdkEventButton *WXUNUSED(gdk_event), wxWindow *win ) { @@ -883,7 +883,7 @@ static gint gtk_scrollbar_button_release_callback( GtkRange *widget, //----------------------------------------------------------------------------- // Callback for wxWindow. This very strange beast has to be used because -// C++ has no virtual methods in a constructor. We have to emulate a +// C++ has no virtual methods in a constructor. We have to emulate a // virtual function here as wxNotebook requires a different way to insert // a child in it. I had opted for creating a wxNotebookPage window class // which would have made this superflouus (such in the MDI window system), @@ -891,13 +891,13 @@ static gint gtk_scrollbar_button_release_callback( GtkRange *widget, static void wxInsertChildInWindow( wxWindow* parent, wxWindow* child ) { - gtk_myfixed_put( GTK_MYFIXED(parent->m_wxwindow), - GTK_WIDGET(child->m_widget), - child->m_x, + gtk_myfixed_put( GTK_MYFIXED(parent->m_wxwindow), + GTK_WIDGET(child->m_widget), + child->m_x, child->m_y ); - gtk_widget_set_usize( GTK_WIDGET(child->m_widget), - child->m_width, + gtk_widget_set_usize( GTK_WIDGET(child->m_widget), + child->m_width, child->m_height ); } @@ -920,7 +920,7 @@ wxWindow::wxWindow() m_wxwindow = (GtkWidget *) NULL; m_parent = (wxWindow *) NULL; m_children.DeleteContents( FALSE ); - + m_x = 0; m_y = 0; m_width = 0; @@ -929,46 +929,46 @@ wxWindow::wxWindow() m_minHeight = -1; m_maxWidth = -1; m_maxHeight = -1; - + m_retCode = 0; - + m_eventHandler = this; m_windowValidator = (wxValidator *) NULL; - + m_windowId = -1; - + m_cursor = (wxCursor *) NULL; 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_isScrolling = FALSE; m_hAdjust = (GtkAdjustment*) NULL; m_vAdjust = (GtkAdjustment*) NULL; m_oldHorizontalPos = 0.0; m_oldVerticalPos = 0.0; - + m_isShown = FALSE; m_isEnabled = TRUE; - + m_dropTarget = (wxDropTarget*) NULL; m_resizing = FALSE; m_scrollGC = (GdkGC*) NULL; m_widgetStyle = (GtkStyle*) NULL; - + m_insertCallback = wxInsertChildInWindow; - + m_clientObject = (wxClientData*) NULL; m_clientData = NULL; } @@ -980,7 +980,7 @@ wxWindow::wxWindow( wxWindow *parent, wxWindowID id, m_insertCallback = wxInsertChildInWindow; Create( parent, id, pos, size, style, name ); } - + bool wxWindow::Create( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style, const wxString &name ) @@ -1058,7 +1058,7 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id, // 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", (GtkSignalFunc)gtk_scrollbar_button_press_callback, (gpointer) this ); @@ -1070,7 +1070,7 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id, gtk_signal_connect( GTK_OBJECT(s_window->hscrollbar), "button_release_event", (GtkSignalFunc)gtk_scrollbar_button_release_callback, (gpointer) this ); - + // these handers het notified when screen updates are required either when // scrolling or when the window size (and therefore scrollbar configuration) // has changed @@ -1086,13 +1086,13 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id, (GtkSignalFunc) gtk_window_vscroll_change_callback, (gpointer) this ); gtk_widget_show( m_wxwindow ); - + if (m_parent) m_parent->AddChild( this ); (m_parent->m_insertCallback)( m_parent, this ); - + PostCreation(); - + Show( TRUE ); return TRUE; @@ -1110,13 +1110,13 @@ wxWindow::~wxWindow() DestroyChildren(); if (m_widgetStyle) gtk_style_unref( m_widgetStyle ); - + if (m_scrollGC) gdk_gc_unref( m_scrollGC ); - + if (m_wxwindow) gtk_widget_destroy( m_wxwindow ); if (m_widget) gtk_widget_destroy( m_widget ); - + if (m_cursor) delete m_cursor; DeleteRelatedConstraints(); @@ -1147,7 +1147,7 @@ wxWindow::~wxWindow() wxTopLevelWindows.DeleteObject(this); if (m_windowValidator) delete m_windowValidator; - + if (m_clientObject) delete m_clientObject; } @@ -1157,21 +1157,21 @@ void wxWindow::PreCreation( wxWindow *parent, wxWindowID id, { if (m_needParent && (parent == NULL)) wxFatalError( "Need complete parent.", name ); - + m_widget = (GtkWidget*) NULL; m_wxwindow = (GtkWidget*) NULL; m_hasVMT = FALSE; m_parent = parent; m_children.DeleteContents( FALSE ); - + m_width = size.x; if (m_width == -1) m_width = 20; m_height = size.y; if (m_height == -1) m_height = 20; - + m_x = (int)pos.x; m_y = (int)pos.y; - + if (!m_needParent) // some reasonable defaults { if (m_x == -1) @@ -1185,49 +1185,49 @@ void wxWindow::PreCreation( wxWindow *parent, wxWindowID id, 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 = new wxCursor( wxCURSOR_ARROW ); m_font = *wxSWISS_FONT; // m_backgroundColour = wxWHITE; // 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; - + m_dropTarget = (wxDropTarget *) NULL; m_resizing = FALSE; m_windowValidator = (wxValidator *) NULL; m_scrollGC = (GdkGC*) NULL; m_widgetStyle = (GtkStyle*) NULL; - + m_clientObject = (wxClientData*)NULL; m_clientData = NULL; } @@ -1336,7 +1336,7 @@ void wxWindow::AdjustForParentClientOrigin( int& x, int& y, int sizeFlags ) if (((sizeFlags & wxSIZE_NO_ADJUSTMENTS) == 0) && GetParent()) { wxPoint pt(GetParent()->GetClientAreaOrigin()); - x += pt.x; + x += pt.x; y += pt.y; } } @@ -1345,7 +1345,7 @@ void wxWindow::SetSize( int x, int y, int width, int height, int sizeFlags ) { wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_parent != NULL), "wxWindow::SetSize requires parent.\n" ); - + if (m_resizing) return; // I don't like recursions m_resizing = TRUE; @@ -1361,7 +1361,7 @@ void wxWindow::SetSize( int x, int y, int width, int height, int sizeFlags ) { int old_width = m_width; int old_height = m_height; - + if ((sizeFlags & wxSIZE_USE_EXISTING) == wxSIZE_USE_EXISTING) { if (x != -1) m_x = x; @@ -1386,7 +1386,7 @@ void wxWindow::SetSize( int x, int y, int width, int height, int sizeFlags ) { if (height == -1) m_height = 26; } - + if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth; if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight; if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_minWidth; @@ -1394,11 +1394,11 @@ void wxWindow::SetSize( int x, int y, int width, int height, int sizeFlags ) wxPoint pt( m_parent->GetClientAreaOrigin() ); gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), m_widget, m_x+pt.x, m_y+pt.y ); - + if ((old_width != m_width) || (old_height != m_height)) gtk_widget_set_usize( m_widget, m_width, m_height ); } - + m_sizeSet = TRUE; wxSizeEvent event( wxSize(m_width,m_height), GetId() ); @@ -1457,7 +1457,7 @@ void wxWindow::SetClientSize( int width, int height ) #ifdef NEW_GTK_SCROLL_CODE GtkWidget *viewport = scroll_window->child; -#else +#else GtkWidget *viewport = scroll_window->viewport; #endif @@ -1522,7 +1522,7 @@ void wxWindow::GetClientSize( int *width, int *height ) const #ifdef NEW_GTK_SCROLL_CODE GtkWidget *viewport = scroll_window->child; -#else +#else GtkWidget *viewport = scroll_window->viewport; #endif @@ -1589,7 +1589,7 @@ void wxWindow::ClientToScreen( int *x, int *y ) wxPoint pt(GetClientAreaOrigin()); org_x += pt.x; org_y += pt.y; - + if (x) *x += org_x; if (y) *y += org_y; } @@ -1620,7 +1620,7 @@ void wxWindow::ScreenToClient( int *x, int *y ) wxPoint pt(GetClientAreaOrigin()); org_x -= pt.x; org_y -= pt.y; - + if (x) *x -= org_x; if (y) *y -= org_y; } @@ -1631,7 +1631,7 @@ void wxWindow::Centre( int direction ) int x = m_x; int y = m_y; - + if (m_parent) { int p_w = 0; @@ -1645,7 +1645,7 @@ void wxWindow::Centre( int direction ) if (direction & wxHORIZONTAL == wxHORIZONTAL) x = (gdk_screen_width () - m_width) / 2; if (direction & wxVERTICAL == wxVERTICAL) y = (gdk_screen_height () - m_height) / 2; } - + Move( x, y ); } @@ -1655,7 +1655,7 @@ void wxWindow::Fit() int maxX = 0; int maxY = 0; - wxNode *node = m_childrenFirst(); + wxNode *node = m_children.First(); while ( node ) { wxWindow *win = (wxWindow *)node->Data(); @@ -1803,25 +1803,20 @@ void wxWindow::AddChild( wxWindow *child ) m_children.Append( child ); } -wxList& wxWindow::GetChildren() const -{ - return m_children; -} - wxWindow *wxWindow::ReParent( wxWindow *newParent ) { wxWindow *oldParent = GetParent(); - + if (oldParent) oldParent->RemoveChild( this ); - + gtk_widget_unparent( m_widget ); - + if (newParent) { newParent->AddChild( this ); (newParent->m_insertCallback)( newParent, this ); } - + return oldParent; } @@ -1855,7 +1850,7 @@ void wxWindow::Lower() if (m_widget) gdk_window_lower( m_widget->window ); } -wxEvtHandler *wxWindow::GetEventHandler() +wxEvtHandler *wxWindow::GetEventHandler() const { return m_eventHandler; } @@ -1934,7 +1929,7 @@ void wxWindow::SetId( wxWindowID id ) m_windowId = id; } -wxWindowID wxWindow::GetId() +wxWindowID wxWindow::GetId() const { return m_windowId; } @@ -1951,7 +1946,8 @@ void wxWindow::SetCursor( const wxCursor &cursor ) if (cursor.Ok()) { - if (*((wxCursor*)&cursor) == m_cursor) return; + if ( cursor == *m_cursor ) + return; *m_cursor = cursor; } else @@ -2054,13 +2050,13 @@ void wxWindow::SetBackgroundColour( const wxColour &colour ) wxCHECK_RET( m_widget != NULL, "invalid window" ); if (m_backgroundColour == colour) return; - + if (!m_backgroundColour.Ok()) if (wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE ) == colour) return; - + m_backgroundColour = colour; if (!m_backgroundColour.Ok()) return; - + if (m_wxwindow) { GdkWindow *window = m_wxwindow->window; @@ -2068,7 +2064,7 @@ void wxWindow::SetBackgroundColour( const wxColour &colour ) gdk_window_set_background( window, m_backgroundColour.GetColor() ); gdk_window_clear( window ); } - + ApplyWidgetStyle(); } @@ -2082,31 +2078,31 @@ void wxWindow::SetForegroundColour( const wxColour &colour ) wxCHECK_RET( m_widget != NULL, "invalid window" ); if (m_foregroundColour == colour) return; - + m_foregroundColour = colour; if (!m_foregroundColour.Ok()) return; - + ApplyWidgetStyle(); } GtkStyle *wxWindow::GetWidgetStyle() { if (m_widgetStyle) gtk_style_unref( m_widgetStyle ); - - m_widgetStyle = - gtk_style_copy( + + m_widgetStyle = + gtk_style_copy( gtk_widget_get_style( m_widget ) ); - + return m_widgetStyle; } void wxWindow::SetWidgetStyle() { GtkStyle *style = GetWidgetStyle(); - + gdk_font_unref( style->font ); style->font = gdk_font_ref( m_font.GetInternalFont( 1.0 ) ); - + if (m_foregroundColour.Ok()) { m_foregroundColour.CalcPixel( gdk_window_get_colormap( m_widget->window ) ); @@ -2114,7 +2110,7 @@ void wxWindow::SetWidgetStyle() style->fg[GTK_STATE_PRELIGHT] = *m_foregroundColour.GetColor(); style->fg[GTK_STATE_ACTIVE] = *m_foregroundColour.GetColor(); } - + if (m_backgroundColour.Ok()) { m_backgroundColour.CalcPixel( gdk_window_get_colormap( m_widget->window ) ); @@ -2219,7 +2215,7 @@ bool wxWindow::PopupMenu( wxMenu *menu, int WXUNUSED(x), int WXUNUSED(y) ) wxCHECK_MSG( m_widget != NULL, FALSE, "invalid window" ); wxCHECK_MSG( menu != NULL, FALSE, "invalid popup-menu" ); - + SetInvokingWindow( menu, this ); gtk_menu_popup( GTK_MENU(menu->m_menu), @@ -2274,13 +2270,8 @@ void wxWindow::SetFont( const wxFont &font ) m_font = font; else m_font = *wxSWISS_FONT; - - ApplyWidgetStyle(); -} -wxFont *wxWindow::GetFont() -{ - return &m_font; + ApplyWidgetStyle(); } void wxWindow::SetWindowStyleFlag( long flag ) @@ -2392,7 +2383,7 @@ void wxWindow::SetScrollbar( int orient, int pos, int thumbVisible, wxASSERT_MSG( (m_wxwindow != NULL), "window needs client area" ); if (!m_wxwindow) return; - + m_hasScrolling = TRUE; if (orient == wxHORIZONTAL) @@ -2556,13 +2547,13 @@ void wxWindow::ScrollWindow( int dx, int dy, const wxRect* WXUNUSED(rect) ) int d_y = 0; if (dx > 0) d_x = dx; if (dy > 0) d_y = dy; - + if (!m_scrollGC) { m_scrollGC = gdk_gc_new( m_wxwindow->window ); gdk_gc_set_exposures( m_scrollGC, TRUE ); } - + gdk_window_copy_area( m_wxwindow->window, m_scrollGC, d_x, d_y, m_wxwindow->window, s_x, s_y, w, h ); @@ -2795,7 +2786,7 @@ bool wxWindow::DoPhase(int phase) { noChanges = 0; noFailures = 0; - wxNode *node = m_children.first(); + wxNode *node = m_children.First(); while (node) { wxWindow *child = (wxWindow *)node->Data(); diff --git a/src/gtk1/app.cpp b/src/gtk1/app.cpp index 0e7eec9b1b..630733a3ae 100644 --- a/src/gtk1/app.cpp +++ b/src/gtk1/app.cpp @@ -4,7 +4,7 @@ // Author: Robert Roebling // Id: $Id$ // Copyright: (c) 1998 Robert Roebling, Julian Smart -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -213,8 +213,8 @@ bool wxApp::SendIdleEvents(void) wxNode* node = wxTopLevelWindows.First(); while (node) { - wxWindow* win = (wxWindow*) node->Data(); - if (SendIdleEvents(win)) + wxWindow* win = (wxWindow*) node->Data(); + if (SendIdleEvents(win)) needMore = TRUE; node = node->Next(); } @@ -225,22 +225,22 @@ bool wxApp::SendIdleEvents( wxWindow* win ) { bool needMore = FALSE; - wxIdleEvent event; - event.SetEventObject(win); - win->ProcessEvent(event); + wxIdleEvent event; + event.SetEventObject(win); + win->ProcessEvent(event); if (event.MoreRequested()) needMore = TRUE; - wxNode* node = win->GetChildren()->First(); - while (node) - { - wxWindow* win = (wxWindow*) node->Data(); - if (SendIdleEvents(win)) + wxNode* node = win->GetChildren().First(); + while (node) + { + wxWindow* win = (wxWindow*) node->Data(); + if (SendIdleEvents(win)) needMore = TRUE; - node = node->Next(); - } + node = node->Next(); + } return needMore ; } diff --git a/src/gtk1/bitmap.cpp b/src/gtk1/bitmap.cpp index f92b146377..000c58e5ad 100644 --- a/src/gtk1/bitmap.cpp +++ b/src/gtk1/bitmap.cpp @@ -4,7 +4,7 @@ // Author: Robert Roebling // RCS-ID: $Id$ // Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -24,7 +24,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxMask,wxObject) -wxMask::wxMask(void) +wxMask::wxMask() { m_bitmap = (GdkBitmap *) NULL; } @@ -41,7 +41,7 @@ wxMask::wxMask( const wxBitmap& WXUNUSED(bitmap) ) { } -wxMask::~wxMask(void) +wxMask::~wxMask() { if (m_bitmap) gdk_bitmap_unref( m_bitmap ); } @@ -50,7 +50,7 @@ GdkBitmap *wxMask::GetBitmap(void) const { return m_bitmap; } - + //----------------------------------------------------------------------------- // wxBitmap //----------------------------------------------------------------------------- @@ -60,7 +60,7 @@ class wxBitmapRefData: public wxObjectRefData public: wxBitmapRefData(void); ~wxBitmapRefData(void); - + GdkPixmap *m_pixmap; GdkBitmap *m_bitmap; wxMask *m_mask; @@ -70,7 +70,7 @@ public: wxPalette *m_palette; }; -wxBitmapRefData::wxBitmapRefData(void) +wxBitmapRefData::wxBitmapRefData() { m_pixmap = (GdkPixmap *) NULL; m_bitmap = (GdkBitmap *) NULL; @@ -81,7 +81,7 @@ wxBitmapRefData::wxBitmapRefData(void) m_palette = (wxPalette *) NULL; } -wxBitmapRefData::~wxBitmapRefData(void) +wxBitmapRefData::~wxBitmapRefData() { if (m_pixmap) gdk_pixmap_unref( m_pixmap ); if (m_bitmap) gdk_bitmap_unref( m_bitmap ); @@ -95,95 +95,88 @@ wxBitmapRefData::~wxBitmapRefData(void) IMPLEMENT_DYNAMIC_CLASS(wxBitmap,wxGDIObject) -wxBitmap::wxBitmap(void) +wxBitmap::wxBitmap() { if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this); } - + wxBitmap::wxBitmap( int width, int height, int depth ) { wxCHECK_RET( (width > 0) && (height > 0), "invalid bitmap size" ) wxCHECK_RET( (depth > 0) || (depth == -1), "invalid bitmap depth" ) m_refData = new wxBitmapRefData(); - + GdkWindow *parent = (GdkWindow*) &gdk_root_parent; - + M_BMPDATA->m_mask = (wxMask *) NULL; M_BMPDATA->m_pixmap = gdk_pixmap_new( parent, width, height, depth ); M_BMPDATA->m_width = width; M_BMPDATA->m_height = height; M_BMPDATA->m_bpp = gdk_window_get_visual( parent )->depth; - + if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this); } wxBitmap::wxBitmap( const char **bits ) { wxCHECK_RET( bits != NULL, "invalid bitmap data" ) - + m_refData = new wxBitmapRefData(); GdkBitmap *mask = (GdkBitmap*) NULL; GdkWindow *parent = (GdkWindow*) &gdk_root_parent; - + M_BMPDATA->m_pixmap = gdk_pixmap_create_from_xpm_d( parent, &mask, NULL, (gchar **) bits ); - + if (mask) { M_BMPDATA->m_mask = new wxMask(); M_BMPDATA->m_mask->m_bitmap = mask; } - + gdk_window_get_size( M_BMPDATA->m_pixmap, &(M_BMPDATA->m_width), &(M_BMPDATA->m_height) ); - + M_BMPDATA->m_bpp = gdk_window_get_visual( parent )->depth; // ? if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this); } - + wxBitmap::wxBitmap( char **bits ) { wxCHECK_RET( bits != NULL, "invalid bitmap data" ) - + m_refData = new wxBitmapRefData(); GdkBitmap *mask = (GdkBitmap*) NULL; GdkWindow *parent = (GdkWindow*) &gdk_root_parent; - + M_BMPDATA->m_pixmap = gdk_pixmap_create_from_xpm_d( parent, &mask, NULL, (gchar **) bits ); - + wxCHECK_RET( M_BMPDATA->m_pixmap, "couldn't create pixmap" ); - + if (mask) { M_BMPDATA->m_mask = new wxMask(); M_BMPDATA->m_mask->m_bitmap = mask; } - + gdk_window_get_size( M_BMPDATA->m_pixmap, &(M_BMPDATA->m_width), &(M_BMPDATA->m_height) ); - + M_BMPDATA->m_bpp = gdk_window_get_visual( parent )->depth; // ? if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this); } - + wxBitmap::wxBitmap( const wxBitmap& bmp ) { Ref( bmp ); - - if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this); -} - -wxBitmap::wxBitmap( const wxBitmap* bmp ) -{ - if (bmp) Ref( *bmp ); - + if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this); } wxBitmap::wxBitmap( const wxString &filename, int type ) { LoadFile( filename, type ); - + if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this); } @@ -192,44 +185,44 @@ wxBitmap::wxBitmap( const char bits[], int width, int height, int WXUNUSED(depth m_refData = new wxBitmapRefData(); M_BMPDATA->m_mask = (wxMask *) NULL; - M_BMPDATA->m_bitmap = + M_BMPDATA->m_bitmap = gdk_bitmap_create_from_data( (GdkWindow*) &gdk_root_parent, (gchar *) bits, width, height ); M_BMPDATA->m_width = width; M_BMPDATA->m_height = height; M_BMPDATA->m_bpp = 1; wxCHECK_RET( M_BMPDATA->m_bitmap, "couldn't create bitmap" ); - + if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this); } - -wxBitmap::~wxBitmap(void) + +wxBitmap::~wxBitmap() { if (wxTheBitmapList) wxTheBitmapList->DeleteObject(this); } - + wxBitmap& wxBitmap::operator = ( const wxBitmap& bmp ) { - if (*this == bmp) return (*this); - Ref( bmp ); - return *this; + if (*this == bmp) return (*this); + Ref( bmp ); + return *this; } - + bool wxBitmap::operator == ( const wxBitmap& bmp ) { - return m_refData == bmp.m_refData; + return m_refData == bmp.m_refData; } - + bool wxBitmap::operator != ( const wxBitmap& bmp ) { - return m_refData != bmp.m_refData; + return m_refData != bmp.m_refData; } - + bool wxBitmap::Ok(void) const { return (m_refData != NULL); } - + int wxBitmap::GetHeight(void) const { wxCHECK_MSG( Ok(), -1, "invalid bitmap" ); @@ -240,69 +233,69 @@ int wxBitmap::GetHeight(void) const int wxBitmap::GetWidth(void) const { wxCHECK_MSG( Ok(), -1, "invalid bitmap" ); - + return M_BMPDATA->m_width; } int wxBitmap::GetDepth(void) const { wxCHECK_MSG( Ok(), -1, "invalid bitmap" ); - + return M_BMPDATA->m_bpp; } wxMask *wxBitmap::GetMask(void) const { wxCHECK_MSG( Ok(), (wxMask *) NULL, "invalid bitmap" ); - + return M_BMPDATA->m_mask; } void wxBitmap::SetMask( wxMask *mask ) { wxCHECK_RET( Ok(), "invalid bitmap" ); - + if (M_BMPDATA->m_mask) delete M_BMPDATA->m_mask; - + M_BMPDATA->m_mask = mask; } bool wxBitmap::SaveFile( const wxString &name, int type, wxPalette *WXUNUSED(palette) ) { wxCHECK_MSG( Ok(), FALSE, "invalid bitmap" ); - + if (type == wxBITMAP_TYPE_PNG) { wxImage image( *this ); if (image.Ok()) return image.SaveFile( name, type ); } - + return FALSE; } bool wxBitmap::LoadFile( const wxString &name, int type ) { UnRef(); - + if (!wxFileExists(name)) return FALSE; - + if (type == wxBITMAP_TYPE_XPM) { m_refData = new wxBitmapRefData(); - + GdkBitmap *mask = (GdkBitmap*) NULL; GdkWindow *parent = (GdkWindow*) &gdk_root_parent; - + M_BMPDATA->m_pixmap = gdk_pixmap_create_from_xpm( parent, &mask, NULL, name ); - + if (mask) { M_BMPDATA->m_mask = new wxMask(); M_BMPDATA->m_mask->m_bitmap = mask; } - + gdk_window_get_size( M_BMPDATA->m_pixmap, &(M_BMPDATA->m_width), &(M_BMPDATA->m_height) ); - M_BMPDATA->m_bpp = gdk_window_get_visual( parent )->depth; + M_BMPDATA->m_bpp = gdk_window_get_visual( parent )->depth; } else if (type == wxBITMAP_TYPE_PNG) { @@ -316,16 +309,16 @@ bool wxBitmap::LoadFile( const wxString &name, int type ) image.LoadFile( name, type ); if (image.Ok()) *this = image.ConvertToBitmap(); } - else + else return FALSE; - + return TRUE; } - + wxPalette *wxBitmap::GetPalette(void) const { if (!Ok()) return (wxPalette *) NULL; - + return M_BMPDATA->m_palette; } @@ -360,17 +353,17 @@ void wxBitmap::SetPixmap( GdkPixmap *pixmap ) GdkPixmap *wxBitmap::GetPixmap(void) const { wxCHECK_MSG( Ok(), (GdkPixmap *) NULL, "invalid bitmap" ); - + return M_BMPDATA->m_pixmap; } - + GdkBitmap *wxBitmap::GetBitmap(void) const { wxCHECK_MSG( Ok(), (GdkBitmap *) NULL, "invalid bitmap" ); - + return M_BMPDATA->m_bitmap; } - + //----------------------------------------------------------------------------- // wxImage //----------------------------------------------------------------------------- @@ -383,46 +376,46 @@ wxBitmap wxImage::ConvertToBitmap() const int width = GetWidth(); int height = GetHeight(); - + bitmap.SetHeight( height ); bitmap.SetWidth( width ); - + // Create picture - - GdkImage *data_image = + + GdkImage *data_image = gdk_image_new( GDK_IMAGE_FASTEST, gdk_visual_get_system(), width, height ); - + bitmap.SetPixmap( gdk_pixmap_new( (GdkWindow*)&gdk_root_parent, width, height, -1 ) ); // Create mask - + GdkImage *mask_image = (GdkImage*) NULL; - + if (HasMask()) { unsigned char *mask_data = (unsigned char*)malloc( ((width >> 3)+8) * height ); - + mask_image = gdk_image_new_bitmap( gdk_visual_get_system(), mask_data, width, height ); - + wxMask *mask = new wxMask(); mask->m_bitmap = gdk_pixmap_new( (GdkWindow*)&gdk_root_parent, width, height, 1 ); - + bitmap.SetMask( mask ); } - - // Retrieve depth - + + // Retrieve depth + GdkVisual *visual = gdk_window_get_visual( bitmap.GetPixmap() ); if (visual == NULL) visual = gdk_window_get_visual( (GdkWindow*) &gdk_root_parent ); int bpp = visual->depth; if ((bpp == 16) && (visual->red_mask != 0xf800)) bpp = 15; if (bpp < 8) bpp = 8; - + // Render enum byte_order { RGB, RBG, BRG, BGR, GRB, GBR }; byte_order b_o = RGB; - + if (bpp >= 24) { GdkVisual *visual = gdk_visual_get_system(); @@ -433,13 +426,13 @@ wxBitmap wxImage::ConvertToBitmap() const else if ((visual->green_mask > visual->red_mask) && (visual->red_mask > visual->blue_mask)) b_o = GRB; else if ((visual->green_mask > visual->blue_mask) && (visual->blue_mask > visual->red_mask)) b_o = GBR; } - + int r_mask = GetMaskRed(); int g_mask = GetMaskGreen(); int b_mask = GetMaskBlue(); - + unsigned char* data = GetData(); - + int index = 0; for (int y = 0; y < height; y++) { @@ -451,7 +444,7 @@ wxBitmap wxImage::ConvertToBitmap() const index++; int b = data[index]; index++; - + if (HasMask()) { if ((r == r_mask) && (b == b_mask) && (g == g_mask)) @@ -459,7 +452,7 @@ wxBitmap wxImage::ConvertToBitmap() const else gdk_image_put_pixel( mask_image, x, y, 0 ); } - + switch (bpp) { case 8: @@ -477,9 +470,9 @@ wxBitmap wxImage::ConvertToBitmap() const int sum = ABS (rdiff) + ABS (gdiff) + ABS (bdiff); if (sum < max) { index = i; max = sum; } } - + gdk_image_put_pixel( data_image, x, y, index ); - + break; } case 15: @@ -513,68 +506,68 @@ wxBitmap wxImage::ConvertToBitmap() const } } // for } // for - + // Blit picture - + GdkGC *data_gc = gdk_gc_new( bitmap.GetPixmap() ); - + gdk_draw_image( bitmap.GetPixmap(), data_gc, data_image, 0, 0, 0, 0, width, height ); - + gdk_image_destroy( data_image ); gdk_gc_unref( data_gc ); - + // Blit mask - + if (HasMask()) { GdkGC *mask_gc = gdk_gc_new( bitmap.GetMask()->GetBitmap() ); - + gdk_draw_image( bitmap.GetMask()->GetBitmap(), mask_gc, mask_image, 0, 0, 0, 0, width, height ); - + gdk_image_destroy( mask_image ); gdk_gc_unref( mask_gc ); } - + return bitmap; } wxImage::wxImage( const wxBitmap &bitmap ) { wxCHECK_RET( bitmap.Ok(), "invalid bitmap" ); - - GdkImage *gdk_image = gdk_image_get( bitmap.GetPixmap(), - 0, 0, + + GdkImage *gdk_image = gdk_image_get( bitmap.GetPixmap(), + 0, 0, bitmap.GetWidth(), bitmap.GetHeight() ); - + wxCHECK_RET( gdk_image, "couldn't create image" ); - + Create( bitmap.GetWidth(), bitmap.GetHeight() ); char unsigned *data = GetData(); - + if (!data) { gdk_image_destroy( gdk_image ); wxFAIL_MSG( "couldn't create image" ); return; } - + GdkImage *gdk_image_mask = (GdkImage*) NULL; if (bitmap.GetMask()) { - gdk_image_mask = gdk_image_get( bitmap.GetMask()->GetBitmap(), - 0, 0, + gdk_image_mask = gdk_image_get( bitmap.GetMask()->GetBitmap(), + 0, 0, bitmap.GetWidth(), bitmap.GetHeight() ); SetMaskColour( 16, 16, 16 ); // anything unlikely and dividable } - + GdkVisual *visual = gdk_window_get_visual( bitmap.GetPixmap() ); if (visual == NULL) visual = gdk_window_get_visual( (GdkWindow*) &gdk_root_parent ); int bpp = visual->depth; if ((bpp == 16) && (visual->red_mask != 0xf800)) bpp = 15; GdkColormap *cmap = gtk_widget_get_default_colormap(); - + long pos = 0; for (int j = 0; j < bitmap.GetHeight(); j++) { @@ -602,7 +595,7 @@ wxImage::wxImage( const wxBitmap &bitmap ) data[pos+1] = (pixel >> 8) & 0xff; data[pos+2] = pixel & 0xff; } - + if (gdk_image_mask) { int mask_pixel = gdk_image_get_pixel( gdk_image_mask, i, j ); @@ -613,11 +606,11 @@ wxImage::wxImage( const wxBitmap &bitmap ) data[pos+2] = 16; } } - + pos += 3; } } - + gdk_image_destroy( gdk_image ); if (gdk_image_mask) gdk_image_destroy( gdk_image_mask ); } diff --git a/src/gtk1/brush.cpp b/src/gtk1/brush.cpp index 698c499596..146a4d0d88 100644 --- a/src/gtk1/brush.cpp +++ b/src/gtk1/brush.cpp @@ -20,16 +20,16 @@ class wxBrushRefData: public wxObjectRefData { public: - - wxBrushRefData(void); + + wxBrushRefData(); wxBrushRefData( const wxBrushRefData& data ); - + int m_style; wxBitmap m_stipple; wxColour m_colour; }; -wxBrushRefData::wxBrushRefData(void) +wxBrushRefData::wxBrushRefData() { m_style = 0; } @@ -47,7 +47,7 @@ wxBrushRefData::wxBrushRefData( const wxBrushRefData& data ) IMPLEMENT_DYNAMIC_CLASS(wxBrush,wxGDIObject) -wxBrush::wxBrush(void) +wxBrush::wxBrush() { if (wxTheBrushList) wxTheBrushList->AddBrush( this ); } @@ -57,7 +57,7 @@ wxBrush::wxBrush( const wxColour &colour, int style ) m_refData = new wxBrushRefData(); M_BRUSHDATA->m_style = style; M_BRUSHDATA->m_colour = colour; - + if (wxTheBrushList) wxTheBrushList->AddBrush( this ); } @@ -67,52 +67,45 @@ wxBrush::wxBrush( const wxBitmap &stippleBitmap ) M_BRUSHDATA->m_style = wxSTIPPLE; M_BRUSHDATA->m_colour = *wxBLACK; M_BRUSHDATA->m_stipple = stippleBitmap; - + if (wxTheBrushList) wxTheBrushList->AddBrush( this ); } wxBrush::wxBrush( const wxBrush &brush ) { Ref( brush ); - - if (wxTheBrushList) wxTheBrushList->AddBrush( this ); -} -wxBrush::wxBrush( const wxBrush *brush ) -{ - if (brush) Ref( *brush ); - - if (wxTheBrushList) wxTheBrushList->Append( this ); + if (wxTheBrushList) wxTheBrushList->AddBrush( this ); } -wxBrush::~wxBrush(void) +wxBrush::~wxBrush() { if (wxTheBrushList) wxTheBrushList->RemoveBrush( this ); } wxBrush& wxBrush::operator = ( const wxBrush& brush ) { - if (*this == brush) return (*this); - Ref( brush ); - return *this; + if (*this == brush) return (*this); + Ref( brush ); + return *this; } - + bool wxBrush::operator == ( const wxBrush& brush ) { - return m_refData == brush.m_refData; + return m_refData == brush.m_refData; } bool wxBrush::operator != ( const wxBrush& brush ) { - return m_refData != brush.m_refData; + return m_refData != brush.m_refData; } -bool wxBrush::Ok(void) const +bool wxBrush::Ok() const { return ((m_refData) && M_BRUSHDATA->m_colour.Ok()); } -int wxBrush::GetStyle(void) const +int wxBrush::GetStyle() const { if (m_refData == NULL) { @@ -123,25 +116,25 @@ int wxBrush::GetStyle(void) const return M_BRUSHDATA->m_style; } -wxColour &wxBrush::GetColour(void) const +wxColour &wxBrush::GetColour() const { if (m_refData == NULL) { wxFAIL_MSG( "invalid brush" ); return wxNullColour; } - + return M_BRUSHDATA->m_colour; } -wxBitmap *wxBrush::GetStipple(void) const +wxBitmap *wxBrush::GetStipple() const { if (m_refData == NULL) { wxFAIL_MSG( "invalid brush" ); return &wxNullBitmap; } - + return &M_BRUSHDATA->m_stipple; } @@ -169,7 +162,7 @@ void wxBrush::SetStipple( const wxBitmap& stipple ) M_BRUSHDATA->m_stipple = stipple; } -void wxBrush::Unshare(void) +void wxBrush::Unshare() { if (!m_refData) { diff --git a/src/gtk1/colour.cpp b/src/gtk1/colour.cpp index 09479c1230..526ef17636 100644 --- a/src/gtk1/colour.cpp +++ b/src/gtk1/colour.cpp @@ -4,7 +4,7 @@ // Author: Robert Roebling // Id: $Id$ // Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -23,15 +23,15 @@ class wxColourRefData: public wxObjectRefData { public: - + wxColourRefData(); ~wxColourRefData(); void FreeColour(); - + GdkColor m_color; GdkColormap *m_colormap; bool m_hasPixel; - + friend wxColour; }; @@ -75,17 +75,17 @@ wxColour::wxColour( unsigned char red, unsigned char green, unsigned char blue ) M_COLDATA->m_color.blue = ((unsigned short)blue) << SHIFT; M_COLDATA->m_color.pixel = 0; } - + void wxColour::InitFromName( const wxString &colourName ) { wxNode *node = (wxNode *) NULL; - if ( (wxTheColourDatabase) && (node = wxTheColourDatabase->Find(colourName)) ) + if ( (wxTheColourDatabase) && (node = wxTheColourDatabase->Find(colourName)) ) { wxColour *col = (wxColour*)node->Data(); UnRef(); if (col) Ref( *col ); - } - else + } + else { m_refData = new wxColourRefData(); if (!gdk_color_parse( colourName, &M_COLDATA->m_color )) @@ -98,34 +98,29 @@ void wxColour::InitFromName( const wxString &colourName ) } wxColour::wxColour( const wxColour& col ) -{ - Ref( col ); -} - -wxColour::wxColour( const wxColour* col ) -{ - if (col) Ref( *col ); +{ + Ref( col ); } wxColour::~wxColour() { } -wxColour& wxColour::operator = ( const wxColour& col ) -{ - if (*this == col) return (*this); - Ref( col ); - return *this; +wxColour& wxColour::operator = ( const wxColour& col ) +{ + if (*this == col) return (*this); + Ref( col ); + return *this; } -bool wxColour::operator == ( const wxColour& col ) -{ - return m_refData == col.m_refData; +bool wxColour::operator == ( const wxColour& col ) +{ + return m_refData == col.m_refData; } -bool wxColour::operator != ( const wxColour& col) -{ - return m_refData != col.m_refData; +bool wxColour::operator != ( const wxColour& col) +{ + return m_refData != col.m_refData; } void wxColour::Set( unsigned char red, unsigned char green, unsigned char blue ) @@ -145,7 +140,7 @@ unsigned char wxColour::Red() const wxFAIL_MSG( "invalid colour" ); return 0; } - + return (unsigned char)(M_COLDATA->m_color.red >> SHIFT); } @@ -156,7 +151,7 @@ unsigned char wxColour::Green() const wxFAIL_MSG( "invalid colour" ); return 0; } - + return (unsigned char)(M_COLDATA->m_color.green >> SHIFT); } @@ -167,7 +162,7 @@ unsigned char wxColour::Blue() const wxFAIL_MSG( "invalid colour" ); return 0; } - + return (unsigned char)(M_COLDATA->m_color.blue >> SHIFT); } @@ -179,10 +174,10 @@ bool wxColour::Ok() const void wxColour::CalcPixel( GdkColormap *cmap ) { if (!Ok()) return; - + if ((M_COLDATA->m_hasPixel) && (M_COLDATA->m_colormap == cmap)) return; M_COLDATA->FreeColour(); - + GdkColormapPrivate *private_colormap = (GdkColormapPrivate*) cmap; if ((private_colormap->visual->type == GDK_VISUAL_GRAYSCALE) || (private_colormap->visual->type == GDK_VISUAL_PSEUDO_COLOR)) @@ -199,7 +194,7 @@ void wxColour::CalcPixel( GdkColormap *cmap ) int sum = ABS (rdiff) + ABS (gdiff) + ABS (bdiff); if (sum < max) { index = i; max = sum; } } - + M_COLDATA->m_hasPixel = TRUE; M_COLDATA->m_color.pixel = index; } @@ -207,21 +202,21 @@ void wxColour::CalcPixel( GdkColormap *cmap ) { M_COLDATA->m_hasPixel = gdk_color_alloc( cmap, &M_COLDATA->m_color ); } - + M_COLDATA->m_colormap = cmap; } int wxColour::GetPixel() const { if (!Ok()) return 0; - + return M_COLDATA->m_color.pixel; } GdkColor *wxColour::GetColor() const { if (!Ok()) return (GdkColor *) NULL; - + return &M_COLDATA->m_color; } diff --git a/src/gtk1/cursor.cpp b/src/gtk1/cursor.cpp index 01a469f84f..73babdfb05 100644 --- a/src/gtk1/cursor.cpp +++ b/src/gtk1/cursor.cpp @@ -4,7 +4,7 @@ // Author: Robert Roebling // Id: $Id$ // Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -21,19 +21,19 @@ class wxCursorRefData: public wxObjectRefData { public: - - wxCursorRefData(void); - ~wxCursorRefData(void); - + + wxCursorRefData(); + ~wxCursorRefData(); + GdkCursor *m_cursor; }; -wxCursorRefData::wxCursorRefData(void) +wxCursorRefData::wxCursorRefData() { m_cursor = (GdkCursor *) NULL; } -wxCursorRefData::~wxCursorRefData(void) +wxCursorRefData::~wxCursorRefData() { if (m_cursor) gdk_cursor_destroy( m_cursor ); } @@ -44,14 +44,14 @@ wxCursorRefData::~wxCursorRefData(void) IMPLEMENT_DYNAMIC_CLASS(wxCursor,wxObject) -wxCursor::wxCursor(void) +wxCursor::wxCursor() { } wxCursor::wxCursor( int cursorId ) { m_refData = new wxCursorRefData(); - + GdkCursorType gdk_cur = GDK_LEFT_PTR; switch (cursorId) { @@ -67,12 +67,12 @@ wxCursor::wxCursor( int cursorId ) case wxCURSOR_PENCIL: gdk_cur = GDK_PENCIL; break; case wxCURSOR_NO_ENTRY: gdk_cur = GDK_PIRATE; break; } - + M_CURSORDATA->m_cursor = gdk_cursor_new( gdk_cur ); - + /* do that yourself - + wxCURSOR_BULLSEYE, wxCURSOR_CHAR, wxCURSOR_LEFT_BUTTON, @@ -95,7 +95,7 @@ wxCursor::wxCursor( int cursorId ) wxCURSOR_BASED_ARROW_UP, wxCURSOR_BASED_ARROW_DOWN */ - + } wxCursor::wxCursor( const wxCursor &cursor ) @@ -103,39 +103,33 @@ wxCursor::wxCursor( const wxCursor &cursor ) Ref( cursor ); } -wxCursor::wxCursor( const wxCursor *cursor ) -{ - UnRef(); - if (cursor) Ref( *cursor ); -} - -wxCursor::~wxCursor(void) +wxCursor::~wxCursor() { } wxCursor& wxCursor::operator = ( const wxCursor& cursor ) { - if (*this == cursor) return (*this); - Ref( cursor ); - return *this; + if (*this == cursor) return (*this); + Ref( cursor ); + return *this; } -bool wxCursor::operator == ( const wxCursor& cursor ) +bool wxCursor::operator == ( const wxCursor& cursor ) const { - return m_refData == cursor.m_refData; + return m_refData == cursor.m_refData; } -bool wxCursor::operator != ( const wxCursor& cursor ) +bool wxCursor::operator != ( const wxCursor& cursor ) const { - return m_refData != cursor.m_refData; + return m_refData != cursor.m_refData; } -bool wxCursor::Ok(void) const +bool wxCursor::Ok() const { return (m_refData != NULL); } -GdkCursor *wxCursor::GetCursor(void) const +GdkCursor *wxCursor::GetCursor() const { return M_CURSORDATA->m_cursor; } @@ -146,7 +140,7 @@ GdkCursor *wxCursor::GetCursor(void) const bool g_isBusy = FALSE; -void wxEndBusyCursor(void) +void wxEndBusyCursor() { g_isBusy = FALSE; } @@ -156,7 +150,7 @@ void wxBeginBusyCursor( wxCursor *WXUNUSED(cursor) ) g_isBusy = TRUE; } -bool wxIsBusy(void) +bool wxIsBusy() { return g_isBusy; } diff --git a/src/gtk1/font.cpp b/src/gtk1/font.cpp index 6a2d12c7af..c1f43fcf7f 100644 --- a/src/gtk1/font.cpp +++ b/src/gtk1/font.cpp @@ -4,7 +4,7 @@ // Author: Robert Roebling // Id: $Id$ // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -27,53 +27,53 @@ extern wxFontNameDirectory *wxTheFontNameDirectory; class wxFontRefData: public wxObjectRefData { - public: - - wxFontRefData(void); - ~wxFontRefData(void); - +public: + + wxFontRefData(); + ~wxFontRefData(); + wxList m_scaled_xfonts; int m_pointSize; int m_family, m_style, m_weight; bool m_underlined; int m_fontId; char* m_faceName; - + bool m_byXFontName; GdkFont *m_font; - + friend wxFont; }; -wxFontRefData::wxFontRefData(void) : m_scaled_xfonts(wxKEY_INTEGER) -{ - m_byXFontName = FALSE; - m_pointSize = 12; - m_family = wxSWISS; - m_style = wxNORMAL; - m_weight = wxNORMAL; - m_underlined = FALSE; - m_fontId = 0; - m_faceName = (char *) NULL; - m_font = (GdkFont *) NULL; -} - -wxFontRefData::~wxFontRefData(void) -{ - wxNode *node = m_scaled_xfonts.First(); - while (node) - { - GdkFont *font = (GdkFont*)node->Data(); - wxNode *next = node->Next(); - gdk_font_unref( font ); - node = next; - } - if (m_faceName) - { - delete m_faceName; +wxFontRefData::wxFontRefData() : m_scaled_xfonts(wxKEY_INTEGER) +{ + m_byXFontName = FALSE; + m_pointSize = 12; + m_family = wxSWISS; + m_style = wxNORMAL; + m_weight = wxNORMAL; + m_underlined = FALSE; + m_fontId = 0; m_faceName = (char *) NULL; - } - if (m_font) gdk_font_unref( m_font ); + m_font = (GdkFont *) NULL; +} + +wxFontRefData::~wxFontRefData() +{ + wxNode *node = m_scaled_xfonts.First(); + while (node) + { + GdkFont *font = (GdkFont*)node->Data(); + wxNode *next = node->Next(); + gdk_font_unref( font ); + node = next; + } + if (m_faceName) + { + delete m_faceName; + m_faceName = (char *) NULL; + } + if (m_font) gdk_font_unref( m_font ); } //----------------------------------------------------------------------------- @@ -82,257 +82,249 @@ wxFontRefData::~wxFontRefData(void) IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject) -wxFont::wxFont(void) +wxFont::wxFont() { - if (wxTheFontList) wxTheFontList->Append( this ); + if (wxTheFontList) wxTheFontList->Append( this ); } wxFont::wxFont( char *xFontName ) { - if (!xFontName) return; - - m_refData = new wxFontRefData(); - - M_FONTDATA->m_byXFontName = TRUE; - M_FONTDATA->m_font = gdk_font_load( xFontName ); + if (!xFontName) return; + + m_refData = new wxFontRefData(); + + M_FONTDATA->m_byXFontName = TRUE; + M_FONTDATA->m_font = gdk_font_load( xFontName ); } wxFont::wxFont(int PointSize, int FontIdOrFamily, int Style, int Weight, - bool Underlined, const char* Face) -{ - m_refData = new wxFontRefData(); - - if (FontIdOrFamily == wxDEFAULT) FontIdOrFamily = wxSWISS; - M_FONTDATA->m_family = FontIdOrFamily; - - if ((M_FONTDATA->m_faceName = (Face) ? copystring(Face) : (char*)NULL) ) - { - M_FONTDATA->m_fontId = wxTheFontNameDirectory->FindOrCreateFontId( Face, FontIdOrFamily ); - M_FONTDATA->m_family = wxTheFontNameDirectory->GetFamily( FontIdOrFamily ); - } - else - { - M_FONTDATA->m_fontId = FontIdOrFamily; - M_FONTDATA->m_family = wxTheFontNameDirectory->GetFamily( FontIdOrFamily ); - } - - if (Style == wxDEFAULT) Style = wxNORMAL; - M_FONTDATA->m_style = Style; - if (Weight == wxDEFAULT) Weight = wxNORMAL; - M_FONTDATA->m_weight = Weight; - if (PointSize == wxDEFAULT) PointSize = 12; - M_FONTDATA->m_pointSize = PointSize; - M_FONTDATA->m_underlined = Underlined; - - if (wxTheFontList) wxTheFontList->Append( this ); -} - -wxFont::wxFont(int PointSize, const char *Face, int Family, int Style, - int Weight, bool Underlined) -{ - m_refData = new wxFontRefData(); - - M_FONTDATA->m_fontId = wxTheFontNameDirectory->FindOrCreateFontId( Face, Family ); - M_FONTDATA->m_faceName = (Face) ? copystring(Face) : (char*)NULL; - M_FONTDATA->m_family = wxTheFontNameDirectory->GetFamily( M_FONTDATA->m_fontId ); - M_FONTDATA->m_style = Style; - M_FONTDATA->m_weight = Weight; - M_FONTDATA->m_pointSize = PointSize; - M_FONTDATA->m_underlined = Underlined; - - if (wxTheFontList) wxTheFontList->Append( this ); + bool Underlined, const char* Face) +{ + m_refData = new wxFontRefData(); + + if (FontIdOrFamily == wxDEFAULT) FontIdOrFamily = wxSWISS; + M_FONTDATA->m_family = FontIdOrFamily; + + if ((M_FONTDATA->m_faceName = (Face) ? copystring(Face) : (char*)NULL) ) + { + M_FONTDATA->m_fontId = wxTheFontNameDirectory->FindOrCreateFontId( Face, FontIdOrFamily ); + M_FONTDATA->m_family = wxTheFontNameDirectory->GetFamily( FontIdOrFamily ); + } + else + { + M_FONTDATA->m_fontId = FontIdOrFamily; + M_FONTDATA->m_family = wxTheFontNameDirectory->GetFamily( FontIdOrFamily ); + } + + if (Style == wxDEFAULT) Style = wxNORMAL; + M_FONTDATA->m_style = Style; + if (Weight == wxDEFAULT) Weight = wxNORMAL; + M_FONTDATA->m_weight = Weight; + if (PointSize == wxDEFAULT) PointSize = 12; + M_FONTDATA->m_pointSize = PointSize; + M_FONTDATA->m_underlined = Underlined; + + if (wxTheFontList) wxTheFontList->Append( this ); } -wxFont::wxFont( const wxFont& font ) -{ - Ref( font ); - - if (wxTheFontList) wxTheFontList->Append( this ); +wxFont::wxFont(int PointSize, const char *Face, int Family, int Style, + int Weight, bool Underlined) +{ + m_refData = new wxFontRefData(); + + M_FONTDATA->m_fontId = wxTheFontNameDirectory->FindOrCreateFontId( Face, Family ); + M_FONTDATA->m_faceName = (Face) ? copystring(Face) : (char*)NULL; + M_FONTDATA->m_family = wxTheFontNameDirectory->GetFamily( M_FONTDATA->m_fontId ); + M_FONTDATA->m_style = Style; + M_FONTDATA->m_weight = Weight; + M_FONTDATA->m_pointSize = PointSize; + M_FONTDATA->m_underlined = Underlined; + + if (wxTheFontList) wxTheFontList->Append( this ); } -wxFont::wxFont( const wxFont* font ) -{ - UnRef(); - if (font) Ref( *font ); - - if (wxTheFontList) wxTheFontList->Append( this ); +wxFont::wxFont( const wxFont& font ) +{ + Ref( font ); + + if (wxTheFontList) wxTheFontList->Append( this ); } -wxFont::~wxFont(void) +wxFont::~wxFont() { - if (wxTheFontList) wxTheFontList->DeleteObject( this ); + if (wxTheFontList) wxTheFontList->DeleteObject( this ); } -wxFont& wxFont::operator = ( const wxFont& font ) -{ - if (*this == font) return (*this); - Ref( font ); - return *this; +wxFont& wxFont::operator = ( const wxFont& font ) +{ + if (*this == font) return (*this); + Ref( font ); + return *this; } -bool wxFont::operator == ( const wxFont& font ) -{ - return m_refData == font.m_refData; +bool wxFont::operator == ( const wxFont& font ) +{ + return m_refData == font.m_refData; } -bool wxFont::operator != ( const wxFont& font ) -{ - return m_refData != font.m_refData; +bool wxFont::operator != ( const wxFont& font ) +{ + return m_refData != font.m_refData; } bool wxFont::Ok() const { - return (m_refData != NULL); + return (m_refData != NULL); } -int wxFont::GetPointSize(void) const +int wxFont::GetPointSize() const { - if (!Ok()) - { - wxFAIL_MSG( "invalid font" ); - return 0; - } - - return M_FONTDATA->m_pointSize; + if (!Ok()) + { + wxFAIL_MSG( "invalid font" ); + return 0; + } + + return M_FONTDATA->m_pointSize; } -wxString wxFont::GetFaceString(void) const +wxString wxFont::GetFaceString() const { - if (!Ok()) - { - wxFAIL_MSG( "invalid font" ); - return ""; - } - - wxString s = wxTheFontNameDirectory->GetFontName( M_FONTDATA->m_fontId ); - return s; + if (!Ok()) + { + wxFAIL_MSG( "invalid font" ); + return ""; + } + + wxString s = wxTheFontNameDirectory->GetFontName( M_FONTDATA->m_fontId ); + return s; } -wxString wxFont::GetFaceName(void) const +wxString wxFont::GetFaceName() const { - if (!Ok()) - { - wxFAIL_MSG( "invalid font" ); - return ""; - } - - wxString s = wxTheFontNameDirectory->GetFontName( M_FONTDATA->m_fontId ); - return s; + if (!Ok()) + { + wxFAIL_MSG( "invalid font" ); + return ""; + } + + wxString s = wxTheFontNameDirectory->GetFontName( M_FONTDATA->m_fontId ); + return s; } -int wxFont::GetFamily(void) const +int wxFont::GetFamily() const { - if (!Ok()) - { - wxFAIL_MSG( "invalid font" ); - return 0; - } - - return M_FONTDATA->m_family; + if (!Ok()) + { + wxFAIL_MSG( "invalid font" ); + return 0; + } + + return M_FONTDATA->m_family; } -wxString wxFont::GetFamilyString(void) const +wxString wxFont::GetFamilyString() const { - if (!Ok()) - { - wxFAIL_MSG( "invalid font" ); + if (!Ok()) + { + wxFAIL_MSG( "invalid font" ); + return "wxDEFAULT"; + } + + switch (M_FONTDATA->m_family) + { + case wxDECORATIVE: return wxString("wxDECORATIVE"); + case wxROMAN: return wxString("wxROMAN"); + case wxSCRIPT: return wxString("wxSCRIPT"); + case wxSWISS: return wxString("wxSWISS"); + case wxMODERN: return wxString("wxMODERN"); + case wxTELETYPE: return wxString("wxTELETYPE"); + default: return "wxDEFAULT"; + } + return "wxDEFAULT"; - } - - switch (M_FONTDATA->m_family) - { - case wxDECORATIVE: return wxString("wxDECORATIVE"); - case wxROMAN: return wxString("wxROMAN"); - case wxSCRIPT: return wxString("wxSCRIPT"); - case wxSWISS: return wxString("wxSWISS"); - case wxMODERN: return wxString("wxMODERN"); - case wxTELETYPE: return wxString("wxTELETYPE"); - default: return "wxDEFAULT"; - } - - return "wxDEFAULT"; -} - -int wxFont::GetFontId(void) const -{ - if (!Ok()) - { - wxFAIL_MSG( "invalid font" ); - return 0; - } - - return M_FONTDATA->m_fontId; // stub } -int wxFont::GetStyle(void) const +int wxFont::GetFontId() const { - if (!Ok()) - { - wxFAIL_MSG( "invalid font" ); - return 0; - } - - return M_FONTDATA->m_style; + if (!Ok()) + { + wxFAIL_MSG( "invalid font" ); + return 0; + } + + return M_FONTDATA->m_fontId; // stub } -wxString wxFont::GetStyleString(void) const +int wxFont::GetStyle() const { - if (!Ok()) - { - wxFAIL_MSG( "invalid font" ); - return "wxDEFAULT"; - } - - switch (M_FONTDATA->m_style) - { - case wxNORMAL: return wxString("wxNORMAL"); - case wxSLANT: return wxString("wxSLANT"); - case wxITALIC: return wxString("wxITALIC"); - default: return wxString("wxDEFAULT"); - } - - return wxString("wxDEFAULT"); -} - -int wxFont::GetWeight(void) const -{ - if (!Ok()) - { - wxFAIL_MSG( "invalid font" ); - return 0; - } + if (!Ok()) + { + wxFAIL_MSG( "invalid font" ); + return 0; + } - return M_FONTDATA->m_weight; + return M_FONTDATA->m_style; } -wxString wxFont::GetWeightString(void) const +wxString wxFont::GetStyleString() const { - if (!Ok()) - { - wxFAIL_MSG( "invalid font" ); - return "wxDEFAULT"; - } + if (!Ok()) + { + wxFAIL_MSG( "invalid font" ); + return "wxDEFAULT"; + } + + switch (M_FONTDATA->m_style) + { + case wxNORMAL: return wxString("wxNORMAL"); + case wxSLANT: return wxString("wxSLANT"); + case wxITALIC: return wxString("wxITALIC"); + default: return wxString("wxDEFAULT"); + } - switch (M_FONTDATA->m_weight) - { - case wxNORMAL: return wxString("wxNORMAL"); - case wxBOLD: return wxString("wxBOLD"); - case wxLIGHT: return wxString("wxLIGHT"); - default: return wxString("wxDEFAULT"); - } - - return wxString("wxDEFAULT"); + return wxString("wxDEFAULT"); } -bool wxFont::GetUnderlined(void) const +int wxFont::GetWeight() const { - if (!Ok()) - { - wxFAIL_MSG( "invalid font" ); - return FALSE; - } - - return M_FONTDATA->m_underlined; + if (!Ok()) + { + wxFAIL_MSG( "invalid font" ); + return 0; + } + + return M_FONTDATA->m_weight; +} + +wxString wxFont::GetWeightString() const +{ + if (!Ok()) + { + wxFAIL_MSG( "invalid font" ); + return "wxDEFAULT"; + } + + switch (M_FONTDATA->m_weight) + { + case wxNORMAL: return wxString("wxNORMAL"); + case wxBOLD: return wxString("wxBOLD"); + case wxLIGHT: return wxString("wxLIGHT"); + default: return wxString("wxDEFAULT"); + } + + return wxString("wxDEFAULT"); +} + +bool wxFont::GetUnderlined() const +{ + if (!Ok()) + { + wxFAIL_MSG( "invalid font" ); + return FALSE; + } + + return M_FONTDATA->m_underlined; } //----------------------------------------------------------------------------- @@ -341,57 +333,57 @@ bool wxFont::GetUnderlined(void) const // local help function static GdkFont *wxLoadQueryNearestFont(int point_size, int fontid, - int style, int weight, - bool underlined); + int style, int weight, + bool underlined); GdkFont *wxFont::GetInternalFont(float scale) const { - if (!Ok()) - { - wxFAIL_MSG( "invalid font" ); - return (GdkFont*) NULL; - } - - if (M_FONTDATA->m_byXFontName) return M_FONTDATA->m_font; - - long int_scale = long(scale * 100.0 + 0.5); // key for fontlist - int point_scale = (M_FONTDATA->m_pointSize * 10 * int_scale) / 100; - GdkFont *font = (GdkFont *) NULL; - - wxNode *node = M_FONTDATA->m_scaled_xfonts.Find(int_scale); - if (node) - { - font = (GdkFont*)node->Data(); - } - else - { -/* - if (int_scale == 100) printf( "int_scale.\n" ); - if (M_FONTDATA->m_style == wxSWISS) printf( "swiss.\n" ); - if (M_FONTDATA->m_pointSize == 12) printf( "12.\n" ); - if (M_FONTDATA->m_weight == wxNORMAL) printf( "normal.\n" ); - if (M_FONTDATA->m_underlined == FALSE) printf( "false.\n" ); -*/ - if ((int_scale == 100) && - (M_FONTDATA->m_family == wxSWISS) && - (M_FONTDATA->m_style == wxNORMAL) && - (M_FONTDATA->m_pointSize == 12) && - (M_FONTDATA->m_weight == wxNORMAL) && - (M_FONTDATA->m_underlined == FALSE)) - { - font = gdk_font_load( "-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*" ); - } - else - { - font = wxLoadQueryNearestFont( point_scale, M_FONTDATA->m_fontId, M_FONTDATA->m_style, - M_FONTDATA->m_weight, M_FONTDATA->m_underlined ); - } - M_FONTDATA->m_scaled_xfonts.Append( int_scale, (wxObject*)font ); - } - if (!font) - printf("could not load any font"); -// wxError("could not load any font", "wxFont"); - return font; + if (!Ok()) + { + wxFAIL_MSG( "invalid font" ); + return (GdkFont*) NULL; + } + + if (M_FONTDATA->m_byXFontName) return M_FONTDATA->m_font; + + long int_scale = long(scale * 100.0 + 0.5); // key for fontlist + int point_scale = (M_FONTDATA->m_pointSize * 10 * int_scale) / 100; + GdkFont *font = (GdkFont *) NULL; + + wxNode *node = M_FONTDATA->m_scaled_xfonts.Find(int_scale); + if (node) + { + font = (GdkFont*)node->Data(); + } + else + { + /* + if (int_scale == 100) printf( "int_scale.\n" ); + if (M_FONTDATA->m_style == wxSWISS) printf( "swiss.\n" ); + if (M_FONTDATA->m_pointSize == 12) printf( "12.\n" ); + if (M_FONTDATA->m_weight == wxNORMAL) printf( "normal.\n" ); + if (M_FONTDATA->m_underlined == FALSE) printf( "false.\n" ); + */ + if ((int_scale == 100) && + (M_FONTDATA->m_family == wxSWISS) && + (M_FONTDATA->m_style == wxNORMAL) && + (M_FONTDATA->m_pointSize == 12) && + (M_FONTDATA->m_weight == wxNORMAL) && + (M_FONTDATA->m_underlined == FALSE)) + { + font = gdk_font_load( "-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*" ); + } + else + { + font = wxLoadQueryNearestFont( point_scale, M_FONTDATA->m_fontId, M_FONTDATA->m_style, + M_FONTDATA->m_weight, M_FONTDATA->m_underlined ); + } + M_FONTDATA->m_scaled_xfonts.Append( int_scale, (wxObject*)font ); + } + if (!font) + printf("could not load any font"); + // wxError("could not load any font", "wxFont"); + return font; } //----------------------------------------------------------------------------- @@ -399,46 +391,46 @@ GdkFont *wxFont::GetInternalFont(float scale) const //----------------------------------------------------------------------------- static GdkFont *wxLoadQueryFont(int point_size, int fontid, int style, - int weight, bool WXUNUSED(underlined)) + int weight, bool WXUNUSED(underlined)) { char buffer[512]; char *name = wxTheFontNameDirectory->GetScreenName( fontid, weight, style ); if (!name) - name = "-*-*-*-*-*-*-*-%d-*-*-*-*-*-*"; + name = "-*-*-*-*-*-*-*-%d-*-*-*-*-*-*"; sprintf(buffer, name, point_size); return gdk_font_load( buffer ); } static GdkFont *wxLoadQueryNearestFont(int point_size, int fontid, - int style, int weight, - bool underlined) + int style, int weight, + bool underlined) { GdkFont *font; font = wxLoadQueryFont( point_size, fontid, style, weight, underlined ); if (!font) { - // search up and down by stepsize 10 - int max_size = point_size + 20 * (1 + (point_size/180)); - int min_size = point_size - 20 * (1 + (point_size/180)); - int i; - - // Search for smaller size (approx.) - for (i=point_size-10; !font && i >= 10 && i >= min_size; i -= 10) - font = wxLoadQueryFont(i, fontid, style, weight, underlined); - // Search for larger size (approx.) - for (i=point_size+10; !font && i <= max_size; i += 10) - font = wxLoadQueryFont(i, fontid, style, weight, underlined); - // Try default family - if (!font && fontid != wxDEFAULT) - font = wxLoadQueryFont(point_size, wxDEFAULT, style, - weight, underlined); - // Bogus font - if (!font) - font = wxLoadQueryFont(120, wxDEFAULT, wxNORMAL, wxNORMAL, - underlined); + // search up and down by stepsize 10 + int max_size = point_size + 20 * (1 + (point_size/180)); + int min_size = point_size - 20 * (1 + (point_size/180)); + int i; + + // Search for smaller size (approx.) + for (i=point_size-10; !font && i >= 10 && i >= min_size; i -= 10) + font = wxLoadQueryFont(i, fontid, style, weight, underlined); + // Search for larger size (approx.) + for (i=point_size+10; !font && i <= max_size; i += 10) + font = wxLoadQueryFont(i, fontid, style, weight, underlined); + // Try default family + if (!font && fontid != wxDEFAULT) + font = wxLoadQueryFont(point_size, wxDEFAULT, style, + weight, underlined); + // Bogus font + if (!font) + font = wxLoadQueryFont(120, wxDEFAULT, wxNORMAL, wxNORMAL, + underlined); } return font; } @@ -466,7 +458,7 @@ static char *font_defaults[] = { "AfmTimes", "Times", "AfmHelvetica", "Helv", "AfmCourier", "Cour", - + "Afm___", "${AfmTimes,$[weight],$[style]}", "AfmTimes__", "${AfmTimes}${Afm$[weight]}${Afm$[style]}", @@ -489,7 +481,7 @@ static char *font_defaults[] = { "PostScriptBoldStraight", "-Bold", "PostScriptBoldItalic", "-BoldOblique", "PostScriptBoldSlant", "-BoldOblique", - + #if WX_NORMALIZED_PS_FONTS "PostScript___", "${PostScriptTimes,$[weight],$[style]}", #else @@ -532,7 +524,7 @@ static char *font_defaults[] = { "ScreenScriptBase", "*-zapfchancery", "ScreenStdSuffix", "-${Screen$[weight]}-${Screen$[style]}" - "-normal-*-*-%d-*-*-*-*-*-*", + "-normal-*-*-%d-*-*-*-*-*-*", "Screen___", "-${ScreenDefaultBase}${ScreenStdSuffix}", @@ -557,20 +549,20 @@ enum {wxSTYLE_NORMAL, wxSTYLE_ITALIC, wxSTYLE_SLANT, wxNUM_STYLES}; static int WCoordinate(int w) { switch (w) { - case wxBOLD: return wxWEIGHT_BOLD; - case wxLIGHT: return wxWEIGHT_LIGHT; - case wxNORMAL: - default: return wxWEIGHT_NORMAL; + case wxBOLD: return wxWEIGHT_BOLD; + case wxLIGHT: return wxWEIGHT_LIGHT; + case wxNORMAL: + default: return wxWEIGHT_NORMAL; } }; static int SCoordinate(int s) { switch (s) { - case wxITALIC: return wxSTYLE_ITALIC; - case wxSLANT: return wxSTYLE_SLANT; - case wxNORMAL: - default: return wxSTYLE_NORMAL; + case wxITALIC: return wxSTYLE_ITALIC; + case wxSLANT: return wxSTYLE_SLANT; + case wxNORMAL: + default: return wxSTYLE_NORMAL; } }; @@ -580,11 +572,11 @@ static int SCoordinate(int s) class wxSuffixMap { public: - ~wxSuffixMap(void); + ~wxSuffixMap(); inline char *GetName(int weight, int style) { - return ( map [WCoordinate(weight)] [SCoordinate(style)] ); + return ( map [WCoordinate(weight)] [SCoordinate(style)] ); } char *map[wxNUM_WEIGHTS][wxNUM_STYLES]; @@ -601,45 +593,45 @@ static void SearchResource(const char *prefix, const char **names, int count, ch char resource[1024], **defaults, *internal; k = 1 << count; - + *v = (char *) NULL; internal = (char *) NULL; for (i = 0; i < k; i++) { - strcpy(resource, prefix); - for (j = 0; j < count; j++) { - if (!(i & (1 << j))) - strcat(resource, names[j]); - else - strcat(resource, "_"); - } - if (wxGetResource(wxAPP_CLASS, (char *)resource, v)) - return; - if (!internal) { - defaults = font_defaults; - while (*defaults) { - if (!strcmp(*defaults, resource)) { - internal = defaults[1]; - break; - } - defaults += 2; - } - } + strcpy(resource, prefix); + for (j = 0; j < count; j++) { + if (!(i & (1 << j))) + strcat(resource, names[j]); + else + strcat(resource, "_"); + } + if (wxGetResource(wxAPP_CLASS, (char *)resource, v)) + return; + if (!internal) { + defaults = font_defaults; + while (*defaults) { + if (!strcmp(*defaults, resource)) { + internal = defaults[1]; + break; + } + defaults += 2; + } + } } if (internal) - *v = copystring(internal); + *v = copystring(internal); } -wxSuffixMap::~wxSuffixMap(void) +wxSuffixMap::~wxSuffixMap() { int k, j; for (k = 0; k < wxNUM_WEIGHTS; ++k) - for (j = 0; j < wxNUM_STYLES; ++j) - if (map[k][j]) { - delete[] map[k][j]; - map[k][j] = (char *) NULL; - } + for (j = 0; j < wxNUM_STYLES; ++j) + if (map[k][j]) { + delete[] map[k][j]; + map[k][j] = (char *) NULL; + } } void wxSuffixMap::Initialize(const char *resname, const char *devresname) @@ -650,100 +642,100 @@ void wxSuffixMap::Initialize(const char *resname, const char *devresname) const char *names[3]; for (k = 0; k < wxNUM_WEIGHTS; k++) { - switch (k) { - case wxWEIGHT_NORMAL: weight = "Medium"; break; - case wxWEIGHT_LIGHT: weight = "Light"; break; - case wxWEIGHT_BOLD: - default: weight = "Bold"; - } - for (j = 0; j < wxNUM_STYLES; j++) { - switch (j) { - case wxSTYLE_NORMAL: style = "Straight"; break; - case wxSTYLE_ITALIC: style = "Italic"; break; - case wxSTYLE_SLANT: - default: style = "Slant"; - } - names[0] = resname; - names[1] = weight; - names[2] = style; - - SearchResource(devresname, names, 3, &v); - - /* Expand macros in the found string: */ - found: - int len, closer = 0, startpos = 0; - - len = (v ? strlen(v) : 0); - for (i = 0; i < len; i++) { - if (v[i] == '$' && ((v[i+1] == '[') || (v[i+1] == '{'))) { - startpos = i; - closer = (v[i+1] == '[') ? ']' : '}'; - ++i; - } else if (v[i] == closer) { - int newstrlen; - const char *r = (char *) NULL; bool delete_r = FALSE; - char *name; - - name = v + startpos + 2; - v[i] = 0; - - if (closer == '}') { - int i, count, len; - char **names; - - for (i = 0, count = 1; name[i]; i++) - if (name[i] == ',') - count++; - - len = i; - - names = new char*[count]; - names[0] = name; - for (i = 0, count = 1; i < len; i++) - if (name[i] == ',') { - names[count++] = name + i + 1; - name[i] = 0; - } - - SearchResource("", (const char **)names, count, (char **)&r); - delete_r = (r != 0); - delete[] names; - - if (!r) { - for (i = 0; i < len; i++) - if (!name[i]) - name[i] = ','; - r = ""; - printf("Bad resource name \"%s\" in font lookup\n", name); - } - } else if (!strcmp(name, "weight")) { - r = weight; - } else if (!strcmp(name, "style")) { - r = style; - } else if (!strcmp(name, "family")) { - r = resname; - } else { - r = ""; - printf("Bad font macro name \"%s\"\n", name); - } - - // add r to v - newstrlen = strlen(r); - char *naya = new char[startpos + newstrlen + len - i]; - memcpy(naya, v, startpos); - memcpy(naya + startpos, r, newstrlen); - memcpy(naya + startpos + newstrlen, v + i + 1, len - i); - if (delete_r) - delete[] (char*)r; - delete[] v; - v = naya; - - goto found; - } - } - /* We have a final value: */ - map[k][j] = v; - } + switch (k) { + case wxWEIGHT_NORMAL: weight = "Medium"; break; + case wxWEIGHT_LIGHT: weight = "Light"; break; + case wxWEIGHT_BOLD: + default: weight = "Bold"; + } + for (j = 0; j < wxNUM_STYLES; j++) { + switch (j) { + case wxSTYLE_NORMAL: style = "Straight"; break; + case wxSTYLE_ITALIC: style = "Italic"; break; + case wxSTYLE_SLANT: + default: style = "Slant"; + } + names[0] = resname; + names[1] = weight; + names[2] = style; + + SearchResource(devresname, names, 3, &v); + + /* Expand macros in the found string: */ +found: + int len, closer = 0, startpos = 0; + + len = (v ? strlen(v) : 0); + for (i = 0; i < len; i++) { + if (v[i] == '$' && ((v[i+1] == '[') || (v[i+1] == '{'))) { + startpos = i; + closer = (v[i+1] == '[') ? ']' : '}'; + ++i; + } else if (v[i] == closer) { + int newstrlen; + const char *r = (char *) NULL; bool delete_r = FALSE; + char *name; + + name = v + startpos + 2; + v[i] = 0; + + if (closer == '}') { + int i, count, len; + char **names; + + for (i = 0, count = 1; name[i]; i++) + if (name[i] == ',') + count++; + + len = i; + + names = new char*[count]; + names[0] = name; + for (i = 0, count = 1; i < len; i++) + if (name[i] == ',') { + names[count++] = name + i + 1; + name[i] = 0; + } + + SearchResource("", (const char **)names, count, (char **)&r); + delete_r = (r != 0); + delete[] names; + + if (!r) { + for (i = 0; i < len; i++) + if (!name[i]) + name[i] = ','; + r = ""; + printf("Bad resource name \"%s\" in font lookup\n", name); + } + } else if (!strcmp(name, "weight")) { + r = weight; + } else if (!strcmp(name, "style")) { + r = style; + } else if (!strcmp(name, "family")) { + r = resname; + } else { + r = ""; + printf("Bad font macro name \"%s\"\n", name); + } + + // add r to v + newstrlen = strlen(r); + char *naya = new char[startpos + newstrlen + len - i]; + memcpy(naya, v, startpos); + memcpy(naya + startpos, r, newstrlen); + memcpy(naya + startpos + newstrlen, v + i + 1, len - i); + if (delete_r) + delete[] (char*)r; + delete[] v; + v = naya; + + goto found; + } + } + /* We have a final value: */ + map[k][j] = v; + } } } @@ -752,27 +744,27 @@ void wxSuffixMap::Initialize(const char *resname, const char *devresname) //----------------------------------------------------------------------------- class wxFontNameItem : public wxObject { -DECLARE_DYNAMIC_CLASS(wxFontNameItem) + DECLARE_DYNAMIC_CLASS(wxFontNameItem) public: - wxFontNameItem(const char *name, int id, int family); - ~wxFontNameItem(); - - inline char* GetScreenName(int w, int s) {return screen.GetName(w, s);} - inline char* GetPostScriptName(int w, int s) {return printing.GetName(w, s);} - inline char* GetAFMName(int w, int s) {return afm.GetName(w, s);} - inline char* GetName(void) {return name;} - inline int GetFamily(void) {return family;} - inline int GetId(void) {return id;} - inline bool IsRoman(void) {return isroman;} + wxFontNameItem(const char *name, int id, int family); + ~wxFontNameItem(); + + inline char* GetScreenName(int w, int s) {return screen.GetName(w, s);} + inline char* GetPostScriptName(int w, int s) {return printing.GetName(w, s);} + inline char* GetAFMName(int w, int s) {return afm.GetName(w, s);} + inline char* GetName() {return name;} + inline int GetFamily() {return family;} + inline int GetId() {return id;} + inline bool IsRoman() {return isroman;} #if defined(__WXDEBUG__) - void Dump(ostream& str); + void Dump(ostream& str); #endif - int id; - int family; - char *name; - wxSuffixMap screen, printing, afm; - bool isroman; + int id; + int family; + char *name; + wxSuffixMap screen, printing, afm; + bool isroman; }; IMPLEMENT_ABSTRACT_CLASS(wxFontNameItem, wxObject) @@ -788,10 +780,10 @@ wxFontNameItem::wxFontNameItem(const char *Name, int Id, int Family) afm. Initialize(name, "Afm"); } -wxFontNameItem::~wxFontNameItem(void) +wxFontNameItem::~wxFontNameItem() { if (name) - delete[] name; + delete[] name; name = (char *) NULL; } @@ -808,7 +800,7 @@ void wxFontNameItem::Dump(ostream& str) IMPLEMENT_DYNAMIC_CLASS(wxFontNameDirectory, wxObject) -wxFontNameDirectory::wxFontNameDirectory(void) +wxFontNameDirectory::wxFontNameDirectory() { table = new wxHashTable(wxKEY_INTEGER, 20); nextFontId = -1; @@ -820,14 +812,14 @@ wxFontNameDirectory::~wxFontNameDirectory() table->BeginFind(); wxNode *node = table->Next(); while (node) { - wxFontNameItem *item = (wxFontNameItem*)node->Data(); - delete item; - node = table->Next(); + wxFontNameItem *item = (wxFontNameItem*)node->Data(); + delete item; + node = table->Next(); } delete table; } -int wxFontNameDirectory::GetNewFontId(void) +int wxFontNameDirectory::GetNewFontId() { return (nextFontId--); } @@ -846,18 +838,18 @@ void wxFontNameDirectory::Initialize() void wxFontNameDirectory::Initialize(int fontid, int family, const char *resname) { char *fam, resource[256]; - + sprintf(resource, "Family%s", resname); SearchResource((const char *)resource, (const char **) NULL, 0, (char **)&fam); if (fam) { - if (!strcmp(fam, "Default")) family = wxDEFAULT; - else if (!strcmp(fam, "Roman")) family = wxROMAN; - else if (!strcmp(fam, "Decorative")) family = wxDECORATIVE; - else if (!strcmp(fam, "Modern")) family = wxMODERN; - else if (!strcmp(fam, "Teletype")) family = wxTELETYPE; - else if (!strcmp(fam, "Swiss")) family = wxSWISS; - else if (!strcmp(fam, "Script")) family = wxSCRIPT; - delete[] fam; // free resource + if (!strcmp(fam, "Default")) family = wxDEFAULT; + else if (!strcmp(fam, "Roman")) family = wxROMAN; + else if (!strcmp(fam, "Decorative")) family = wxDECORATIVE; + else if (!strcmp(fam, "Modern")) family = wxMODERN; + else if (!strcmp(fam, "Teletype")) family = wxTELETYPE; + else if (!strcmp(fam, "Swiss")) family = wxSWISS; + else if (!strcmp(fam, "Script")) family = wxSCRIPT; + delete[] fam; // free resource } table->Put(fontid, new wxFontNameItem(resname, fontid, family)); } @@ -877,7 +869,7 @@ char *wxFontNameDirectory::GetScreenName(int fontid, int weight, int style) { wxFontNameItem *item = (wxFontNameItem*)table->Get(fontid); // find font if (item) - return item->GetScreenName(weight, style); + return item->GetScreenName(weight, style); // font does not exist return (char *) NULL; } @@ -886,7 +878,7 @@ char *wxFontNameDirectory::GetPostScriptName(int fontid, int weight, int style) { wxFontNameItem *item = (wxFontNameItem*)table->Get(fontid); // find font if (item) - return item->GetPostScriptName(weight, style); + return item->GetPostScriptName(weight, style); // font does not exist return (char *) NULL; } @@ -895,7 +887,7 @@ char *wxFontNameDirectory::GetAFMName(int fontid, int weight, int style) { wxFontNameItem *item = (wxFontNameItem *)table->Get(fontid); // find font if (item) - return item->GetAFMName(weight, style); + return item->GetAFMName(weight, style); // font does not exist return (char *) NULL; } @@ -904,7 +896,7 @@ char *wxFontNameDirectory::GetFontName(int fontid) { wxFontNameItem *item = (wxFontNameItem *)table->Get(fontid); // find font if (item) - return item->GetName(); + return item->GetName(); // font does not exist return (char *) NULL; } @@ -916,9 +908,9 @@ int wxFontNameDirectory::GetFontId(const char *name) table->BeginFind(); while ( (node = table->Next()) ) { - wxFontNameItem *item = (wxFontNameItem*)node->Data(); - if (!strcmp(name, item->name)) - return item->id; + wxFontNameItem *item = (wxFontNameItem*)node->Data(); + if (!strcmp(name, item->name)) + return item->id; } // font does not exist return 0; @@ -927,9 +919,9 @@ int wxFontNameDirectory::GetFontId(const char *name) int wxFontNameDirectory::GetFamily(int fontid) { wxFontNameItem *item = (wxFontNameItem *)table->Get(fontid); - + if (item) - return item->family; + return item->family; // font does not exist return wxDEFAULT; } diff --git a/src/gtk1/frame.cpp b/src/gtk1/frame.cpp index 1dfee32d43..4e9104c7a9 100644 --- a/src/gtk1/frame.cpp +++ b/src/gtk1/frame.cpp @@ -42,14 +42,14 @@ extern wxList wxPendingDelete; static void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxFrame *win ) { if (!win->HasVMT()) return; - + /* printf( "OnFrameResize from " ); if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) printf( win->GetClassInfo()->GetClassName() ); printf( ".\n" ); */ - + if ((win->m_width != alloc->width) || (win->m_height != alloc->height)) { win->m_sizeSet = FALSE; @@ -83,10 +83,10 @@ static gint gtk_frame_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WX static gint gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *event, wxFrame *win ) { if (!win->HasVMT()) return FALSE; - + win->m_x = event->x; win->m_y = event->y; - + return FALSE; } @@ -130,7 +130,7 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title, long style, const wxString &name ) { wxTopLevelWindows.Append( this ); - + m_needParent = FALSE; PreCreation( parent, id, pos, size, style, name ); @@ -139,9 +139,9 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title, GtkWindowType win_type = GTK_WINDOW_TOPLEVEL; if (style & wxSIMPLE_BORDER) win_type = GTK_WINDOW_POPUP; - + m_widget = gtk_window_new( win_type ); - + if ((size.x != -1) && (size.y != -1)) gtk_widget_set_usize( m_widget, m_width, m_height ); if ((pos.x != -1) && (pos.y != -1)) @@ -166,11 +166,11 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title, gtk_signal_connect( GTK_OBJECT(m_widget), "configure_event", GTK_SIGNAL_FUNC(gtk_frame_configure_callback), (gpointer)this ); - + if (m_parent) m_parent->AddChild( this ); - + PostCreation(); - + return TRUE; } @@ -187,17 +187,17 @@ wxFrame::~wxFrame() bool wxFrame::Show( bool show ) { wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); - + if (show && !m_sizeSet) { - // by calling GtkOnSize here, we don't have to call - // either after showing the frame, which would entail - // much ugly flicker nor from within the size_allocate - // handler, because GTK 1.1.X forbids that. - + // by calling GtkOnSize here, we don't have to call + // either after showing the frame, which would entail + // much ugly flicker nor from within the size_allocate + // handler, because GTK 1.1.X forbids that. + GtkOnSize( m_x, m_y, m_width, m_height ); } - + return wxWindow::Show( show ); } @@ -209,7 +209,7 @@ void wxFrame::OnCloseWindow( wxCloseEvent &event ) bool wxFrame::Destroy() { wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); - + if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this); return TRUE; @@ -236,7 +236,7 @@ wxPoint wxFrame::GetClientAreaOrigin() const void wxFrame::SetSize( int x, int y, int width, int height, int sizeFlags ) { wxASSERT_MSG( (m_widget != NULL), "invalid window" ); - + // Don't do anything for children of wxMDIChildFrame if (!m_wxwindow) return; @@ -247,7 +247,7 @@ void wxFrame::SetSize( int x, int y, int width, int height, int sizeFlags ) int old_y = m_y; int old_width = m_width; int old_height = m_height; - + if ((sizeFlags & wxSIZE_USE_EXISTING) == wxSIZE_USE_EXISTING) { if (x != -1) m_x = x; @@ -272,7 +272,7 @@ void wxFrame::SetSize( int x, int y, int width, int height, int sizeFlags ) { if (height == -1) m_height = 26; } - + if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth; if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight; if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_minWidth; @@ -280,15 +280,15 @@ void wxFrame::SetSize( int x, int y, int width, int height, int sizeFlags ) if ((m_x != -1) || (m_y != -1)) { - if ((m_x != old_x) || (m_y != old_y)) + if ((m_x != old_x) || (m_y != old_y)) gtk_widget_set_uposition( m_widget, m_x, m_y ); } - + if ((m_width != old_width) || (m_height != old_height)) { gtk_widget_set_usize( m_widget, m_width, m_height ); } - + wxSizeEvent event( wxSize(m_width,m_height), GetId() ); event.SetEventObject( this ); GetEventHandler()->ProcessEvent( event ); @@ -304,20 +304,20 @@ void wxFrame::SetSize( int width, int height ) void wxFrame::Centre( int direction ) { wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); - + int x = 0; int y = 0; - + if (direction & wxHORIZONTAL == wxHORIZONTAL) x = (gdk_screen_width () - m_width) / 2; if (direction & wxVERTICAL == wxVERTICAL) y = (gdk_screen_height () - m_height) / 2; - + Move( x, y ); } void wxFrame::GetClientSize( int *width, int *height ) const { wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); - + wxWindow::GetClientSize( width, height ); if (height) { @@ -340,7 +340,7 @@ void wxFrame::GetClientSize( int *width, int *height ) const void wxFrame::SetClientSize( int const width, int const height ) { wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); - + int h = height; if (m_frameMenuBar) h += wxMENU_HEIGHT; if (m_frameStatusBar) h += wxSTATUS_HEIGHT; @@ -361,35 +361,35 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height if (m_resizing) return; m_resizing = TRUE; - + if (!m_wxwindow) return; - + m_width = width; m_height = height; - + if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth; if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight; if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_minWidth; if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_minHeight; gtk_widget_set_usize( m_widget, m_width, m_height ); - + // this emulates the new wxMSW behaviour of placing all // frame-subwindows (menu, toolbar..) on one native window // OK, this hurts in the eye, but I don't want to call SetSize() // because I don't want to call any non-native functions here. - + if (m_frameMenuBar) { int xx = m_miniEdge; - int yy = m_miniEdge + m_miniTitle; - int ww = m_width - 2*m_miniEdge; - int hh = wxMENU_HEIGHT; + int yy = m_miniEdge + m_miniTitle; + int ww = m_width - 2*m_miniEdge; + int hh = wxMENU_HEIGHT; m_frameMenuBar->m_x = xx; m_frameMenuBar->m_y = yy; m_frameMenuBar->m_width = ww; m_frameMenuBar->m_height = hh; - + gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_frameMenuBar->m_widget, xx, yy ); gtk_widget_set_usize( m_frameMenuBar->m_widget, ww, hh ); } @@ -397,42 +397,42 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height if (m_frameToolBar) { int xx = m_miniEdge; - int yy = m_miniEdge + m_miniTitle; + int yy = m_miniEdge + m_miniTitle; if (m_frameMenuBar) yy += wxMENU_HEIGHT; - int ww = m_width - 2*m_miniEdge; + int ww = m_width - 2*m_miniEdge; int hh = m_frameToolBar->m_height; - - m_frameToolBar->m_x = xx; + + m_frameToolBar->m_x = xx; m_frameToolBar->m_y = yy; m_frameToolBar->m_height = hh; m_frameToolBar->m_width = ww; - + gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_frameToolBar->m_widget, xx, yy ); gtk_widget_set_usize( m_frameToolBar->m_widget, ww, hh ); } - + if (m_frameStatusBar) { int xx = 0 + m_miniEdge; - int yy = m_height - wxSTATUS_HEIGHT - m_miniEdge; - int ww = m_width - 2*m_miniEdge; - int hh = wxSTATUS_HEIGHT; - + int yy = m_height - wxSTATUS_HEIGHT - m_miniEdge; + 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; - + gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_frameStatusBar->m_widget, xx, yy ); gtk_widget_set_usize( m_frameStatusBar->m_widget, ww, hh ); } - + m_sizeSet = TRUE; - + wxSizeEvent event( wxSize(m_width,m_height), GetId() ); event.SetEventObject( this ); GetEventHandler()->ProcessEvent( event ); - + m_resizing = FALSE; } @@ -440,23 +440,23 @@ void wxFrame::OnIdle(wxIdleEvent& WXUNUSED(event) ) { if (!m_sizeSet) GtkOnSize( m_x, m_y, m_width, m_height ); - + DoMenuUpdates(); } void wxFrame::OnSize( wxSizeEvent &WXUNUSED(event) ) { wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); - + if (GetAutoLayout()) { Layout(); } - else + else { // no child: go out ! if (!GetChildren().First()) return; - + // do we have exactly one child? wxWindow *child = (wxWindow *) NULL; for(wxNode *node = GetChildren().First(); node; node = node->Next()) @@ -470,7 +470,7 @@ void wxFrame::OnSize( wxSizeEvent &WXUNUSED(event) ) #endif ) { - // it's the second one: do nothing + // it's the second one: do nothing if (child) return; child = win; } @@ -500,9 +500,9 @@ void wxFrame::SetMenuBar( wxMenuBar *menuBar ) { wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); wxASSERT_MSG( (m_wxwindow != NULL), "invalid frame" ); - + m_frameMenuBar = menuBar; - + if (m_frameMenuBar) { wxNode *node = m_frameMenuBar->m_menus.First(); @@ -512,7 +512,7 @@ void wxFrame::SetMenuBar( wxMenuBar *menuBar ) SetInvokingWindow( menu, this ); node = node->Next(); } - + if (m_frameMenuBar->m_parent != this) { m_frameMenuBar->m_parent = this; @@ -520,11 +520,11 @@ void wxFrame::SetMenuBar( wxMenuBar *menuBar ) m_frameMenuBar->m_widget, m_frameMenuBar->m_x, m_frameMenuBar->m_y ); } } - + if (m_sizeSet) GtkOnSize( m_x, m_y, m_width, m_height ); } -wxMenuBar *wxFrame::GetMenuBar(void) const +wxMenuBar *wxFrame::GetMenuBar() const { return m_frameMenuBar; } @@ -532,15 +532,15 @@ wxMenuBar *wxFrame::GetMenuBar(void) const wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name) { wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); - + wxCHECK_MSG( m_frameToolBar == NULL, FALSE, "recreating toolbar in wxFrame" ); m_frameToolBar = OnCreateToolBar( style, id, name ); - + GetChildren().DeleteObject( m_frameToolBar ); - + if (m_sizeSet) GtkOnSize( m_x, m_y, m_width, m_height ); - + return m_frameToolBar; } @@ -549,33 +549,33 @@ wxToolBar* wxFrame::OnCreateToolBar( long style, wxWindowID id, const wxString& return new wxToolBar( this, id, wxDefaultPosition, wxDefaultSize, style, name ); } -wxToolBar *wxFrame::GetToolBar(void) const -{ - return m_frameToolBar; +wxToolBar *wxFrame::GetToolBar() const +{ + return m_frameToolBar; } wxStatusBar* wxFrame::CreateStatusBar( int number, long style, wxWindowID id, const wxString& name ) { wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); - + wxCHECK_MSG( m_frameStatusBar == NULL, FALSE, "recreating status bar in wxFrame" ); m_frameStatusBar = OnCreateStatusBar( number, style, id, name ); - + if (m_sizeSet) GtkOnSize( m_x, m_y, m_width, m_height ); - + return m_frameStatusBar; } wxStatusBar *wxFrame::OnCreateStatusBar( int number, long style, wxWindowID id, const wxString& name ) { wxStatusBar *statusBar = (wxStatusBar *) NULL; - + statusBar = new wxStatusBar(this, id, wxPoint(0, 0), wxSize(100, 20), style, name); - + // Set the height according to the font and the border size wxClientDC dc(statusBar); - dc.SetFont( *statusBar->GetFont() ); + dc.SetFont( statusBar->GetFont() ); long x, y; dc.GetTextExtent( "X", &x, &y ); @@ -591,7 +591,7 @@ wxStatusBar *wxFrame::OnCreateStatusBar( int number, long style, wxWindowID id, void wxFrame::SetStatusText(const wxString& text, int number) { wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); - + wxCHECK_RET( m_frameStatusBar != NULL, "no statusbar to set text for" ); m_frameStatusBar->SetStatusText(text, number); @@ -600,13 +600,13 @@ void wxFrame::SetStatusText(const wxString& text, int number) void wxFrame::SetStatusWidths(int n, const int widths_field[] ) { wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); - + wxCHECK_RET( m_frameStatusBar != NULL, "no statusbar to set widths for" ); m_frameStatusBar->SetStatusWidths(n, widths_field); } -wxStatusBar *wxFrame::GetStatusBar(void) const +wxStatusBar *wxFrame::GetStatusBar() const { return m_frameStatusBar; } @@ -614,7 +614,7 @@ wxStatusBar *wxFrame::GetStatusBar(void) const void wxFrame::SetTitle( const wxString &title ) { wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); - + m_title = title; if (m_title.IsNull()) m_title = ""; gtk_window_set_title( GTK_WINDOW(m_widget), title ); @@ -623,14 +623,14 @@ void wxFrame::SetTitle( const wxString &title ) void wxFrame::SetIcon( const wxIcon &icon ) { wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); - + m_icon = icon; if (!icon.Ok()) return; - + wxMask *mask = icon.GetMask(); GdkBitmap *bm = (GdkBitmap *) NULL; if (mask) bm = mask->GetBitmap(); - + gdk_window_set_icon( m_widget->window, (GdkWindow *) NULL, icon.GetPixmap(), bm ); } diff --git a/src/gtk1/icon.cpp b/src/gtk1/icon.cpp index 37ce52b757..a372cb9869 100644 --- a/src/gtk1/icon.cpp +++ b/src/gtk1/icon.cpp @@ -19,34 +19,29 @@ IMPLEMENT_DYNAMIC_CLASS(wxIcon,wxBitmap) -wxIcon::wxIcon( const char **bits, int WXUNUSED(width), int WXUNUSED(height) ) : - wxBitmap( bits ) +wxIcon::wxIcon( const char **bits, int WXUNUSED(width), int WXUNUSED(height) ) : + wxBitmap( bits ) { } - -wxIcon::wxIcon( char **bits, int WXUNUSED(width), int WXUNUSED(height) ) : - wxBitmap( bits ) + +wxIcon::wxIcon( char **bits, int WXUNUSED(width), int WXUNUSED(height) ) : + wxBitmap( bits ) { } - -wxIcon::wxIcon() : wxBitmap() -{ -} -wxIcon::wxIcon( const wxIcon& icon ) : wxBitmap() -{ - Ref(icon); +wxIcon::wxIcon() : wxBitmap() +{ } -wxIcon::wxIcon( const wxIcon* icon ) : wxBitmap() -{ - if (icon) Ref(*icon); +wxIcon::wxIcon( const wxIcon& icon ) : wxBitmap() +{ + Ref(icon); } wxIcon& wxIcon::operator = ( const wxIcon& icon ) -{ - if (*this == icon) return (*this); - Ref(icon); - return *this; +{ + if (*this == icon) return (*this); + Ref(icon); + return *this; } diff --git a/src/gtk1/menu.cpp b/src/gtk1/menu.cpp index 7d8900886e..09c77c3479 100644 --- a/src/gtk1/menu.cpp +++ b/src/gtk1/menu.cpp @@ -31,7 +31,7 @@ wxMenuBar::wxMenuBar() m_menus.DeleteContents( TRUE ); m_menubar = gtk_menu_bar_new(); - + m_widget = GTK_WIDGET(m_menubar); PostCreation(); @@ -159,7 +159,7 @@ static void gtk_menu_clicked_callback( GtkWidget *widget, wxMenu *menu ) wxCommandEvent event( wxEVT_COMMAND_MENU_SELECTED, id ); event.SetEventObject( menu ); event.SetInt(id ); - + if (menu->m_callback) { (void) (*(menu->m_callback)) (*menu, event); @@ -187,7 +187,7 @@ static void gtk_menu_hilight_callback( GtkWidget *widget, wxMenu *menu ) wxCommandEvent event( wxEVT_MENU_HIGHLIGHT, id ); event.SetEventObject( menu ); event.SetInt(id ); - + /* wxMSW doesn't call callback here either if (menu->m_callback) { @@ -218,22 +218,24 @@ wxMenuItem::wxMenuItem() m_menuItem = (GtkWidget *) NULL; } +// it's valid for this function to be called even if m_menuItem == NULL void wxMenuItem::SetName(const wxString& str) { - wxCHECK_RET( m_menuItem, "invalid menu item" ); - m_text = ""; - for ( const char *pc = str; *pc != '\0'; pc++ ) + for ( const char *pc = str; *pc != '\0'; pc++ ) { if ( *pc == '&' ) pc++; // skip it m_text << *pc; } - - GtkLabel *label = GTK_LABEL( GTK_BIN(m_menuItem)->child ); - - gtk_label_set( label, m_text.c_str()); + + if ( m_menuItem ) + { + GtkLabel *label = GTK_LABEL( GTK_BIN(m_menuItem)->child ); + + gtk_label_set( label, m_text.c_str()); + } } void wxMenuItem::Check( bool check ) @@ -246,12 +248,12 @@ void wxMenuItem::Check( bool check ) gtk_check_menu_item_set_state( (GtkCheckMenuItem*)m_menuItem, (gint)check ); } -void wxMenuItem::Enable( bool enable ) -{ +void wxMenuItem::Enable( bool enable ) +{ wxCHECK_RET( m_menuItem, "invalid menu item" ); gtk_widget_set_sensitive( m_menuItem, enable ); - m_isEnabled = enable; + m_isEnabled = enable; } bool wxMenuItem::IsChecked() const @@ -279,11 +281,11 @@ wxMenu::wxMenu( const wxString& title, const wxFunction func ) m_items.DeleteContents( TRUE ); m_invokingWindow = (wxWindow *) NULL; m_menu = gtk_menu_new(); // Do not show! - + m_callback = func; m_eventHandler = this; m_clientData = (void*) NULL; - + if (m_title.IsNull()) m_title = ""; if (m_title != "") { @@ -325,7 +327,7 @@ void wxMenu::Append( int id, const wxString &item, const wxString &helpStr, bool const char *text = mitem->GetText(); GtkWidget *menuItem = checkable ? gtk_check_menu_item_new_with_label(text) : gtk_menu_item_new_with_label(text); - + mitem->SetMenuItem(menuItem); gtk_signal_connect( GTK_OBJECT(menuItem), "activate", @@ -466,7 +468,7 @@ wxMenuItem *wxMenu::FindItem(int id) const // Not finding anything here can be correct // when search the entire menu system for // an entry -> no error message. - + return (wxMenuItem *) NULL; } diff --git a/src/gtk1/palette.cpp b/src/gtk1/palette.cpp index 9f49402c61..07d99dc13c 100644 --- a/src/gtk1/palette.cpp +++ b/src/gtk1/palette.cpp @@ -22,19 +22,19 @@ class wxPaletteRefData: public wxObjectRefData { public: - + wxPaletteRefData(void); ~wxPaletteRefData(void); - + GdkColormap *m_colormap; }; -wxPaletteRefData::wxPaletteRefData(void) +wxPaletteRefData::wxPaletteRefData() { m_colormap = (GdkColormap *) NULL; }; -wxPaletteRefData::~wxPaletteRefData(void) +wxPaletteRefData::~wxPaletteRefData() { if (m_colormap) gdk_colormap_unref( m_colormap ); }; @@ -45,7 +45,7 @@ wxPaletteRefData::~wxPaletteRefData(void) IMPLEMENT_DYNAMIC_CLASS(wxPalette,wxGDIObject) -wxPalette::wxPalette(void) +wxPalette::wxPalette() { }; @@ -60,31 +60,25 @@ wxPalette::wxPalette( const wxPalette& palette ) Ref( palette ); }; -wxPalette::wxPalette( const wxPalette* palette ) -{ - UnRef(); - if (palette) Ref( *palette ); -}; - -wxPalette::~wxPalette(void) +wxPalette::~wxPalette() { }; wxPalette& wxPalette::operator = ( const wxPalette& palette ) { - if (*this == palette) return (*this); - Ref( palette ); - return *this; + if (*this == palette) return (*this); + Ref( palette ); + return *this; }; bool wxPalette::operator == ( const wxPalette& palette ) { - return m_refData == palette.m_refData; + return m_refData == palette.m_refData; }; bool wxPalette::operator != ( const wxPalette& palette ) { - return m_refData != palette.m_refData; + return m_refData != palette.m_refData; }; bool wxPalette::Ok(void) const diff --git a/src/gtk1/pen.cpp b/src/gtk1/pen.cpp index dc2fec60a0..8402796a46 100644 --- a/src/gtk1/pen.cpp +++ b/src/gtk1/pen.cpp @@ -4,7 +4,7 @@ // Author: Robert Roebling // Id: $Id$ // Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -21,10 +21,10 @@ class wxPenRefData: public wxObjectRefData { public: - + wxPenRefData(void); wxPenRefData(const wxPenRefData& data); - + int m_width; int m_style; int m_joinStyle; @@ -55,7 +55,7 @@ wxPenRefData::wxPenRefData( const wxPenRefData& data ) IMPLEMENT_DYNAMIC_CLASS(wxPen,wxGDIObject) -wxPen::wxPen(void) +wxPen::wxPen() { if (wxThePenList) wxThePenList->AddPen( this ); } @@ -66,7 +66,7 @@ wxPen::wxPen( const wxColour &colour, int width, int style ) M_PENDATA->m_width = width; M_PENDATA->m_style = style; M_PENDATA->m_colour = colour; - + if (wxThePenList) wxThePenList->AddPen( this ); } @@ -76,14 +76,6 @@ wxPen::wxPen( const wxPen& pen ) if (wxThePenList) wxThePenList->AddPen( this ); } -wxPen::wxPen( const wxPen* pen ) -{ - UnRef(); - if (pen) Ref( *pen ); - - if (wxThePenList) wxThePenList->AddPen( this ); -} - wxPen::~wxPen() { if (wxThePenList) wxThePenList->RemovePen( this ); @@ -91,19 +83,19 @@ wxPen::~wxPen() wxPen& wxPen::operator = ( const wxPen& pen ) { - if (*this == pen) return (*this); - Ref( pen ); - return *this; + if (*this == pen) return (*this); + Ref( pen ); + return *this; } bool wxPen::operator == ( const wxPen& pen ) { - return m_refData == pen.m_refData; + return m_refData == pen.m_refData; } bool wxPen::operator != ( const wxPen& pen ) { - return m_refData != pen.m_refData; + return m_refData != pen.m_refData; } void wxPen::SetColour( const wxColour &colour ) @@ -145,35 +137,35 @@ void wxPen::SetWidth( int width ) int wxPen::GetCap() const { wxCHECK_MSG( Ok(), -1, "invalid pen" ); - + return M_PENDATA->m_capStyle; } int wxPen::GetJoin() const { wxCHECK_MSG( Ok(), -1, "invalid pen" ); - + return M_PENDATA->m_joinStyle; } int wxPen::GetStyle() const { wxCHECK_MSG( Ok(), -1, "invalid pen" ); - + return M_PENDATA->m_style; } int wxPen::GetWidth() const { wxCHECK_MSG( Ok(), -1, "invalid pen" ); - + return M_PENDATA->m_width; } wxColour &wxPen::GetColour() const { wxCHECK_MSG( Ok(), wxNullColour, "invalid pen" ); - + return M_PENDATA->m_colour; } diff --git a/src/gtk1/textctrl.cpp b/src/gtk1/textctrl.cpp index e99ff0e8b7..c2fb43427b 100644 --- a/src/gtk1/textctrl.cpp +++ b/src/gtk1/textctrl.cpp @@ -26,7 +26,7 @@ static void gtk_text_changed_callback( GtkWidget *WXUNUSED(widget), wxTextCtrl *win ) { win->SetModified(); - + wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, win->m_windowId ); wxString val( win->GetValue() ); if (!val.IsNull()) event.m_commandString = WXSTRINGCAST val; @@ -89,7 +89,7 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value, 0, 0); // put the horizontal scrollbar in the lower left hand corner - if (bHasHScrollbar) + if (bHasHScrollbar) { GtkWidget *hscrollbar = gtk_hscrollbar_new(GTK_TEXT(m_text)->hadj); gtk_table_attach(GTK_TABLE(m_widget), hscrollbar, 0, 1, 1, 2, @@ -107,7 +107,7 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value, 0, 0); gtk_widget_show( vscrollbar ); } - else + else { // a single-line text control: no need for scrollbars m_widget = @@ -122,10 +122,10 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value, m_parent->AddChild( this ); (m_parent->m_insertCallback)( m_parent, this ); - + PostCreation(); - if (multi_line) + if (multi_line) { gtk_widget_realize(m_text); gtk_widget_show(m_text); @@ -148,9 +148,9 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value, if (!multi_line) gtk_entry_set_visibility( GTK_ENTRY(m_text), FALSE ); } - + if (style & wxTE_READONLY) - { + { if (!multi_line) gtk_entry_set_editable( GTK_ENTRY(m_text), FALSE ); } @@ -171,7 +171,7 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value, wxString wxTextCtrl::GetValue() const { wxCHECK_MSG( m_text != NULL, "", "invalid text ctrl" ); - + wxString tmp; if (m_windowStyle & wxTE_MULTILINE) { @@ -190,7 +190,7 @@ wxString wxTextCtrl::GetValue() const void wxTextCtrl::SetValue( const wxString &value ) { wxCHECK_RET( m_text != NULL, "invalid text ctrl" ); - + wxString tmp = ""; if (!value.IsNull()) tmp = value; if (m_windowStyle & wxTE_MULTILINE) @@ -209,7 +209,7 @@ void wxTextCtrl::SetValue( const wxString &value ) void wxTextCtrl::WriteText( const wxString &text ) { wxCHECK_RET( m_text != NULL, "invalid text ctrl" ); - + if (text.IsNull()) return; if (m_windowStyle & wxTE_MULTILINE) @@ -226,14 +226,14 @@ void wxTextCtrl::WriteText( const wxString &text ) bool wxTextCtrl::LoadFile( const wxString &file ) { wxCHECK_MSG( m_text != NULL, FALSE, "invalid text ctrl" ); - + if (!wxFileExists(file)) return FALSE; Clear(); FILE *fp = NULL; struct stat statb; - + if ((stat ((char*) (const char*) file, &statb) == -1) || (statb.st_mode & S_IFMT) != S_IFREG || !(fp = fopen ((char*) (const char*) file, "r"))) { @@ -254,7 +254,7 @@ bool wxTextCtrl::LoadFile( const wxString &file ) fclose (fp); text[len] = 0; - + if (m_windowStyle & wxTE_MULTILINE) { gtk_editable_insert_text( GTK_EDITABLE(m_text), text, 0, &len ); @@ -263,7 +263,7 @@ bool wxTextCtrl::LoadFile( const wxString &file ) { gtk_entry_set_text( GTK_ENTRY(m_text), text ); } - + free (text); m_modified = FALSE; return TRUE; @@ -274,9 +274,9 @@ bool wxTextCtrl::LoadFile( const wxString &file ) bool wxTextCtrl::SaveFile( const wxString &file ) { wxCHECK_MSG( m_text != NULL, FALSE, "invalid text ctrl" ); - + if (file == "") return FALSE; - + FILE *fp; if (!(fp = fopen ((char*) (const char*) file, "w"))) @@ -287,7 +287,7 @@ bool wxTextCtrl::SaveFile( const wxString &file ) { char *text = NULL; gint len = 0; - + if (m_windowStyle & wxTE_MULTILINE) { len = gtk_text_get_length( GTK_TEXT(m_text) ); @@ -297,20 +297,20 @@ bool wxTextCtrl::SaveFile( const wxString &file ) { text = gtk_entry_get_text( GTK_ENTRY(m_text) ); } - + if (fwrite (text, sizeof (char), len, fp) != (size_t) len) { // Did not write whole file } - + // Make sure newline terminates the file if (text[len - 1] != '\n') fputc ('\n', fp); fclose (fp); - + if (m_windowStyle & wxTE_MULTILINE) g_free( text ); - + m_modified = FALSE; return TRUE; } @@ -337,7 +337,7 @@ wxString wxTextCtrl::GetLineText( long lineNo ) const int j; for (j = 0; text[i] && text[i] != '\n'; i++, j++ ) buf += text[i]; - + g_free( text ); return buf; } @@ -366,7 +366,7 @@ long wxTextCtrl::PositionToXY(long pos, long *x, long *y ) const return 0; if( pos >= len) return pos=len-1; - + *x=1; // Col 1 *y=1; // Line 1 for (int i = 0; i < pos; i++ ) @@ -378,7 +378,7 @@ long wxTextCtrl::PositionToXY(long pos, long *x, long *y ) const } else (*x)++; - } + } g_free( text ); return 1; } @@ -388,7 +388,7 @@ long wxTextCtrl::XYToPosition(long x, long y ) const if (!(m_windowStyle & wxTE_MULTILINE)) return 0; long pos=0; - + for(int i=1;icurrent_pos; } long wxTextCtrl::GetLastPosition() const { wxCHECK_MSG( m_text != NULL, 0, "invalid text ctrl" ); - + int pos = 0; if (m_windowStyle & wxTE_MULTILINE) pos = gtk_text_get_length( GTK_TEXT(m_text) ); @@ -494,14 +494,14 @@ long wxTextCtrl::GetLastPosition() const void wxTextCtrl::Remove( long from, long to ) { wxCHECK_RET( m_text != NULL, "invalid text ctrl" ); - + gtk_editable_delete_text( GTK_EDITABLE(m_text), (gint)from, (gint)to ); } void wxTextCtrl::Replace( long from, long to, const wxString &value ) { wxCHECK_RET( m_text != NULL, "invalid text ctrl" ); - + gtk_editable_delete_text( GTK_EDITABLE(m_text), (gint)from, (gint)to ); if (value.IsNull()) return; gint pos = (gint)to; @@ -511,7 +511,7 @@ void wxTextCtrl::Replace( long from, long to, const wxString &value ) void wxTextCtrl::Cut() { wxCHECK_RET( m_text != NULL, "invalid text ctrl" ); - + #if (GTK_MINOR_VERSION == 1) gtk_editable_cut_clipboard( GTK_EDITABLE(m_text) ); #else @@ -522,7 +522,7 @@ void wxTextCtrl::Cut() void wxTextCtrl::Copy() { wxCHECK_RET( m_text != NULL, "invalid text ctrl" ); - + #if (GTK_MINOR_VERSION == 1) gtk_editable_copy_clipboard( GTK_EDITABLE(m_text) ); #else @@ -533,7 +533,7 @@ void wxTextCtrl::Copy() void wxTextCtrl::Paste() { wxCHECK_RET( m_text != NULL, "invalid text ctrl" ); - + #if (GTK_MINOR_VERSION == 1) gtk_editable_paste_clipboard( GTK_EDITABLE(m_text) ); #else @@ -554,7 +554,7 @@ void wxTextCtrl::OnChar( wxKeyEvent &key_event ) event.SetEventObject(this); if (GetEventHandler()->ProcessEvent(event)) return; } - else if (key_event.KeyCode() == WXK_TAB) + else if (key_event.KeyCode() == WXK_TAB) { wxNavigationKeyEvent event; event.SetDirection( key_event.m_shiftDown ); @@ -659,14 +659,14 @@ bool wxTextCtrl::IsOwnGtkWindow( GdkWindow *window ) void wxTextCtrl::SetFont( const wxFont &WXUNUSED(font) ) { wxCHECK_RET( m_text != NULL, "invalid text ctrl" ); - + // doesn't work } void wxTextCtrl::SetForegroundColour( const wxColour &WXUNUSED(colour) ) { wxCHECK_RET( m_text != NULL, "invalid text ctrl" ); - + // doesn't work } @@ -675,9 +675,9 @@ void wxTextCtrl::SetBackgroundColour( const wxColour &colour ) wxCHECK_RET( m_text != NULL, "invalid text ctrl" ); wxControl::SetBackgroundColour( colour ); - + if (!m_backgroundColour.Ok()) return; - + if (m_windowStyle & wxTE_MULTILINE) { GdkWindow *window = GTK_TEXT(m_text)->text_area; diff --git a/src/gtk1/utilsres.cpp b/src/gtk1/utilsres.cpp index d743ad554e..748d845d37 100644 --- a/src/gtk1/utilsres.cpp +++ b/src/gtk1/utilsres.cpp @@ -109,7 +109,7 @@ static char *GetIniFile(char *dest, const char *filename) return dest; } -static void wxXMergeDatabases(void) +static void wxXMergeDatabases() { XrmDatabase homeDB, serverDB, applicationDB; char filenamebuf[1024]; @@ -159,7 +159,7 @@ static void wxXMergeDatabases(void) // called on application exit //----------------------------------------------------------------------------- -void wxFlushResources(void) +void wxFlushResources() { char nameBuffer[512]; diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index c3eba590fa..0a7b3f3bc5 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -86,14 +86,14 @@ this is (in most cases) the only GTK widget the class manages. E.g. the wxStatitText class handles only a GtkLabel widget a pointer to which you can find in m_widget (defined in wxWindow) - + When the class has a client area for drawing into and for containing children - it has to handle the client area widget (of the type GtkMyFixed, defined in - win_gtk.c), but there could be any number of widgets, handled by a class - The common rule for all windows is only, that the widget that interacts with - the rest of GTK must be referenced in m_widget and all other widgets must be - children of this widget on the GTK level. The top-most widget, which also - represents the client area, must be in the m_wxwindow field and must be of + it has to handle the client area widget (of the type GtkMyFixed, defined in + win_gtk.c), but there could be any number of widgets, handled by a class + The common rule for all windows is only, that the widget that interacts with + the rest of GTK must be referenced in m_widget and all other widgets must be + children of this widget on the GTK level. The top-most widget, which also + represents the client area, must be in the m_wxwindow field and must be of the type GtkMyFixed. As I said, the window classes that display a GTK native widget only have @@ -504,7 +504,7 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion if (g_blockEventsOnDrag) return TRUE; if (g_blockEventsOnScroll) return TRUE; - + if (!win->HasVMT()) return TRUE; /* @@ -762,7 +762,7 @@ static void gtk_window_hscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow * float line_step = win->m_hAdjust->step_increment; float page_step = win->m_hAdjust->page_increment; - + if (win->m_isScrolling) { command = wxEVT_SCROLL_THUMBTRACK; @@ -839,12 +839,12 @@ static void gtk_window_hscroll_change_callback( GtkWidget *WXUNUSED(widget), wxW // "button_press_event" from scrollbar //----------------------------------------------------------------------------- -static gint gtk_scrollbar_button_press_callback( GtkRange *WXUNUSED(widget), - GdkEventButton *WXUNUSED(gdk_event), +static gint gtk_scrollbar_button_press_callback( GtkRange *WXUNUSED(widget), + GdkEventButton *WXUNUSED(gdk_event), wxWindow *win ) { // if (gdk_event->window != widget->slider) return FALSE; - + win->m_isScrolling = TRUE; g_blockEventsOnScroll = TRUE; @@ -855,8 +855,8 @@ static gint gtk_scrollbar_button_press_callback( GtkRange *WXUNUSED(widget), // "button_release_event" from scrollbar //----------------------------------------------------------------------------- -static gint gtk_scrollbar_button_release_callback( GtkRange *widget, - GdkEventButton *WXUNUSED(gdk_event), +static gint gtk_scrollbar_button_release_callback( GtkRange *widget, + GdkEventButton *WXUNUSED(gdk_event), wxWindow *win ) { @@ -883,7 +883,7 @@ static gint gtk_scrollbar_button_release_callback( GtkRange *widget, //----------------------------------------------------------------------------- // Callback for wxWindow. This very strange beast has to be used because -// C++ has no virtual methods in a constructor. We have to emulate a +// C++ has no virtual methods in a constructor. We have to emulate a // virtual function here as wxNotebook requires a different way to insert // a child in it. I had opted for creating a wxNotebookPage window class // which would have made this superflouus (such in the MDI window system), @@ -891,13 +891,13 @@ static gint gtk_scrollbar_button_release_callback( GtkRange *widget, static void wxInsertChildInWindow( wxWindow* parent, wxWindow* child ) { - gtk_myfixed_put( GTK_MYFIXED(parent->m_wxwindow), - GTK_WIDGET(child->m_widget), - child->m_x, + gtk_myfixed_put( GTK_MYFIXED(parent->m_wxwindow), + GTK_WIDGET(child->m_widget), + child->m_x, child->m_y ); - gtk_widget_set_usize( GTK_WIDGET(child->m_widget), - child->m_width, + gtk_widget_set_usize( GTK_WIDGET(child->m_widget), + child->m_width, child->m_height ); } @@ -920,7 +920,7 @@ wxWindow::wxWindow() m_wxwindow = (GtkWidget *) NULL; m_parent = (wxWindow *) NULL; m_children.DeleteContents( FALSE ); - + m_x = 0; m_y = 0; m_width = 0; @@ -929,46 +929,46 @@ wxWindow::wxWindow() m_minHeight = -1; m_maxWidth = -1; m_maxHeight = -1; - + m_retCode = 0; - + m_eventHandler = this; m_windowValidator = (wxValidator *) NULL; - + m_windowId = -1; - + m_cursor = (wxCursor *) NULL; 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_isScrolling = FALSE; m_hAdjust = (GtkAdjustment*) NULL; m_vAdjust = (GtkAdjustment*) NULL; m_oldHorizontalPos = 0.0; m_oldVerticalPos = 0.0; - + m_isShown = FALSE; m_isEnabled = TRUE; - + m_dropTarget = (wxDropTarget*) NULL; m_resizing = FALSE; m_scrollGC = (GdkGC*) NULL; m_widgetStyle = (GtkStyle*) NULL; - + m_insertCallback = wxInsertChildInWindow; - + m_clientObject = (wxClientData*) NULL; m_clientData = NULL; } @@ -980,7 +980,7 @@ wxWindow::wxWindow( wxWindow *parent, wxWindowID id, m_insertCallback = wxInsertChildInWindow; Create( parent, id, pos, size, style, name ); } - + bool wxWindow::Create( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style, const wxString &name ) @@ -1058,7 +1058,7 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id, // 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", (GtkSignalFunc)gtk_scrollbar_button_press_callback, (gpointer) this ); @@ -1070,7 +1070,7 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id, gtk_signal_connect( GTK_OBJECT(s_window->hscrollbar), "button_release_event", (GtkSignalFunc)gtk_scrollbar_button_release_callback, (gpointer) this ); - + // these handers het notified when screen updates are required either when // scrolling or when the window size (and therefore scrollbar configuration) // has changed @@ -1086,13 +1086,13 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id, (GtkSignalFunc) gtk_window_vscroll_change_callback, (gpointer) this ); gtk_widget_show( m_wxwindow ); - + if (m_parent) m_parent->AddChild( this ); (m_parent->m_insertCallback)( m_parent, this ); - + PostCreation(); - + Show( TRUE ); return TRUE; @@ -1110,13 +1110,13 @@ wxWindow::~wxWindow() DestroyChildren(); if (m_widgetStyle) gtk_style_unref( m_widgetStyle ); - + if (m_scrollGC) gdk_gc_unref( m_scrollGC ); - + if (m_wxwindow) gtk_widget_destroy( m_wxwindow ); if (m_widget) gtk_widget_destroy( m_widget ); - + if (m_cursor) delete m_cursor; DeleteRelatedConstraints(); @@ -1147,7 +1147,7 @@ wxWindow::~wxWindow() wxTopLevelWindows.DeleteObject(this); if (m_windowValidator) delete m_windowValidator; - + if (m_clientObject) delete m_clientObject; } @@ -1157,21 +1157,21 @@ void wxWindow::PreCreation( wxWindow *parent, wxWindowID id, { if (m_needParent && (parent == NULL)) wxFatalError( "Need complete parent.", name ); - + m_widget = (GtkWidget*) NULL; m_wxwindow = (GtkWidget*) NULL; m_hasVMT = FALSE; m_parent = parent; m_children.DeleteContents( FALSE ); - + m_width = size.x; if (m_width == -1) m_width = 20; m_height = size.y; if (m_height == -1) m_height = 20; - + m_x = (int)pos.x; m_y = (int)pos.y; - + if (!m_needParent) // some reasonable defaults { if (m_x == -1) @@ -1185,49 +1185,49 @@ void wxWindow::PreCreation( wxWindow *parent, wxWindowID id, 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 = new wxCursor( wxCURSOR_ARROW ); m_font = *wxSWISS_FONT; // m_backgroundColour = wxWHITE; // 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; - + m_dropTarget = (wxDropTarget *) NULL; m_resizing = FALSE; m_windowValidator = (wxValidator *) NULL; m_scrollGC = (GdkGC*) NULL; m_widgetStyle = (GtkStyle*) NULL; - + m_clientObject = (wxClientData*)NULL; m_clientData = NULL; } @@ -1336,7 +1336,7 @@ void wxWindow::AdjustForParentClientOrigin( int& x, int& y, int sizeFlags ) if (((sizeFlags & wxSIZE_NO_ADJUSTMENTS) == 0) && GetParent()) { wxPoint pt(GetParent()->GetClientAreaOrigin()); - x += pt.x; + x += pt.x; y += pt.y; } } @@ -1345,7 +1345,7 @@ void wxWindow::SetSize( int x, int y, int width, int height, int sizeFlags ) { wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_parent != NULL), "wxWindow::SetSize requires parent.\n" ); - + if (m_resizing) return; // I don't like recursions m_resizing = TRUE; @@ -1361,7 +1361,7 @@ void wxWindow::SetSize( int x, int y, int width, int height, int sizeFlags ) { int old_width = m_width; int old_height = m_height; - + if ((sizeFlags & wxSIZE_USE_EXISTING) == wxSIZE_USE_EXISTING) { if (x != -1) m_x = x; @@ -1386,7 +1386,7 @@ void wxWindow::SetSize( int x, int y, int width, int height, int sizeFlags ) { if (height == -1) m_height = 26; } - + if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth; if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight; if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_minWidth; @@ -1394,11 +1394,11 @@ void wxWindow::SetSize( int x, int y, int width, int height, int sizeFlags ) wxPoint pt( m_parent->GetClientAreaOrigin() ); gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), m_widget, m_x+pt.x, m_y+pt.y ); - + if ((old_width != m_width) || (old_height != m_height)) gtk_widget_set_usize( m_widget, m_width, m_height ); } - + m_sizeSet = TRUE; wxSizeEvent event( wxSize(m_width,m_height), GetId() ); @@ -1457,7 +1457,7 @@ void wxWindow::SetClientSize( int width, int height ) #ifdef NEW_GTK_SCROLL_CODE GtkWidget *viewport = scroll_window->child; -#else +#else GtkWidget *viewport = scroll_window->viewport; #endif @@ -1522,7 +1522,7 @@ void wxWindow::GetClientSize( int *width, int *height ) const #ifdef NEW_GTK_SCROLL_CODE GtkWidget *viewport = scroll_window->child; -#else +#else GtkWidget *viewport = scroll_window->viewport; #endif @@ -1589,7 +1589,7 @@ void wxWindow::ClientToScreen( int *x, int *y ) wxPoint pt(GetClientAreaOrigin()); org_x += pt.x; org_y += pt.y; - + if (x) *x += org_x; if (y) *y += org_y; } @@ -1620,7 +1620,7 @@ void wxWindow::ScreenToClient( int *x, int *y ) wxPoint pt(GetClientAreaOrigin()); org_x -= pt.x; org_y -= pt.y; - + if (x) *x -= org_x; if (y) *y -= org_y; } @@ -1631,7 +1631,7 @@ void wxWindow::Centre( int direction ) int x = m_x; int y = m_y; - + if (m_parent) { int p_w = 0; @@ -1645,7 +1645,7 @@ void wxWindow::Centre( int direction ) if (direction & wxHORIZONTAL == wxHORIZONTAL) x = (gdk_screen_width () - m_width) / 2; if (direction & wxVERTICAL == wxVERTICAL) y = (gdk_screen_height () - m_height) / 2; } - + Move( x, y ); } @@ -1655,7 +1655,7 @@ void wxWindow::Fit() int maxX = 0; int maxY = 0; - wxNode *node = m_childrenFirst(); + wxNode *node = m_children.First(); while ( node ) { wxWindow *win = (wxWindow *)node->Data(); @@ -1803,25 +1803,20 @@ void wxWindow::AddChild( wxWindow *child ) m_children.Append( child ); } -wxList& wxWindow::GetChildren() const -{ - return m_children; -} - wxWindow *wxWindow::ReParent( wxWindow *newParent ) { wxWindow *oldParent = GetParent(); - + if (oldParent) oldParent->RemoveChild( this ); - + gtk_widget_unparent( m_widget ); - + if (newParent) { newParent->AddChild( this ); (newParent->m_insertCallback)( newParent, this ); } - + return oldParent; } @@ -1855,7 +1850,7 @@ void wxWindow::Lower() if (m_widget) gdk_window_lower( m_widget->window ); } -wxEvtHandler *wxWindow::GetEventHandler() +wxEvtHandler *wxWindow::GetEventHandler() const { return m_eventHandler; } @@ -1934,7 +1929,7 @@ void wxWindow::SetId( wxWindowID id ) m_windowId = id; } -wxWindowID wxWindow::GetId() +wxWindowID wxWindow::GetId() const { return m_windowId; } @@ -1951,7 +1946,8 @@ void wxWindow::SetCursor( const wxCursor &cursor ) if (cursor.Ok()) { - if (*((wxCursor*)&cursor) == m_cursor) return; + if ( cursor == *m_cursor ) + return; *m_cursor = cursor; } else @@ -2054,13 +2050,13 @@ void wxWindow::SetBackgroundColour( const wxColour &colour ) wxCHECK_RET( m_widget != NULL, "invalid window" ); if (m_backgroundColour == colour) return; - + if (!m_backgroundColour.Ok()) if (wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE ) == colour) return; - + m_backgroundColour = colour; if (!m_backgroundColour.Ok()) return; - + if (m_wxwindow) { GdkWindow *window = m_wxwindow->window; @@ -2068,7 +2064,7 @@ void wxWindow::SetBackgroundColour( const wxColour &colour ) gdk_window_set_background( window, m_backgroundColour.GetColor() ); gdk_window_clear( window ); } - + ApplyWidgetStyle(); } @@ -2082,31 +2078,31 @@ void wxWindow::SetForegroundColour( const wxColour &colour ) wxCHECK_RET( m_widget != NULL, "invalid window" ); if (m_foregroundColour == colour) return; - + m_foregroundColour = colour; if (!m_foregroundColour.Ok()) return; - + ApplyWidgetStyle(); } GtkStyle *wxWindow::GetWidgetStyle() { if (m_widgetStyle) gtk_style_unref( m_widgetStyle ); - - m_widgetStyle = - gtk_style_copy( + + m_widgetStyle = + gtk_style_copy( gtk_widget_get_style( m_widget ) ); - + return m_widgetStyle; } void wxWindow::SetWidgetStyle() { GtkStyle *style = GetWidgetStyle(); - + gdk_font_unref( style->font ); style->font = gdk_font_ref( m_font.GetInternalFont( 1.0 ) ); - + if (m_foregroundColour.Ok()) { m_foregroundColour.CalcPixel( gdk_window_get_colormap( m_widget->window ) ); @@ -2114,7 +2110,7 @@ void wxWindow::SetWidgetStyle() style->fg[GTK_STATE_PRELIGHT] = *m_foregroundColour.GetColor(); style->fg[GTK_STATE_ACTIVE] = *m_foregroundColour.GetColor(); } - + if (m_backgroundColour.Ok()) { m_backgroundColour.CalcPixel( gdk_window_get_colormap( m_widget->window ) ); @@ -2219,7 +2215,7 @@ bool wxWindow::PopupMenu( wxMenu *menu, int WXUNUSED(x), int WXUNUSED(y) ) wxCHECK_MSG( m_widget != NULL, FALSE, "invalid window" ); wxCHECK_MSG( menu != NULL, FALSE, "invalid popup-menu" ); - + SetInvokingWindow( menu, this ); gtk_menu_popup( GTK_MENU(menu->m_menu), @@ -2274,13 +2270,8 @@ void wxWindow::SetFont( const wxFont &font ) m_font = font; else m_font = *wxSWISS_FONT; - - ApplyWidgetStyle(); -} -wxFont *wxWindow::GetFont() -{ - return &m_font; + ApplyWidgetStyle(); } void wxWindow::SetWindowStyleFlag( long flag ) @@ -2392,7 +2383,7 @@ void wxWindow::SetScrollbar( int orient, int pos, int thumbVisible, wxASSERT_MSG( (m_wxwindow != NULL), "window needs client area" ); if (!m_wxwindow) return; - + m_hasScrolling = TRUE; if (orient == wxHORIZONTAL) @@ -2556,13 +2547,13 @@ void wxWindow::ScrollWindow( int dx, int dy, const wxRect* WXUNUSED(rect) ) int d_y = 0; if (dx > 0) d_x = dx; if (dy > 0) d_y = dy; - + if (!m_scrollGC) { m_scrollGC = gdk_gc_new( m_wxwindow->window ); gdk_gc_set_exposures( m_scrollGC, TRUE ); } - + gdk_window_copy_area( m_wxwindow->window, m_scrollGC, d_x, d_y, m_wxwindow->window, s_x, s_y, w, h ); @@ -2795,7 +2786,7 @@ bool wxWindow::DoPhase(int phase) { noChanges = 0; noFailures = 0; - wxNode *node = m_children.first(); + wxNode *node = m_children.First(); while (node) { wxWindow *child = (wxWindow *)node->Data(); diff --git a/src/make.env b/src/make.env index d618b07d3c..465773788c 100644 --- a/src/make.env +++ b/src/make.env @@ -8,8 +8,7 @@ ########################### Programs ################################# # Replace this with your own path if necessary -#WXDIR = /home/karl/wxWindows -WXDIR = /home/jacs/wx2 +WXDIR = $(wx) # C++ compiler CC = g++ -- 2.45.2