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
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;
~wxMask();
// implementation
-
+
GdkBitmap *m_bitmap;
GdkBitmap *GetBitmap() const;
};
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;
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;
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
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 :-)
};
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// copy ctors and assignment operators
wxColour( const wxColour& col );
- wxColour( const wxColour* col );
wxColour& operator = ( const wxColour& col );
// dtor
// 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;
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#include "wx/object.h"
#include "wx/gdicmn.h"
-//-----------------------------------------------------------------------------
-// classes
-//-----------------------------------------------------------------------------
-
-class wxWindow;
-
-class wxCursor;
-
//-----------------------------------------------------------------------------
// wxCursor
//-----------------------------------------------------------------------------
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 :-)
};
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// 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
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;
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)
{
{
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 )
{
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);
}
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; }
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;
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 ?
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;
};
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
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;
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 );
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 );
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;
GdkGC *m_bgGC;
GdkColormap *m_cmap;
bool m_isMemDC;
-
+
void SetUpDC();
void Destroy();
GdkWindow *GetWindow();
// Author: Robert Roebling
// RCS-ID: $Id$
// Copyright: (c) 1998 Robert Roebling
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
virtual void SelectObject( const wxBitmap& bitmap );
void GetSize( int *width, int *height ) const;
- // implementation
-
+ // implementation
+
wxBitmap m_selected;
};
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();
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();
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:
double m_underlineThickness;
};
-#endif
+#endif
// wxUSE_POSTSCRIPT
#endif
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// 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 :-)
// 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);
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;
};
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
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 );
// 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; }
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;
};
-#endif
+#endif
//__GTKMENUITEMH__
// Created: 01/02/97
// Id:
// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
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;
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
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 :-)
};
wxStringClientData( wxString &data ) { m_data = data; }
void SetData( wxString &data ) { m_data = data; }
wxString GetData() const { return m_data; }
-
+
private:
wxString m_data;
};
class wxWindow: public wxEvtHandler
{
DECLARE_DYNAMIC_CLASS(wxWindow)
-
+
public:
wxWindow();
wxWindow(wxWindow *parent, wxWindowID id,
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);
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();
{ 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 );
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;
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 );
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 );
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;
bool m_resizing;
GdkGC *m_scrollGC;
GtkStyle *m_widgetStyle;
-
+
wxInsertChildFunction m_insertCallback;
public:
~wxMask();
// implementation
-
+
GdkBitmap *m_bitmap;
GdkBitmap *GetBitmap() const;
};
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;
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;
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
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 :-)
};
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// copy ctors and assignment operators
wxColour( const wxColour& col );
- wxColour( const wxColour* col );
wxColour& operator = ( const wxColour& col );
// dtor
// 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;
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#include "wx/object.h"
#include "wx/gdicmn.h"
-//-----------------------------------------------------------------------------
-// classes
-//-----------------------------------------------------------------------------
-
-class wxWindow;
-
-class wxCursor;
-
//-----------------------------------------------------------------------------
// wxCursor
//-----------------------------------------------------------------------------
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 :-)
};
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// 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
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;
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)
{
{
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 )
{
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);
}
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; }
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;
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 ?
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;
};
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
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;
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 );
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 );
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;
GdkGC *m_bgGC;
GdkColormap *m_cmap;
bool m_isMemDC;
-
+
void SetUpDC();
void Destroy();
GdkWindow *GetWindow();
// Author: Robert Roebling
// RCS-ID: $Id$
// Copyright: (c) 1998 Robert Roebling
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
virtual void SelectObject( const wxBitmap& bitmap );
void GetSize( int *width, int *height ) const;
- // implementation
-
+ // implementation
+
wxBitmap m_selected;
};
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();
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();
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:
double m_underlineThickness;
};
-#endif
+#endif
// wxUSE_POSTSCRIPT
#endif
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// 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 :-)
// 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);
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;
};
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
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 );
// 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; }
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;
};
-#endif
+#endif
//__GTKMENUITEMH__
// Created: 01/02/97
// Id:
// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
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;
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
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 :-)
};
wxStringClientData( wxString &data ) { m_data = data; }
void SetData( wxString &data ) { m_data = data; }
wxString GetData() const { return m_data; }
-
+
private:
wxString m_data;
};
class wxWindow: public wxEvtHandler
{
DECLARE_DYNAMIC_CLASS(wxWindow)
-
+
public:
wxWindow();
wxWindow(wxWindow *parent, wxWindowID id,
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);
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();
{ 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 );
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;
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 );
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 );
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;
bool m_resizing;
GdkGC *m_scrollGC;
GtkStyle *m_widgetStyle;
-
+
wxInsertChildFunction m_insertCallback;
public:
// 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"
// Define a new application type
// ----------------------------------------------------------------------------
class DnDApp : public wxApp
-{
+{
public:
bool OnInit();
};
// Define a new frame type
// ----------------------------------------------------------------------------
class DnDFrame : public wxFrame
-{
+{
public:
DnDFrame(wxFrame *frame, char *title, int x, int y, int w, int h);
~DnDFrame();
void OnLeftDown(wxMouseEvent& event);
void OnRightDown(wxMouseEvent& event);
-
+
bool OnClose();
-
+
DECLARE_EVENT_TABLE()
private:
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
// frame icon and status bar
SetIcon(wxICON(mondrian));
-
+
// const int widths[] = { -1 };
CreateStatusBar();
menu_bar->Append(help_menu, "&Help");
SetMenuBar(menu_bar);
-
+
// make a panel with 3 subwindows
wxPoint pos(0, 0);
wxSize size(400, 200);
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!)
// 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);
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 );
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",
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"
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;
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() );
}
return TRUE;
}
-bool DnDFile::OnDropFiles(long, long, size_t nFiles,
+bool DnDFile::OnDropFiles(long, long, size_t nFiles,
const char * const aszFiles[])
{
wxString str;
#endif
#include "wx/toolbar.h"
+#include <wx/log.h>
+
#include "test.h"
#if defined(__WXGTK__) || defined(__WXMOTIF__)
IMPLEMENT_APP(MyApp)
-
// The `main program' equivalent, creating the windows and returning the
// main frame
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;
bool MyApp::InitToolbar(wxToolBar* toolBar)
{
- toolBar->SetMargins(5, 5);
-
// Set up toolbar
wxBitmap* toolBarBitmaps[8];
// 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);
}
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
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
{
private:
wxTextCtrl* m_textWindow;
+ MyTimer m_timer;
+
DECLARE_EVENT_TABLE()
};
// Created: 01/02/97
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
* wxColourData
*/
-wxColourData::wxColourData(void)
+wxColourData::wxColourData()
{
int i;
for (i = 0; i < 16; i++)
chooseFull = FALSE;
dataColour.Set(0,0,0);
-}
+}
-wxColourData::~wxColourData(void)
+wxColourData::~wxColourData()
{
}
* Font data
*/
-wxFontData::wxFontData(void)
+wxFontData::wxFontData()
{
// Intialize colour to black.
fontColour.Set(0, 0, 0);
maxSize = 0;
}
-wxFontData::~wxFontData(void)
+wxFontData::~wxFontData()
{
}
* Print data
*/
-wxPrintData::wxPrintData(void)
+wxPrintData::wxPrintData()
{
#ifdef __WXMSW__
printData = NULL;
printSetupDialog = FALSE;
}
-wxPrintData::~wxPrintData(void)
+wxPrintData::~wxPrintData()
{
#ifdef __WXMSW__
PRINTDLG *pd = (PRINTDLG *)printData;
}
#ifdef __WXMSW__
-void wxPrintData::ConvertToNative(void)
+void wxPrintData::ConvertToNative()
{
PRINTDLG *pd = (PRINTDLG*) printData;
if ( pd == NULL )
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;
GlobalFree(pd->hDevNames);
pd->hDevNames = NULL;
}
-#endif
}
if ( pd->hDevMode )
pd->Flags |= PD_PRINTSETUP;
}
-void wxPrintData::ConvertFromNative(void)
+void wxPrintData::ConvertFromNative()
{
PRINTDLG *pd = (PRINTDLG*) printData;
if ( pd == NULL )
* wxPageSetupData
*/
-wxPageSetupData::wxPageSetupData(void)
+wxPageSetupData::wxPageSetupData()
{
#if defined(__WIN95__)
m_pageSetupData = NULL;
m_getDefaultInfo = FALSE;
}
-wxPageSetupData::~wxPageSetupData(void)
+wxPageSetupData::~wxPageSetupData()
{
#if defined(__WIN95__) && defined(__WXMSW__)
PAGESETUPDLG *pd = (PAGESETUPDLG *)m_pageSetupData;
}
#if defined(__WXMSW__) && defined(__WIN95__)
-void wxPageSetupData::ConvertToNative(void)
+void wxPageSetupData::ConvertToNative()
{
PAGESETUPDLG *pd = (PAGESETUPDLG*) m_pageSetupData;
if ( m_pageSetupData == NULL )
pd->hDevMode = GlobalAlloc(GMEM_MOVEABLE, sizeof(DEVMODE));
m_pageSetupData = (void *)pd;
}
-
+
pd->Flags = PSD_MARGINS|PSD_MINMARGINS;
if ( m_defaultMinMargins )
}
}
-void wxPageSetupData::ConvertFromNative(void)
+void wxPageSetupData::ConvertFromNative()
{
PAGESETUPDLG *pd = (PAGESETUPDLG *) m_pageSetupData ;
if ( !pd )
}
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
pc++;
}
}
-
-
wxString wxFileConfig::GetLocalDir()
{
wxString strDir;
-
+
wxGetHomeDir(&strDir);
-
+
#ifdef __UNIX__
if (strDir.Last() != '/') strDir << '/';
#else
if ( strchr(szFile, '.') == NULL )
str << ".ini";
#endif
-
+
return str;
}
// last entry?
if ( pNext == NULL )
m_linesTail = pPrev;
- else
+ else
pNext->SetPrev(pPrev);
delete pLine;
{
if(str.IsEmpty())
return str;
-
+
wxString strResult;
strResult.Alloc(str.Len());
// Created: 01/02/97
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
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;
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;
}
// 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},
{"LIGHT MAGENTA", 255, 0, 255},
{"MEDIUM GREY", 100, 100, 100},
#endif
-
+
{0,0,0,0}
};
int i;
wxNode *node = Find(str);
if (node)
return (wxColour *)node->Data();
-
+
#ifdef __WXMSW__
else return NULL;
#endif
#ifdef __WXGTK__
else {
wxColour *col = new wxColour( colour );
-
+
if (!(col->Ok())) {
delete col;
return (wxColour *) NULL;
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
}
wxCROSS_CURSOR = new wxCursor (wxCURSOR_CROSS);
}
-void
-wxDeleteStockObjects ()
+void wxDeleteStockObjects ()
{
wxDELETE(wxNORMAL_FONT);
wxDELETE(wxSMALL_FONT);
{
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);
{
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
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;
}
}
}
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);
}
void wxBitmapList::AddBitmap(wxBitmap *bitmap)
-{ Append(bitmap); }
+{
+ Append(bitmap);
+}
+
void wxBitmapList::RemoveBitmap(wxBitmap *bitmap)
-{ DeleteObject(bitmap); }
+{
+ DeleteObject(bitmap);
+}
wxSize wxGetDisplaySize()
{
return wxSize(x, y);
}
-wxResourceCache::~wxResourceCache () {
+wxResourceCache::~wxResourceCache ()
+{
wxNode *node = First ();
while (node) {
wxGDIObject *item = (wxGDIObject *)node->Data();
/*
* Resource table
*/
-
+
wxResourceTable::wxResourceTable():wxHashTable(wxKEY_STRING), identifiers(wxKEY_STRING)
{
}
{
ClearTable();
}
-
+
wxItemResource *wxResourceTable::FindResource(const wxString& name) const
{
wxItemResource *item = (wxItemResource *)Get((char *)(const char *)name);
break;
}
}
-
+
delete item;
return TRUE;
}
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;
dialogItem->SetName(name);
dialogItem->SetTitle(title);
dialogItem->SetSize(x, y, width, height);
-
+
if (backColourHex != "")
{
int r = 0;
controlItem->SetValue4(str);
count ++;
-
+
wxExpr *valueList = (wxExpr *) NULL;
// Check for default value list
if ((valueList = expr->Nth(count)) && (valueList->Type() == PrologList))
return controlItem;
}
-// Forward declaration
+// Forward declaration
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);
wxExpr *subMenuExpr = expr->GetFirst();
while (subMenuExpr && (subMenuExpr->Type() != PrologList))
subMenuExpr = subMenuExpr->GetNext();
-
+
while (subMenuExpr)
{
wxItemResource *child = wxResourceInterpretMenuItem(table, subMenuExpr);
expr->GetAttributeValue("menu", &listExpr);
if (!listExpr)
return (wxItemResource *) NULL;
-
+
wxItemResource *menuResource = wxResourceInterpretMenuItem(table, listExpr);
if (!menuResource)
{
menuResource->SetName(name);
}
-
+
return menuResource;
}
wxItemResource *resource = new wxItemResource;
resource->SetType("wxMenu");
// resource->SetType(wxTYPE_MENU);
-
+
wxExpr *element = listExpr->GetFirst();
while (element)
{
{
resource->SetName(name);
}
-
+
return resource;
}
}
else
bitmapSpec->SetValue1(0);
-
+
if (platformExpr && platformExpr->StringValue())
{
wxString plat(platformExpr->StringValue());
if (yresExpr)
yres = (int)yresExpr->IntegerValue();
bitmapSpec->SetSize(0, 0, xres, yres);
-
+
bitmapItem->GetChildren().Append(bitmapSpec);
}
}
}
bitmapExpr = bitmapExpr->GetNext();
}
-
+
return bitmapItem;
}
int weight = wxNORMAL;
int underline = 0;
wxString faceName("");
-
+
wxExpr *pointExpr = expr->Nth(0);
wxExpr *familyExpr = expr->Nth(1);
wxExpr *styleExpr = expr->Nth(2);
wxReallocateResourceBuffer();
wxResourceBuffer[wxResourceBufferCount] = (char)ch;
wxResourceBufferCount ++;
-
+
ch = getc(fd);
}
wxResourceBuffer[wxResourceBufferCount] = 0;
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))
{
}
delete[] name;
delete[] value;
-
+
return TRUE;
}
else if (strcmp(wxResourceBuffer, "#include") == 0)
wxLogWarning(_("Expected 'char' whilst parsing resource."));
return FALSE;
}
-
+
// *name
if (!wxGetResourceToken(fd))
{
}
char nameBuf[100];
strncpy(nameBuf, wxResourceBuffer+1, 99);
-
+
// =
if (!wxGetResourceToken(fd))
{
/*
* Parses string window style into integer window style
*/
-
+
/*
* Style flag parsing, e.g.
* "wxSYSTEM_MENU | wxBORDER" -> integer
{ "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 },
{ "wxALIGN_CENTRE", wxALIGN_CENTRE},
{ "wxALIGN_RIGHT", wxALIGN_RIGHT},
{ "wxCOLOURED", wxCOLOURED},
-
+
/* wxToolBar */
{ "wxTB_3DBUTTONS", wxTB_3DBUTTONS},
{ "wxTB_HORIZONTAL", wxTB_HORIZONTAL},
* 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)
{
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)
{
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
{
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
* 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)
{
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)
{
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
{
if (!table)
table = wxDefaultResourceTable;
-
+
wxItemResource *menuResource = table->FindResource(resource);
if (menuResource && (menuResource->GetType() != "") && (menuResource->GetType() == "wxMenu"))
{
{
if (!table)
table = wxDefaultResourceTable;
-
+
wxItemResource *menuResource = table->FindResource(resource);
if (menuResource && (menuResource->GetType() != "") && (menuResource->GetType() == "wxMenu"))
// if (menuResource && (menuResource->GetType() == wxTYPE_MENU))
{
if (!table)
table = wxDefaultResourceTable;
-
+
return table->ParseResourceData(resource);
}
{
if (!table)
table = wxDefaultResourceTable;
-
+
return table->ParseResourceFile(filename);
}
{
if (!table)
table = wxDefaultResourceTable;
-
+
return table->RegisterResourceBitmapData(name, bits, width, height);
}
{
if (!table)
table = wxDefaultResourceTable;
-
+
table->identifiers.Put(name, (wxObject *)value);
return TRUE;
}
{
if (!table)
table = wxDefaultResourceTable;
-
+
return (int)table->identifiers.Get(name);
}
{
if (!table)
table = wxDefaultResourceTable;
-
+
FILE *fd = fopen(f, "r");
if (!fd)
{
int ch = getc_string(s);
if (ch == EOF)
return TRUE;
-
+
if ((ch != ' ') && (ch != '/') && (ch != ' ') && (ch != 10) && (ch != 13) && (ch != 9))
{
ungetc_string();
wxReallocateResourceBuffer();
wxResourceBuffer[wxResourceBufferCount] = (char)ch;
wxResourceBufferCount ++;
-
+
ch = getc_string(s);
}
wxResourceBuffer[wxResourceBufferCount] = 0;
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))
{
}
delete[] name;
delete[] value;
-
+
return TRUE;
}
/*
wxLogWarning(_("Expected 'char' whilst parsing resource."));
return FALSE;
}
-
+
// *name
if (!wxGetResourceTokenString(s))
{
}
char nameBuf[100];
strncpy(nameBuf, wxResourceBuffer+1, 99);
-
+
// =
if (!wxGetResourceTokenString(s))
{
{
if (!table)
table = wxDefaultResourceTable;
-
+
if (!s)
return FALSE;
-
- // Turn backslashes into spaces
+
+ // Turn backslashes into spaces
if (s)
{
int len = strlen(s);
{
if (!table)
table = wxDefaultResourceTable;
-
+
wxItemResource *resource = table->FindResource((const char *)resourceName);
// if (!resource || (resource->GetType() != wxTYPE_DIALOG_BOX))
if (!resource || !resource->GetType() ||
while (node)
{
wxItemResource *childResource = (wxItemResource *)node->Data();
-
+
(void) CreateItem(childResource, resource, table);
node = node->Next();
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling, Julian Smart
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
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();
}
{
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 ;
}
// Author: Robert Roebling
// RCS-ID: $Id$
// Copyright: (c) 1998 Robert Roebling
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
IMPLEMENT_DYNAMIC_CLASS(wxMask,wxObject)
-wxMask::wxMask(void)
+wxMask::wxMask()
{
m_bitmap = (GdkBitmap *) NULL;
}
{
}
-wxMask::~wxMask(void)
+wxMask::~wxMask()
{
if (m_bitmap) gdk_bitmap_unref( m_bitmap );
}
{
return m_bitmap;
}
-
+
//-----------------------------------------------------------------------------
// wxBitmap
//-----------------------------------------------------------------------------
public:
wxBitmapRefData(void);
~wxBitmapRefData(void);
-
+
GdkPixmap *m_pixmap;
GdkBitmap *m_bitmap;
wxMask *m_mask;
wxPalette *m_palette;
};
-wxBitmapRefData::wxBitmapRefData(void)
+wxBitmapRefData::wxBitmapRefData()
{
m_pixmap = (GdkPixmap *) NULL;
m_bitmap = (GdkBitmap *) NULL;
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 );
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);
}
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" );
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)
{
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;
}
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
//-----------------------------------------------------------------------------
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();
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++)
{
index++;
int b = data[index];
index++;
-
+
if (HasMask())
{
if ((r == r_mask) && (b == b_mask) && (g == g_mask))
else
gdk_image_put_pixel( mask_image, x, y, 0 );
}
-
+
switch (bpp)
{
case 8:
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:
}
} // 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++)
{
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 );
data[pos+2] = 16;
}
}
-
+
pos += 3;
}
}
-
+
gdk_image_destroy( gdk_image );
if (gdk_image_mask) gdk_image_destroy( gdk_image_mask );
}
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;
}
IMPLEMENT_DYNAMIC_CLASS(wxBrush,wxGDIObject)
-wxBrush::wxBrush(void)
+wxBrush::wxBrush()
{
if (wxTheBrushList) wxTheBrushList->AddBrush( this );
}
m_refData = new wxBrushRefData();
M_BRUSHDATA->m_style = style;
M_BRUSHDATA->m_colour = colour;
-
+
if (wxTheBrushList) wxTheBrushList->AddBrush( this );
}
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)
{
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;
}
M_BRUSHDATA->m_stipple = stipple;
}
-void wxBrush::Unshare(void)
+void wxBrush::Unshare()
{
if (!m_refData)
{
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
class wxColourRefData: public wxObjectRefData
{
public:
-
+
wxColourRefData();
~wxColourRefData();
void FreeColour();
-
+
GdkColor m_color;
GdkColormap *m_colormap;
bool m_hasPixel;
-
+
friend wxColour;
};
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 ))
}
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 )
wxFAIL_MSG( "invalid colour" );
return 0;
}
-
+
return (unsigned char)(M_COLDATA->m_color.red >> SHIFT);
}
wxFAIL_MSG( "invalid colour" );
return 0;
}
-
+
return (unsigned char)(M_COLDATA->m_color.green >> SHIFT);
}
wxFAIL_MSG( "invalid colour" );
return 0;
}
-
+
return (unsigned char)(M_COLDATA->m_color.blue >> SHIFT);
}
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))
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;
}
{
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;
}
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
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 );
}
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)
{
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,
wxCURSOR_BASED_ARROW_UP,
wxCURSOR_BASED_ARROW_DOWN
*/
-
+
}
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;
}
bool g_isBusy = FALSE;
-void wxEndBusyCursor(void)
+void wxEndBusyCursor()
{
g_isBusy = FALSE;
}
g_isBusy = TRUE;
}
-bool wxIsBusy(void)
+bool wxIsBusy()
{
return g_isBusy;
}
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
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 );
}
//-----------------------------------------------------------------------------
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;
}
//-----------------------------------------------------------------------------
// 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;
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
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;
}
"AfmTimes", "Times",
"AfmHelvetica", "Helv",
"AfmCourier", "Cour",
-
+
"Afm___", "${AfmTimes,$[weight],$[style]}",
"AfmTimes__", "${AfmTimes}${Afm$[weight]}${Afm$[style]}",
"PostScriptBoldStraight", "-Bold",
"PostScriptBoldItalic", "-BoldOblique",
"PostScriptBoldSlant", "-BoldOblique",
-
+
#if WX_NORMALIZED_PS_FONTS
"PostScript___", "${PostScriptTimes,$[weight],$[style]}",
#else
"ScreenScriptBase", "*-zapfchancery",
"ScreenStdSuffix", "-${Screen$[weight]}-${Screen$[style]}"
- "-normal-*-*-%d-*-*-*-*-*-*",
+ "-normal-*-*-%d-*-*-*-*-*-*",
"Screen___",
"-${ScreenDefaultBase}${ScreenStdSuffix}",
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;
}
};
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];
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)
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;
+ }
}
}
//-----------------------------------------------------------------------------
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)
afm. Initialize(name, "Afm");
}
-wxFontNameItem::~wxFontNameItem(void)
+wxFontNameItem::~wxFontNameItem()
{
if (name)
- delete[] name;
+ delete[] name;
name = (char *) NULL;
}
IMPLEMENT_DYNAMIC_CLASS(wxFontNameDirectory, wxObject)
-wxFontNameDirectory::wxFontNameDirectory(void)
+wxFontNameDirectory::wxFontNameDirectory()
{
table = new wxHashTable(wxKEY_INTEGER, 20);
nextFontId = -1;
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--);
}
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));
}
{
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;
}
{
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;
}
{
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;
}
{
wxFontNameItem *item = (wxFontNameItem *)table->Get(fontid); // find font
if (item)
- return item->GetName();
+ return item->GetName();
// font does not exist
return (char *) NULL;
}
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;
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;
}
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;
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;
}
long style, const wxString &name )
{
wxTopLevelWindows.Append( this );
-
+
m_needParent = FALSE;
PreCreation( parent, id, pos, size, style, name );
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))
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;
}
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 );
}
bool wxFrame::Destroy()
{
wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
-
+
if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this);
return TRUE;
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;
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;
{
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;
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 );
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)
{
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;
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 );
}
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;
}
{
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())
#endif
)
{
- // it's the second one: do nothing
+ // it's the second one: do nothing
if (child) return;
child = win;
}
{
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();
SetInvokingWindow( menu, this );
node = node->Next();
}
-
+
if (m_frameMenuBar->m_parent != this)
{
m_frameMenuBar->m_parent = this;
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;
}
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;
}
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 );
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);
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;
}
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 );
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 );
}
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;
}
m_menus.DeleteContents( TRUE );
m_menubar = gtk_menu_bar_new();
-
+
m_widget = GTK_WIDGET(m_menubar);
PostCreation();
wxCommandEvent event( wxEVT_COMMAND_MENU_SELECTED, id );
event.SetEventObject( menu );
event.SetInt(id );
-
+
if (menu->m_callback)
{
(void) (*(menu->m_callback)) (*menu, event);
wxCommandEvent event( wxEVT_MENU_HIGHLIGHT, id );
event.SetEventObject( menu );
event.SetInt(id );
-
+
/* wxMSW doesn't call callback here either
if (menu->m_callback)
{
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 )
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
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 != "")
{
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",
// Not finding anything here can be correct
// when search the entire menu system for
// an entry -> no error message.
-
+
return (wxMenuItem *) NULL;
}
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 );
};
IMPLEMENT_DYNAMIC_CLASS(wxPalette,wxGDIObject)
-wxPalette::wxPalette(void)
+wxPalette::wxPalette()
{
};
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
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
class wxPenRefData: public wxObjectRefData
{
public:
-
+
wxPenRefData(void);
wxPenRefData(const wxPenRefData& data);
-
+
int m_width;
int m_style;
int m_joinStyle;
IMPLEMENT_DYNAMIC_CLASS(wxPen,wxGDIObject)
-wxPen::wxPen(void)
+wxPen::wxPen()
{
if (wxThePenList) wxThePenList->AddPen( this );
}
M_PENDATA->m_width = width;
M_PENDATA->m_style = style;
M_PENDATA->m_colour = colour;
-
+
if (wxThePenList) wxThePenList->AddPen( this );
}
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 );
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 )
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;
}
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;
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,
0, 0);
gtk_widget_show( vscrollbar );
}
- else
+ else
{
// a single-line text control: no need for scrollbars
m_widget =
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);
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 );
}
wxString wxTextCtrl::GetValue() const
{
wxCHECK_MSG( m_text != NULL, "", "invalid text ctrl" );
-
+
wxString tmp;
if (m_windowStyle & wxTE_MULTILINE)
{
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)
void wxTextCtrl::WriteText( const wxString &text )
{
wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
-
+
if (text.IsNull()) return;
if (m_windowStyle & wxTE_MULTILINE)
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")))
{
fclose (fp);
text[len] = 0;
-
+
if (m_windowStyle & wxTE_MULTILINE)
{
gtk_editable_insert_text( GTK_EDITABLE(m_text), text, 0, &len );
{
gtk_entry_set_text( GTK_ENTRY(m_text), text );
}
-
+
free (text);
m_modified = FALSE;
return TRUE;
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")))
{
char *text = NULL;
gint len = 0;
-
+
if (m_windowStyle & wxTE_MULTILINE)
{
len = gtk_text_get_length( GTK_TEXT(m_text) );
{
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;
}
int j;
for (j = 0; text[i] && text[i] != '\n'; i++, j++ )
buf += text[i];
-
+
g_free( text );
return buf;
}
return 0;
if( pos >= len)
return pos=len-1;
-
+
*x=1; // Col 1
*y=1; // Line 1
for (int i = 0; i < pos; i++ )
}
else
(*x)++;
- }
+ }
g_free( text );
return 1;
}
if (!(m_windowStyle & wxTE_MULTILINE))
return 0;
long pos=0;
-
+
for(int i=1;i<y;i++)
pos +=GetLineLength(i);
pos +=x-1; // Pos start with 0
for (int i = 0; i < len; i++ )
if (text[i] == '\n')
currentLine++;
-
+
g_free( text );
return currentLine;
}
void wxTextCtrl::SetInsertionPoint( long pos )
{
wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
-
+
int tmp = (int) pos;
if (m_windowStyle & wxTE_MULTILINE)
gtk_text_set_point( GTK_TEXT(m_text), tmp );
void wxTextCtrl::SetInsertionPointEnd()
{
wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
-
+
int pos = 0;
if (m_windowStyle & wxTE_MULTILINE)
pos = gtk_text_get_length( GTK_TEXT(m_text) );
void wxTextCtrl::SetEditable( bool editable )
{
wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
-
+
if (m_windowStyle & wxTE_MULTILINE)
gtk_text_set_editable( GTK_TEXT(m_text), editable );
else
void wxTextCtrl::SetSelection( long from, long to )
{
wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
-
+
gtk_editable_select_region( GTK_EDITABLE(m_text), (gint)from, (gint)to );
}
long wxTextCtrl::GetInsertionPoint() const
{
wxCHECK_MSG( m_text != NULL, 0, "invalid text ctrl" );
-
+
return (long) GTK_EDITABLE(m_text)->current_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) );
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;
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
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
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
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 );
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
}
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;
return dest;
}
-static void wxXMergeDatabases(void)
+static void wxXMergeDatabases()
{
XrmDatabase homeDB, serverDB, applicationDB;
char filenamebuf[1024];
// called on application exit
//-----------------------------------------------------------------------------
-void wxFlushResources(void)
+void wxFlushResources()
{
char nameBuffer[512];
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
if (g_blockEventsOnDrag) return TRUE;
if (g_blockEventsOnScroll) return TRUE;
-
+
if (!win->HasVMT()) return TRUE;
/*
float line_step = win->m_hAdjust->step_increment;
float page_step = win->m_hAdjust->page_increment;
-
+
if (win->m_isScrolling)
{
command = wxEVT_SCROLL_THUMBTRACK;
// "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;
// "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 )
{
//-----------------------------------------------------------------------------
// 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),
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 );
}
m_wxwindow = (GtkWidget *) NULL;
m_parent = (wxWindow *) NULL;
m_children.DeleteContents( FALSE );
-
+
m_x = 0;
m_y = 0;
m_width = 0;
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;
}
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 )
// 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 );
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
(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;
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();
wxTopLevelWindows.DeleteObject(this);
if (m_windowValidator) delete m_windowValidator;
-
+
if (m_clientObject) delete m_clientObject;
}
{
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)
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;
}
if (((sizeFlags & wxSIZE_NO_ADJUSTMENTS) == 0) && GetParent())
{
wxPoint pt(GetParent()->GetClientAreaOrigin());
- x += pt.x;
+ x += pt.x;
y += pt.y;
}
}
{
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;
{
int old_width = m_width;
int old_height = m_height;
-
+
if ((sizeFlags & wxSIZE_USE_EXISTING) == wxSIZE_USE_EXISTING)
{
if (x != -1) m_x = x;
{
if (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;
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() );
#ifdef NEW_GTK_SCROLL_CODE
GtkWidget *viewport = scroll_window->child;
-#else
+#else
GtkWidget *viewport = scroll_window->viewport;
#endif
#ifdef NEW_GTK_SCROLL_CODE
GtkWidget *viewport = scroll_window->child;
-#else
+#else
GtkWidget *viewport = scroll_window->viewport;
#endif
wxPoint pt(GetClientAreaOrigin());
org_x += pt.x;
org_y += pt.y;
-
+
if (x) *x += org_x;
if (y) *y += org_y;
}
wxPoint pt(GetClientAreaOrigin());
org_x -= pt.x;
org_y -= pt.y;
-
+
if (x) *x -= org_x;
if (y) *y -= org_y;
}
int x = m_x;
int y = m_y;
-
+
if (m_parent)
{
int p_w = 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 );
}
int maxX = 0;
int maxY = 0;
- wxNode *node = m_childrenFirst();
+ wxNode *node = m_children.First();
while ( node )
{
wxWindow *win = (wxWindow *)node->Data();
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;
}
if (m_widget) gdk_window_lower( m_widget->window );
}
-wxEvtHandler *wxWindow::GetEventHandler()
+wxEvtHandler *wxWindow::GetEventHandler() const
{
return m_eventHandler;
}
m_windowId = id;
}
-wxWindowID wxWindow::GetId()
+wxWindowID wxWindow::GetId() const
{
return m_windowId;
}
if (cursor.Ok())
{
- if (*((wxCursor*)&cursor) == m_cursor) return;
+ if ( cursor == *m_cursor )
+ return;
*m_cursor = cursor;
}
else
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;
gdk_window_set_background( window, m_backgroundColour.GetColor() );
gdk_window_clear( window );
}
-
+
ApplyWidgetStyle();
}
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 ) );
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 ) );
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),
m_font = font;
else
m_font = *wxSWISS_FONT;
-
- ApplyWidgetStyle();
-}
-wxFont *wxWindow::GetFont()
-{
- return &m_font;
+ ApplyWidgetStyle();
}
void wxWindow::SetWindowStyleFlag( long flag )
wxASSERT_MSG( (m_wxwindow != NULL), "window needs client area" );
if (!m_wxwindow) return;
-
+
m_hasScrolling = TRUE;
if (orient == wxHORIZONTAL)
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 );
{
noChanges = 0;
noFailures = 0;
- wxNode *node = m_children.first();
+ wxNode *node = m_children.First();
while (node)
{
wxWindow *child = (wxWindow *)node->Data();
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling, Julian Smart
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
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();
}
{
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 ;
}
// Author: Robert Roebling
// RCS-ID: $Id$
// Copyright: (c) 1998 Robert Roebling
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
IMPLEMENT_DYNAMIC_CLASS(wxMask,wxObject)
-wxMask::wxMask(void)
+wxMask::wxMask()
{
m_bitmap = (GdkBitmap *) NULL;
}
{
}
-wxMask::~wxMask(void)
+wxMask::~wxMask()
{
if (m_bitmap) gdk_bitmap_unref( m_bitmap );
}
{
return m_bitmap;
}
-
+
//-----------------------------------------------------------------------------
// wxBitmap
//-----------------------------------------------------------------------------
public:
wxBitmapRefData(void);
~wxBitmapRefData(void);
-
+
GdkPixmap *m_pixmap;
GdkBitmap *m_bitmap;
wxMask *m_mask;
wxPalette *m_palette;
};
-wxBitmapRefData::wxBitmapRefData(void)
+wxBitmapRefData::wxBitmapRefData()
{
m_pixmap = (GdkPixmap *) NULL;
m_bitmap = (GdkBitmap *) NULL;
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 );
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);
}
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" );
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)
{
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;
}
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
//-----------------------------------------------------------------------------
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();
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++)
{
index++;
int b = data[index];
index++;
-
+
if (HasMask())
{
if ((r == r_mask) && (b == b_mask) && (g == g_mask))
else
gdk_image_put_pixel( mask_image, x, y, 0 );
}
-
+
switch (bpp)
{
case 8:
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:
}
} // 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++)
{
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 );
data[pos+2] = 16;
}
}
-
+
pos += 3;
}
}
-
+
gdk_image_destroy( gdk_image );
if (gdk_image_mask) gdk_image_destroy( gdk_image_mask );
}
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;
}
IMPLEMENT_DYNAMIC_CLASS(wxBrush,wxGDIObject)
-wxBrush::wxBrush(void)
+wxBrush::wxBrush()
{
if (wxTheBrushList) wxTheBrushList->AddBrush( this );
}
m_refData = new wxBrushRefData();
M_BRUSHDATA->m_style = style;
M_BRUSHDATA->m_colour = colour;
-
+
if (wxTheBrushList) wxTheBrushList->AddBrush( this );
}
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)
{
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;
}
M_BRUSHDATA->m_stipple = stipple;
}
-void wxBrush::Unshare(void)
+void wxBrush::Unshare()
{
if (!m_refData)
{
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
class wxColourRefData: public wxObjectRefData
{
public:
-
+
wxColourRefData();
~wxColourRefData();
void FreeColour();
-
+
GdkColor m_color;
GdkColormap *m_colormap;
bool m_hasPixel;
-
+
friend wxColour;
};
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 ))
}
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 )
wxFAIL_MSG( "invalid colour" );
return 0;
}
-
+
return (unsigned char)(M_COLDATA->m_color.red >> SHIFT);
}
wxFAIL_MSG( "invalid colour" );
return 0;
}
-
+
return (unsigned char)(M_COLDATA->m_color.green >> SHIFT);
}
wxFAIL_MSG( "invalid colour" );
return 0;
}
-
+
return (unsigned char)(M_COLDATA->m_color.blue >> SHIFT);
}
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))
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;
}
{
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;
}
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
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 );
}
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)
{
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,
wxCURSOR_BASED_ARROW_UP,
wxCURSOR_BASED_ARROW_DOWN
*/
-
+
}
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;
}
bool g_isBusy = FALSE;
-void wxEndBusyCursor(void)
+void wxEndBusyCursor()
{
g_isBusy = FALSE;
}
g_isBusy = TRUE;
}
-bool wxIsBusy(void)
+bool wxIsBusy()
{
return g_isBusy;
}
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
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 );
}
//-----------------------------------------------------------------------------
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;
}
//-----------------------------------------------------------------------------
// 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;
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
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;
}
"AfmTimes", "Times",
"AfmHelvetica", "Helv",
"AfmCourier", "Cour",
-
+
"Afm___", "${AfmTimes,$[weight],$[style]}",
"AfmTimes__", "${AfmTimes}${Afm$[weight]}${Afm$[style]}",
"PostScriptBoldStraight", "-Bold",
"PostScriptBoldItalic", "-BoldOblique",
"PostScriptBoldSlant", "-BoldOblique",
-
+
#if WX_NORMALIZED_PS_FONTS
"PostScript___", "${PostScriptTimes,$[weight],$[style]}",
#else
"ScreenScriptBase", "*-zapfchancery",
"ScreenStdSuffix", "-${Screen$[weight]}-${Screen$[style]}"
- "-normal-*-*-%d-*-*-*-*-*-*",
+ "-normal-*-*-%d-*-*-*-*-*-*",
"Screen___",
"-${ScreenDefaultBase}${ScreenStdSuffix}",
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;
}
};
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];
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)
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;
+ }
}
}
//-----------------------------------------------------------------------------
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)
afm. Initialize(name, "Afm");
}
-wxFontNameItem::~wxFontNameItem(void)
+wxFontNameItem::~wxFontNameItem()
{
if (name)
- delete[] name;
+ delete[] name;
name = (char *) NULL;
}
IMPLEMENT_DYNAMIC_CLASS(wxFontNameDirectory, wxObject)
-wxFontNameDirectory::wxFontNameDirectory(void)
+wxFontNameDirectory::wxFontNameDirectory()
{
table = new wxHashTable(wxKEY_INTEGER, 20);
nextFontId = -1;
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--);
}
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));
}
{
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;
}
{
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;
}
{
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;
}
{
wxFontNameItem *item = (wxFontNameItem *)table->Get(fontid); // find font
if (item)
- return item->GetName();
+ return item->GetName();
// font does not exist
return (char *) NULL;
}
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;
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;
}
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;
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;
}
long style, const wxString &name )
{
wxTopLevelWindows.Append( this );
-
+
m_needParent = FALSE;
PreCreation( parent, id, pos, size, style, name );
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))
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;
}
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 );
}
bool wxFrame::Destroy()
{
wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
-
+
if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this);
return TRUE;
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;
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;
{
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;
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 );
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)
{
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;
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 );
}
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;
}
{
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())
#endif
)
{
- // it's the second one: do nothing
+ // it's the second one: do nothing
if (child) return;
child = win;
}
{
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();
SetInvokingWindow( menu, this );
node = node->Next();
}
-
+
if (m_frameMenuBar->m_parent != this)
{
m_frameMenuBar->m_parent = this;
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;
}
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;
}
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 );
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);
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;
}
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 );
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 );
}
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;
}
m_menus.DeleteContents( TRUE );
m_menubar = gtk_menu_bar_new();
-
+
m_widget = GTK_WIDGET(m_menubar);
PostCreation();
wxCommandEvent event( wxEVT_COMMAND_MENU_SELECTED, id );
event.SetEventObject( menu );
event.SetInt(id );
-
+
if (menu->m_callback)
{
(void) (*(menu->m_callback)) (*menu, event);
wxCommandEvent event( wxEVT_MENU_HIGHLIGHT, id );
event.SetEventObject( menu );
event.SetInt(id );
-
+
/* wxMSW doesn't call callback here either
if (menu->m_callback)
{
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 )
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
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 != "")
{
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",
// Not finding anything here can be correct
// when search the entire menu system for
// an entry -> no error message.
-
+
return (wxMenuItem *) NULL;
}
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 );
};
IMPLEMENT_DYNAMIC_CLASS(wxPalette,wxGDIObject)
-wxPalette::wxPalette(void)
+wxPalette::wxPalette()
{
};
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
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
class wxPenRefData: public wxObjectRefData
{
public:
-
+
wxPenRefData(void);
wxPenRefData(const wxPenRefData& data);
-
+
int m_width;
int m_style;
int m_joinStyle;
IMPLEMENT_DYNAMIC_CLASS(wxPen,wxGDIObject)
-wxPen::wxPen(void)
+wxPen::wxPen()
{
if (wxThePenList) wxThePenList->AddPen( this );
}
M_PENDATA->m_width = width;
M_PENDATA->m_style = style;
M_PENDATA->m_colour = colour;
-
+
if (wxThePenList) wxThePenList->AddPen( this );
}
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 );
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 )
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;
}
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;
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,
0, 0);
gtk_widget_show( vscrollbar );
}
- else
+ else
{
// a single-line text control: no need for scrollbars
m_widget =
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);
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 );
}
wxString wxTextCtrl::GetValue() const
{
wxCHECK_MSG( m_text != NULL, "", "invalid text ctrl" );
-
+
wxString tmp;
if (m_windowStyle & wxTE_MULTILINE)
{
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)
void wxTextCtrl::WriteText( const wxString &text )
{
wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
-
+
if (text.IsNull()) return;
if (m_windowStyle & wxTE_MULTILINE)
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")))
{
fclose (fp);
text[len] = 0;
-
+
if (m_windowStyle & wxTE_MULTILINE)
{
gtk_editable_insert_text( GTK_EDITABLE(m_text), text, 0, &len );
{
gtk_entry_set_text( GTK_ENTRY(m_text), text );
}
-
+
free (text);
m_modified = FALSE;
return TRUE;
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")))
{
char *text = NULL;
gint len = 0;
-
+
if (m_windowStyle & wxTE_MULTILINE)
{
len = gtk_text_get_length( GTK_TEXT(m_text) );
{
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;
}
int j;
for (j = 0; text[i] && text[i] != '\n'; i++, j++ )
buf += text[i];
-
+
g_free( text );
return buf;
}
return 0;
if( pos >= len)
return pos=len-1;
-
+
*x=1; // Col 1
*y=1; // Line 1
for (int i = 0; i < pos; i++ )
}
else
(*x)++;
- }
+ }
g_free( text );
return 1;
}
if (!(m_windowStyle & wxTE_MULTILINE))
return 0;
long pos=0;
-
+
for(int i=1;i<y;i++)
pos +=GetLineLength(i);
pos +=x-1; // Pos start with 0
for (int i = 0; i < len; i++ )
if (text[i] == '\n')
currentLine++;
-
+
g_free( text );
return currentLine;
}
void wxTextCtrl::SetInsertionPoint( long pos )
{
wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
-
+
int tmp = (int) pos;
if (m_windowStyle & wxTE_MULTILINE)
gtk_text_set_point( GTK_TEXT(m_text), tmp );
void wxTextCtrl::SetInsertionPointEnd()
{
wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
-
+
int pos = 0;
if (m_windowStyle & wxTE_MULTILINE)
pos = gtk_text_get_length( GTK_TEXT(m_text) );
void wxTextCtrl::SetEditable( bool editable )
{
wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
-
+
if (m_windowStyle & wxTE_MULTILINE)
gtk_text_set_editable( GTK_TEXT(m_text), editable );
else
void wxTextCtrl::SetSelection( long from, long to )
{
wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
-
+
gtk_editable_select_region( GTK_EDITABLE(m_text), (gint)from, (gint)to );
}
long wxTextCtrl::GetInsertionPoint() const
{
wxCHECK_MSG( m_text != NULL, 0, "invalid text ctrl" );
-
+
return (long) GTK_EDITABLE(m_text)->current_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) );
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;
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
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
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
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 );
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
}
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;
return dest;
}
-static void wxXMergeDatabases(void)
+static void wxXMergeDatabases()
{
XrmDatabase homeDB, serverDB, applicationDB;
char filenamebuf[1024];
// called on application exit
//-----------------------------------------------------------------------------
-void wxFlushResources(void)
+void wxFlushResources()
{
char nameBuffer[512];
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
if (g_blockEventsOnDrag) return TRUE;
if (g_blockEventsOnScroll) return TRUE;
-
+
if (!win->HasVMT()) return TRUE;
/*
float line_step = win->m_hAdjust->step_increment;
float page_step = win->m_hAdjust->page_increment;
-
+
if (win->m_isScrolling)
{
command = wxEVT_SCROLL_THUMBTRACK;
// "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;
// "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 )
{
//-----------------------------------------------------------------------------
// 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),
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 );
}
m_wxwindow = (GtkWidget *) NULL;
m_parent = (wxWindow *) NULL;
m_children.DeleteContents( FALSE );
-
+
m_x = 0;
m_y = 0;
m_width = 0;
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;
}
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 )
// 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 );
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
(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;
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();
wxTopLevelWindows.DeleteObject(this);
if (m_windowValidator) delete m_windowValidator;
-
+
if (m_clientObject) delete m_clientObject;
}
{
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)
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;
}
if (((sizeFlags & wxSIZE_NO_ADJUSTMENTS) == 0) && GetParent())
{
wxPoint pt(GetParent()->GetClientAreaOrigin());
- x += pt.x;
+ x += pt.x;
y += pt.y;
}
}
{
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;
{
int old_width = m_width;
int old_height = m_height;
-
+
if ((sizeFlags & wxSIZE_USE_EXISTING) == wxSIZE_USE_EXISTING)
{
if (x != -1) m_x = x;
{
if (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;
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() );
#ifdef NEW_GTK_SCROLL_CODE
GtkWidget *viewport = scroll_window->child;
-#else
+#else
GtkWidget *viewport = scroll_window->viewport;
#endif
#ifdef NEW_GTK_SCROLL_CODE
GtkWidget *viewport = scroll_window->child;
-#else
+#else
GtkWidget *viewport = scroll_window->viewport;
#endif
wxPoint pt(GetClientAreaOrigin());
org_x += pt.x;
org_y += pt.y;
-
+
if (x) *x += org_x;
if (y) *y += org_y;
}
wxPoint pt(GetClientAreaOrigin());
org_x -= pt.x;
org_y -= pt.y;
-
+
if (x) *x -= org_x;
if (y) *y -= org_y;
}
int x = m_x;
int y = m_y;
-
+
if (m_parent)
{
int p_w = 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 );
}
int maxX = 0;
int maxY = 0;
- wxNode *node = m_childrenFirst();
+ wxNode *node = m_children.First();
while ( node )
{
wxWindow *win = (wxWindow *)node->Data();
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;
}
if (m_widget) gdk_window_lower( m_widget->window );
}
-wxEvtHandler *wxWindow::GetEventHandler()
+wxEvtHandler *wxWindow::GetEventHandler() const
{
return m_eventHandler;
}
m_windowId = id;
}
-wxWindowID wxWindow::GetId()
+wxWindowID wxWindow::GetId() const
{
return m_windowId;
}
if (cursor.Ok())
{
- if (*((wxCursor*)&cursor) == m_cursor) return;
+ if ( cursor == *m_cursor )
+ return;
*m_cursor = cursor;
}
else
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;
gdk_window_set_background( window, m_backgroundColour.GetColor() );
gdk_window_clear( window );
}
-
+
ApplyWidgetStyle();
}
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 ) );
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 ) );
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),
m_font = font;
else
m_font = *wxSWISS_FONT;
-
- ApplyWidgetStyle();
-}
-wxFont *wxWindow::GetFont()
-{
- return &m_font;
+ ApplyWidgetStyle();
}
void wxWindow::SetWindowStyleFlag( long flag )
wxASSERT_MSG( (m_wxwindow != NULL), "window needs client area" );
if (!m_wxwindow) return;
-
+
m_hasScrolling = TRUE;
if (orient == wxHORIZONTAL)
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 );
{
noChanges = 0;
noFailures = 0;
- wxNode *node = m_children.first();
+ wxNode *node = m_children.First();
while (node)
{
wxWindow *child = (wxWindow *)node->Data();
########################### Programs #################################
# Replace this with your own path if necessary
-#WXDIR = /home/karl/wxWindows
-WXDIR = /home/jacs/wx2
+WXDIR = $(wx)
# C++ compiler
CC = g++