m_mappingMode = wxMM_TEXT;
- m_backgroundBrush = *wxWHITE_BRUSH;
+ m_backgroundBrush = *wxTRANSPARENT_BRUSH;
m_textForegroundColour = *wxBLACK;
m_textBackgroundColour = *wxWHITE;
virtual void Clear() = 0;
- virtual bool StartDoc(const wxString& message) = 0;
- virtual void EndDoc() = 0;
+ virtual bool StartDoc(const wxString& WXUNUSED(message)) { return TRUE; }
+ virtual void EndDoc() { }
- virtual void StartPage() = 0;
- virtual void EndPage() = 0;
+ virtual void StartPage() { }
+ virtual void EndPage() { }
// set objects to use for drawing
// ------------------------------
#include "wx/dialog.h"
#include "wx/module.h"
#include "wx/cmndata.h"
-#include <fstream.h>
+#include <fstream.h>
//-----------------------------------------------------------------------------
// classes
void SetClippingRegion(long x, long y, long width, long height);
void SetClippingRegion( const wxRegion ®ion );
void DestroyClippingRegion();
-
+
void DoSetClippingRegionAsRegion( const wxRegion &WXUNUSED(clip) ) {}
bool StartDoc(const wxString& message);
inline void SetBackgroundMode(int WXUNUSED(mode)) {}
inline void SetPalette(const wxPalette& WXUNUSED(palette)) {}
- inline ofstream *GetStream(void) const { return m_pstream; }
+ ofstream *GetStream(void) const { return m_pstream; }
- inline wxPrintData& GetPrintData() { return m_printData; }
- inline void SetPrintData(const wxPrintData& data) { m_printData = data; }
-
- int GetDepth() const { return 24; }
+ wxPrintData& GetPrintData() { return m_printData; }
+ void SetPrintData(const wxPrintData& data) { m_printData = data; }
+
+ virtual int GetDepth() const { return 24; }
protected:
#endif
// Print Orientation (Should also add Left, Right)
-enum {
+enum
+{
PS_PORTRAIT = 1,
PS_LANDSCAPE = 2
};// ps_orientation = PS_PORTRAIT;
// Print Actions
-enum {
+enum
+{
PS_NONE,
PS_PREVIEW,
PS_FILE,
// Modified by:
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_NOTEBOOK_H_
typedef wxWindow wxNotebookPage; // so far, any window can be a page
WX_DEFINE_ARRAY(wxNotebookPage *, wxArrayPages);
-// ----------------------------------------------------------------------------
-// notebook events
-// ----------------------------------------------------------------------------
-class WXDLLEXPORT wxNotebookEvent : public wxCommandEvent
-{
-public:
- wxNotebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
- int nSel = -1, int nOldSel = -1)
- : wxCommandEvent(commandType, id) { m_nSel = nSel; m_nOldSel = nOldSel; }
-
- // accessors
- int GetSelection() const { return m_nSel; }
- int GetOldSelection() const { return m_nOldSel; }
-
- void SetSelection(int sel) { m_nSel = sel; }
- void SetOldSelection(int oldSel) { m_nOldSel = oldSel; }
-
-private:
- int m_nSel, // currently selected page
- m_nOldSel; // previously selected page
-
- DECLARE_DYNAMIC_CLASS(wxNotebookEvent)
-};
-
// ----------------------------------------------------------------------------
// wxNotebook
// ----------------------------------------------------------------------------
wxNotebook();
// the same arguments as for wxControl (@@@ any special styles?)
wxNotebook(wxWindow *parent,
- wxWindowID id,
+ wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = "notebook");
// Create() function
bool Create(wxWindow *parent,
- wxWindowID id,
+ wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
void OnSelChange(wxNotebookEvent& event);
void OnSetFocus(wxFocusEvent& event);
void OnNavigationKey(wxNavigationKeyEvent& event);
-
+
// base class virtuals
// -------------------
virtual void Command(wxCommandEvent& event);
virtual void SetConstraintSizes(bool recurse = TRUE);
virtual bool DoPhase(int nPhase);
-// Implementation
+ // Implementation
// wxNotebook on Motif uses a generic wxTabView to implement itself.
- inline wxTabView *GetTabView() const { return m_tabView; }
- inline void SetTabView(wxTabView *v) { m_tabView = v; }
-
+ wxTabView *GetTabView() const { return m_tabView; }
+ void SetTabView(wxTabView *v) { m_tabView = v; }
+
void OnMouseEvent(wxMouseEvent& event);
void OnPaint(wxPaintEvent& event);
DECLARE_EVENT_TABLE()
};
-// ----------------------------------------------------------------------------
-// event macros
-// ----------------------------------------------------------------------------
-typedef void (wxEvtHandler::*wxNotebookEventFunction)(wxNotebookEvent&);
-
-// Because of name truncation!
-#if defined(__BORLANDC__) && defined(__WIN16__)
-
-#define EVT_NOTEBOOK_PAGE_CHANGED(id, fn) \
- { \
- wxEVT_COMMAND_NB_PAGE_CHANGED, \
- id, \
- -1, \
- (wxObjectEventFunction)(wxEventFunction)(wxNotebookEventFunction) &fn, \
- NULL \
- },
-
-#define EVT_NOTEBOOK_PAGE_CHANGING(id, fn) \
- { \
- wxEVT_COMMAND_NB_PAGE_CHANGING, \ \
- id, \
- -1, \
- (wxObjectEventFunction)(wxEventFunction)(wxNotebookEventFunction) &fn, \
- NULL \
- },
-
-#else
-
-#define EVT_NOTEBOOK_PAGE_CHANGED(id, fn) \
- { \
- wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, \
- id, \
- -1, \
- (wxObjectEventFunction)(wxEventFunction)(wxNotebookEventFunction) &fn, \
- NULL \
- },
-
-#define EVT_NOTEBOOK_PAGE_CHANGING(id, fn) \
- { \
- wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, \ \
- id, \
- -1, \
- (wxObjectEventFunction)(wxEventFunction)(wxNotebookEventFunction) &fn, \
- NULL \
- },
-
-#endif
-
#endif // _WX_NOTEBOOK_H_
virtual bool Ok() const { return ((m_refData != NULL) && M_CURSORDATA->m_ok); }
inline wxCursor& operator = (const wxCursor& cursor) { if (*this == cursor) return (*this); Ref(cursor); return *this; }
- inline bool operator == (const wxCursor& cursor) { return m_refData == cursor.m_refData; }
- inline bool operator != (const wxCursor& cursor) { return m_refData != cursor.m_refData; }
+ inline bool operator == (const wxCursor& cursor) const { return m_refData == cursor.m_refData; }
+ inline bool operator != (const wxCursor& cursor) const { return m_refData != cursor.m_refData; }
// Motif-specific.
// Create/get a cursor for the current display
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DC_H_
#define _WX_DC_H_
#ifdef __GNUG__
-#pragma interface "dc.h"
+ #pragma interface "dc.h"
#endif
#include "wx/pen.h"
//-----------------------------------------------------------------------------
#ifndef MM_TEXT
-#define MM_TEXT 0
-#define MM_ISOTROPIC 1
-#define MM_ANISOTROPIC 2
-#define MM_LOMETRIC 3
-#define MM_HIMETRIC 4
-#define MM_TWIPS 5
-#define MM_POINTS 6
-#define MM_METRIC 7
+ #define MM_TEXT 0
+ #define MM_ISOTROPIC 1
+ #define MM_ANISOTROPIC 2
+ #define MM_LOMETRIC 3
+ #define MM_HIMETRIC 4
+ #define MM_TWIPS 5
+ #define MM_POINTS 6
+ #define MM_METRIC 7
#endif
-//-----------------------------------------------------------------------------
-// global variables
-//-----------------------------------------------------------------------------
-
-extern int wxPageNumber;
-
//-----------------------------------------------------------------------------
// wxDC
//-----------------------------------------------------------------------------
-class WXDLLEXPORT wxDC: public wxObject
+class WXDLLEXPORT wxDC : public wxDCBase
{
- DECLARE_ABSTRACT_CLASS(wxDC)
+ DECLARE_DYNAMIC_CLASS(wxDC)
- public:
+public:
+ wxDC();
+ ~wxDC() { }
- wxDC(void);
- ~wxDC(void);
-
- void BeginDrawing(void) {};
- void EndDrawing(void) {};
-
- virtual bool Ok(void) const { return m_ok; };
+ // implement base class pure virtuals
+ // ----------------------------------
- virtual void FloodFill( long x1, long y1, const wxColour& col, int style=wxFLOOD_SURFACE ) = 0;
- inline void FloodFill(const wxPoint& pt, const wxColour& col, int style=wxFLOOD_SURFACE)
- {
- FloodFill(pt.x, pt.y, col, style);
- }
+ virtual void DestroyClippingRegion();
- virtual bool GetPixel( long x1, long y1, wxColour *col ) const = 0;
- inline bool GetPixel(const wxPoint& pt, wxColour *col) const
- {
- return GetPixel(pt.x, pt.y, col);
- }
+ virtual wxSize GetPPI() const;
- virtual void DrawLine( long x1, long y1, long x2, long y2 ) = 0;
- inline void DrawLine(const wxPoint& pt1, const wxPoint& pt2)
- {
- DrawLine(pt1.x, pt1.y, pt2.x, pt2.y);
- }
+ virtual void SetMapMode(int mode);
+ virtual void SetUserScale(double x, double y);
+ virtual void SetSystemScale(double x, double y);
+ virtual void SetLogicalScale(double x, double y);
+ virtual void SetLogicalOrigin(long x, long y);
+ virtual void SetDeviceOrigin(long x, long y);
+ virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
+ virtual void SetLogicalFunction(int function);
- virtual void CrossHair( long x, long y ) = 0;
- inline void CrossHair(const wxPoint& pt)
- {
- CrossHair(pt.x, pt.y);
- }
+protected:
+ virtual void DoDrawIcon(const wxIcon& icon, long x, long y);
+ virtual void DoDrawBitmap(const wxBitmap &bmp, long x, long y,
+ bool useMask = FALSE);
- virtual void DrawArc( long x1, long y1, long x2, long y2, long xc, long yc ) = 0;
- inline void DrawArc(const wxPoint& pt1, const wxPoint& pt2, const wxPoint& centre)
- {
- DrawArc(pt1.x, pt1.y, pt2.x, pt2.y, centre.x, centre.y);
- }
+ virtual void DoSetClippingRegion(long x, long y,
+ long width, long height);
+ virtual void DoGetSize(int *width, int *height) const;
+ virtual void DoGetSizeMM(int* width, int* height) const;
- virtual void DrawEllipticArc( long x, long y, long width, long height, double sa, double ea ) = 0;
- virtual void DrawEllipticArc (const wxPoint& pt, const wxSize& sz, double sa, double ea)
+public:
+ void ComputeScaleAndOrigin();
+
+ long XDEV2LOG(long x) const
{
- DrawEllipticArc(pt.x, pt.y, sz.x, sz.y, sa, ea);
+ 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;
}
-
- virtual void DrawPoint( long x, long y ) = 0;
- 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,
- int fillStyle=wxODDEVEN_RULE ) = 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)
+ long XDEV2LOGREL(long x) const
{
- DrawRectangle(pt.x, pt.y, sz.x, sz.y);
+ if (x > 0)
+ return (long)((double)(x) / m_scaleX + 0.5);
+ else
+ return (long)((double)(x) / m_scaleX - 0.5);
}
- inline void DrawRectangle(const wxRect& rect)
+ long YDEV2LOG(long y) const
{
- DrawRectangle(rect.x, rect.y, rect.width, rect.height);
+ 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;
}
- virtual void DrawRoundedRectangle( long x, long y, long width, long height, double radius = 20.0 ) = 0;
- inline void DrawRoundedRectangle(const wxPoint& pt, const wxSize& sz, double radius = 20.0)
+ long YDEV2LOGREL(long y) const
{
- DrawRoundedRectangle(pt.x, pt.y, sz.x, sz.y, radius);
+ if (y > 0)
+ return (long)((double)(y) / m_scaleY + 0.5);
+ else
+ return (long)((double)(y) / m_scaleY - 0.5);
}
- inline void DrawRoundedRectangle(const wxRect& rect, double radius = 20.0)
+ long XLOG2DEV(long x) const
{
- DrawRoundedRectangle(rect.x, rect.y, rect.width, rect.height, radius);
+ 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;
}
-
- virtual void DrawEllipse( long x, long y, long width, long height ) = 0;
- inline void DrawEllipse(const wxPoint& pt, const wxSize& sz)
+ // Without device translation, for backing pixmap purposes
+ long XLOG2DEV_2(long x) const
{
- DrawEllipse(pt.x, pt.y, sz.x, sz.y);
+ long new_x = x - m_logicalOriginX;
+ if (new_x > 0)
+ return (long)((double)(new_x) * m_scaleX + 0.5) * m_signX;
+ else
+ return (long)((double)(new_x) * m_scaleX - 0.5) * m_signX;
}
- inline void DrawEllipse(const wxRect& rect)
+ long XLOG2DEVREL(long x) const
{
- DrawEllipse(rect.x, rect.y, rect.width, rect.height);
+ if (x > 0)
+ return (long)((double)(x) * m_scaleX + 0.5);
+ else
+ return (long)((double)(x) * m_scaleX - 0.5);
}
-
- 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);
- inline void DrawIcon(const wxIcon& icon, const wxPoint& pt)
+ long YLOG2DEV(long y) const
{
- DrawIcon(icon, pt.x, pt.y);
+ 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;
}
-
- // DrawBitmap is not always the same as DrawIcon, especially if bitmaps and
- // icons are implemented differently.
- virtual void DrawBitmap( const wxBitmap &bmp, long x, long y, bool useMask=FALSE ) ;
-
- 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, const wxSize& sz,
- wxDC *source, const wxPoint& srcPt, int rop = wxCOPY, bool useMask = FALSE)
+ // Without device translation, for backing pixmap purposes
+ long YLOG2DEV_2(long y) const
{
- return Blit(destPt.x, destPt.y, sz.x, sz.y, source, srcPt.x, srcPt.y, rop, useMask);
+ long new_y = y - m_logicalOriginY;
+ if (new_y > 0)
+ return (long)((double)(new_y) * m_scaleY + 0.5) * m_signY;
+ else
+ return (long)((double)(new_y) * m_scaleY - 0.5) * m_signY;
}
-
- virtual void DrawText( const wxString &text, long x, long y, bool use16 = FALSE ) = 0;
- inline void DrawText(const wxString& text, const wxPoint& pt, bool use16bit = FALSE)
+ long YLOG2DEVREL(long y) const
{
- DrawText(text, pt.x, pt.y, use16bit);
+ if (y > 0)
+ return (long)((double)(y) * m_scaleY + 0.5);
+ else
+ return (long)((double)(y) * m_scaleY - 0.5);
}
- virtual bool CanGetTextExtent(void) const = 0;
- virtual void GetTextExtent( const wxString &string, long *width, long *height,
- long *descent = NULL, long *externalLeading = NULL,
- wxFont *theFont = NULL, bool use16 = FALSE ) = 0;
- virtual long GetCharWidth(void) = 0;
- virtual long GetCharHeight(void) = 0;
-
- virtual void Clear(void) = 0;
-
- virtual void SetFont( const wxFont &font ) = 0;
- virtual wxFont& GetFont(void) const { return (wxFont&) m_font; };
-
- virtual void SetPen( const wxPen &pen ) = 0;
- virtual wxPen& GetPen(void) const { return (wxPen&) m_pen; };
-
- virtual void SetBrush( const wxBrush &brush ) = 0;
- virtual wxBrush& GetBrush(void) const { return (wxBrush&) m_brush; };
+ void SetInternalDeviceOrigin( long x, long y );
+ void GetInternalDeviceOrigin( long *x, long *y );
- virtual void SetBackground( const wxBrush &brush ) = 0;
- virtual wxBrush& GetBackground(void) const { return (wxBrush&) m_backgroundBrush; };
-
- virtual void SetLogicalFunction( int function ) = 0;
- virtual int GetLogicalFunction(void) const { return m_logicalFunction; };
-
- virtual void SetTextForeground( const wxColour &col );
- virtual void SetTextBackground( const wxColour &col );
- virtual wxColour& GetTextBackground(void) const { return (wxColour&)m_textBackgroundColour; };
- virtual wxColour& GetTextForeground(void) const { return (wxColour&)m_textForegroundColour; };
-
- virtual void SetBackgroundMode( int mode ) = 0;
- virtual int GetBackgroundMode(void) const { 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 SetClippingRegion( long x, long y, long width, long height );
- virtual void DestroyClippingRegion(void);
- virtual void GetClippingBox( long *x, long *y, long *width, long *height ) const;
-
- virtual inline long MinX(void) const { return m_minX; }
- virtual inline long MaxX(void) const { return m_maxX; }
- virtual inline long MinY(void) const { return m_minY; }
- virtual inline long MaxY(void) const { return m_maxY; }
-
- // Size in device units
- virtual void GetSize( int* width, int* height ) const;
- inline wxSize GetSize(void) const { int w, h; GetSize(&w, &h); return wxSize(w, h); }
-
- // Size in millimetres
- virtual void GetSizeMM( int* width, int* height ) const;
- inline wxSize GetSizeMM(void) const { int w, h; GetSizeMM(&w, &h); return wxSize(w, h); }
-
- // Resolution in pixels per logical inch
- wxSize GetPPI(void) const ;
-
- virtual bool StartDoc( const wxString& WXUNUSED(message) ) { return TRUE; };
- virtual void EndDoc(void) {};
- virtual void StartPage(void) {};
- virtual void EndPage(void) {};
-
- 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 SetInternalDeviceOrigin( long x, long y );
- virtual void GetInternalDeviceOrigin( long *x, long *y );
+public:
+ // not sure what for, but what is a mm on a screen you don't know the size of?
+ double m_mm_to_pix_x,m_mm_to_pix_y;
- virtual void SetAxisOrientation( bool xLeftRight, bool yBottomUp );
-
- virtual void SetOptimization( bool optimize ) { m_optimize = optimize; };
- virtual bool GetOptimization(void) { return m_optimize; };
-
- virtual long DeviceToLogicalX(long x) const;
- virtual long DeviceToLogicalY(long y) const;
- virtual long DeviceToLogicalXRel(long x) const;
- virtual long DeviceToLogicalYRel(long y) const;
- virtual long LogicalToDeviceX(long x) const;
- virtual long LogicalToDeviceY(long y) const;
- virtual long LogicalToDeviceXRel(long x) const;
- virtual long LogicalToDeviceYRel(long y) const;
+ // If un-scrolled is non-zero or d.o. changes with scrolling. Set using
+ // SetInternalDeviceOrigin().
+ long m_internalDeviceOriginX,m_internalDeviceOriginY;
- public:
-
- void CalcBoundingBox( long x, long y );
- void ComputeScaleAndOrigin(void);
-
- 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 XDEV2LOGREL(long x) const
- {
- 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 YDEV2LOGREL(long y) const
- {
- 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;
- }
- // Without device translation, for backing pixmap purposes
- long XLOG2DEV_2(long x) const
- {
- long new_x = x - m_logicalOriginX;
- if (new_x > 0)
- return (long)((double)(new_x) * m_scaleX + 0.5) * m_signX;
- else
- return (long)((double)(new_x) * m_scaleX - 0.5) * m_signX;
- }
- 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);
- }
- 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;
- }
- // Without device translation, for backing pixmap purposes
- long YLOG2DEV_2(long y) const
- {
- long new_y = y - m_logicalOriginY;
- if (new_y > 0)
- return (long)((double)(new_y) * m_scaleY + 0.5) * m_signY;
- else
- return (long)((double)(new_y) * m_scaleY - 0.5) * m_signY;
- }
- 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);
- }
-
- public:
-
- bool m_ok;
- bool m_colour;
-
- // not sure, what these mean
- bool m_clipping; // Is clipping on right now ?
- bool m_optimize; // wxMSW only ?
- bool m_isInteractive; // For wxPostScriptDC
+ // To be set by external classes such as wxScrolledWindow using
+ // SetDeviceOrigin()
+ long m_externalDeviceOriginX,m_externalDeviceOriginY;
- 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_internalDeviceOriginX,m_internalDeviceOriginY; // If un-scrolled is non-zero or
- // d.o. changes with scrolling.
- // Set using SetInternalDeviceOrigin().
-
- long m_externalDeviceOriginX,m_externalDeviceOriginY; // To be set by external classes
- // such as wxScrolledWindow
- // using SetDeviceOrigin()
-
- long m_deviceOriginX,m_deviceOriginY; // Sum of the two above.
-
- long m_logicalOriginX,m_logicalOriginY; // User defined.
+ // recompute scale?
+ bool m_needComputeScaleX, m_needComputeScaleY;
- 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;
+ // wxPSDC wants to have this. Will disappear.
+ float m_scaleFactor;
};
#endif
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DCCLIENT_H_
#define _WX_DCCLIENT_H_
#ifdef __GNUG__
-#pragma interface "dcclient.h"
+ #pragma interface "dcclient.h"
#endif
#include "wx/dc.h"
-//-----------------------------------------------------------------------------
-// classes
-//-----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+// fwd declarations
+// -----------------------------------------------------------------------------
class WXDLLEXPORT wxWindowDC;
class WXDLLEXPORT wxWindow;
-// Under Windows, wxClientDC, wxPaintDC and wxWindowDC are implemented differently.
-// On many platforms, however, they will be the same.
+// Under Windows, wxClientDC, wxPaintDC and wxWindowDC are implemented
+// differently. On many platforms, however, they will be the same.
//-----------------------------------------------------------------------------
// wxWindowDC
//-----------------------------------------------------------------------------
-class WXDLLEXPORT wxWindowDC: public wxDC
+class WXDLLEXPORT wxWindowDC : public wxDC
{
- DECLARE_DYNAMIC_CLASS(wxWindowDC)
+ DECLARE_DYNAMIC_CLASS(wxWindowDC)
- public:
-
- wxWindowDC(void);
+public:
+ wxWindowDC();
wxWindowDC( wxWindow *win );
-
- ~wxWindowDC(void);
-
- virtual void FloodFill( long x1, long y1, const wxColour& col, int style=wxFLOOD_SURFACE );
- inline void FloodFill(const wxPoint& pt, const wxColour& col, int style=wxFLOOD_SURFACE)
- {
- FloodFill(pt.x, pt.y, col, style);
- }
-
- virtual bool GetPixel( long x1, long y1, wxColour *col ) const;
- inline bool GetPixel(const wxPoint& pt, wxColour *col) const
- {
- return GetPixel(pt.x, pt.y, col);
- }
-
- virtual void DrawLine( long x1, long y1, long x2, long y2 );
- inline void DrawLine(const wxPoint& pt1, const wxPoint& pt2)
- {
- DrawLine(pt1.x, pt1.y, pt2.x, pt2.y);
- }
-
- virtual void CrossHair( long x, long y );
- inline void CrossHair(const wxPoint& pt)
- {
- CrossHair(pt.x, pt.y);
- }
-
- virtual void DrawArc( long x1, long y1, long x2, long y2, long xc, long yc );
- inline void DrawArc(const wxPoint& pt1, const wxPoint& pt2, const wxPoint& centre)
- {
- DrawArc(pt1.x, pt1.y, pt2.x, pt2.y, centre.x, centre.y);
- }
-
- virtual void DrawEllipticArc( long x, long y, long width, long height, double sa, double ea );
- virtual void DrawEllipticArc (const wxPoint& pt, const wxSize& sz, double sa, double ea)
- {
- DrawEllipticArc(pt.x, pt.y, sz.x, sz.y, sa, ea);
- }
-
- virtual void DrawPoint( long x, long y );
- inline void DrawPoint( wxPoint& point )
- { DrawPoint(point.x, point.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,
- int fillStyle=wxODDEVEN_RULE );
- 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 );
- inline void DrawRectangle(const wxPoint& pt, const wxSize& sz)
- {
- DrawRectangle(pt.x, pt.y, sz.x, sz.y);
- }
- inline void DrawRectangle(const wxRect& rect)
- {
- DrawRectangle(rect.x, rect.y, rect.width, rect.height);
- }
-
- virtual void DrawRoundedRectangle( long x, long y, long width, long height, double radius = 20.0 );
- inline void DrawRoundedRectangle(const wxPoint& pt, const wxSize& sz, double radius = 20.0)
- {
- DrawRoundedRectangle(pt.x, pt.y, sz.x, sz.y, radius);
- }
- inline void DrawRoundedRectangle(const wxRect& rect, double radius = 20.0)
- {
- DrawRoundedRectangle(rect.x, rect.y, rect.width, rect.height, radius);
- }
-
- virtual void DrawEllipse( long x, long y, long width, long height );
- inline void DrawEllipse(const wxPoint& pt, const wxSize& sz)
- {
- DrawEllipse(pt.x, pt.y, sz.x, sz.y);
- }
- inline void DrawEllipse(const wxRect& rect)
- {
- DrawEllipse(rect.x, rect.y, rect.width, rect.height);
- }
-
- virtual bool CanDrawBitmap(void) const;
-
- virtual void DrawIcon( const wxIcon &icon, long x, long y);
- inline void DrawIcon(const wxIcon& icon, const wxPoint& pt)
- {
- DrawIcon(icon, pt.x, pt.y);
- }
-
- virtual bool Blit( long xdest, long ydest, long width, long height,
- wxDC *source, long xsrc, long ysrc, int logical_func = wxCOPY, bool useMask=FALSE );
- inline bool Blit(const wxPoint& destPt, const wxSize& sz,
- 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);
- }
-
- virtual void DrawText( const wxString &text, long x, long y, bool use16 = FALSE );
- inline void DrawText(const wxString& text, const wxPoint& pt, bool use16bit = FALSE)
- {
- DrawText(text, pt.x, pt.y, use16bit);
- }
-
- virtual bool CanGetTextExtent(void) const;
- virtual void GetTextExtent( const wxString &string, long *width, long *height,
- long *descent = NULL, long *externalLeading = NULL,
- wxFont *theFont = NULL, bool use16 = FALSE );
- virtual long GetCharWidth(void);
- virtual long GetCharHeight(void);
-
- virtual void Clear(void);
- virtual void Clear(const wxRect& rect);
-
- virtual void SetFont( const wxFont &font );
- virtual void SetPen( const wxPen &pen );
- virtual void SetBrush( const wxBrush &brush );
- virtual void SetBackground( const wxBrush &brush );
+
+ ~wxWindowDC();
+
+ // TODO this function is Motif-only for now - should it go into base class?
+ void Clear(const wxRect& rect);
+
+ // implement base class pure virtuals
+ // ----------------------------------
+
+ virtual void Clear();
+
+ virtual void SetFont(const wxFont& font);
+ virtual void SetPen(const wxPen& pen);
+ virtual void SetBrush(const wxBrush& brush);
+ virtual void SetBackground(const wxBrush& brush);
+ virtual void SetBackgroundMode(int mode);
+ virtual void SetPalette(const wxPalette& palette);
virtual void SetLogicalFunction( int function );
- virtual void SetTextForeground( const wxColour &col );
- 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 SetClippingRegion( const wxRegion& region );
- virtual void DestroyClippingRegion(void);
-
- virtual void DrawSpline( wxList *points );
- virtual void DrawSpline( long x1, long y1, long x2, long y2, long x3, long y3 )
- { wxDC::DrawSpline(x1, y1, x2, y2, x3, y3); }
- virtual void DrawSpline( int n, wxPoint points[] )
- { wxDC::DrawSpline(n, points); }
-
- // Resolution in pixels per logical inch
- wxSize GetPPI(void) const;
-
- // Motif-specific
- void SetDCClipping (); // Helper function for setting clipping
-
- inline WXGC GetGC() const { return m_gc; }
- inline WXGC GetBackingGC() const { return m_gcBacking; }
- inline WXDisplay* GetDisplay() const { return m_display; }
- inline bool GetAutoSetting() const { return m_autoSetting; }
- inline void SetAutoSetting(bool flag) { m_autoSetting = flag; }
+
+ virtual void SetTextForeground(const wxColour& colour);
+ virtual void SetTextBackground(const wxColour& colour);
+
+ virtual long GetCharHeight() const;
+ virtual long GetCharWidth() const;
+ virtual void GetTextExtent(const wxString& string,
+ long *x, long *y,
+ long *descent = NULL,
+ long *externalLeading = NULL,
+ wxFont *theFont = NULL) const;
+
+ virtual bool CanDrawBitmap() const;
+ virtual bool CanGetTextExtent() const;
+
+ virtual int GetDepth() const;
+ virtual wxSize GetPPI() const;
+
+ virtual void DestroyClippingRegion();
+
+ // Helper function for setting clipping
+ void SetDCClipping();
+
+ // implementation from now on
+ // --------------------------
+
+ WXGC GetGC() const { return m_gc; }
+ WXGC GetBackingGC() const { return m_gcBacking; }
+ WXDisplay* GetDisplay() const { return m_display; }
+ bool GetAutoSetting() const { return m_autoSetting; }
+ void SetAutoSetting(bool flag) { m_autoSetting = flag; }
protected:
+ virtual void DoFloodFill(long x, long y, const wxColour& col,
+ int style = wxFLOOD_SURFACE);
+
+ virtual bool DoGetPixel(long x, long y, wxColour *col) const;
+
+ virtual void DoDrawPoint(long x, long y);
+ virtual void DoDrawLine(long x1, long y1, long x2, long y2);
+
+ virtual void DoDrawArc(long x1, long y1,
+ long x2, long y2,
+ long xc, long yc);
+ virtual void DoDrawEllipticArc(long x, long y, long w, long h,
+ double sa, double ea);
+
+ virtual void DoDrawRectangle(long x, long y, long width, long height);
+ virtual void DoDrawRoundedRectangle(long x, long y,
+ long width, long height,
+ double radius);
+ virtual void DoDrawEllipse(long x, long y, long width, long height);
+
+ virtual void DoCrossHair(long x, long y);
+
+ virtual void DoDrawText(const wxString& text, long x, long y);
+
+ virtual bool DoBlit(long xdest, long ydest, long width, long height,
+ wxDC *source, long xsrc, long ysrc,
+ int rop = wxCOPY, bool useMask = FALSE);
+
+ virtual void DoSetClippingRegionAsRegion(const wxRegion& region);
+ virtual void DoSetClippingRegion(long x, long y,
+ long width, long height);
+
+ virtual void DoGetSize(int *width, int *height) const;
+ virtual void DoGetSizeMM(int* width, int* height) const;
+
+ virtual void DoDrawLines(int n, wxPoint points[],
+ long xoffset, long yoffset);
+ virtual void DoDrawPolygon(int n, wxPoint points[],
+ long xoffset, long yoffset,
+ int fillStyle = wxODDEVEN_RULE);
+
+#if wxUSE_SPLINES
+ virtual void DoDrawSpline(wxList *points);
+#endif // wxUSE_SPLINES
+
WXGC m_gc;
WXGC m_gcBacking;
WXDisplay* m_display;
// Not sure if we'll need all of these
int m_backgroundPixel;
wxColour m_currentColour;
-// int m_currentBkMode;
+ // int m_currentBkMode;
int m_currentPenWidth ;
int m_currentPenJoin ;
int m_currentPenCap ;
class WXDLLEXPORT wxPaintDC: public wxWindowDC
{
- DECLARE_DYNAMIC_CLASS(wxPaintDC)
+ DECLARE_DYNAMIC_CLASS(wxPaintDC)
+
public:
- wxPaintDC() {}
- wxPaintDC(wxWindow* win);
- ~wxPaintDC();
+ wxPaintDC() { }
+ wxPaintDC(wxWindow* win);
+
+ ~wxPaintDC();
};
class WXDLLEXPORT wxClientDC: public wxWindowDC
{
- DECLARE_DYNAMIC_CLASS(wxClientDC)
+ DECLARE_DYNAMIC_CLASS(wxClientDC)
+
public:
- wxClientDC() {}
- wxClientDC(wxWindow* win): wxWindowDC(win) {}
+ wxClientDC() { }
+ wxClientDC(wxWindow* win) : wxWindowDC(win) { }
};
#endif
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DCMEMORY_H_
#define _WX_DCMEMORY_H_
#ifdef __GNUG__
-#pragma interface "dcmemory.h"
+ #pragma interface "dcmemory.h"
#endif
#include "wx/dcclient.h"
-class WXDLLEXPORT wxMemoryDC: public wxWindowDC
+class wxMemoryDC : public wxWindowDC
{
- DECLARE_DYNAMIC_CLASS(wxMemoryDC)
+DECLARE_DYNAMIC_CLASS(wxMemoryDC)
- public:
- wxMemoryDC(void);
+public:
+ wxMemoryDC();
wxMemoryDC( wxDC *dc ); // Create compatible DC
- ~wxMemoryDC(void);
+ ~wxMemoryDC();
+
virtual void SelectObject( const wxBitmap& bitmap );
+
void GetSize( int *width, int *height ) const;
- inline wxBitmap& GetBitmap() const { return (wxBitmap&) m_bitmap; }
+ wxBitmap& GetBitmap() const { return (wxBitmap&) m_bitmap; }
- private:
+private:
friend wxPaintDC;
+
wxBitmap m_bitmap;
};
void SetUnderlined(bool underlined);
inline wxFont& operator = (const wxFont& font) { if (*this == font) return (*this); Ref(font); return *this; }
- inline bool operator == (const wxFont& font) { return m_refData == font.m_refData; }
- inline bool operator != (const wxFont& font) { return m_refData != font.m_refData; }
+ inline bool operator == (const wxFont& font) const { return m_refData == font.m_refData; }
+ inline bool operator != (const wxFont& font) const { return m_refData != font.m_refData; }
// Implementation
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_FRAME_H_
#include "wx/window.h"
#include "wx/toolbar.h"
#include "wx/accel.h"
+#include "wx/icon.h"
WXDLLEXPORT_DATA(extern const char*) wxFrameNameStr;
WXDLLEXPORT_DATA(extern const char*) wxToolBarNameStr;
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_RADIOBOX_H_
void SetLabel(int item, const wxString& label) ;
wxString GetLabel(int item) const;
wxString GetLabel() const { return wxControl::GetLabel(); };
- void Enable(bool enable);
+ bool Enable(bool enable);
void Enable(int item, bool enable);
void Show(int item, bool show) ;
bool Show(bool show) ;
#pragma interface "window.h"
#endif
+// ----------------------------------------------------------------------------
+// A list of rectangles type used by wxWindow
+// ----------------------------------------------------------------------------
+
+WX_DECLARE_LIST(wxRect, wxRectList);
+
// ----------------------------------------------------------------------------
// wxWindow class for Motif - see also wxWindowBase
// ----------------------------------------------------------------------------
const wxRect *rect = (const wxRect *) NULL );
virtual void Clear();
+ virtual bool SetBackgroundColour( const wxColour &colour );
+ virtual bool SetForegroundColour( const wxColour &colour );
+
virtual bool SetCursor( const wxCursor &cursor );
virtual bool SetFont( const wxFont &font );
virtual void ScrollWindow( int dx, int dy,
const wxRect* rect = (wxRect *) NULL );
+ virtual void SetSizeHints(int minW, int minH,
+ int maxW, int maxH,
+ int incW, int incH);
#if wxUSE_DRAG_AND_DROP
virtual void SetDropTarget( wxDropTarget *dropTarget );
#endif // wxUSE_DRAG_AND_DROP
// Accept files for dragging
virtual void DragAcceptFiles(bool accept);
+ // Get the unique identifier of a window
+ virtual WXWidget GetHandle() const { return GetMainWidget(); }
+
+ // implementation from now on
+ // --------------------------
+
+ // accessors
+ // ---------
+
+ // Get main widget for this window, e.g. a text widget
+ virtual WXWidget GetMainWidget() const;
+ // Get the widget that corresponds to the label (for font setting, label setting etc.)
+ virtual WXWidget GetLabelWidget() const;
+ // Get the client widget for this window (something we can create other
+ // windows on)
+ virtual WXWidget GetClientWidget() const;
+ // Get the top widget for this window, e.g. the scrolled widget parent of a
+ // multi-line text widget. Top means, top in the window hierarchy that
+ // implements this window.
+ virtual WXWidget GetTopWidget() const;
+
+ // Get the underlying X window and display
+ WXWindow GetXWindow() const;
+ WXDisplay *GetXDisplay() const;
+
+ // called from Motif callbacks - and should only be called from there
+
+ void SetButton1(bool pressed) { m_button1Pressed = pressed; }
+ void SetButton2(bool pressed) { m_button2Pressed = pressed; }
+ void SetButton3(bool pressed) { m_button3Pressed = pressed; }
+
+ void SetLastClick(int button, long timestamp)
+ { m_lastButton = button; m_lastTS = timestamp; }
+
+ int GetLastClickedButton() const { return m_lastButton; }
+ long GetLastClickTime() const { return m_lastTS; }
+
+ // Gives window a chance to do something in response to a size message, e.g.
+ // arrange status bar, toolbar etc.
+ virtual bool PreResize();
+
+ // Generates a paint event
+ virtual void DoPaint();
+
+ // update rectangle/region manipulation
+ // (for wxWindowDC and Motif callbacks only)
+ // -----------------------------------------
+
+ // read/write access to the update rect list
+ const wxRectList& GetUpdateRects() const { return m_updateRects; }
+
+ // Adds a recangle to the updates list
+ void AddUpdateRect(int x, int y, int w, int h)
+ { m_updateRects.Append(new wxRect(x, y, w, h)); }
+
+ // Empties the m_updateRects list
+ void ClearUpdateRects();
+
+ void ClearUpdateRegion() { m_updateRegion.Clear(); }
+ void SetUpdateRegion(const wxRegion& region) { m_updateRegion = region; }
+
protected:
// event handlers (not virtual by design)
void OnIdle(wxIdleEvent& event);
// a toolbar that it manages itself).
virtual void AdjustForParentClientOrigin(int& x, int& y, int sizeFlags);
- virtual void AddChild(wxWindow *child); // Adds reference to the child object
- virtual void RemoveChild(wxWindow *child); // Removes reference to child
- virtual void DestroyChildren(); // Removes and destroys all children
-
wxWindow *GetChild(int number) const
{ return GetChildren().Item(number)->GetData(); }
// Motif-specific
- // empties the m_updateRects list
- void ClearUpdateRects();
-
// CanvasXXXSiize functions
void CanvasGetSize(int* width, int* height) const; // If have drawing area
void CanvasGetClientSize(int *width, int *height) const;
void CanvasSetClientSize(int width, int size);
void CanvasSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
- // Gives window a chance to do something in response to a size message, e.g.
- // arrange status bar, toolbar etc.
- virtual bool PreResize() { return TRUE; }
-
- // accessors
- // ---------
-
- // Get main widget for this window, e.g. a text widget
- virtual WXWidget GetMainWidget() const;
- // Get the widget that corresponds to the label (for font setting, label setting etc.)
- virtual WXWidget GetLabelWidget() const;
- // Get the client widget for this window (something we can create other
- // windows on)
- virtual WXWidget GetClientWidget() const;
- // Get the top widget for this window, e.g. the scrolled widget parent of a
- // multi-line text widget. Top means, top in the window hierarchy that
- // implements this window.
- virtual WXWidget GetTopWidget() const;
-
- // base class pure virtual
- virtual WXWidget GetHandle() const { return GetMainWidget(); }
-
void SetMainWidget(WXWidget w) { m_mainWidget = w; }
bool CanAddEventHandler() const { return m_canAddEventHandler; }
void SetCanAddEventHandler(bool flag) { m_canAddEventHandler = flag; }
- // Get the underlying X window and display
- WXWindow GetXWindow() const;
- WXDisplay *GetXDisplay() const;
-
WXPixmap GetBackingPixmap() const { return m_backingPixmap; }
int GetPixmapWidth() const { return m_pixmapWidth; }
int GetPixmapHeight() const { return m_pixmapHeight; }
WXWidget formWidget, int x, int y, int width, int height);
bool DetachWidget(WXWidget widget);
- // Generates a paint event
- virtual void DoPaint();
-
// How to implement accelerators. If we find a key event, translate to
// wxWindows wxKeyEvent form. Find a widget for the window. Now find a
// wxWindow for the widget. If there isn't one, go up the widget hierarchy
// event and send it.
virtual bool ProcessAccelerator(wxKeyEvent& event);
-protected:
// unmanage and destroy an X widget f it's !NULL (passing NULL is ok)
void UnmanageAndDestroy(WXWidget widget);
// mapped/unmapped
bool MapOrUnmap(WXWidget widget, bool map);
+ // scrolling stuff
+ // ---------------
+
+ // create/destroy window scrollbars
+ void CreateScrollbar(wxOrientation orientation);
+ void DestroyScrollbar(wxOrientation orientation);
+
// get either hor or vert scrollbar widget
WXWidget GetScrollbar(wxOrientation orient) const
{ return orient == wxHORIZONTAL ? m_hScrollBar : m_vScrollBar; }
}
// Motif-specific flags
+ // --------------------
+
bool m_needsRefresh:1; // repaint backing store?
bool m_canAddEventHandler:1; // ???
bool m_button1Pressed:1;
// For double-click detection
long m_lastTS; // last timestamp
int m_lastButton; // last pressed button
- wxList m_updateRects; // List of wxRects representing damaged region
+
+ // List of wxRects representing damaged region
+ wxRectList m_updateRects;
protected:
WXWidget m_mainWidget;
};
// ----------------------------------------------------------------------------
-// A little class to switch off size optimization while an instance of the object
-// exists
+// A little class to switch off `size optimization' while an instance of the
+// object exists: this may be useful to temporarily disable the optimisation
+// which consists to do nothing when the new size is equal to the old size -
+// although quite useful usually to avoid flicker, sometimes it leads to
+// undesired effects.
//
-// TODO what is it for??
+// Usage: create an instance of this class on the stack to disable the size
+// optimisation, it will be reenabled as soon as the object goes out from scope.
// ----------------------------------------------------------------------------
-class WXDLLEXPORT wxNoOptimize: public wxObject
+
+class WXDLLEXPORT wxNoOptimize
{
public:
- wxNoOptimize();
- ~wxNoOptimize();
+ wxNoOptimize() { ms_count++; }
+ ~wxNoOptimize() { ms_count--; }
- static bool CanOptimize();
+ static bool CanOptimize() { return ms_count == 0; }
protected:
- static int m_count;
+ static int ms_count;
};
#endif
// Created: 01/02/97
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
-#pragma implementation "dc.h"
+ #pragma implementation "dc.h"
#endif
#include "wx/dc.h"
#include "wx/dcmemory.h"
#if !USE_SHARED_LIBRARY
-IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject)
+ IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject)
#endif
//-----------------------------------------------------------------------------
// constants
//-----------------------------------------------------------------------------
-#define mm2inches 0.0393700787402
-#define inches2mm 25.4
-#define mm2twips 56.6929133859
-#define twips2mm 0.0176388888889
-#define mm2pt 2.83464566929
-#define pt2mm 0.352777777778
+#define mm2inches 0.0393700787402
+#define inches2mm 25.4
+#define mm2twips 56.6929133859
+#define twips2mm 0.0176388888889
+#define mm2pt 2.83464566929
+#define pt2mm 0.352777777778
//-----------------------------------------------------------------------------
// wxDC
//-----------------------------------------------------------------------------
-wxDC::wxDC(void)
+wxDC::wxDC()
{
m_ok = FALSE;
- m_optimize = FALSE;
- m_colour = TRUE;
- m_clipping = FALSE;
-
+
m_mm_to_pix_x = 1.0;
m_mm_to_pix_y = 1.0;
-
- m_logicalOriginX = 0;
- m_logicalOriginY = 0;
- m_deviceOriginX = 0;
- m_deviceOriginY = 0;
- m_internalDeviceOriginX = 0;
- m_internalDeviceOriginY = 0;
- m_externalDeviceOriginX = 0;
- m_externalDeviceOriginY = 0;
-
- m_logicalScaleX = 1.0;
- m_logicalScaleY = 1.0;
- m_userScaleX = 1.0;
- m_userScaleY = 1.0;
- m_scaleX = 1.0;
- m_scaleY = 1.0;
-
- m_mappingMode = wxMM_TEXT;
- m_needComputeScaleX = FALSE;
- m_needComputeScaleY = FALSE;
-
- m_signX = 1; // default x-axis left to right
- m_signY = 1; // default y-axis top down
-
- m_maxX = m_maxY = 0;
- m_minX = m_minY = 0;
-
- m_logicalFunction = wxCOPY;
- // m_textAlignment = wxALIGN_TOP_LEFT;
+
m_backgroundMode = wxTRANSPARENT;
-
- m_textForegroundColour = *wxBLACK;
- m_textBackgroundColour = *wxWHITE;
- m_pen = *wxBLACK_PEN;
- m_font = *wxNORMAL_FONT;
- m_brush = *wxTRANSPARENT_BRUSH;
- m_backgroundBrush = *wxWHITE_BRUSH;
-
+
m_isInteractive = FALSE;
-
- // m_palette = wxAPP_COLOURMAP;
-};
+}
-wxDC::~wxDC(void)
+void wxDC::DoDrawIcon( const wxIcon &icon, long x, long y)
{
-};
+ wxCHECK_RET( Ok(), "invalid dc" );
+ wxCHECK_RET( icon.Ok(), "invalid icon" );
-void wxDC::DrawIcon( const wxIcon &WXUNUSED(icon), long WXUNUSED(x), long WXUNUSED(y))
-{
-};
+ DoDrawBitmap(icon, x, y, TRUE);
+}
-void wxDC::DrawBitmap( const wxBitmap& bitmap, long x, long y, bool useMask )
+void wxDC::DoDrawBitmap( const wxBitmap& bitmap, long x, long y, bool useMask )
{
- if (!bitmap.Ok())
- return;
-
+ wxCHECK_RET( bitmap.Ok(), "invalid bitmap" );
+
wxMemoryDC memDC;
memDC.SelectObject(bitmap);
-
- /* Not sure if we need this. The mask should leave the
- * masked areas as per the original background of this DC.
+
+#if 0
+ // Not sure if we need this. The mask should leave the masked areas as per
+ // the original background of this DC.
if (useMask)
{
- // There might be transparent areas, so make these
- // the same colour as this DC
- memDC.SetBackground(* GetBackground());
- memDC.Clear();
+ // There might be transparent areas, so make these the same colour as this
+ // DC
+ memDC.SetBackground(* GetBackground());
+ memDC.Clear();
}
- */
-
- Blit(x, y, bitmap.GetWidth(), bitmap.GetHeight(), & memDC, 0, 0, wxCOPY, useMask);
-
- memDC.SelectObject(wxNullBitmap);
-};
-
+#endif // 0
-void wxDC::DrawPoint( wxPoint& point )
-{
- DrawPoint( point.x, point.y );
-};
+ Blit(x, y, bitmap.GetWidth(), bitmap.GetHeight(), &memDC, 0, 0, wxCOPY, useMask);
-void wxDC::DrawPolygon( wxList *list, long xoffset, long yoffset, int fillStyle )
-{
- int n = list->Number();
- wxPoint *points = new wxPoint[n];
-
- int i = 0;
- for( wxNode *node = list->First(); node; node = node->Next() )
- {
- wxPoint *point = (wxPoint *)node->Data();
- points[i].x = point->x;
- points[i++].y = point->y;
- };
- DrawPolygon( n, points, xoffset, yoffset, fillStyle );
- delete[] points;
-};
-
-void wxDC::DrawLines( wxList *list, long xoffset, long yoffset )
-{
- int n = list->Number();
- wxPoint *points = new wxPoint[n];
-
- int i = 0;
- for( wxNode *node = list->First(); node; node = node->Next() )
- {
- wxPoint *point = (wxPoint *)node->Data();
- points[i].x = point->x;
- points[i++].y = point->y;
- };
- DrawLines( n, points, xoffset, yoffset );
- delete []points;
-};
-
-void wxDC::DrawSpline( long x1, long y1, long x2, long y2, long x3, long y3 )
-{
- wxList list;
- list.Append( (wxObject*)new wxPoint(x1, y1) );
- list.Append( (wxObject*)new wxPoint(x2, y2) );
- list.Append( (wxObject*)new wxPoint(x3, y3) );
- DrawSpline(&list);
- wxNode *node = list.First();
- while (node)
- {
- wxPoint *p = (wxPoint*)node->Data();
- delete p;
- node = node->Next();
- };
-};
-
-void wxDC::DrawSpline( int n, wxPoint points[] )
-{
- wxList list;
- for (int i = 0; i < n; i++) list.Append( (wxObject*)&points[i] );
- DrawSpline( &list );
-};
+ memDC.SelectObject(wxNullBitmap);
+}
-void wxDC::SetClippingRegion( long x, long y, long width, long height )
+void wxDC::DoSetClippingRegion( long x, long y, long width, long height )
{
m_clipping = TRUE;
m_clipX1 = x;
m_clipY1 = y;
m_clipX2 = x + width;
m_clipY2 = y + height;
-};
+}
-void wxDC::DestroyClippingRegion(void)
+void wxDC::DestroyClippingRegion()
{
m_clipping = FALSE;
-};
-
-void wxDC::GetClippingBox( long *x, long *y, long *width, long *height ) const
-{
- if (m_clipping)
- {
- if (x) *x = m_clipX1;
- if (y) *y = m_clipY1;
- if (width) *width = (m_clipX2 - m_clipX1);
- if (height) *height = (m_clipY2 - m_clipY1);
- }
- else
- *x = *y = *width = *height = 0;
-};
+}
-void wxDC::GetSize( int* width, int* height ) const
+void wxDC::DoGetSize( int* width, int* height ) const
{
- *width = m_maxX-m_minX;
- *height = m_maxY-m_minY;
-};
+ if ( width )
+ *width = m_maxX - m_minX;
+ if ( height )
+ *height = m_maxY - m_minY;
+}
-void wxDC::GetSizeMM( int* width, int* height ) const
+void wxDC::DoGetSizeMM( int* width, int* height ) const
{
- int w = 0;
- int h = 0;
+ int w, h;
GetSize( &w, &h );
- *width = int( double(w) / (m_scaleX*m_mm_to_pix_x) );
- *height = int( double(h) / (m_scaleY*m_mm_to_pix_y) );
-};
+
+ if ( width )
+ *width = int( double(w) / (m_scaleX*m_mm_to_pix_x) );
+ if ( height )
+ *height = int( double(h) / (m_scaleY*m_mm_to_pix_y) );
+}
// Resolution in pixels per logical inch
-wxSize wxDC::GetPPI(void) const
+wxSize wxDC::GetPPI() const
{
// TODO (should probably be pure virtual)
return wxSize(0, 0);
}
-void wxDC::SetTextForeground( const wxColour &col )
-{
- if (!Ok()) return;
- m_textForegroundColour = col;
-};
-
-void wxDC::SetTextBackground( const wxColour &col )
-{
- if (!Ok()) return;
- m_textBackgroundColour = col;
-};
-
void wxDC::SetMapMode( int mode )
{
- switch (mode)
+ switch (mode)
{
case wxMM_TWIPS:
SetLogicalScale( twips2mm*m_mm_to_pix_x, twips2mm*m_mm_to_pix_y );
case wxMM_TEXT:
SetLogicalScale( 1.0, 1.0 );
break;
- };
+ }
if (mode != wxMM_TEXT)
{
m_needComputeScaleX = TRUE;
m_needComputeScaleY = TRUE;
- };
-};
+ }
+}
void wxDC::SetUserScale( double x, double y )
{
- // allow negative ? -> no
- m_userScaleX = x;
- m_userScaleY = y;
+ wxDCBase::SetUserScale(x, y);
ComputeScaleAndOrigin();
-};
-
-void wxDC::GetUserScale( double *x, double *y )
-{
- if (x) *x = m_userScaleX;
- if (y) *y = m_userScaleY;
-};
+}
void wxDC::SetLogicalScale( double x, double y )
{
- // allow negative ?
- m_logicalScaleX = x;
- m_logicalScaleY = y;
+ wxDCBase::SetLogicalScale(x, y);
ComputeScaleAndOrigin();
-};
-
-void wxDC::GetLogicalScale( double *x, double *y )
-{
- if (x) *x = m_logicalScaleX;
- if (y) *y = m_logicalScaleY;
-};
+}
void wxDC::SetLogicalOrigin( long x, long y )
{
m_logicalOriginX = x * m_signX; // is this still correct ?
m_logicalOriginY = y * m_signY;
ComputeScaleAndOrigin();
-};
-
-void wxDC::GetLogicalOrigin( long *x, long *y )
-{
- if (x) *x = m_logicalOriginX;
- if (y) *y = m_logicalOriginY;
-};
+}
void wxDC::SetDeviceOrigin( long x, long y )
{
m_externalDeviceOriginX = x;
m_externalDeviceOriginY = y;
ComputeScaleAndOrigin();
-};
-
-void wxDC::GetDeviceOrigin( long *x, long *y )
-{
- // if (x) *x = m_externalDeviceOriginX;
- // if (y) *y = m_externalDeviceOriginY;
- if (x) *x = m_deviceOriginX;
- if (y) *y = m_deviceOriginY;
-};
+}
void wxDC::SetInternalDeviceOrigin( long x, long y )
{
m_internalDeviceOriginX = x;
m_internalDeviceOriginY = y;
ComputeScaleAndOrigin();
-};
+}
void wxDC::GetInternalDeviceOrigin( long *x, long *y )
{
if (x) *x = m_internalDeviceOriginX;
if (y) *y = m_internalDeviceOriginY;
-};
+}
void wxDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp )
{
- m_signX = (xLeftRight ? 1 : -1);
- m_signY = (yBottomUp ? -1 : 1);
+ m_signX = xLeftRight ? 1 : -1;
+ m_signY = yBottomUp ? -1 : 1;
ComputeScaleAndOrigin();
-};
-
-long wxDC::DeviceToLogicalX(long x) const
-{
- return XDEV2LOG(x);
-};
+}
-long wxDC::DeviceToLogicalY(long y) const
+long wxDCBase::DeviceToLogicalX(long x) const
{
- return YDEV2LOG(y);
-};
+ return ((wxDC *)this)->XDEV2LOG(x);
+}
-long wxDC::DeviceToLogicalXRel(long x) const
+long wxDCBase::DeviceToLogicalY(long y) const
{
- return XDEV2LOGREL(x);
-};
+ return ((wxDC *)this)->YDEV2LOG(y);
+}
-long wxDC::DeviceToLogicalYRel(long y) const
+long wxDCBase::DeviceToLogicalXRel(long x) const
{
- return YDEV2LOGREL(y);
-};
+ return ((wxDC *)this)->XDEV2LOGREL(x);
+}
-long wxDC::LogicalToDeviceX(long x) const
+long wxDCBase::DeviceToLogicalYRel(long y) const
{
- return XLOG2DEV(x);
-};
+ return ((wxDC *)this)->YDEV2LOGREL(y);
+}
-long wxDC::LogicalToDeviceY(long y) const
+long wxDCBase::LogicalToDeviceX(long x) const
{
- return YLOG2DEV(y);
-};
+ return ((wxDC *)this)->XLOG2DEV(x);
+}
-long wxDC::LogicalToDeviceXRel(long x) const
+long wxDCBase::LogicalToDeviceY(long y) const
{
- return XLOG2DEVREL(x);
-};
+ return ((wxDC *)this)->YLOG2DEV(y);
+}
-long wxDC::LogicalToDeviceYRel(long y) const
+long wxDCBase::LogicalToDeviceXRel(long x) const
{
- return YLOG2DEVREL(y);
-};
+ return ((wxDC *)this)->XLOG2DEVREL(x);
+}
-void wxDC::CalcBoundingBox( long x, long y )
+long wxDCBase::LogicalToDeviceYRel(long y) const
{
- if (x < m_minX) m_minX = x;
- if (y < m_minY) m_minY = y;
- if (x > m_maxX) m_maxX = x;
- if (y > m_maxY) m_maxY = y;
-};
+ return ((wxDC *)this)->YLOG2DEVREL(y);
+}
-void wxDC::ComputeScaleAndOrigin(void)
+void wxDC::ComputeScaleAndOrigin()
{
// CMB: copy scale to see if it changes
double origScaleX = m_scaleX;
double origScaleY = m_scaleY;
-
+
m_scaleX = m_logicalScaleX * m_userScaleX;
m_scaleY = m_logicalScaleY * m_userScaleY;
-
+
m_deviceOriginX = m_internalDeviceOriginX + m_externalDeviceOriginX;
m_deviceOriginY = m_internalDeviceOriginY + m_externalDeviceOriginY;
-
- // CMB: if scale has changed call SetPen to recalulate the line width
+
+ // CMB: if scale has changed call SetPen to recalulate the line width
if (m_scaleX != origScaleX || m_scaleY != origScaleY)
{
// this is a bit artificial, but we need to force wxDC to think
m_pen = tempPen;
SetPen(* pen);
}
-};
+}
// Created: 01/02/97
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/*
-About pens, brushes, and the autoSetting flag:
-
- Under X, pens and brushes control some of the same X drawing
- parameters. Therefore, it is impossible to independently maintain
- the current pen and the current brush. Also, some settings depend
- on the current logical function. The m_currentFill, etc. instance
- variables remember state across the brush and pen.
-
- Since pens are used more than brushes, the autoSetting flag
- is used to indicate that a brush was recently used, and SetPen
- must be called to reinstall the current pen's parameters.
- If autoSetting includes 0x2, then the pens color may need
- to be set based on XOR.
-
- There is, unfortunately, some confusion between setting the
- current pen/brush and actually installing the brush/pen parameters.
- Both functionalies are perform by SetPen and SetBrush. C'est la vie.
+ About pens, brushes, and the autoSetting flag:
+
+ Under X, pens and brushes control some of the same X drawing parameters.
+ Therefore, it is impossible to independently maintain the current pen and the
+ current brush. Also, some settings depend on the current logical function. The
+ m_currentFill, etc. instance variables remember state across the brush and
+ pen.
+
+ Since pens are used more than brushes, the autoSetting flag is used to
+ indicate that a brush was recently used, and SetPen must be called to
+ reinstall the current pen's parameters. If autoSetting includes 0x2, then the
+ pens color may need to be set based on XOR.
+
+ There is, unfortunately, some confusion between setting the current pen/brush
+ and actually installing the brush/pen parameters. Both functionalies are
+ perform by SetPen and SetBrush. C'est la vie.
*/
+// ============================================================================
+// declarations
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
#ifdef __GNUG__
-#pragma implementation "dcclient.h"
+ #pragma implementation "dcclient.h"
#endif
#include "wx/dcclient.h"
static Pixmap bdiag, cdiag, fdiag, cross, horiz, verti;
-//-----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
// constants
-//-----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
#define RAD2DEG 57.2957795131
-// Fudge factor. Obsolete?
-// No. Robert Roebling
+// Fudge factor (VZ: what??)
#define WX_GC_CF 1
-//-----------------------------------------------------------------------------
-// wxWindowDC
-//-----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
+// macros
+// ----------------------------------------------------------------------------
#if !USE_SHARED_LIBRARY
-IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxWindowDC)
-IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC)
-IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC)
+ IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxWindowDC)
+ IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC)
+ IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC)
#endif
-wxWindowDC::wxWindowDC(void)
+// ----------------------------------------------------------------------------
+// prototypes
+// ----------------------------------------------------------------------------
+
+static void XCopyRemote(Display *src_display, Display *dest_display,
+ Drawable src, Drawable dest,
+ GC destgc,
+ int srcx, int srcy,
+ unsigned int w, unsigned int h,
+ int destx, int desty,
+ bool more, XImage **cache);
+
+// ============================================================================
+// implementation
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// wxWindowDC
+// ----------------------------------------------------------------------------
+
+wxWindowDC::wxWindowDC()
{
m_gc = (WXGC) 0;
m_gcBacking = (WXGC) 0;
m_pixmap = (WXPixmap) 0;
m_autoSetting = 0;
m_oldFont = (WXFont) 0;
-};
+}
wxWindowDC::wxWindowDC( wxWindow *window )
{
wxASSERT_MSG( (window != (wxWindow*) NULL), "You must pass a valid wxWindow to wxWindowDC/wxClientDC/wxPaintDC constructor." );
-
+
m_window = window;
m_gc = (WXGC) 0;
m_gcBacking = (WXGC) 0;
m_userRegion = (WXRegion) 0;
m_ok = TRUE;
m_autoSetting = 0;
-
+
m_display = window->GetXDisplay();
m_pixmap = window->GetXWindow();
Display* display = (Display*) m_display;
-
+
XSetWindowColormap (display, (Pixmap) m_pixmap, (Colormap) wxTheApp->GetMainColormap(m_display));
-
+
XGCValues gcvalues;
gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
gcvalues.background = WhitePixel (display, DefaultScreen (display));
m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)),
GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth,
&gcvalues);
-
+
if (m_window->GetBackingPixmap())
{
m_gcBacking = (WXGC) XCreateGC (display, RootWindow (display,
GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth,
&gcvalues);
}
-
+
m_backgroundPixel = (int) gcvalues.background;
-
+
// Get the current Font so we can set it back later
XGCValues valReturn;
XGetGCValues((Display*) m_display, (GC) m_gc, GCFont, &valReturn);
m_oldFont = (WXFont) valReturn.font;
SetBackground(wxBrush(m_window->GetBackgroundColour(), wxSOLID));
-};
+}
-wxWindowDC::~wxWindowDC(void)
+wxWindowDC::~wxWindowDC()
{
if (m_gc && (m_oldFont != (WXFont) 0) && ((long) m_oldFont != -1))
{
XSetFont ((Display*) m_display, (GC) m_gc, (Font) m_oldFont);
-
+
if (m_window && m_window->GetBackingPixmap())
XSetFont ((Display*) m_display,(GC) m_gcBacking, (Font) m_oldFont);
}
-
+
if (m_gc)
XFreeGC ((Display*) m_display, (GC) m_gc);
m_gc = (WXGC) 0;
-
+
if (m_gcBacking)
XFreeGC ((Display*) m_display, (GC) m_gcBacking);
m_gcBacking = (WXGC) 0;
-
+
if (m_currentRegion)
XDestroyRegion ((Region) m_currentRegion);
m_currentRegion = (WXRegion) 0;
-
+
if (m_userRegion)
XDestroyRegion ((Region) m_userRegion);
m_userRegion = (WXRegion) 0;
-};
+}
-void wxWindowDC::FloodFill( long WXUNUSED(x1), long WXUNUSED(y1),
+void wxWindowDC::DoFloodFill( long WXUNUSED(x1), long WXUNUSED(y1),
const wxColour& WXUNUSED(col), int WXUNUSED(style) )
{
- // TODO
-};
+ wxFAIL_MSG("not implemented");
+}
-bool wxWindowDC::GetPixel( long WXUNUSED(x1), long WXUNUSED(y1), wxColour *WXUNUSED(col) ) const
+bool wxWindowDC::DoGetPixel( long WXUNUSED(x1), long WXUNUSED(y1), wxColour *WXUNUSED(col) ) const
{
- // TODO
+ wxFAIL_MSG("not implemented");
+
return FALSE;
-};
+}
-void wxWindowDC::DrawLine( long x1, long y1, long x2, long y2 )
+void wxWindowDC::DoDrawLine( long x1, long y1, long x2, long y2 )
{
- if (!Ok()) return;
-
+ wxCHECK_RET( Ok(), "invalid dc" );
+
int x1d, y1d, x2d, y2d;
-
+
// FreeGetPixelCache();
-
+
x1d = XLOG2DEV(x1);
y1d = YLOG2DEV(y1);
x2d = XLOG2DEV(x2);
y2d = YLOG2DEV(y2);
-
+
if (m_autoSetting)
SetPen (m_pen);
-
+
XDrawLine ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, x1d, y1d, x2d, y2d);
-
+
if (m_window && m_window->GetBackingPixmap())
- XDrawLine ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking,
+ XDrawLine ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking,
XLOG2DEV_2(x1), YLOG2DEV_2(y1),
XLOG2DEV_2(x2), YLOG2DEV_2(y2));
-
+
CalcBoundingBox(x1, y1);
CalcBoundingBox(x2, y2);
-};
+}
-void wxWindowDC::CrossHair( long x, long y )
+void wxWindowDC::DoCrossHair( long x, long y )
{
- if (!Ok()) return;
-
+ wxCHECK_RET( Ok(), "invalid dc" );
+
if (m_autoSetting)
SetPen (m_pen);
-
+
int xx = XLOG2DEV (x);
int yy = YLOG2DEV (y);
int ww, hh;
ww, yy);
XDrawLine ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xx, 0,
xx, hh);
-
+
if (m_window && m_window->GetBackingPixmap())
{
xx = XLOG2DEV_2 (x);
xx, 0,
xx, hh);
}
-};
+}
-void wxWindowDC::DrawArc( long x1, long y1, long x2, long y2, long xc, long yc )
+void wxWindowDC::DoDrawArc( long x1, long y1, long x2, long y2, long xc, long yc )
{
- if (!Ok()) return;
-
+ wxCHECK_RET( Ok(), "invalid dc" );
+
// FreeGetPixelCache();
-
+
int xx1 = XLOG2DEV (x1);
int yy1 = YLOG2DEV (y1);
int xx2 = XLOG2DEV (x2);
int yyc = YLOG2DEV (yc);
int xxc_2 = XLOG2DEV_2 (xc);
int yyc_2 = YLOG2DEV_2 (yc);
-
+
long dx = xx1 - xxc;
long dy = yy1 - yyc;
double radius = sqrt (dx * dx + dy * dy);
long r = (long) radius;
-
+
double radius1, radius2;
-
+
if (xx1 == xx2 && yy1 == yy2)
{
radius1 = 0.0;
radius1 = -90.0;
else
radius1 = -atan2 ((double) (yy1 - yyc), (double) (xx1 - xxc)) * 360.0 / (2 * M_PI);
-
+
if (xx2 - xxc == 0)
if (yy2 - yyc < 0)
radius2 = 90.0;
alpha2 += 360 * 64;
while (alpha2 > 360 * 64)
alpha2 -= 360 * 64;
-
+
if (m_brush.Ok() && m_brush.GetStyle () != wxTRANSPARENT)
{
SetBrush (m_brush);
XFillArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) (GC) m_gc,
xxc - r, yyc - r, 2 * r, 2 * r, alpha1, alpha2);
-
+
if (m_window && m_window->GetBackingPixmap())
XFillArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking,
xxc_2 - r, yyc_2 - r, 2 * r, 2 * r, alpha1, alpha2);
-
+
}
-
+
if (m_pen.Ok() && m_pen.GetStyle () != wxTRANSPARENT)
{
if (m_autoSetting)
SetPen (m_pen);
XDrawArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc,
xxc - r, yyc - r, 2 * r, 2 * r, alpha1, alpha2);
-
+
if (m_window && m_window->GetBackingPixmap())
XDrawArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking,
xxc_2 - r, yyc_2 - r, 2 * r, 2 * r, alpha1, alpha2);
}
CalcBoundingBox (x1, y1);
CalcBoundingBox (x2, y2);
-};
+}
-void wxWindowDC::DrawEllipticArc( long x, long y, long width, long height, double sa, double ea )
+void wxWindowDC::DoDrawEllipticArc( long x, long y, long width, long height, double sa, double ea )
{
- if (!Ok()) return;
-
+ wxCHECK_RET( Ok(), "invalid dc" );
+
int xd, yd, wd, hd;
-
+
xd = XLOG2DEV(x);
yd = YLOG2DEV(y);
wd = XLOG2DEVREL(width);
hd = YLOG2DEVREL(height);
-
+
if (sa>=360 || sa<=-360) sa=sa-int(sa/360)*360;
if (ea>=360 || ea<=-360) ea=ea-int(ea/360)*360;
int start = int(sa*64);
if (end <0) end +=360*64;
if (end>start) end-=start;
else end+=360*64-start;
-
+
if (m_brush.Ok() && m_brush.GetStyle () != wxTRANSPARENT)
{
m_autoSetting = TRUE; // must be reset
-
+
SetBrush (m_brush);
XFillArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd, wd, hd, start, end);
-
+
if (m_window && m_window->GetBackingPixmap())
XFillArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking,
XLOG2DEV_2 (x), YLOG2DEV_2 (y),wd,hd,start,end);
}
-
+
if (m_pen.Ok() && m_pen.GetStyle () != wxTRANSPARENT)
{
if (m_autoSetting)
}
CalcBoundingBox (x, y);
CalcBoundingBox (x + width, y + height);
-};
+}
-void wxWindowDC::DrawPoint( long x, long y )
+void wxWindowDC::DoDrawPoint( long x, long y )
{
- if (!Ok()) return;
-
+ wxCHECK_RET( Ok(), "invalid dc" );
+
// FreeGetPixelCache();
-
+
if (m_pen.Ok() && m_autoSetting)
SetPen (m_pen);
-
+
XDrawPoint ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, XLOG2DEV (x), YLOG2DEV (y));
if (m_window && m_window->GetBackingPixmap())
XDrawPoint ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, XLOG2DEV_2 (x), YLOG2DEV_2 (y));
-
+
CalcBoundingBox (x, y);
-};
+}
-void wxWindowDC::DrawLines( int n, wxPoint points[], long xoffset, long yoffset )
+void wxWindowDC::DoDrawLines( int n, wxPoint points[], long xoffset, long yoffset )
{
- if (!Ok()) return;
-
+ wxCHECK_RET( Ok(), "invalid dc" );
+
// FreeGetPixelCache();
-
+
if (m_pen.Ok() && m_pen.GetStyle () != wxTRANSPARENT)
{
if (m_autoSetting)
SetPen (m_pen);
-
+
XPoint *xpoints = new XPoint[n];
int i;
-
+
for (i = 0; i < n; i++)
{
xpoints[i].x = XLOG2DEV (points[i].x + xoffset);
xpoints[i].y = YLOG2DEV (points[i].y + yoffset);
}
XDrawLines ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xpoints, n, 0);
-
+
if (m_window && m_window->GetBackingPixmap())
{
for (i = 0; i < n; i++)
}
delete[]xpoints;
}
-};
+}
-void wxWindowDC::DrawLines( wxList *list, long xoffset, long yoffset )
+void wxWindowDC::DoDrawPolygon( int n, wxPoint points[],
+ long xoffset, long yoffset, int fillStyle )
{
- if (!Ok()) return;
-
- if (m_pen.GetStyle() == wxTRANSPARENT) return;
-
- int n = list->Number();
- wxPoint *points = new wxPoint[n];
-
- int i = 0;
- for(wxNode *node = list->First(); node; node = node->Next()) {
- wxPoint *point = (wxPoint *)node->Data();
- points[i].x = point->x;
- points[i++].y = point->y;
- }
- DrawLines(n, points, xoffset, yoffset);
- delete []points;
-};
+ wxCHECK_RET( Ok(), "invalid dc" );
-void wxWindowDC::DrawPolygon( int n, wxPoint points[],
- long xoffset, long yoffset, int fillStyle )
-{
// FreeGetPixelCache();
-
+
XPoint *xpoints1 = new XPoint[n + 1];
XPoint *xpoints2 = new XPoint[n + 1];
int i;
xpoints2[i].y = YLOG2DEV_2 (points[i].y + yoffset);
CalcBoundingBox (points[i].x + xoffset, points[i].y + yoffset);
}
-
+
// Close figure for XDrawLines (not needed for XFillPolygon)
xpoints1[i].x = xpoints1[0].x;
xpoints1[i].y = xpoints1[0].y;
xpoints2[i].x = xpoints2[0].x;
xpoints2[i].y = xpoints2[0].y;
-
+
if (m_brush.Ok() && m_brush.GetStyle () != wxTRANSPARENT)
{
SetBrush (m_brush);
XSetFillRule ((Display*) m_display,(GC) m_gcBacking, EvenOddRule); // default mode
}
}
-
+
if (m_pen.Ok() && m_pen.GetStyle () != wxTRANSPARENT)
{
if (m_autoSetting)
SetPen (m_pen);
XDrawLines ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xpoints1, n + 1, 0);
-
+
if (m_window && m_window->GetBackingPixmap())
XDrawLines ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, xpoints2, n + 1, 0);
}
-
+
delete[]xpoints1;
delete[]xpoints2;
-};
+}
-void wxWindowDC::DrawPolygon( wxList *list, long xoffset,
- long yoffset, int fillStyle )
+void wxWindowDC::DoDrawRectangle( long x, long y, long width, long height )
{
- if (!Ok()) return;
-
- int n = list->Number();
- wxPoint *points = new wxPoint[n];
-
- int i = 0;
- for(wxNode *node = list->First(); node; node = node->Next()) {
- wxPoint *point = (wxPoint *)node->Data();
- points[i].x = point->x;
- points[i++].y = point->y;
- }
- DrawPolygon(n, points, xoffset, yoffset,fillStyle);
- delete[] points;
-};
+ wxCHECK_RET( Ok(), "invalid dc" );
-void wxWindowDC::DrawRectangle( long x, long y, long width, long height )
-{
- if (!Ok()) return;
-
// FreeGetPixelCache();
-
+
int xd, yd, wfd, hfd, wd, hd;
-
+
xd = XLOG2DEV(x);
yd = YLOG2DEV(y);
wfd = XLOG2DEVREL(width);
wd = wfd - WX_GC_CF;
hfd = YLOG2DEVREL(height);
hd = hfd - WX_GC_CF;
-
+
if (wfd == 0 || hfd == 0) return;
if (wd < 0) { wd = - wd; xd = xd - wd; }
if (hd < 0) { hd = - hd; yd = yd - hd; }
-
+
if (m_brush.Ok() && m_brush.GetStyle () != wxTRANSPARENT)
{
SetBrush (m_brush);
XFillRectangle ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd, wfd, hfd);
-
+
if (m_window && m_window->GetBackingPixmap())
XFillRectangle ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
XLOG2DEV_2 (x), YLOG2DEV_2 (y),
wfd, hfd);
}
-
+
if (m_pen.Ok() && m_pen.GetStyle () != wxTRANSPARENT)
{
if (m_autoSetting)
SetPen (m_pen);
XDrawRectangle ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd, wd, hd);
-
+
if (m_window && m_window->GetBackingPixmap())
XDrawRectangle ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
XLOG2DEV_2 (x), YLOG2DEV_2 (y),
}
CalcBoundingBox (x, y);
CalcBoundingBox (x + width, y + height);
-};
+}
-void wxWindowDC::DrawRoundedRectangle( long x, long y, long width, long height, double radius )
+void wxWindowDC::DoDrawRoundedRectangle( long x, long y, long width, long height, double radius )
{
- if (!Ok()) return;
-
+ wxCHECK_RET( Ok(), "invalid dc" );
+
// FreeGetPixelCache();
-
+
// If radius is negative, it's a proportion of the smaller dimension.
-
+
if (radius < 0.0) radius = - radius * ((width < height) ? width : height);
-
+
int xd = XLOG2DEV (x);
int yd = YLOG2DEV (y);
int rd = XLOG2DEVREL ((long) radius);
int wd = XLOG2DEVREL (width) - WX_GC_CF;
int hd = YLOG2DEVREL (height) - WX_GC_CF;
-
+
int rw_d = rd * 2;
int rh_d = rw_d;
-
+
// If radius is zero use DrawRectangle() instead to avoid
// X drawing errors with small radii
if (rd == 0)
DrawRectangle( x, y, width, height );
return;
}
-
+
// Draw nothing if transformed w or h is 0
if (wd == 0 || hd == 0) return;
-
+
// CMB: adjust size if outline is drawn otherwise the result is
// 1 pixel too wide and high
if (m_pen.GetStyle() != wxTRANSPARENT)
wd--;
hd--;
}
-
+
// CMB: ensure dd is not larger than rectangle otherwise we
// get an hour glass shape
if (rw_d > wd) rw_d = wd;
if (rw_d > hd) rw_d = hd;
rd = rw_d / 2;
-
+
// For backing pixmap
int xd2 = XLOG2DEV_2 (x);
int yd2 = YLOG2DEV_2 (y);
int rd2 = XLOG2DEVREL ((long) radius);
int wd2 = XLOG2DEVREL (width) ;
int hd2 = YLOG2DEVREL (height) ;
-
+
int rw_d2 = rd2 * 2;
int rh_d2 = rw_d2;
-
+
if (m_brush.Ok() && m_brush.GetStyle () != wxTRANSPARENT)
{
SetBrush (m_brush);
-
+
XFillRectangle ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd + rd, yd,
wd - rw_d, hd);
XFillRectangle ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd + rd,
wd, hd - rh_d);
-
+
// Arcs start from 3 o'clock, positive angles anticlockwise
// Top-left
XFillArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd,
// Bottom-left
XFillArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd + hd - rh_d,
rw_d, rh_d, 180 * 64, 90 * 64);
-
+
if (m_window && m_window->GetBackingPixmap())
{
XFillRectangle ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
xd2 + rd2, yd2, wd2 - rw_d2, hd2);
XFillRectangle ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
xd2, yd2 + rd2, wd2, hd2 - rh_d2);
-
+
XFillArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
xd2, yd2, rw_d2, rh_d2, 90 * 64, 90 * 64);
XFillArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
rw_d2, rh_d2, 180 * 64, 90 * 64);
}
}
-
+
if (m_pen.Ok() && m_pen.GetStyle () != wxTRANSPARENT)
{
SetPen (m_pen);
xd + wd - rd + 1, yd);
XDrawLine ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd + rd, yd + hd,
xd + wd - rd, yd + hd);
-
+
XDrawLine ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd + rd,
xd, yd + hd - rd);
XDrawLine ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd + wd, yd + rd,
rw_d, rh_d, 269 * 64, 92 * 64);
XDrawArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd + hd - rh_d,
rw_d, rh_d, 180 * 64, 90 * 64);
-
+
if (m_window && m_window->GetBackingPixmap())
{
XDrawLine ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
XDrawLine ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
xd2 + rd2, yd2 + hd2,
xd2 + wd2 - rd2, yd2 + hd2);
-
+
XDrawLine ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
xd2, yd2 + rd2,
xd2, yd2 + hd2 - rd2);
}
CalcBoundingBox (x, y);
CalcBoundingBox (x + width, y + height);
-
-
-};
-void wxWindowDC::DrawEllipse( long x, long y, long width, long height )
+
+}
+
+void wxWindowDC::DoDrawEllipse( long x, long y, long width, long height )
{
- if (!Ok()) return;
-
+ wxCHECK_RET( Ok(), "invalid dc" );
+
// Check for negative width and height
if (height < 0)
{
y = y + height;
height = - height ;
}
-
+
if (width < 0)
{
x = x + width;
width = - width ;
}
-
+
// FreeGetPixelCache();
-
+
static const int angle = 23040;
-
+
int xd, yd, wd, hd;
-
+
xd = XLOG2DEV(x);
yd = YLOG2DEV(y);
wd = XLOG2DEVREL(width) ;
hd = YLOG2DEVREL(height) ;
-
+
if (m_brush.Ok() && m_brush.GetStyle () != wxTRANSPARENT)
{
SetBrush (m_brush);
XLOG2DEVREL (width) - WX_GC_CF,
YLOG2DEVREL (height) - WX_GC_CF, 0, angle);
}
-
+
if (m_pen.Ok() && m_pen.GetStyle () != wxTRANSPARENT)
{
if (m_autoSetting)
}
CalcBoundingBox (x, y);
CalcBoundingBox (x + width, y + height);
-
-};
-bool wxWindowDC::CanDrawBitmap(void) const
-{
- return TRUE;
-};
-
-/* Used when copying between drawables on different (Display*) m_displays.
-Not very fast, but better than giving up.
-*/
+}
-static void XCopyRemote(Display *src_display, Display *dest_display,
- Drawable src, Drawable dest,
- GC destgc,
- int srcx, int srcy,
- unsigned int w, unsigned int h,
- int destx, int desty,
- bool more, XImage **cache)
+bool wxWindowDC::CanDrawBitmap() const
{
- XImage *image, *destimage;
- Colormap destcm, srccm;
-#define CACHE_SIZE 256
- unsigned int i, j;
- unsigned long cachesrc[CACHE_SIZE], cachedest[CACHE_SIZE];
- int k, cache_pos, all_cache;
-
- if (!cache || !*cache)
- image = XGetImage(src_display, src, srcx, srcy, w, h, AllPlanes, ZPixmap);
- else
- image = *cache;
-
- destimage = XGetImage(dest_display, dest, destx, desty, w, h, AllPlanes, ZPixmap);
-
- srccm = (Colormap) wxTheApp->GetMainColormap((WXDisplay*) src_display);
- destcm = (Colormap) wxTheApp->GetMainColormap((WXDisplay*) dest_display);
-
- cache_pos = 0;
- all_cache = FALSE;
-
- for (i = 0; i < w; i++)
- for (j = 0; j < h; j++) {
- unsigned long pixel;
- XColor xcol;
-
- pixel = XGetPixel(image, i, j);
- for (k = cache_pos; k--; )
- if (cachesrc[k] == pixel) {
- pixel = cachedest[k];
- goto install;
- }
- if (all_cache)
- for (k = CACHE_SIZE; k-- > cache_pos; )
- if (cachesrc[k] == pixel) {
- pixel = cachedest[k];
- goto install;
- }
-
- cachesrc[cache_pos] = xcol.pixel = pixel;
- XQueryColor(src_display, srccm, &xcol);
- if (!XAllocColor(dest_display, destcm, &xcol))
- xcol.pixel = 0;
- cachedest[cache_pos] = pixel = xcol.pixel;
-
- if (++cache_pos >= CACHE_SIZE) {
- cache_pos = 0;
- all_cache = TRUE;
- }
-
-install:
- XPutPixel(destimage, i, j, pixel);
- }
-
- XPutImage(dest_display, dest, destgc, destimage, 0, 0, destx, desty, w, h);
- XDestroyImage(destimage);
-
- if (more)
- *cache = image;
- else
- XDestroyImage(image);
+ wxCHECK_MSG( Ok(), FALSE, "invalid dc" );
+
+ return TRUE;
}
-void wxWindowDC::DrawIcon( const wxIcon &icon, long x, long y)
-{
- if (!Ok()) return;
-
- if (!icon.Ok()) return;
-
- DrawBitmap(icon, x, y, TRUE);
-
#if 0
+void wxWindowDC::DoDrawIcon( const wxIcon &icon, long x, long y)
+{
// FreeGetPixelCache();
-
+
// Be sure that foreground pixels (1) of
// the Icon will be painted with pen colour. [m_pen.SetColour()]
// Background pixels (0) will be painted with
// last selected background color. [::SetBackground]
if (m_pen.Ok() && m_autoSetting)
SetPen (m_pen);
-
+
int width, height;
Pixmap iconPixmap = (Pixmap) icon.GetPixmap();
width = icon.GetWidth();
0, 0, width, height,
(int) XLOG2DEV (x), (int) YLOG2DEV (y));
}
-
-
+
+
if (m_window && m_window->GetBackingPixmap())
{
if (icon.GetDepth() <= 1)
(int) XLOG2DEV (x), (int) YLOG2DEV (y), FALSE, &cache);
}
CalcBoundingBox (x, y);
-#endif
-};
+}
+#endif // 0
// TODO: use scaled Blit e.g. as per John Price's implementation in Contrib/Utilities
-bool wxWindowDC::Blit( long xdest, long ydest, long width, long height,
- wxDC *source, long xsrc, long ysrc, int rop, bool useMask )
+bool wxWindowDC::DoBlit( long xdest, long ydest, long width, long height,
+ wxDC *source, long xsrc, long ysrc, int rop, bool useMask )
{
- if (!Ok()) return FALSE;
-
- wxASSERT_MSG( (source->IsKindOf(CLASSINFO(wxWindowDC))), "Blit source DC must be wxWindowDC or derived class." );
-
- wxWindowDC* sourceDC = (wxWindowDC*) source;
-
+ wxCHECK_MSG( Ok(), FALSE, "invalid dc" );
+
+ wxWindowDC* sourceDC = wxDynamicCast(source, wxWindowDC);
+
+ wxASSERT_MSG( sourceDC, "Blit source DC must be wxWindowDC or derived class." );
+
// FreeGetPixelCache();
-
- // Be sure that foreground pixels (1) of
- // the Icon will be painted with pen colour. [m_pen.SetColour()]
- // Background pixels (0) will be painted with
+
+ // Be sure that foreground pixels (1) of the Icon will be painted with pen
+ // colour. [m_pen.SetColour()] Background pixels (0) will be painted with
// last selected background color. [::SetBackground]
if (m_pen.Ok() && m_autoSetting)
SetPen (m_pen);
{
int scaledW = (int) (bitmap.GetWidth() * scaleX);
int scaledH = (int) (bitmap.GetHeight() * scaleY);
-
+
image = image.Scale(scaledW, scaledH);
scaledBitmap = new wxBitmap(image.ConvertToBitmap());
sourcePixmap = (Pixmap) scaledBitmap->GetPixmap();
- }
+ }
}
else
sourcePixmap = (Pixmap) sourceDC->m_pixmap;
{
/* MATTHEW: [9] */
int orig = m_logicalFunction;
-
+
SetLogicalFunction (rop);
-
+
if (m_display != sourceDC->m_display)
{
XImage *cache = NULL;
-
+
if (m_window && m_window->GetBackingPixmap())
XCopyRemote((Display*) sourceDC->m_display, (Display*) m_display,
(Pixmap) sourcePixmap, (Pixmap) m_window->GetBackingPixmap(),
source->LogicalToDeviceYRel(height),
XLOG2DEV_2 (xdest), YLOG2DEV_2 (ydest),
TRUE, &cache);
-
+
if ( useMask && source->IsKindOf(CLASSINFO(wxMemoryDC)) )
{
wxMemoryDC *memDC = (wxMemoryDC *)source;
XSetClipOrigin ((Display*) m_display, (GC) m_gc, XLOG2DEV (xdest), YLOG2DEV (ydest));
}
}
-
+
XCopyRemote((Display*) sourceDC->m_display, (Display*) m_display, (Pixmap) sourcePixmap, (Pixmap) m_pixmap, (GC) m_gc,
source->LogicalToDeviceX (xsrc),
source->LogicalToDeviceY (ysrc),
source->LogicalToDeviceYRel(height),
XLOG2DEV (xdest), YLOG2DEV (ydest),
FALSE, &cache);
-
+
if ( useMask )
{
XSetClipMask ((Display*) m_display, (GC) m_gc, None);
XSetClipOrigin ((Display*) m_display, (GC) m_gc, 0, 0);
}
-
+
} else
{
if (m_window && m_window->GetBackingPixmap())
XSetClipOrigin ((Display*) m_display, (GC) m_gc, XLOG2DEV (xdest), YLOG2DEV (ydest));
}
}
-
+
// Check if we're copying from a mono bitmap
if (source->IsKindOf(CLASSINFO(wxMemoryDC)) &&
((wxMemoryDC*)source)->GetBitmap().Ok() && (((wxMemoryDC*)source)->GetBitmap().GetDepth () == 1))
source->LogicalToDeviceXRel(width),
source->LogicalToDeviceYRel(height),
XLOG2DEV (xdest), YLOG2DEV (ydest));
-
+
}
if ( useMask )
{
XSetClipMask ((Display*) m_display, (GC) m_gc, None);
XSetClipOrigin ((Display*) m_display, (GC) m_gc, 0, 0);
}
-
+
} /* Remote/local (Display*) m_display */
CalcBoundingBox (xdest, ydest);
CalcBoundingBox (xdest + width, ydest + height);
-
+
SetLogicalFunction(orig);
if (scaledBitmap) delete scaledBitmap;
-
+
return TRUE;
}
if (scaledBitmap) delete scaledBitmap;
return FALSE;
-};
-
-/* Helper function for 16-bit fonts */
-static int str16len(const char *s)
-{
- int count = 0;
-
- while (s[0] && s[1]) {
- count++;
- s += 2;
- }
-
- return count;
}
-void wxWindowDC::DrawText( const wxString &text, long x, long y, bool use16 )
+void wxWindowDC::DoDrawText( const wxString &text, long x, long y )
{
- if (!Ok()) return;
-
- // Since X draws from the baseline of the text, must
- // add the text height
+ wxCHECK_RET( Ok(), "invalid dc" );
+
+ // Since X draws from the baseline of the text, must add the text height
int cx = 0;
int cy = 0;
int ascent = 0;
int slen;
-
- if (use16)
- slen = str16len(text);
- else
- slen = strlen(text);
-
+
+ slen = strlen(text);
+
if (m_font.Ok())
{
WXFontStructPtr pFontStruct = m_font.GetFontStruct(m_userScaleY*m_logicalScaleY, m_display);
int direction, descent;
XCharStruct overall_return;
+#if 0
if (use16)
(void)XTextExtents16((XFontStruct*) pFontStruct, (XChar2b *)(const char*) text, slen, &direction,
&ascent, &descent, &overall_return);
else
+#endif // 0
(void)XTextExtents((XFontStruct*) pFontStruct, (char*) (const char*) text, slen, &direction,
- &ascent, &descent, &overall_return);
+ &ascent, &descent, &overall_return);
+
cx = overall_return.width;
cy = ascent + descent;
}
-
- // First draw a rectangle representing the text background,
- // if a text background is specified
+
+ // First draw a rectangle representing the text background, if a text
+ // background is specified
if (m_textBackgroundColour.Ok () && (m_backgroundMode != wxTRANSPARENT))
{
wxColour oldPenColour = m_currentColour;
(oldPenColour.Red () == m_textBackgroundColour.Red ()) &&
(oldPenColour.Blue () == m_textBackgroundColour.Blue ()) &&
(oldPenColour.Green () == m_textBackgroundColour.Green ()));
-
+
// This separation of the big && test required for gcc2.7/HP UX 9.02
// or pixel value can be corrupted!
sameColour = (sameColour &&
(oldPenColour.GetPixel() == m_textBackgroundColour.GetPixel()));
-
+
if (!sameColour || !GetOptimization())
{
int pixel = m_textBackgroundColour.AllocColour(m_display);
m_currentColour = m_textBackgroundColour;
-
+
// Set the GC to the required colour
if (pixel > -1)
{
}
else
m_textBackgroundColour = oldPenColour ;
-
+
XFillRectangle ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, XLOG2DEV (x), YLOG2DEV (y), cx, cy);
if (m_window && m_window->GetBackingPixmap())
XFillRectangle ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
XLOG2DEV_2 (x), YLOG2DEV_2 (y), cx, cy);
}
-
+
// Now set the text foreground and draw the text
if (m_textForegroundColour.Ok ())
{
(oldPenColour.Blue () == m_currentColour.Blue ()) &&
(oldPenColour.Green () == m_currentColour.Green ()) &&
(oldPenColour.GetPixel() == m_currentColour.GetPixel()));
-
+
if (!sameColour || !GetOptimization())
{
int pixel = -1;
pixel = m_textForegroundColour.AllocColour((Display*) m_display);
m_currentColour.SetPixel(pixel);
}
-
+
// Set the GC to the required colour
if (pixel > -1)
{
else
m_textForegroundColour = oldPenColour;
}
-
- // We need to add the ascent, not the whole height, since X draws
- // at the point above the descender.
+
+ // We need to add the ascent, not the whole height, since X draws at the
+ // point above the descender.
+#if 0
if (use16)
- XDrawString16((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, XLOG2DEV (x), YLOG2DEV (y) + ascent,
+ XDrawString16((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, XLOG2DEV (x), YLOG2DEV (y) + ascent,
(XChar2b *)(char*) (const char*) text, slen);
else
- XDrawString((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, XLOG2DEV (x), YLOG2DEV (y) + ascent,
- text, slen);
-
+#endif // 0
+ XDrawString((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, XLOG2DEV (x), YLOG2DEV (y) + ascent, text, slen);
+
if (m_window && m_window->GetBackingPixmap()) {
+#if 0
if (use16)
XDrawString16((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking,
XLOG2DEV_2 (x), YLOG2DEV_2 (y) + ascent,
(XChar2b *)(char*) (const char*) text, slen);
else
+#endif // 0
XDrawString((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking,
XLOG2DEV_2 (x), YLOG2DEV_2 (y) + ascent, (char*) (const char*) text, slen);
}
-
+
long w, h;
GetTextExtent (text, &w, &h);
CalcBoundingBox (x + w, y + h);
CalcBoundingBox (x, y);
-};
+}
-bool wxWindowDC::CanGetTextExtent(void) const
+bool wxWindowDC::CanGetTextExtent() const
{
return TRUE;
-};
+}
void wxWindowDC::GetTextExtent( const wxString &string, long *width, long *height,
- long *descent, long *externalLeading,
- wxFont *font, bool use16 )
+ long *descent, long *externalLeading,
+ wxFont *font ) const
{
- if (!Ok()) return;
-
+ wxCHECK_RET( Ok(), "invalid dc" );
+
wxFont* theFont = font;
if (!theFont)
- theFont = & m_font;
-
+ theFont = (wxFont *)&m_font; // const_cast
+
if (!theFont->Ok())
{
// TODO: this should be an error log function
wxFAIL_MSG("set a valid font before calling GetTextExtent!");
-
+
*width = -1;
*height = -1;
return;
}
-
+
WXFontStructPtr pFontStruct = theFont->GetFontStruct(m_userScaleY*m_logicalScaleY, m_display);
-
+
int direction, ascent, descent2;
XCharStruct overall;
int slen;
-
- if (use16) slen = str16len(string); else slen = strlen(string);
-
+
+#if 0
+ if (use16)
+ slen = str16len(string);
+ else
+#endif // 0
+ slen = strlen(string);
+
+#if 0
if (use16)
XTextExtents16((XFontStruct*) pFontStruct, (XChar2b *) (char*) (const char*) string, slen, &direction,
&ascent, &descent2, &overall);
else
+#endif // 0
XTextExtents((XFontStruct*) pFontStruct, (char*) (const char*) string, slen, &direction,
&ascent, &descent2, &overall);
-
+
*width = XDEV2LOGREL (overall.width);
*height = YDEV2LOGREL (ascent + descent2);
if (descent)
*descent = descent2;
if (externalLeading)
*externalLeading = 0;
-};
+}
-long wxWindowDC::GetCharWidth(void)
+long wxWindowDC::GetCharWidth() const
{
- if (!Ok()) return 0;
-
- if (!m_font.Ok())
- return 0;
-
+ wxCHECK_MSG( Ok(), 0, "invalid dc" );
+ wxCHECK_MSG( m_font.Ok(), 0, "invalid font" );
+
WXFontStructPtr pFontStruct = m_font.GetFontStruct(m_userScaleY * m_logicalScaleY, m_display);
-
+
int direction, ascent, descent;
XCharStruct overall;
XTextExtents ((XFontStruct*) pFontStruct, "x", 1, &direction, &ascent,
&descent, &overall);
return XDEV2LOGREL(overall.width);
-};
+}
-long wxWindowDC::GetCharHeight(void)
+long wxWindowDC::GetCharHeight() const
{
- if (!Ok()) return 0;
-
- if (!m_font.Ok())
- return 0;
-
+ wxCHECK_MSG( Ok(), 0, "invalid dc" );
+ wxCHECK_MSG( m_font.Ok(), 0, "invalid font" );
+
WXFontStructPtr pFontStruct = m_font.GetFontStruct(m_userScaleY*m_logicalScaleY, m_display);
-
+
int direction, ascent, descent;
XCharStruct overall;
XTextExtents ((XFontStruct*) pFontStruct, "x", 1, &direction, &ascent,
&descent, &overall);
// return XDEV2LOGREL(overall.ascent + overall.descent);
return XDEV2LOGREL(ascent + descent);
-};
+}
-void wxWindowDC::Clear(void)
+void wxWindowDC::Clear()
{
- if (!Ok()) return;
-
+ wxCHECK_RET( Ok(), "invalid dc" );
+
int w, h;
if (m_window)
{
m_window->GetSize(&w, &h);
-
+
if (m_window && m_window->GetBackingPixmap())
{
w = m_window->GetPixmapWidth();
else
return;
}
-
+
wxBrush saveBrush = m_brush;
SetBrush (m_backgroundBrush);
-
+
XFillRectangle ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, 0, 0, w, h);
-
+
if (m_window && m_window->GetBackingPixmap())
XFillRectangle ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, 0, 0, w, h);
-
+
m_brush = saveBrush;
-};
+}
void wxWindowDC::Clear(const wxRect& rect)
{
- if (!Ok()) return;
-
+ wxCHECK_RET( Ok(), "invalid dc" );
+
int x = rect.x; int y = rect.y;
int w = rect.width; int h = rect.height;
-
+
wxBrush saveBrush = m_brush;
SetBrush (m_backgroundBrush);
-
+
XFillRectangle ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, x, y, w, h);
-
+
if (m_window && m_window->GetBackingPixmap())
XFillRectangle ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, x, y, w, h);
-
+
m_brush = saveBrush;
-};
+}
void wxWindowDC::SetFont( const wxFont &font )
{
- if (!Ok()) return;
-
+ wxCHECK_RET( Ok(), "invalid dc" );
+
m_font = font;
-
+
if (!m_font.Ok())
{
if ((m_oldFont != (WXFont) 0) && ((long) m_oldFont != -1))
{
XSetFont ((Display*) m_display, (GC) m_gc, (Font) m_oldFont);
-
+
if (m_window && m_window->GetBackingPixmap())
XSetFont ((Display*) m_display,(GC) m_gcBacking, (Font) m_oldFont);
}
return;
}
-
+
WXFontStructPtr pFontStruct = m_font.GetFontStruct(m_userScaleY*m_logicalScaleY, m_display);
-
+
Font fontId = ((XFontStruct*)pFontStruct)->fid;
XSetFont ((Display*) m_display, (GC) m_gc, fontId);
-
+
if (m_window && m_window->GetBackingPixmap())
XSetFont ((Display*) m_display,(GC) m_gcBacking, fontId);
-};
+}
void wxWindowDC::SetPen( const wxPen &pen )
{
- if (!Ok()) return;
-
+ wxCHECK_RET( Ok(), "invalid dc" );
+
m_pen = pen;
if (!m_pen.Ok())
return;
-
+
wxBitmap oldStipple = m_currentStipple;
int oldStyle = m_currentStyle;
int oldFill = m_currentFill;
int old_pen_cap = m_currentPenCap;
int old_pen_nb_dash = m_currentPenDashCount;
char *old_pen_dash = m_currentPenDash;
-
+
wxColour oldPenColour = m_currentColour;
m_currentColour = m_pen.GetColour ();
m_currentStyle = m_pen.GetStyle ();
m_currentPenCap = m_pen.GetCap ();
m_currentPenDashCount = m_pen.GetDashCount();
m_currentPenDash = m_pen.GetDash();
-
+
if (m_currentStyle == wxSTIPPLE)
m_currentStipple = * m_pen.GetStipple ();
-
+
bool sameStyle = (oldStyle == m_currentStyle &&
oldFill == m_currentFill &&
old_pen_join == m_currentPenJoin &&
old_pen_nb_dash == m_currentPenDashCount &&
old_pen_dash == m_currentPenDash &&
old_pen_width == m_currentPenWidth);
-
+
bool sameColour = (oldPenColour.Ok () &&
(oldPenColour.Red () == m_currentColour.Red ()) &&
(oldPenColour.Blue () == m_currentColour.Blue ()) &&
(oldPenColour.Green () == m_currentColour.Green ()) &&
(oldPenColour.GetPixel() == m_currentColour.GetPixel()));
-
+
if (!sameStyle || !GetOptimization())
{
int scaled_width = (int) XLOG2DEVREL (m_pen.GetWidth ());
if (scaled_width < 0)
scaled_width = 0;
-
+
int style;
int join;
int cap;
- static char dotted[] =
- {2, 5};
- static char short_dashed[] =
- {4, 4};
- static char long_dashed[] =
- {4, 8};
- static char dotted_dashed[] =
- {6, 6, 2, 6};
-
+ const static char dotted[] = {2, 5};
+ const static char short_dashed[] = {4, 4};
+ const static char long_dashed[] = {4, 8};
+ const static char dotted_dashed[] = {6, 6, 2, 6};
+
// We express dash pattern in pen width unit, so we are
// independent of zoom factor and so on...
int req_nb_dash;
- char *req_dash;
-
+ const char *req_dash;
+
switch (m_pen.GetStyle ())
{
case wxUSER_DASH:
req_dash = NULL;
req_nb_dash = 0;
}
-
+
if (req_dash && req_nb_dash)
{
char *real_req_dash = new char[req_nb_dash];
for (int i = 0; i < req_nb_dash; i++)
real_req_dash[i] = req_dash[i] * factor;
XSetDashes ((Display*) m_display, (GC) m_gc, 0, real_req_dash, req_nb_dash);
-
+
if (m_window && m_window->GetBackingPixmap())
XSetDashes ((Display*) m_display,(GC) m_gcBacking, 0, real_req_dash, req_nb_dash);
delete[]real_req_dash;
{
// No Memory. We use non-scaled dash pattern...
XSetDashes ((Display*) m_display, (GC) m_gc, 0, req_dash, req_nb_dash);
-
+
if (m_window && m_window->GetBackingPixmap())
XSetDashes ((Display*) m_display,(GC) m_gcBacking, 0, req_dash, req_nb_dash);
}
}
-
+
switch (m_pen.GetCap ())
{
case wxCAP_PROJECTING:
cap = (scaled_width <= 1) ? CapNotLast : CapRound;
break;
}
-
+
switch (m_pen.GetJoin ())
{
case wxJOIN_BEVEL:
join = JoinRound;
break;
}
-
+
XSetLineAttributes ((Display*) m_display, (GC) m_gc, scaled_width, style, cap, join);
-
+
if (m_window && m_window->GetBackingPixmap())
XSetLineAttributes ((Display*) m_display,(GC) m_gcBacking, scaled_width, style, cap, join);
}
-
+
if (IS_HATCH(m_currentFill) && ((m_currentFill != oldFill) || !GetOptimization()))
{
Pixmap myStipple;
-
+
oldStipple = wxNullBitmap; // For later reset!!
-
+
switch (m_currentFill)
{
case wxBDIAGONAL_HATCH:
break;
}
XSetStipple ((Display*) m_display, (GC) m_gc, myStipple);
-
+
if (m_window && m_window->GetBackingPixmap())
XSetStipple ((Display*) m_display,(GC) m_gcBacking, myStipple);
}
&& ((m_currentStipple != oldStipple) || !GetOptimization()))
{
XSetStipple ((Display*) m_display, (GC) m_gc, (Pixmap) m_currentStipple.GetPixmap());
-
+
if (m_window && m_window->GetBackingPixmap())
XSetStipple ((Display*) m_display,(GC) m_gcBacking, (Pixmap) m_currentStipple.GetPixmap());
}
-
+
if ((m_currentFill != oldFill) || !GetOptimization())
{
int fill_style;
-
+
if (m_currentFill == wxSTIPPLE)
fill_style = FillStippled;
else if (IS_HATCH (m_currentFill))
if (m_window && m_window->GetBackingPixmap())
XSetFillStyle ((Display*) m_display,(GC) m_gcBacking, fill_style);
}
-
+
// must test m_logicalFunction, because it involves background!
if (!sameColour || !GetOptimization()
|| ((m_logicalFunction == wxXOR) || (m_autoSetting & 0x2)))
pixel = m_pen.GetColour ().AllocColour(m_display);
m_currentColour.SetPixel(pixel);
}
-
+
// Finally, set the GC to the required colour
if (pixel > -1)
{
}
else
m_pen.GetColour().SetPixel(oldPenColour.GetPixel());
-
+
m_autoSetting = 0;
-};
+}
void wxWindowDC::SetBrush( const wxBrush &brush )
{
- if (!Ok()) return;
-
+ wxCHECK_RET( Ok(), "invalid dc" );
+
m_brush = brush;
-
+
if (!m_brush.Ok() || m_brush.GetStyle () == wxTRANSPARENT)
return;
-
+
int oldFill = m_currentFill;
wxBitmap oldStipple = m_currentStipple;
-
+
m_autoSetting |= 0x1;
-
+
m_currentFill = m_brush.GetStyle ();
if (m_currentFill == wxSTIPPLE)
m_currentStipple = * m_brush.GetStipple ();
-
+
wxColour oldBrushColour(m_currentColour);
m_currentColour = m_brush.GetColour ();
-
+
bool sameColour = (oldBrushColour.Ok () &&
(oldBrushColour.Red () == m_currentColour.Red ()) &&
(oldBrushColour.Blue () == m_currentColour.Blue ()) &&
(oldBrushColour.Green () == m_currentColour.Green ()) &&
(oldBrushColour.GetPixel() == m_currentColour.GetPixel()));
-
+
if ((oldFill != m_brush.GetStyle ()) || !GetOptimization())
{
switch (brush.GetStyle ())
XSetFillStyle ((Display*) m_display,(GC) m_gcBacking, FillSolid);
}
}
-
+
if (IS_HATCH(m_currentFill) && ((m_currentFill != oldFill) || !GetOptimization()))
{
Pixmap myStipple;
-
+
switch (m_currentFill)
{
case wxBDIAGONAL_HATCH:
break;
}
XSetStipple ((Display*) m_display, (GC) m_gc, myStipple);
-
+
if (m_window && m_window->GetBackingPixmap())
XSetStipple ((Display*) m_display,(GC) m_gcBacking, myStipple);
}
if (m_window && m_window->GetBackingPixmap())
XSetStipple ((Display*) m_display,(GC) m_gcBacking, (Pixmap) m_currentStipple.GetPixmap());
}
-
+
// must test m_logicalFunction, because it involves background!
if (!sameColour || !GetOptimization() || m_logicalFunction == wxXOR)
{
unsigned char red = m_brush.GetColour ().Red ();
unsigned char blue = m_brush.GetColour ().Blue ();
unsigned char green = m_brush.GetColour ().Green ();
-
+
if (red == (unsigned char) 0 && blue == (unsigned char) 0
&& green == (unsigned char) 0)
{
m_brush.GetColour().SetPixel(pixel);
m_currentColour.SetPixel(pixel);
}
-
+
// N.B. comment out the above line and uncomment the following lines
// if you want non-white colours to be black on a monochrome display.
/*
}
else
m_brush.GetColour().SetPixel(oldBrushColour.GetPixel());
-};
+}
void wxWindowDC::SetBackground( const wxBrush &brush )
{
- if (!Ok()) return;
-
+ wxCHECK_RET( Ok(), "invalid dc" );
+
m_backgroundBrush = brush;
-
+
if (!m_backgroundBrush.Ok())
return;
-
+
int pixel = m_backgroundBrush.GetColour().AllocColour(m_display);
// New behaviour, 10/2/99: setting the background brush of a DC
if (!this->IsKindOf(CLASSINFO(wxMemoryDC)))
XSetWindowBackground ((Display*) m_display, (Pixmap) m_pixmap, pixel);
*/
-
+
// Necessary for ::DrawIcon, which use fg/bg pixel or the GC.
// And Blit,... (Any fct that use XCopyPlane, in fact.)
XSetBackground ((Display*) m_display, (GC) m_gc, pixel);
if (m_window && m_window->GetBackingPixmap())
XSetBackground ((Display*) m_display,(GC) m_gcBacking, pixel);
-};
+}
void wxWindowDC::SetLogicalFunction( int function )
{
+ wxCHECK_RET( Ok(), "invalid dc" );
+
int x_function;
-
+
/* MATTHEW: [9] */
if (m_logicalFunction == function)
return;
-
+
switch (function)
{
case wxCLEAR:
x_function = GXcopy;
break;
}
-
+
XSetFunction((Display*) m_display, (GC) m_gc, x_function);
if (m_window && m_window->GetBackingPixmap())
XSetFunction((Display*) m_display, (GC) m_gcBacking, x_function);
-
+
if ((m_logicalFunction == wxXOR) != (function == wxXOR))
/* MATTHEW: [9] Need to redo pen simply */
m_autoSetting |= 0x2;
-
+
m_logicalFunction = function;
-
-};
+
+}
void wxWindowDC::SetTextForeground( const wxColour &col )
{
- if (!Ok()) return;
-
- if (m_textForegroundColour == col) return;
-
+ wxCHECK_RET( Ok(), "invalid dc" );
+
+ if (m_textForegroundColour == col)
+ return;
+
m_textForegroundColour = col;
-
-};
+
+}
void wxWindowDC::SetTextBackground( const wxColour &col )
{
- if (!Ok()) return;
-
- if (m_textBackgroundColour == col) return;
-
+ wxCHECK_RET( Ok(), "invalid dc" );
+
+ if (m_textBackgroundColour == col)
+ return;
+
m_textBackgroundColour = col;
- if (!m_textBackgroundColour.Ok()) return;
-};
+ if (!m_textBackgroundColour.Ok())
+ return;
+}
void wxWindowDC::SetBackgroundMode( int mode )
{
m_backgroundMode = mode;
-
-};
+}
void wxWindowDC::SetPalette( const wxPalette& palette )
{
XSetWindowColormap ((Display*) m_display, (Window) m_window->GetXWindow(),
(Colormap) wxTheApp->GetMainColormap(m_display));
}
-};
+}
// Helper function
-void wxWindowDC:: SetDCClipping ()
+void wxWindowDC::SetDCClipping()
{
// m_userRegion is the region set by calling SetClippingRegion
-
+
if (m_currentRegion)
XDestroyRegion ((Region) m_currentRegion);
-
+
// We need to take into account
// clipping imposed on a window by a repaint.
// We'll combine it with the user region. But for now,
m_currentRegion = (WXRegion) XCreateRegion ();
else
m_currentRegion = (WXRegion) NULL;
-
+
if ((m_window && m_window->GetUpdateRegion().Ok()) && m_userRegion)
XIntersectRegion ((Region) m_window->GetUpdateRegion().GetXRegion(), (Region) m_userRegion, (Region) m_currentRegion);
else if (m_userRegion)
XIntersectRegion ((Region) m_userRegion, (Region) m_userRegion, (Region) m_currentRegion);
else if (m_window && m_window->GetUpdateRegion().Ok())
- XIntersectRegion ((Region) m_window->GetUpdateRegion().GetXRegion(), (Region) m_window->GetUpdateRegion().GetXRegion(),
+ XIntersectRegion ((Region) m_window->GetUpdateRegion().GetXRegion(), (Region) m_window->GetUpdateRegion().GetXRegion(),
(Region) m_currentRegion);
-
+
if (m_currentRegion)
{
XSetRegion ((Display*) m_display, (GC) m_gc, (Region) m_currentRegion);
{
XSetClipMask ((Display*) m_display, (GC) m_gc, None);
}
-
+
}
-void wxWindowDC::SetClippingRegion( long x, long y, long width, long height )
+void wxWindowDC::DoSetClippingRegion( long x, long y, long width, long height )
{
wxDC::SetClippingRegion( x, y, width, height );
-
+
if (m_userRegion)
XDestroyRegion ((Region) m_userRegion);
m_userRegion = (WXRegion) XCreateRegion ();
r.width = XLOG2DEVREL(width);
r.height = YLOG2DEVREL(height);
XUnionRectWithRegion (&r, (Region) m_userRegion, (Region) m_userRegion);
-
+
SetDCClipping ();
-
+
// Needs to work differently for Pixmap: without this,
// there's a nasty (Display*) m_display bug. 8/12/94
if (m_window && m_window->GetBackingPixmap())
{
XRectangle rects[1];
- rects[0].x = XLOG2DEV_2(x);
+ rects[0].x = XLOG2DEV_2(x);
rects[0].y = YLOG2DEV_2(y);
rects[0].width = XLOG2DEVREL(width);
rects[0].height = YLOG2DEVREL(height);
XSetClipRectangles((Display*) m_display, (GC) m_gcBacking, 0, 0, rects, 1, Unsorted);
}
-};
+}
-void wxWindowDC::SetClippingRegion( const wxRegion& region )
+void wxWindowDC::DoSetClippingRegionAsRegion( const wxRegion& region )
{
wxRect box = region.GetBox();
-
+
wxDC::SetClippingRegion( box.x, box.y, box.width, box.height );
-
+
if (m_userRegion)
XDestroyRegion ((Region) m_userRegion);
m_userRegion = (WXRegion) XCreateRegion ();
-
+
XUnionRegion((Region) m_userRegion, (Region) region.GetXRegion(), (Region) m_userRegion);
-
+
SetDCClipping ();
-
+
// Needs to work differently for Pixmap: without this,
// there's a nasty (Display*) m_display bug. 8/12/94
if (m_window && m_window->GetBackingPixmap())
rects[0].height = YLOG2DEVREL(box.height);
XSetClipRectangles((Display*) m_display, (GC) m_gcBacking, 0, 0, rects, 1, Unsorted);
}
-};
+}
-void wxWindowDC::DestroyClippingRegion(void)
+void wxWindowDC::DestroyClippingRegion()
{
wxDC::DestroyClippingRegion();
-
+
if (m_userRegion)
XDestroyRegion ((Region) m_userRegion);
m_userRegion = NULL;
-
+
SetDCClipping ();
-
+
XGCValues gc_val;
gc_val.clip_mask = None;
if (m_window && m_window->GetBackingPixmap())
XChangeGC((Display*) m_display, (GC) m_gcBacking, GCClipMask, &gc_val);
-};
-
-// ----------------------------------- spline code ----------------------------------------
-
-void wx_quadratic_spline(double a1, double b1, double a2, double b2,
- double a3, double b3, double a4, double b4);
-void wx_clear_stack(void);
-int wx_spline_pop(double *x1, double *y1, double *x2, double *y2, double *x3,
- double *y3, double *x4, double *y4);
-void wx_spline_push(double x1, double y1, double x2, double y2, double x3, double y3,
- double x4, double y4);
-static bool wx_spline_add_point(double x, double y);
-static void wx_spline_draw_point_array(wxDC *dc);
-
-wxList wx_spline_point_list;
-
-#define half(z1, z2) ((z1+z2)/2.0)
-#define THRESHOLD 5
-
-/* iterative version */
-
-void wx_quadratic_spline(double a1, double b1, double a2, double b2, double a3, double b3, double a4,
- double b4)
-{
- register double xmid, ymid;
- double x1, y1, x2, y2, x3, y3, x4, y4;
-
- wx_clear_stack();
- wx_spline_push(a1, b1, a2, b2, a3, b3, a4, b4);
-
- while (wx_spline_pop(&x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4)) {
- xmid = (double)half(x2, x3);
- ymid = (double)half(y2, y3);
- if (fabs(x1 - xmid) < THRESHOLD && fabs(y1 - ymid) < THRESHOLD &&
- fabs(xmid - x4) < THRESHOLD && fabs(ymid - y4) < THRESHOLD) {
- wx_spline_add_point( x1, y1 );
- wx_spline_add_point( xmid, ymid );
- } else {
- wx_spline_push(xmid, ymid, (double)half(xmid, x3), (double)half(ymid, y3),
- (double)half(x3, x4), (double)half(y3, y4), x4, y4);
- wx_spline_push(x1, y1, (double)half(x1, x2), (double)half(y1, y2),
- (double)half(x2, xmid), (double)half(y2, ymid), xmid, ymid);
- }
- }
-}
-
-/* utilities used by spline drawing routines */
-
-typedef struct wx_spline_stack_struct {
- double x1, y1, x2, y2, x3, y3, x4, y4;
-} Stack;
-
-#define SPLINE_STACK_DEPTH 20
-static Stack wx_spline_stack[SPLINE_STACK_DEPTH];
-static Stack *wx_stack_top;
-static int wx_stack_count;
-
-void wx_clear_stack(void)
-{
- wx_stack_top = wx_spline_stack;
- wx_stack_count = 0;
-}
-
-void wx_spline_push(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
-{
- wx_stack_top->x1 = x1;
- wx_stack_top->y1 = y1;
- wx_stack_top->x2 = x2;
- wx_stack_top->y2 = y2;
- wx_stack_top->x3 = x3;
- wx_stack_top->y3 = y3;
- wx_stack_top->x4 = x4;
- wx_stack_top->y4 = y4;
- wx_stack_top++;
- wx_stack_count++;
-}
-
-int wx_spline_pop(double *x1, double *y1, double *x2, double *y2,
- double *x3, double *y3, double *x4, double *y4)
-{
- if (wx_stack_count == 0)
- return (0);
- wx_stack_top--;
- wx_stack_count--;
- *x1 = wx_stack_top->x1;
- *y1 = wx_stack_top->y1;
- *x2 = wx_stack_top->x2;
- *y2 = wx_stack_top->y2;
- *x3 = wx_stack_top->x3;
- *y3 = wx_stack_top->y3;
- *x4 = wx_stack_top->x4;
- *y4 = wx_stack_top->y4;
- return (1);
-}
-
-static bool wx_spline_add_point(double x, double y)
-{
- wxPoint *point = new wxPoint ;
- point->x = (int) x;
- point->y = (int) y;
- wx_spline_point_list.Append((wxObject*)point);
- return TRUE;
}
-static void wx_spline_draw_point_array(wxDC *dc)
+// Resolution in pixels per logical inch
+wxSize wxWindowDC::GetPPI() const
{
- dc->DrawLines(&wx_spline_point_list, 0, 0 );
- wxNode *node = wx_spline_point_list.First();
- while (node)
- {
- wxPoint *point = (wxPoint *)node->Data();
- delete point;
- delete node;
- node = wx_spline_point_list.First();
- }
+ return wxSize(100, 100);
}
-void wxWindowDC::DrawSpline( wxList *points )
-{
- wxPoint *p;
- double cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4;
- double x1, y1, x2, y2;
-
- wxNode *node = points->First();
- p = (wxPoint *)node->Data();
-
- x1 = p->x;
- y1 = p->y;
-
- node = node->Next();
- p = (wxPoint *)node->Data();
-
- x2 = p->x;
- y2 = p->y;
- cx1 = (double)((x1 + x2) / 2);
- cy1 = (double)((y1 + y2) / 2);
- cx2 = (double)((cx1 + x2) / 2);
- cy2 = (double)((cy1 + y2) / 2);
-
- wx_spline_add_point(x1, y1);
-
- while ((node = node->Next()) != NULL)
- {
- p = (wxPoint *)node->Data();
- x1 = x2;
- y1 = y2;
- x2 = p->x;
- y2 = p->y;
- cx4 = (double)(x1 + x2) / 2;
- cy4 = (double)(y1 + y2) / 2;
- cx3 = (double)(x1 + cx4) / 2;
- cy3 = (double)(y1 + cy4) / 2;
-
- wx_quadratic_spline(cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4);
-
- cx1 = cx4;
- cy1 = cy4;
- cx2 = (double)(cx1 + x2) / 2;
- cy2 = (double)(cy1 + y2) / 2;
- }
-
- wx_spline_add_point( cx1, cy1 );
- wx_spline_add_point( x2, y2 );
-
- wx_spline_draw_point_array( this );
-};
-
-// Resolution in pixels per logical inch
-wxSize wxWindowDC::GetPPI(void) const
+int wxWindowDC::GetDepth() const
{
- return wxSize(100, 100);
+ // TODO
+ return 24;
}
-/*
-* wxPaintDC
-*/
+// ----------------------------------------------------------------------------
+// wxPaintDC
+// ----------------------------------------------------------------------------
-wxPaintDC::wxPaintDC(wxWindow* win): wxWindowDC(win)
+wxPaintDC::wxPaintDC(wxWindow* win) : wxWindowDC(win)
{
wxRegion* region = NULL;
-
+
// Combine all the update rects into a region
- if (win->m_updateRects.Number() > 0)
+ const wxRectList& updateRects(win->GetUpdateRects());
+ if ( updateRects.GetCount() != 0 )
{
- int i = 0;
- for (i = 0; i < win->m_updateRects.Number(); i++)
+ for ( wxRectList::Node *node = updateRects.GetFirst();
+ node;
+ node = node->GetNext() )
{
- wxRect* rect = (wxRect*) win->m_updateRects.Nth(i)->Data();
- /*
- cout << "wxPaintDC. wxRect: " << rect->x << ", " << rect->y << ", ";
- cout << rect->width << ", " << rect->height << "\n\n";
- */
-
+ wxRect* rect = node->GetData();
+
if (!region)
region = new wxRegion(*rect);
else
win->GetClientSize(&cw, &ch);
region = new wxRegion(wxRect(0, 0, cw, ch));
}
-
- win->m_updateRegion = *region;
-
+
+ win->SetUpdateRegion(*region);
+
// Set the clipping region. Any user-defined region will be combined with this
// one in SetDCClipping.
XSetRegion ((Display*) m_display, (GC) m_gc, (Region) region->GetXRegion());
-
+
delete region;
}
{
XSetClipMask ((Display*) m_display, (GC) m_gc, None);
if (m_window)
- m_window->m_updateRegion.Clear();
+ m_window->ClearUpdateRegion();
+}
+
+// ----------------------------------------------------------------------------
+// private functions
+// ----------------------------------------------------------------------------
+
+/*
+ Used when copying between drawables on different (Display*) m_displays. Not
+ very fast, but better than giving up.
+*/
+
+static void XCopyRemote(Display *src_display, Display *dest_display,
+ Drawable src, Drawable dest,
+ GC destgc,
+ int srcx, int srcy,
+ unsigned int w, unsigned int h,
+ int destx, int desty,
+ bool more, XImage **cache)
+{
+ XImage *image, *destimage;
+ Colormap destcm, srccm;
+ static const int CACHE_SIZE = 256;
+
+ unsigned int i, j;
+ unsigned long cachesrc[CACHE_SIZE], cachedest[CACHE_SIZE];
+ int k, cache_pos, all_cache;
+
+ if (!cache || !*cache)
+ image = XGetImage(src_display, src, srcx, srcy, w, h, AllPlanes, ZPixmap);
+ else
+ image = *cache;
+
+ destimage = XGetImage(dest_display, dest, destx, desty, w, h, AllPlanes, ZPixmap);
+
+ srccm = (Colormap) wxTheApp->GetMainColormap((WXDisplay*) src_display);
+ destcm = (Colormap) wxTheApp->GetMainColormap((WXDisplay*) dest_display);
+
+ cache_pos = 0;
+ all_cache = FALSE;
+
+ for (i = 0; i < w; i++)
+ for (j = 0; j < h; j++) {
+ unsigned long pixel;
+ XColor xcol;
+
+ pixel = XGetPixel(image, i, j);
+ for (k = cache_pos; k--; )
+ if (cachesrc[k] == pixel) {
+ pixel = cachedest[k];
+ goto install;
+ }
+ if (all_cache)
+ for (k = CACHE_SIZE; k-- > cache_pos; )
+ if (cachesrc[k] == pixel) {
+ pixel = cachedest[k];
+ goto install;
+ }
+
+ cachesrc[cache_pos] = xcol.pixel = pixel;
+ XQueryColor(src_display, srccm, &xcol);
+ if (!XAllocColor(dest_display, destcm, &xcol))
+ xcol.pixel = 0;
+ cachedest[cache_pos] = pixel = xcol.pixel;
+
+ if (++cache_pos >= CACHE_SIZE) {
+ cache_pos = 0;
+ all_cache = TRUE;
+ }
+
+install:
+ XPutPixel(destimage, i, j, pixel);
+ }
+
+ XPutImage(dest_display, dest, destgc, destimage, 0, 0, destx, desty, w, h);
+ XDestroyImage(destimage);
+
+ if (more)
+ *cache = image;
+ else
+ XDestroyImage(image);
+}
+
+#if 0
+
+/* Helper function for 16-bit fonts */
+static int str16len(const char *s)
+{
+ int count = 0;
+
+ while (s[0] && s[1]) {
+ count++;
+ s += 2;
+ }
+
+ return count;
}
+#endif // 0
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#include <wx/motif/private.h>
void wxRadioBoxCallback (Widget w, XtPointer clientData,
- XmToggleButtonCallbackStruct * cbs);
+ XmToggleButtonCallbackStruct * cbs);
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxRadioBox, wxControl)
XmString text = XmStringCreateSimple ((char*) (const char*) label1);
Widget formWidget = XtVaCreateManagedWidget ((char*) (const char*) name,
- xmFormWidgetClass, parentWidget,
- XmNmarginHeight, 0,
- XmNmarginWidth, 0,
- NULL);
+ xmFormWidgetClass, parentWidget,
+ XmNmarginHeight, 0,
+ XmNmarginWidth, 0,
+ NULL);
m_formWidget = (WXWidget) formWidget;
text = XmStringCreateSimple ((char*) (const char*) label1);
Widget labelWidget = XtVaCreateManagedWidget ((char*) (const char*) label1,
#if wxUSE_GADGETS
- style & wxCOLOURED ?
- xmLabelWidgetClass : xmLabelGadgetClass,
- formWidget,
+ style & wxCOLOURED ?
+ xmLabelWidgetClass : xmLabelGadgetClass,
+ formWidget,
#else
- xmLabelWidgetClass, formWidget,
+ xmLabelWidgetClass, formWidget,
#endif
XmNfontList, fontList,
- XmNlabelString, text,
- NULL);
+ XmNlabelString, text,
+ NULL);
XmStringFree (text);
}
Widget frameWidget = XtVaCreateManagedWidget ("frame",
- xmFrameWidgetClass, formWidget,
+ xmFrameWidgetClass, formWidget,
XmNshadowType, XmSHADOW_IN,
-// XmNmarginHeight, 0,
-// XmNmarginWidth, 0,
- NULL);
+// XmNmarginHeight, 0,
+// XmNmarginWidth, 0,
+ NULL);
m_frameWidget = (WXWidget) frameWidget;
majorDim = (n + majorDim - 1) / majorDim;
XtSetArg (args[0], XmNorientation, ((style & wxHORIZONTAL) == wxHORIZONTAL ?
- XmHORIZONTAL : XmVERTICAL));
+ XmHORIZONTAL : XmVERTICAL));
XtSetArg (args[1], XmNnumColumns, majorDim);
Widget radioBoxWidget = XmCreateRadioBox (frameWidget, "radioBoxWidget", args, 2);
if (m_labelWidget)
- XtVaSetValues ((Widget) m_labelWidget,
- XmNtopAttachment, XmATTACH_FORM,
- XmNleftAttachment, XmATTACH_FORM,
- XmNalignment, XmALIGNMENT_BEGINNING,
- NULL);
+ XtVaSetValues ((Widget) m_labelWidget,
+ XmNtopAttachment, XmATTACH_FORM,
+ XmNleftAttachment, XmATTACH_FORM,
+ XmNalignment, XmALIGNMENT_BEGINNING,
+ NULL);
XtVaSetValues (radioBoxWidget,
- XmNtopAttachment, m_labelWidget ? XmATTACH_WIDGET : XmATTACH_FORM,
- XmNtopWidget, m_labelWidget ? (Widget) m_labelWidget : formWidget,
- XmNbottomAttachment, XmATTACH_FORM,
- XmNleftAttachment, XmATTACH_FORM,
- XmNrightAttachment, XmATTACH_FORM,
- NULL);
+ XmNtopAttachment, m_labelWidget ? XmATTACH_WIDGET : XmATTACH_FORM,
+ XmNtopWidget, m_labelWidget ? (Widget) m_labelWidget : formWidget,
+ XmNbottomAttachment, XmATTACH_FORM,
+ XmNleftAttachment, XmATTACH_FORM,
+ XmNrightAttachment, XmATTACH_FORM,
+ NULL);
// if (style & wxFLAT)
// XtVaSetValues (radioBoxWidget, XmNborderWidth, 1, NULL);
m_radioButtonLabels[i] = str;
m_radioButtons[i] = (WXWidget) XtVaCreateManagedWidget ((char*) (const char*) str,
#if wxUSE_GADGETS
- xmToggleButtonGadgetClass, radioBoxWidget,
+ xmToggleButtonGadgetClass, radioBoxWidget,
#else
- xmToggleButtonWidgetClass, radioBoxWidget,
+ xmToggleButtonWidgetClass, radioBoxWidget,
#endif
XmNfontList, fontList,
- NULL);
+ NULL);
XtAddCallback ((Widget) m_radioButtons[i], XmNvalueChangedCallback, (XtCallbackProc) wxRadioBoxCallback,
- (XtCallbackProc) this);
+ (XtCallbackProc) this);
}
SetSelection (0);
XmString text;
char *s;
XtVaGetValues (widget,
- XmNlabelString, &text,
- NULL);
+ XmNlabelString, &text,
+ NULL);
if (XmStringGetLtoR (text, XmSTRING_DEFAULT_CHARSET, &s))
{
wxString label1(wxStripMenuCodes(label));
XmString text = XmStringCreateSimple ((char*) (const char*) label1);
XtVaSetValues (widget,
- XmNlabelString, text,
- XmNlabelType, XmSTRING,
- NULL);
+ XmNlabelString, text,
+ XmNlabelType, XmSTRING,
+ NULL);
XmStringFree (text);
}
}
if (x > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
XtVaSetValues ((Widget) m_formWidget, XmNleftAttachment, XmATTACH_SELF,
- XmNx, xx, NULL);
+ XmNx, xx, NULL);
if (y > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
XtVaSetValues ((Widget) m_formWidget, XmNtopAttachment, XmATTACH_SELF,
- XmNy, yy, NULL);
+ XmNy, yy, NULL);
// Must set the actual RadioBox to be desired size MINUS label size
Dimension labelWidth = 0, labelHeight = 0, actualWidth = 0, actualHeight = 0;
}
// Enable all controls
-void wxRadioBox::Enable(bool enable)
+bool wxRadioBox::Enable(bool enable)
{
- wxControl::Enable(enable);
+ if ( !wxControl::Enable(enable) )
+ return FALSE;
int i;
for (i = 0; i < m_noItems; i++)
XtSetSensitive ((Widget) m_radioButtons[i], (Boolean) enable);
+
+ return TRUE;
}
bool wxRadioBox::Show(bool show)
XtVaSetValues ((Widget) radioButton,
XmNfontList, fontList,
- XmNtopAttachment, XmATTACH_FORM,
+ XmNtopAttachment, XmATTACH_FORM,
NULL);
}
}
}
void wxRadioBoxCallback (Widget w, XtPointer clientData,
- XmToggleButtonCallbackStruct * cbs)
+ XmToggleButtonCallbackStruct * cbs)
{
if (!cbs->set)
return;
#include "wx/menuitem.h"
#include "wx/log.h"
+#include "wx/listimpl.cpp"
+
#if wxUSE_DRAG_AND_DROP
#include "wx/dnd.h"
#endif
// implementation
// ============================================================================
+// ----------------------------------------------------------------------------
+// list types
+// ----------------------------------------------------------------------------
+
+WX_DEFINE_LIST(wxRectList);
+
// ----------------------------------------------------------------------------
// helper functions
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// Helper function
-void wxWindow::CreateScrollbar(int orientation)
+void wxWindow::CreateScrollbar(wxOrientation orientation)
{
wxCHECK_RET( m_drawingArea, "this window can't have scrollbars" );
XtVaSetValues((Widget) m_scrolledWindow, XmNresizePolicy, XmRESIZE_ANY, NULL);
}
-void wxWindow::DestroyScrollbar(int orientation)
+void wxWindow::DestroyScrollbar(wxOrientation orientation)
{
wxCHECK_RET( m_drawingArea, "this window can't have scrollbars" );
}
// Get the window with the focus
-wxWindow *wxWindow::FindFocus()
+wxWindow *wxWindowBase::FindFocus()
{
// TODO Problems:
// (1) Can there be multiple focussed widgets in an application?
return winFocus;
}
-void wxWindow::Enable(bool enable)
+bool wxWindow::Enable(bool enable)
{
if ( !wxWindowBase::Enable(enable) )
return FALSE;
- Widget wMain = GetMainWidget();
+ Widget wMain = (Widget)GetMainWidget();
if ( wMain )
{
XtSetSensitive(wMain, enable);
XLowerWindow(XtDisplay(wTop), window);
}
-void wxWindow::SetTitle( const wxString& title)
+void wxWindow::SetTitle(const wxString& title)
{
- SetWindowText(GetHwnd(), title.c_str());
+ XtVaSetValues((Widget)GetMainWidget(), XmNtitle, title.c_str(), NULL);
}
wxString wxWindow::GetTitle() const
{
- return wxGetWindowText(GetHWND());
+ char *title;
+ XtVaGetValues((Widget)GetMainWidget(), XmNtitle, &title, NULL);
+
+ return wxString(title);
}
void wxWindow::CaptureMouse()
if ( m_winCaptured )
return;
- Widget wMain = GetMainWidget();
+ Widget wMain = (Widget)GetMainWidget();
if ( wMain )
XtAddGrab(wMain, TRUE, FALSE);
if ( !m_winCaptured )
return;
- Widget wMain = GetMainWidget();
+ Widget wMain = (Widget)GetMainWidget();
if ( wMain )
XtRemoveGrab(wMain);
Widget w = (Widget) GetMainWidget();
Window win = XtWindow(w);
XDefineCursor((Display*) dpy, win, (Cursor) x_cursor);
+
+ return TRUE;
}
// Coordinates relative to the window
// can scroll.
int wxWindow::GetScrollRange(int orient) const
{
- Widget scrollBar = (Widget)GetScrollbar(orient);
+ Widget scrollBar = (Widget)GetScrollbar((wxOrientation)orient);
wxCHECK_MSG( scrollBar, 0, "no such scrollbar" );
int range;
int wxWindow::GetScrollThumb(int orient) const
{
- Widget scrollBar = (Widget)GetScrollbar(orient);
+ Widget scrollBar = (Widget)GetScrollbar((wxOrientation)orient);
wxCHECK_MSG( scrollBar, 0, "no such scrollbar" );
int thumb;
void wxWindow::SetScrollPos(int orient, int pos, bool WXUNUSED(refresh))
{
- Widget scrollBar = (Widget)GetScrollbar(orient);
+ Widget scrollBar = (Widget)GetScrollbar((wxOrientation)orient);
if ( scrollBar )
{
XtVaSetValues (scrollBar, XmNvalue, pos, NULL);
}
- SetInternalScrollPos(orient, pos);
+ SetInternalScrollPos((wxOrientation)orient, pos);
}
// New function that will replace some of the above.
thumbVisible = range;
// Save the old state to see if it changed
- WXWidget oldScrollBar = GetScrollbar(orient);
+ WXWidget oldScrollBar = GetScrollbar((wxOrientation)orient);
if (orient == wxHORIZONTAL)
{
CreateScrollbar(wxVERTICAL);
}
}
- WXWidget newScrollBar = GetScrollbar(orient);
+ WXWidget newScrollBar = GetScrollbar((wxOrientation)orient);
if (oldScrollBar != newScrollBar)
{
NULL);
}
- SetInternalScrollPos(orient, pos);
+ SetInternalScrollPos((wxOrientation)orient, pos);
int newW, newH;
GetSize(& newW, & newH);
}
// Get total size
-void wxWindow::GetSize(int *x, int *y) const
+void wxWindow::DoGetSize(int *x, int *y) const
{
if (m_drawingArea)
{
*x = xx; *y = yy;
}
-void wxWindow::GetPosition(int *x, int *y) const
+void wxWindow::DoGetPosition(int *x, int *y) const
{
if (m_drawingArea)
{
*x = xx; *y = yy;
}
-void wxWindow::ScreenToClient(int *x, int *y) const
+void wxWindow::DoScreenToClient(int *x, int *y) const
{
Widget widget = (Widget) GetClientWidget();
Display *display = XtDisplay((Widget) GetMainWidget());
XTranslateCoordinates(display, rootWindow, thisWindow, xx, yy, x, y, &childWindow);
}
-void wxWindow::ClientToScreen(int *x, int *y) const
+void wxWindow::DoClientToScreen(int *x, int *y) const
{
Widget widget = (Widget) GetClientWidget();
Display *display = XtDisplay(widget);
// Get size *available for subwindows* i.e. excluding menu bar etc.
-void wxWindow::GetClientSize(int *x, int *y) const
+void wxWindow::DoGetClientSize(int *x, int *y) const
{
Widget widget = (Widget) GetClientWidget();
Dimension xx, yy;
int wxWindow::GetCharHeight() const
{
- wxCHECK_MSG( m_windowFont.Ok(), 0, "valid window font needed" );
+ wxCHECK_MSG( m_font.Ok(), 0, "valid window font needed" );
- WXFontStructPtr pFontStruct = m_windowFont.GetFontStruct(1.0, GetXDisplay());
+ WXFontStructPtr pFontStruct = m_font.GetFontStruct(1.0, GetXDisplay());
int direction, ascent, descent;
XCharStruct overall;
int wxWindow::GetCharWidth() const
{
- wxCHECK_MSG( m_windowFont.Ok(), 0, "valid window font needed" );
+ wxCHECK_MSG( m_font.Ok(), 0, "valid window font needed" );
- WXFontStructPtr pFontStruct = m_windowFont.GetFontStruct(1.0, GetXDisplay());
+ WXFontStructPtr pFontStruct = m_font.GetFontStruct(1.0, GetXDisplay());
int direction, ascent, descent;
XCharStruct overall;
{
wxFont *fontToUse = (wxFont *)theFont;
if (!fontToUse)
- fontToUse = (wxFont *) & m_windowFont;
+ fontToUse = (wxFont *) & m_font;
- wxCHECK_RET( fontToUse.Ok(), "valid window font needed" );
+ wxCHECK_RET( fontToUse->Ok(), "valid window font needed" );
WXFontStructPtr pFontStruct = theFont->GetFontStruct(1.0, GetXDisplay());
void wxWindow::ClearUpdateRects()
{
- wxNode* node = m_updateRects.First();
+ wxRectList::Node* node = m_updateRects.GetFirst();
while (node)
{
- wxRect* rect = (wxRect*) node->Data();
+ wxRect* rect = node->GetData();
delete rect;
- node = node->Next();
+ node = node->GetNext();
}
+
m_updateRects.Clear();
}
// Get the underlying X window
WXWindow wxWindow::GetXWindow() const
{
- Widget wMain = GetMainWidget();
+ Widget wMain = (Widget)GetMainWidget();
if ( wMain )
return (WXWindow) XtWindow(wMain);
else
// Get the underlying X display
WXDisplay *wxWindow::GetXDisplay() const
{
- Widget wMain = GetMainWidget();
+ Widget wMain = (Widget)GetMainWidget();
if ( wMain )
return (WXDisplay*) XtDisplay(wMain);
else
XEvent * event = cbs->event;
wxWindow * win = (wxWindow *) clientData;
- Display * display = (Display *) win->GetXDisplay();
switch (event->type)
{
case Expose:
{
- wxRect* rect = new wxRect(event->xexpose.x, event->xexpose.y,
- event->xexpose.width, event->xexpose.height);
-
- win->m_updateRects.Append((wxObject*) rect);
-
if (event -> xexpose.count == 0)
{
#if 0
win->DoPaint();
win->ClearUpdateRects();
}
+ else
+ {
+ win->AddUpdateRect(event->xexpose.x, event->xexpose.y,
+ event->xexpose.width, event->xexpose.height);
+ }
break;
}
}
if (local_event.xbutton.button == Button1)
{
eventType = wxEVT_LEFT_DOWN;
- canvas->m_button1Pressed = TRUE;
+ canvas->SetButton1(TRUE);
}
else if (local_event.xbutton.button == Button2)
{
eventType = wxEVT_MIDDLE_DOWN;
- canvas->m_button2Pressed = TRUE;
+ canvas->SetButton2(TRUE);
}
else if (local_event.xbutton.button == Button3)
{
eventType = wxEVT_RIGHT_DOWN;
- canvas->m_button3Pressed = TRUE;
+ canvas->SetButton3(TRUE);
}
}
else if (local_event.xany.type == ButtonRelease)
if (local_event.xbutton.button == Button1)
{
eventType = wxEVT_LEFT_UP;
- canvas->m_button1Pressed = FALSE;
+ canvas->SetButton1(FALSE);
}
else if (local_event.xbutton.button == Button2)
{
eventType = wxEVT_MIDDLE_UP;
- canvas->m_button2Pressed = FALSE;
+ canvas->SetButton2(FALSE);
}
else if (local_event.xbutton.button == Button3)
{
eventType = wxEVT_RIGHT_UP;
- canvas->m_button3Pressed = FALSE;
+ canvas->SetButton3(FALSE);
}
}
wxMouseEvent wxevent (eventType);
- wxevent.m_eventHandle = (char *) &local_event;
wxevent.m_leftDown = ((eventType == wxEVT_LEFT_DOWN)
|| (event_left_is_down (&local_event)
// get button and time-stamp
int button = 0;
- if (wxevent.LeftDown()) button = 1;
- else if (wxevent.MiddleDown()) button = 2;
- else if (wxevent.RightDown()) button = 3;
+ if (wxevent.LeftDown())
+ button = 1;
+ else if (wxevent.MiddleDown())
+ button = 2;
+ else if (wxevent.RightDown())
+ button = 3;
long ts = wxevent.GetTimestamp();
+
// check, if single or double click
- if (canvas->m_lastButton && canvas->m_lastButton==button && (ts - canvas->m_lastTS) < dclickTime)
+ int buttonLast = canvas->GetLastClickedButton();
+ long lastTS = canvas->GetLastClickTime();
+ if ( buttonLast && buttonLast == button && (ts - lastTS) < dclickTime )
{
// I have a dclick
- canvas->m_lastButton = 0;
+ canvas->SetLastClick(0, ts);
switch ( eventType )
{
case wxEVT_LEFT_DOWN:
else
{
// not fast enough or different button
- canvas->m_lastTS = ts;
- canvas->m_lastButton = button;
+ canvas->SetLastClick(button, ts);
}
}
}
{
// Widget can be a label or the actual widget.
- wxWindow *window = wxGetWindowFromTable(drawingArea);
+ wxWindow *window = wxGetWindowFromTable(wid);
if (window)
{
wxMouseEvent wxevent(0);
XtPointer clientData,
XmScaleCallbackStruct *cbs)
{
- Widget scrolledWindow = XtParent (scrollbar);
wxWindow *win = wxGetWindowFromTable(scrollbar);
int orientation = (int) clientData;
switch(event -> type)
{
- case Expose :
+ case Expose:
{
window = (Window) win -> GetXWindow();
display = (Display *) win -> GetXDisplay();
- wxRect* rect = new wxRect(event->xexpose.x, event->xexpose.y,
- event->xexpose.width, event->xexpose.height);
- win->m_updateRects.Append((wxObject*) rect);
-
if (event -> xexpose.count == 0)
{
win->DoPaint();
win->ClearUpdateRects();
}
+ else
+ {
+ win->AddUpdateRect(event->xexpose.x, event->xexpose.y,
+ event->xexpose.width, event->xexpose.height);
+ }
+
break;
}
}
if (managed)
XtUnmanageChild (m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow);
- XtVaSetValues((Widget) m_drawingArea, XmNresizePolicy, XmRESIZE_ANY, NULL);
+ XtVaSetValues(drawingArea, XmNresizePolicy, XmRESIZE_ANY, NULL);
int xx = x; int yy = y;
AdjustForParentClientOrigin(xx, yy, sizeFlags);
w -= (spacing + wsbar);
- // XtVaSetValues ((Widget) m_drawingArea, XmNwidth, w, NULL);
+#if 0
+ XtVaSetValues(drawingArea, XmNwidth, w, NULL);
+#endif // 0
}
if (h > -1)
{
h -= (spacing + wsbar);
- // XtVaSetValues ((Widget) m_drawingArea, XmNheight, h, NULL);
-
+#if 0
+ XtVaSetValues(drawingArea, XmNheight, h, NULL);
+#endif // 0
}
}
if (managed)
XtManageChild (m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow);
- XtVaSetValues((Widget) m_drawingArea, XmNresizePolicy, XmRESIZE_NONE, NULL);
+ XtVaSetValues(drawingArea, XmNresizePolicy, XmRESIZE_NONE, NULL);
#if 0
int ww, hh;
wxSizeEvent sizeEvent(wxSize(ww, hh), GetId());
sizeEvent.SetEventObject(this);
- GetEventHandler()->ProcessEvent(sizeEvent);
+ GetEventHandler()->ProcessEvent(sizeEvent);
#endif // 0
}
{
Widget drawingArea = (Widget) m_drawingArea;
- XtVaSetValues((Widget) m_drawingArea, XmNresizePolicy, XmRESIZE_ANY, NULL);
+ XtVaSetValues(drawingArea, XmNresizePolicy, XmRESIZE_ANY, NULL);
if (w > -1)
- XtVaSetValues ((Widget) m_drawingArea, XmNwidth, w, NULL);
+ XtVaSetValues(drawingArea, XmNwidth, w, NULL);
if (h > -1)
- XtVaSetValues ((Widget) m_drawingArea, XmNheight, h, NULL);
+ XtVaSetValues(drawingArea, XmNheight, h, NULL);
#if 0
// TODO: is this necessary?
}
#endif // 0
- XtVaSetValues((Widget) m_drawingArea, XmNresizePolicy, XmRESIZE_NONE, NULL);
+ XtVaSetValues(drawingArea, XmNresizePolicy, XmRESIZE_NONE, NULL);
#if 0
- allowRepainting = TRUE;
- DoRefresh ();
+ allowRepainting = TRUE;
+ DoRefresh ();
- wxSizeEvent sizeEvent(wxSize(w, h), GetId());
- sizeEvent.SetEventObject(this);
+ wxSizeEvent sizeEvent(wxSize(w, h), GetId());
+ sizeEvent.SetEventObject(this);
- GetEventHandler()->ProcessEvent(sizeEvent);
+ GetEventHandler()->ProcessEvent(sizeEvent);
#endif // 0
}
if (xevent->xany.type == LeaveNotify)
{
- win->m_button1Pressed = FALSE;
- win->m_button2Pressed = FALSE;
- win->m_button3Pressed = FALSE;
+ win->SetButton1(FALSE);
+ win->SetButton2(FALSE);
+ win->SetButton3(FALSE);
return FALSE;
}
else if (xevent->xany.type == MotionNotify)
if (xevent->xbutton.button == Button1)
{
eventType = wxEVT_LEFT_DOWN;
- win->m_button1Pressed = TRUE;
+ win->SetButton1(TRUE);
}
else if (xevent->xbutton.button == Button2)
{
eventType = wxEVT_MIDDLE_DOWN;
- win->m_button2Pressed = TRUE;
+ win->SetButton2(TRUE);
}
else if (xevent->xbutton.button == Button3)
{
eventType = wxEVT_RIGHT_DOWN;
- win->m_button3Pressed = TRUE;
+ win->SetButton3(TRUE);
}
}
else if (xevent->xany.type == ButtonRelease)
if (xevent->xbutton.button == Button1)
{
eventType = wxEVT_LEFT_UP;
- win->m_button1Pressed = FALSE;
+ win->SetButton1(FALSE);
}
else if (xevent->xbutton.button == Button2)
{
eventType = wxEVT_MIDDLE_UP;
- win->m_button2Pressed = FALSE;
+ win->SetButton2(FALSE);
}
else if (xevent->xbutton.button == Button3)
{
eventType = wxEVT_RIGHT_UP;
- win->m_button3Pressed = FALSE;
+ win->SetButton3(FALSE);
}
else return FALSE;
}
- else return FALSE;
+ else
+ {
+ return FALSE;
+ }
- wxevent.m_eventHandle = (char *)xevent;
wxevent.SetEventType(eventType);
Position x1, y1;
NULL);
}
-void wxWindow::SetBackgroundColour(const wxColour& col)
+bool wxWindow::SetBackgroundColour(const wxColour& col)
{
- m_backgroundColour = col;
+ if ( !wxWindowBase::SetBackgroundColour(col) )
+ return FALSE;
+
ChangeBackgroundColour();
+
+ return TRUE;
}
-void wxWindow::SetForegroundColour(const wxColour& col)
+bool wxWindow::SetForegroundColour(const wxColour& col)
{
- m_foregroundColour = col;
+ if ( !wxWindowBase::SetForegroundColour(col) )
+ return FALSE;
+
ChangeForegroundColour();
+
+ return TRUE;
}
void wxWindow::ChangeFont(bool keepOriginalSize)
// to its original size! We therefore have to set the size
// back again. TODO: a better way in Motif?
Widget w = (Widget) GetLabelWidget(); // Usually the main widget
- if (w && m_windowFont.Ok())
+ if (w && m_font.Ok())
{
int width, height, width1, height1;
GetSize(& width, & height);
// lesstif 0.87 hangs here
#ifndef LESSTIF_VERSION
XtVaSetValues (w,
- XmNfontList, (XmFontList) m_windowFont.GetFontList(1.0, XtDisplay(w)),
+ XmNfontList, (XmFontList) m_font.GetFontList(1.0, XtDisplay(w)),
NULL);
#endif
// wxNoOptimize: switch off size optimization
// ----------------------------------------------------------------------------
-int wxNoOptimize::m_count = 0;
-
-wxNoOptimize::wxNoOptimize()
-{
- m_count ++;
-}
-
-wxNoOptimize::~wxNoOptimize()
-{
- m_count --;
-}
-
-bool wxNoOptimize::CanOptimize()
-{
- return (m_count == 0);
-}
-
+int wxNoOptimize::ms_count = 0;