more Motif fixes (still doesn't compile, but *really* close :-)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2716 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1999-06-08 19:10:37 +00:00
parent ced859c3dc
commit af0bb3b161
15 changed files with 1195 additions and 1770 deletions

View File

@@ -65,7 +65,7 @@ public:
m_mappingMode = wxMM_TEXT; m_mappingMode = wxMM_TEXT;
m_backgroundBrush = *wxWHITE_BRUSH; m_backgroundBrush = *wxTRANSPARENT_BRUSH;
m_textForegroundColour = *wxBLACK; m_textForegroundColour = *wxBLACK;
m_textBackgroundColour = *wxWHITE; m_textBackgroundColour = *wxWHITE;
@@ -201,11 +201,11 @@ public:
virtual void Clear() = 0; virtual void Clear() = 0;
virtual bool StartDoc(const wxString& message) = 0; virtual bool StartDoc(const wxString& WXUNUSED(message)) { return TRUE; }
virtual void EndDoc() = 0; virtual void EndDoc() { }
virtual void StartPage() = 0; virtual void StartPage() { }
virtual void EndPage() = 0; virtual void EndPage() { }
// set objects to use for drawing // set objects to use for drawing
// ------------------------------ // ------------------------------

View File

@@ -22,8 +22,8 @@
#include "wx/dialog.h" #include "wx/dialog.h"
#include "wx/module.h" #include "wx/module.h"
#include "wx/cmndata.h" #include "wx/cmndata.h"
#include <fstream.h>
#include <fstream.h>
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// classes // classes
@@ -97,7 +97,7 @@ public:
void SetClippingRegion(long x, long y, long width, long height); void SetClippingRegion(long x, long y, long width, long height);
void SetClippingRegion( const wxRegion &region ); void SetClippingRegion( const wxRegion &region );
void DestroyClippingRegion(); void DestroyClippingRegion();
void DoSetClippingRegionAsRegion( const wxRegion &WXUNUSED(clip) ) {} void DoSetClippingRegionAsRegion( const wxRegion &WXUNUSED(clip) ) {}
bool StartDoc(const wxString& message); bool StartDoc(const wxString& message);
@@ -125,12 +125,12 @@ public:
inline void SetBackgroundMode(int WXUNUSED(mode)) {} inline void SetBackgroundMode(int WXUNUSED(mode)) {}
inline void SetPalette(const wxPalette& WXUNUSED(palette)) {} 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; } wxPrintData& GetPrintData() { return m_printData; }
inline void SetPrintData(const wxPrintData& data) { m_printData = data; } void SetPrintData(const wxPrintData& data) { m_printData = data; }
int GetDepth() const { return 24; } virtual int GetDepth() const { return 24; }
protected: protected:
@@ -170,13 +170,15 @@ public:
#endif #endif
// Print Orientation (Should also add Left, Right) // Print Orientation (Should also add Left, Right)
enum { enum
{
PS_PORTRAIT = 1, PS_PORTRAIT = 1,
PS_LANDSCAPE = 2 PS_LANDSCAPE = 2
};// ps_orientation = PS_PORTRAIT; };// ps_orientation = PS_PORTRAIT;
// Print Actions // Print Actions
enum { enum
{
PS_NONE, PS_NONE,
PS_PREVIEW, PS_PREVIEW,
PS_FILE, PS_FILE,

View File

@@ -5,7 +5,7 @@
// Modified by: // Modified by:
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Julian Smart // Copyright: (c) Julian Smart
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef _WX_NOTEBOOK_H_ #ifndef _WX_NOTEBOOK_H_
@@ -35,30 +35,6 @@ class WXDLLEXPORT wxWindow;
typedef wxWindow wxNotebookPage; // so far, any window can be a page typedef wxWindow wxNotebookPage; // so far, any window can be a page
WX_DEFINE_ARRAY(wxNotebookPage *, wxArrayPages); 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
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -89,14 +65,14 @@ public:
wxNotebook(); wxNotebook();
// the same arguments as for wxControl (@@@ any special styles?) // the same arguments as for wxControl (@@@ any special styles?)
wxNotebook(wxWindow *parent, wxNotebook(wxWindow *parent,
wxWindowID id, wxWindowID id,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
long style = 0, long style = 0,
const wxString& name = "notebook"); const wxString& name = "notebook");
// Create() function // Create() function
bool Create(wxWindow *parent, bool Create(wxWindow *parent,
wxWindowID id, wxWindowID id,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
long style = 0, long style = 0,
@@ -184,19 +160,19 @@ public:
void OnSelChange(wxNotebookEvent& event); void OnSelChange(wxNotebookEvent& event);
void OnSetFocus(wxFocusEvent& event); void OnSetFocus(wxFocusEvent& event);
void OnNavigationKey(wxNavigationKeyEvent& event); void OnNavigationKey(wxNavigationKeyEvent& event);
// base class virtuals // base class virtuals
// ------------------- // -------------------
virtual void Command(wxCommandEvent& event); virtual void Command(wxCommandEvent& event);
virtual void SetConstraintSizes(bool recurse = TRUE); virtual void SetConstraintSizes(bool recurse = TRUE);
virtual bool DoPhase(int nPhase); virtual bool DoPhase(int nPhase);
// Implementation // Implementation
// wxNotebook on Motif uses a generic wxTabView to implement itself. // wxNotebook on Motif uses a generic wxTabView to implement itself.
inline wxTabView *GetTabView() const { return m_tabView; } wxTabView *GetTabView() const { return m_tabView; }
inline void SetTabView(wxTabView *v) { m_tabView = v; } void SetTabView(wxTabView *v) { m_tabView = v; }
void OnMouseEvent(wxMouseEvent& event); void OnMouseEvent(wxMouseEvent& event);
void OnPaint(wxPaintEvent& event); void OnPaint(wxPaintEvent& event);
@@ -224,52 +200,4 @@ protected:
DECLARE_EVENT_TABLE() 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_ #endif // _WX_NOTEBOOK_H_

View File

@@ -68,8 +68,8 @@ public:
virtual bool Ok() const { return ((m_refData != NULL) && M_CURSORDATA->m_ok); } 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 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) const { 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; }
// Motif-specific. // Motif-specific.
// Create/get a cursor for the current display // Create/get a cursor for the current display

View File

@@ -6,14 +6,14 @@
// Created: 17/09/98 // Created: 17/09/98
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Julian Smart // Copyright: (c) Julian Smart
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DC_H_ #ifndef _WX_DC_H_
#define _WX_DC_H_ #define _WX_DC_H_
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface "dc.h" #pragma interface "dc.h"
#endif #endif
#include "wx/pen.h" #include "wx/pen.h"
@@ -27,368 +27,156 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#ifndef MM_TEXT #ifndef MM_TEXT
#define MM_TEXT 0 #define MM_TEXT 0
#define MM_ISOTROPIC 1 #define MM_ISOTROPIC 1
#define MM_ANISOTROPIC 2 #define MM_ANISOTROPIC 2
#define MM_LOMETRIC 3 #define MM_LOMETRIC 3
#define MM_HIMETRIC 4 #define MM_HIMETRIC 4
#define MM_TWIPS 5 #define MM_TWIPS 5
#define MM_POINTS 6 #define MM_POINTS 6
#define MM_METRIC 7 #define MM_METRIC 7
#endif #endif
//-----------------------------------------------------------------------------
// global variables
//-----------------------------------------------------------------------------
extern int wxPageNumber;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxDC // 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); // implement base class pure virtuals
~wxDC(void); // ----------------------------------
void BeginDrawing(void) {};
void EndDrawing(void) {};
virtual bool Ok(void) const { return m_ok; };
virtual void FloodFill( long x1, long y1, const wxColour& col, int style=wxFLOOD_SURFACE ) = 0; virtual void DestroyClippingRegion();
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 = 0; virtual wxSize GetPPI() 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 ) = 0; virtual void SetMapMode(int mode);
inline void DrawLine(const wxPoint& pt1, const wxPoint& pt2) virtual void SetUserScale(double x, double y);
{ virtual void SetSystemScale(double x, double y);
DrawLine(pt1.x, pt1.y, pt2.x, pt2.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; protected:
inline void CrossHair(const wxPoint& pt) virtual void DoDrawIcon(const wxIcon& icon, long x, long y);
{ virtual void DoDrawBitmap(const wxBitmap &bmp, long x, long y,
CrossHair(pt.x, pt.y); bool useMask = FALSE);
}
virtual void DrawArc( long x1, long y1, long x2, long y2, long xc, long yc ) = 0; virtual void DoSetClippingRegion(long x, long y,
inline void DrawArc(const wxPoint& pt1, const wxPoint& pt2, const wxPoint& centre) long width, long height);
{ virtual void DoGetSize(int *width, int *height) const;
DrawArc(pt1.x, pt1.y, pt2.x, pt2.y, centre.x, centre.y); virtual void DoGetSizeMM(int* width, int* height) const;
}
virtual void DrawEllipticArc( long x, long y, long width, long height, double sa, double ea ) = 0; public:
virtual void DrawEllipticArc (const wxPoint& pt, const wxSize& sz, double sa, double ea) void ComputeScaleAndOrigin();
{
DrawEllipticArc(pt.x, pt.y, sz.x, sz.y, sa, ea);
}
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)
{
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 ) = 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 ) = 0;
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 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)
{
DrawIcon(icon, pt.x, pt.y);
}
// 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)
{
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 ) = 0;
inline void DrawText(const wxString& text, const wxPoint& pt, bool use16bit = FALSE)
{
DrawText(text, pt.x, pt.y, use16bit);
}
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; };
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 );
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;
public:
void CalcBoundingBox( long x, long y );
void ComputeScaleAndOrigin(void);
long XDEV2LOG(long x) const long XDEV2LOG(long x) const
{ {
long new_x = x - m_deviceOriginX; long new_x = x - m_deviceOriginX;
if (new_x > 0) if (new_x > 0)
return (long)((double)(new_x) / m_scaleX + 0.5) * m_signX + m_logicalOriginX; return (long)((double)(new_x) / m_scaleX + 0.5) * m_signX + m_logicalOriginX;
else else
return (long)((double)(new_x) / m_scaleX - 0.5) * m_signX + m_logicalOriginX; return (long)((double)(new_x) / m_scaleX - 0.5) * m_signX + m_logicalOriginX;
} }
long XDEV2LOGREL(long x) const long XDEV2LOGREL(long x) const
{ {
if (x > 0) if (x > 0)
return (long)((double)(x) / m_scaleX + 0.5); return (long)((double)(x) / m_scaleX + 0.5);
else else
return (long)((double)(x) / m_scaleX - 0.5); return (long)((double)(x) / m_scaleX - 0.5);
} }
long YDEV2LOG(long y) const long YDEV2LOG(long y) const
{ {
long new_y = y - m_deviceOriginY; long new_y = y - m_deviceOriginY;
if (new_y > 0) if (new_y > 0)
return (long)((double)(new_y) / m_scaleY + 0.5) * m_signY + m_logicalOriginY; return (long)((double)(new_y) / m_scaleY + 0.5) * m_signY + m_logicalOriginY;
else else
return (long)((double)(new_y) / m_scaleY - 0.5) * m_signY + m_logicalOriginY; return (long)((double)(new_y) / m_scaleY - 0.5) * m_signY + m_logicalOriginY;
} }
long YDEV2LOGREL(long y) const long YDEV2LOGREL(long y) const
{ {
if (y > 0) if (y > 0)
return (long)((double)(y) / m_scaleY + 0.5); return (long)((double)(y) / m_scaleY + 0.5);
else else
return (long)((double)(y) / m_scaleY - 0.5); return (long)((double)(y) / m_scaleY - 0.5);
} }
long XLOG2DEV(long x) const long XLOG2DEV(long x) const
{ {
long new_x = x - m_logicalOriginX; long new_x = x - m_logicalOriginX;
if (new_x > 0) if (new_x > 0)
return (long)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX; return (long)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX;
else else
return (long)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX; return (long)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX;
} }
// Without device translation, for backing pixmap purposes // Without device translation, for backing pixmap purposes
long XLOG2DEV_2(long x) const long XLOG2DEV_2(long x) const
{ {
long new_x = x - m_logicalOriginX; long new_x = x - m_logicalOriginX;
if (new_x > 0) if (new_x > 0)
return (long)((double)(new_x) * m_scaleX + 0.5) * m_signX; return (long)((double)(new_x) * m_scaleX + 0.5) * m_signX;
else else
return (long)((double)(new_x) * m_scaleX - 0.5) * m_signX; return (long)((double)(new_x) * m_scaleX - 0.5) * m_signX;
} }
long XLOG2DEVREL(long x) const long XLOG2DEVREL(long x) const
{ {
if (x > 0) if (x > 0)
return (long)((double)(x) * m_scaleX + 0.5); return (long)((double)(x) * m_scaleX + 0.5);
else else
return (long)((double)(x) * m_scaleX - 0.5); return (long)((double)(x) * m_scaleX - 0.5);
} }
long YLOG2DEV(long y) const long YLOG2DEV(long y) const
{ {
long new_y = y - m_logicalOriginY; long new_y = y - m_logicalOriginY;
if (new_y > 0) if (new_y > 0)
return (long)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY; return (long)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY;
else else
return (long)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY; return (long)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY;
} }
// Without device translation, for backing pixmap purposes // Without device translation, for backing pixmap purposes
long YLOG2DEV_2(long y) const long YLOG2DEV_2(long y) const
{ {
long new_y = y - m_logicalOriginY; long new_y = y - m_logicalOriginY;
if (new_y > 0) if (new_y > 0)
return (long)((double)(new_y) * m_scaleY + 0.5) * m_signY; return (long)((double)(new_y) * m_scaleY + 0.5) * m_signY;
else else
return (long)((double)(new_y) * m_scaleY - 0.5) * m_signY; return (long)((double)(new_y) * m_scaleY - 0.5) * m_signY;
} }
long YLOG2DEVREL(long y) const long YLOG2DEVREL(long y) const
{ {
if (y > 0) if (y > 0)
return (long)((double)(y) * m_scaleY + 0.5); return (long)((double)(y) * m_scaleY + 0.5);
else else
return (long)((double)(y) * m_scaleY - 0.5); 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
wxPen m_pen; void SetInternalDeviceOrigin( long x, long y );
wxBrush m_brush; void GetInternalDeviceOrigin( long *x, long *y );
wxBrush m_backgroundBrush;
wxColour m_textForegroundColour; public:
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? // 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; 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.
double m_scaleX,m_scaleY; // If un-scrolled is non-zero or d.o. changes with scrolling. Set using
double m_logicalScaleX,m_logicalScaleY; // SetInternalDeviceOrigin().
double m_userScaleX,m_userScaleY; long m_internalDeviceOriginX,m_internalDeviceOriginY;
long m_signX,m_signY;
// To be set by external classes such as wxScrolledWindow using
bool m_needComputeScaleX,m_needComputeScaleY; // not yet used // SetDeviceOrigin()
long m_externalDeviceOriginX,m_externalDeviceOriginY;
float m_scaleFactor; // wxPSDC wants to have this. Will disappear.
// recompute scale?
long m_clipX1,m_clipY1,m_clipX2,m_clipY2; bool m_needComputeScaleX, m_needComputeScaleY;
long m_minX,m_maxX,m_minY,m_maxY;
// wxPSDC wants to have this. Will disappear.
float m_scaleFactor;
}; };
#endif #endif

View File

@@ -6,185 +6,135 @@
// Created: 17/09/98 // Created: 17/09/98
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Julian Smart // Copyright: (c) Julian Smart
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DCCLIENT_H_ #ifndef _WX_DCCLIENT_H_
#define _WX_DCCLIENT_H_ #define _WX_DCCLIENT_H_
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface "dcclient.h" #pragma interface "dcclient.h"
#endif #endif
#include "wx/dc.h" #include "wx/dc.h"
//----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// classes // fwd declarations
//----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
class WXDLLEXPORT wxWindowDC; class WXDLLEXPORT wxWindowDC;
class WXDLLEXPORT wxWindow; class WXDLLEXPORT wxWindow;
// Under Windows, wxClientDC, wxPaintDC and wxWindowDC are implemented differently. // Under Windows, wxClientDC, wxPaintDC and wxWindowDC are implemented
// On many platforms, however, they will be the same. // differently. On many platforms, however, they will be the same.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxWindowDC // wxWindowDC
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class WXDLLEXPORT wxWindowDC: public wxDC class WXDLLEXPORT wxWindowDC : public wxDC
{ {
DECLARE_DYNAMIC_CLASS(wxWindowDC) DECLARE_DYNAMIC_CLASS(wxWindowDC)
public: public:
wxWindowDC();
wxWindowDC(void);
wxWindowDC( wxWindow *win ); 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; ~wxWindowDC();
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 ); // TODO this function is Motif-only for now - should it go into base class?
inline void DrawLine(const wxPoint& pt1, const wxPoint& pt2) void Clear(const wxRect& rect);
{
DrawLine(pt1.x, pt1.y, pt2.x, pt2.y);
}
virtual void CrossHair( long x, long y ); // implement base class pure virtuals
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 ); virtual void Clear();
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 SetFont(const wxFont& font);
virtual void DrawEllipticArc (const wxPoint& pt, const wxSize& sz, double sa, double ea) virtual void SetPen(const wxPen& pen);
{ virtual void SetBrush(const wxBrush& brush);
DrawEllipticArc(pt.x, pt.y, sz.x, sz.y, sa, ea); virtual void SetBackground(const wxBrush& brush);
} virtual void SetBackgroundMode(int mode);
virtual void SetPalette(const wxPalette& palette);
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 );
virtual void SetLogicalFunction( int function ); 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 virtual void SetTextForeground(const wxColour& colour);
wxSize GetPPI(void) const; virtual void SetTextBackground(const wxColour& colour);
// Motif-specific virtual long GetCharHeight() const;
void SetDCClipping (); // Helper function for setting clipping virtual long GetCharWidth() const;
virtual void GetTextExtent(const wxString& string,
long *x, long *y,
long *descent = NULL,
long *externalLeading = NULL,
wxFont *theFont = NULL) const;
inline WXGC GetGC() const { return m_gc; } virtual bool CanDrawBitmap() const;
inline WXGC GetBackingGC() const { return m_gcBacking; } virtual bool CanGetTextExtent() const;
inline WXDisplay* GetDisplay() const { return m_display; }
inline bool GetAutoSetting() const { return m_autoSetting; } virtual int GetDepth() const;
inline void SetAutoSetting(bool flag) { m_autoSetting = flag; } 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: 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_gc;
WXGC m_gcBacking; WXGC m_gcBacking;
WXDisplay* m_display; WXDisplay* m_display;
@@ -196,7 +146,7 @@ protected:
// Not sure if we'll need all of these // Not sure if we'll need all of these
int m_backgroundPixel; int m_backgroundPixel;
wxColour m_currentColour; wxColour m_currentColour;
// int m_currentBkMode; // int m_currentBkMode;
int m_currentPenWidth ; int m_currentPenWidth ;
int m_currentPenJoin ; int m_currentPenJoin ;
int m_currentPenCap ; int m_currentPenCap ;
@@ -211,19 +161,22 @@ protected:
class WXDLLEXPORT wxPaintDC: public wxWindowDC class WXDLLEXPORT wxPaintDC: public wxWindowDC
{ {
DECLARE_DYNAMIC_CLASS(wxPaintDC) DECLARE_DYNAMIC_CLASS(wxPaintDC)
public: public:
wxPaintDC() {} wxPaintDC() { }
wxPaintDC(wxWindow* win); wxPaintDC(wxWindow* win);
~wxPaintDC();
~wxPaintDC();
}; };
class WXDLLEXPORT wxClientDC: public wxWindowDC class WXDLLEXPORT wxClientDC: public wxWindowDC
{ {
DECLARE_DYNAMIC_CLASS(wxClientDC) DECLARE_DYNAMIC_CLASS(wxClientDC)
public: public:
wxClientDC() {} wxClientDC() { }
wxClientDC(wxWindow* win): wxWindowDC(win) {} wxClientDC(wxWindow* win) : wxWindowDC(win) { }
}; };
#endif #endif

View File

@@ -6,33 +6,36 @@
// Created: 17/09/98 // Created: 17/09/98
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Julian Smart // Copyright: (c) Julian Smart
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DCMEMORY_H_ #ifndef _WX_DCMEMORY_H_
#define _WX_DCMEMORY_H_ #define _WX_DCMEMORY_H_
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface "dcmemory.h" #pragma interface "dcmemory.h"
#endif #endif
#include "wx/dcclient.h" #include "wx/dcclient.h"
class WXDLLEXPORT wxMemoryDC: public wxWindowDC class wxMemoryDC : public wxWindowDC
{ {
DECLARE_DYNAMIC_CLASS(wxMemoryDC) DECLARE_DYNAMIC_CLASS(wxMemoryDC)
public: public:
wxMemoryDC(void); wxMemoryDC();
wxMemoryDC( wxDC *dc ); // Create compatible DC wxMemoryDC( wxDC *dc ); // Create compatible DC
~wxMemoryDC(void); ~wxMemoryDC();
virtual void SelectObject( const wxBitmap& bitmap ); virtual void SelectObject( const wxBitmap& bitmap );
void GetSize( int *width, int *height ) const; 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; friend wxPaintDC;
wxBitmap m_bitmap; wxBitmap m_bitmap;
}; };

View File

@@ -91,8 +91,8 @@ public:
void SetUnderlined(bool underlined); void SetUnderlined(bool underlined);
inline wxFont& operator = (const wxFont& font) { if (*this == font) return (*this); Ref(font); return *this; } 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) const { 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; }
// Implementation // Implementation

View File

@@ -6,7 +6,7 @@
// Created: 17/09/98 // Created: 17/09/98
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Julian Smart // Copyright: (c) Julian Smart
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef _WX_FRAME_H_ #ifndef _WX_FRAME_H_
@@ -19,6 +19,7 @@
#include "wx/window.h" #include "wx/window.h"
#include "wx/toolbar.h" #include "wx/toolbar.h"
#include "wx/accel.h" #include "wx/accel.h"
#include "wx/icon.h"
WXDLLEXPORT_DATA(extern const char*) wxFrameNameStr; WXDLLEXPORT_DATA(extern const char*) wxFrameNameStr;
WXDLLEXPORT_DATA(extern const char*) wxToolBarNameStr; WXDLLEXPORT_DATA(extern const char*) wxToolBarNameStr;

View File

@@ -6,7 +6,7 @@
// Created: 17/09/98 // Created: 17/09/98
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Julian Smart // Copyright: (c) Julian Smart
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef _WX_RADIOBOX_H_ #ifndef _WX_RADIOBOX_H_
@@ -56,7 +56,7 @@ public:
void SetLabel(int item, const wxString& label) ; void SetLabel(int item, const wxString& label) ;
wxString GetLabel(int item) const; wxString GetLabel(int item) const;
wxString GetLabel() const { return wxControl::GetLabel(); }; wxString GetLabel() const { return wxControl::GetLabel(); };
void Enable(bool enable); bool Enable(bool enable);
void Enable(int item, bool enable); void Enable(int item, bool enable);
void Show(int item, bool show) ; void Show(int item, bool show) ;
bool Show(bool show) ; bool Show(bool show) ;

View File

@@ -16,6 +16,12 @@
#pragma interface "window.h" #pragma interface "window.h"
#endif #endif
// ----------------------------------------------------------------------------
// A list of rectangles type used by wxWindow
// ----------------------------------------------------------------------------
WX_DECLARE_LIST(wxRect, wxRectList);
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxWindow class for Motif - see also wxWindowBase // wxWindow class for Motif - see also wxWindowBase
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -70,6 +76,9 @@ public:
const wxRect *rect = (const wxRect *) NULL ); const wxRect *rect = (const wxRect *) NULL );
virtual void Clear(); virtual void Clear();
virtual bool SetBackgroundColour( const wxColour &colour );
virtual bool SetForegroundColour( const wxColour &colour );
virtual bool SetCursor( const wxCursor &cursor ); virtual bool SetCursor( const wxCursor &cursor );
virtual bool SetFont( const wxFont &font ); virtual bool SetFont( const wxFont &font );
@@ -93,6 +102,9 @@ public:
virtual void ScrollWindow( int dx, int dy, virtual void ScrollWindow( int dx, int dy,
const wxRect* rect = (wxRect *) NULL ); const wxRect* rect = (wxRect *) NULL );
virtual void SetSizeHints(int minW, int minH,
int maxW, int maxH,
int incW, int incH);
#if wxUSE_DRAG_AND_DROP #if wxUSE_DRAG_AND_DROP
virtual void SetDropTarget( wxDropTarget *dropTarget ); virtual void SetDropTarget( wxDropTarget *dropTarget );
#endif // wxUSE_DRAG_AND_DROP #endif // wxUSE_DRAG_AND_DROP
@@ -100,43 +112,11 @@ public:
// Accept files for dragging // Accept files for dragging
virtual void DragAcceptFiles(bool accept); virtual void DragAcceptFiles(bool accept);
protected: // Get the unique identifier of a window
// event handlers (not virtual by design) virtual WXWidget GetHandle() const { return GetMainWidget(); }
void OnIdle(wxIdleEvent& event);
// For implementation purposes - sometimes decorations make the client area // implementation from now on
// smaller // --------------------------
virtual wxPoint GetClientAreaOrigin() const;
// Makes an adjustment to the window position (for example, a frame that has
// a toolbar that it manages itself).
virtual void AdjustForParentClientOrigin(int& x, int& y, int sizeFlags);
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(); }
// Responds to colour changes: passes event on to children.
void OnSysColourChanged(wxSysColourChangedEvent& event);
// 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 CanvasGetPosition(int *x, int *y) const; // If have drawing area
void CanvasSetClientSize(int width, int size);
void CanvasSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
// 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 // accessors
// --------- // ---------
@@ -153,18 +133,78 @@ protected:
// implements this window. // implements this window.
virtual WXWidget GetTopWidget() const; virtual WXWidget GetTopWidget() const;
// base class pure virtual // Get the underlying X window and display
virtual WXWidget GetHandle() const { return GetMainWidget(); } 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);
// For implementation purposes - sometimes decorations make the client area
// smaller
virtual wxPoint GetClientAreaOrigin() const;
// Makes an adjustment to the window position (for example, a frame that has
// a toolbar that it manages itself).
virtual void AdjustForParentClientOrigin(int& x, int& y, int sizeFlags);
wxWindow *GetChild(int number) const
{ return GetChildren().Item(number)->GetData(); }
// Responds to colour changes: passes event on to children.
void OnSysColourChanged(wxSysColourChangedEvent& event);
// Motif-specific
// CanvasXXXSiize functions
void CanvasGetSize(int* width, int* height) const; // If have drawing area
void CanvasGetClientSize(int *width, int *height) const;
void CanvasGetPosition(int *x, int *y) const; // If have drawing area
void CanvasSetClientSize(int width, int size);
void CanvasSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
void SetMainWidget(WXWidget w) { m_mainWidget = w; } void SetMainWidget(WXWidget w) { m_mainWidget = w; }
bool CanAddEventHandler() const { return m_canAddEventHandler; } bool CanAddEventHandler() const { return m_canAddEventHandler; }
void SetCanAddEventHandler(bool flag) { m_canAddEventHandler = flag; } 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; } WXPixmap GetBackingPixmap() const { return m_backingPixmap; }
int GetPixmapWidth() const { return m_pixmapWidth; } int GetPixmapWidth() const { return m_pixmapWidth; }
int GetPixmapHeight() const { return m_pixmapHeight; } int GetPixmapHeight() const { return m_pixmapHeight; }
@@ -185,9 +225,6 @@ protected:
WXWidget formWidget, int x, int y, int width, int height); WXWidget formWidget, int x, int y, int width, int height);
bool DetachWidget(WXWidget widget); bool DetachWidget(WXWidget widget);
// Generates a paint event
virtual void DoPaint();
// How to implement accelerators. If we find a key event, translate to // How to implement accelerators. If we find a key event, translate to
// wxWindows wxKeyEvent form. Find a widget for the window. Now find a // 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 // wxWindow for the widget. If there isn't one, go up the widget hierarchy
@@ -202,7 +239,6 @@ protected:
// event and send it. // event and send it.
virtual bool ProcessAccelerator(wxKeyEvent& event); virtual bool ProcessAccelerator(wxKeyEvent& event);
protected:
// unmanage and destroy an X widget f it's !NULL (passing NULL is ok) // unmanage and destroy an X widget f it's !NULL (passing NULL is ok)
void UnmanageAndDestroy(WXWidget widget); void UnmanageAndDestroy(WXWidget widget);
@@ -210,6 +246,13 @@ protected:
// mapped/unmapped // mapped/unmapped
bool MapOrUnmap(WXWidget widget, bool map); 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 // get either hor or vert scrollbar widget
WXWidget GetScrollbar(wxOrientation orient) const WXWidget GetScrollbar(wxOrientation orient) const
{ return orient == wxHORIZONTAL ? m_hScrollBar : m_vScrollBar; } { return orient == wxHORIZONTAL ? m_hScrollBar : m_vScrollBar; }
@@ -224,6 +267,8 @@ protected:
} }
// Motif-specific flags // Motif-specific flags
// --------------------
bool m_needsRefresh:1; // repaint backing store? bool m_needsRefresh:1; // repaint backing store?
bool m_canAddEventHandler:1; // ??? bool m_canAddEventHandler:1; // ???
bool m_button1Pressed:1; bool m_button1Pressed:1;
@@ -233,7 +278,9 @@ protected:
// For double-click detection // For double-click detection
long m_lastTS; // last timestamp long m_lastTS; // last timestamp
int m_lastButton; // last pressed button 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: protected:
WXWidget m_mainWidget; WXWidget m_mainWidget;
@@ -280,21 +327,26 @@ private:
}; };
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// A little class to switch off size optimization while an instance of the object // A little class to switch off `size optimization' while an instance of the
// exists // 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: public:
wxNoOptimize(); wxNoOptimize() { ms_count++; }
~wxNoOptimize(); ~wxNoOptimize() { ms_count--; }
static bool CanOptimize(); static bool CanOptimize() { return ms_count == 0; }
protected: protected:
static int m_count; static int ms_count;
}; };
#endif #endif

View File

@@ -6,244 +6,122 @@
// Created: 01/02/97 // Created: 01/02/97
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Julian Smart // Copyright: (c) Julian Smart
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "dc.h" #pragma implementation "dc.h"
#endif #endif
#include "wx/dc.h" #include "wx/dc.h"
#include "wx/dcmemory.h" #include "wx/dcmemory.h"
#if !USE_SHARED_LIBRARY #if !USE_SHARED_LIBRARY
IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject) IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject)
#endif #endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// constants // constants
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#define mm2inches 0.0393700787402 #define mm2inches 0.0393700787402
#define inches2mm 25.4 #define inches2mm 25.4
#define mm2twips 56.6929133859 #define mm2twips 56.6929133859
#define twips2mm 0.0176388888889 #define twips2mm 0.0176388888889
#define mm2pt 2.83464566929 #define mm2pt 2.83464566929
#define pt2mm 0.352777777778 #define pt2mm 0.352777777778
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxDC // wxDC
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
wxDC::wxDC(void) wxDC::wxDC()
{ {
m_ok = FALSE; m_ok = FALSE;
m_optimize = FALSE;
m_colour = TRUE;
m_clipping = FALSE;
m_mm_to_pix_x = 1.0; m_mm_to_pix_x = 1.0;
m_mm_to_pix_y = 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_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_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()) wxCHECK_RET( bitmap.Ok(), "invalid bitmap" );
return;
wxMemoryDC memDC; wxMemoryDC memDC;
memDC.SelectObject(bitmap); memDC.SelectObject(bitmap);
/* Not sure if we need this. The mask should leave the #if 0
* masked areas as per the original background of this DC. // Not sure if we need this. The mask should leave the masked areas as per
// the original background of this DC.
if (useMask) if (useMask)
{ {
// There might be transparent areas, so make these // There might be transparent areas, so make these the same colour as this
// the same colour as this DC // DC
memDC.SetBackground(* GetBackground()); memDC.SetBackground(* GetBackground());
memDC.Clear(); memDC.Clear();
} }
*/ #endif // 0
Blit(x, y, bitmap.GetWidth(), bitmap.GetHeight(), & memDC, 0, 0, wxCOPY, useMask); Blit(x, y, bitmap.GetWidth(), bitmap.GetHeight(), &memDC, 0, 0, wxCOPY, useMask);
memDC.SelectObject(wxNullBitmap); memDC.SelectObject(wxNullBitmap);
}; }
void wxDC::DoSetClippingRegion( long x, long y, long width, long height )
void wxDC::DrawPoint( wxPoint& point )
{
DrawPoint( point.x, point.y );
};
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 );
};
void wxDC::SetClippingRegion( long x, long y, long width, long height )
{ {
m_clipping = TRUE; m_clipping = TRUE;
m_clipX1 = x; m_clipX1 = x;
m_clipY1 = y; m_clipY1 = y;
m_clipX2 = x + width; m_clipX2 = x + width;
m_clipY2 = y + height; m_clipY2 = y + height;
}; }
void wxDC::DestroyClippingRegion(void) void wxDC::DestroyClippingRegion()
{ {
m_clipping = FALSE; m_clipping = FALSE;
}; }
void wxDC::GetClippingBox( long *x, long *y, long *width, long *height ) const void wxDC::DoGetSize( int* width, int* height ) const
{ {
if (m_clipping) if ( width )
{ *width = m_maxX - m_minX;
if (x) *x = m_clipX1; if ( height )
if (y) *y = m_clipY1; *height = m_maxY - m_minY;
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::DoGetSizeMM( int* width, int* height ) const
{ {
*width = m_maxX-m_minX; int w, h;
*height = m_maxY-m_minY;
};
void wxDC::GetSizeMM( int* width, int* height ) const
{
int w = 0;
int h = 0;
GetSize( &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 // Resolution in pixels per logical inch
wxSize wxDC::GetPPI(void) const wxSize wxDC::GetPPI() const
{ {
// TODO (should probably be pure virtual) // TODO (should probably be pure virtual)
return wxSize(0, 0); 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 ) void wxDC::SetMapMode( int mode )
{ {
switch (mode) switch (mode)
{ {
case wxMM_TWIPS: case wxMM_TWIPS:
SetLogicalScale( twips2mm*m_mm_to_pix_x, twips2mm*m_mm_to_pix_y ); SetLogicalScale( twips2mm*m_mm_to_pix_x, twips2mm*m_mm_to_pix_y );
@@ -261,151 +139,113 @@ void wxDC::SetMapMode( int mode )
case wxMM_TEXT: case wxMM_TEXT:
SetLogicalScale( 1.0, 1.0 ); SetLogicalScale( 1.0, 1.0 );
break; break;
}; }
if (mode != wxMM_TEXT) if (mode != wxMM_TEXT)
{ {
m_needComputeScaleX = TRUE; m_needComputeScaleX = TRUE;
m_needComputeScaleY = TRUE; m_needComputeScaleY = TRUE;
}; }
}; }
void wxDC::SetUserScale( double x, double y ) void wxDC::SetUserScale( double x, double y )
{ {
// allow negative ? -> no wxDCBase::SetUserScale(x, y);
m_userScaleX = x;
m_userScaleY = y;
ComputeScaleAndOrigin(); 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 ) void wxDC::SetLogicalScale( double x, double y )
{ {
// allow negative ? wxDCBase::SetLogicalScale(x, y);
m_logicalScaleX = x;
m_logicalScaleY = y;
ComputeScaleAndOrigin(); 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 ) void wxDC::SetLogicalOrigin( long x, long y )
{ {
m_logicalOriginX = x * m_signX; // is this still correct ? m_logicalOriginX = x * m_signX; // is this still correct ?
m_logicalOriginY = y * m_signY; m_logicalOriginY = y * m_signY;
ComputeScaleAndOrigin(); 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 ) void wxDC::SetDeviceOrigin( long x, long y )
{ {
m_externalDeviceOriginX = x; m_externalDeviceOriginX = x;
m_externalDeviceOriginY = y; m_externalDeviceOriginY = y;
ComputeScaleAndOrigin(); 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 ) void wxDC::SetInternalDeviceOrigin( long x, long y )
{ {
m_internalDeviceOriginX = x; m_internalDeviceOriginX = x;
m_internalDeviceOriginY = y; m_internalDeviceOriginY = y;
ComputeScaleAndOrigin(); ComputeScaleAndOrigin();
}; }
void wxDC::GetInternalDeviceOrigin( long *x, long *y ) void wxDC::GetInternalDeviceOrigin( long *x, long *y )
{ {
if (x) *x = m_internalDeviceOriginX; if (x) *x = m_internalDeviceOriginX;
if (y) *y = m_internalDeviceOriginY; if (y) *y = m_internalDeviceOriginY;
}; }
void wxDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp ) void wxDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp )
{ {
m_signX = (xLeftRight ? 1 : -1); m_signX = xLeftRight ? 1 : -1;
m_signY = (yBottomUp ? -1 : 1); m_signY = yBottomUp ? -1 : 1;
ComputeScaleAndOrigin(); ComputeScaleAndOrigin();
}; }
long wxDC::DeviceToLogicalX(long x) const long wxDCBase::DeviceToLogicalX(long x) const
{ {
return XDEV2LOG(x); return ((wxDC *)this)->XDEV2LOG(x);
}; }
long wxDC::DeviceToLogicalY(long y) const long wxDCBase::DeviceToLogicalY(long y) const
{ {
return YDEV2LOG(y); return ((wxDC *)this)->YDEV2LOG(y);
}; }
long wxDC::DeviceToLogicalXRel(long x) const long wxDCBase::DeviceToLogicalXRel(long x) const
{ {
return XDEV2LOGREL(x); return ((wxDC *)this)->XDEV2LOGREL(x);
}; }
long wxDC::DeviceToLogicalYRel(long y) const long wxDCBase::DeviceToLogicalYRel(long y) const
{ {
return YDEV2LOGREL(y); return ((wxDC *)this)->YDEV2LOGREL(y);
}; }
long wxDC::LogicalToDeviceX(long x) const long wxDCBase::LogicalToDeviceX(long x) const
{ {
return XLOG2DEV(x); return ((wxDC *)this)->XLOG2DEV(x);
}; }
long wxDC::LogicalToDeviceY(long y) const long wxDCBase::LogicalToDeviceY(long y) const
{ {
return YLOG2DEV(y); return ((wxDC *)this)->YLOG2DEV(y);
}; }
long wxDC::LogicalToDeviceXRel(long x) const long wxDCBase::LogicalToDeviceXRel(long x) const
{ {
return XLOG2DEVREL(x); return ((wxDC *)this)->XLOG2DEVREL(x);
}; }
long wxDC::LogicalToDeviceYRel(long y) const long wxDCBase::LogicalToDeviceYRel(long y) const
{ {
return YLOG2DEVREL(y); return ((wxDC *)this)->YLOG2DEVREL(y);
}; }
void wxDC::CalcBoundingBox( long x, long y ) void wxDC::ComputeScaleAndOrigin()
{
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;
};
void wxDC::ComputeScaleAndOrigin(void)
{ {
// CMB: copy scale to see if it changes // CMB: copy scale to see if it changes
double origScaleX = m_scaleX; double origScaleX = m_scaleX;
double origScaleY = m_scaleY; double origScaleY = m_scaleY;
m_scaleX = m_logicalScaleX * m_userScaleX; m_scaleX = m_logicalScaleX * m_userScaleX;
m_scaleY = m_logicalScaleY * m_userScaleY; m_scaleY = m_logicalScaleY * m_userScaleY;
m_deviceOriginX = m_internalDeviceOriginX + m_externalDeviceOriginX; m_deviceOriginX = m_internalDeviceOriginX + m_externalDeviceOriginX;
m_deviceOriginY = m_internalDeviceOriginY + m_externalDeviceOriginY; 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) if (m_scaleX != origScaleX || m_scaleY != origScaleY)
{ {
// this is a bit artificial, but we need to force wxDC to think // this is a bit artificial, but we need to force wxDC to think
@@ -415,5 +255,5 @@ void wxDC::ComputeScaleAndOrigin(void)
m_pen = tempPen; m_pen = tempPen;
SetPen(* pen); SetPen(* pen);
} }
}; }

File diff suppressed because it is too large Load Diff

View File

@@ -6,7 +6,7 @@
// Created: 17/09/98 // Created: 17/09/98
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Julian Smart // Copyright: (c) Julian Smart
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
@@ -27,7 +27,7 @@
#include <wx/motif/private.h> #include <wx/motif/private.h>
void wxRadioBoxCallback (Widget w, XtPointer clientData, void wxRadioBoxCallback (Widget w, XtPointer clientData,
XmToggleButtonCallbackStruct * cbs); XmToggleButtonCallbackStruct * cbs);
#if !USE_SHARED_LIBRARY #if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxRadioBox, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxRadioBox, wxControl)
@@ -91,10 +91,10 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title,
XmString text = XmStringCreateSimple ((char*) (const char*) label1); XmString text = XmStringCreateSimple ((char*) (const char*) label1);
Widget formWidget = XtVaCreateManagedWidget ((char*) (const char*) name, Widget formWidget = XtVaCreateManagedWidget ((char*) (const char*) name,
xmFormWidgetClass, parentWidget, xmFormWidgetClass, parentWidget,
XmNmarginHeight, 0, XmNmarginHeight, 0,
XmNmarginWidth, 0, XmNmarginWidth, 0,
NULL); NULL);
m_formWidget = (WXWidget) formWidget; m_formWidget = (WXWidget) formWidget;
@@ -104,25 +104,25 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title,
text = XmStringCreateSimple ((char*) (const char*) label1); text = XmStringCreateSimple ((char*) (const char*) label1);
Widget labelWidget = XtVaCreateManagedWidget ((char*) (const char*) label1, Widget labelWidget = XtVaCreateManagedWidget ((char*) (const char*) label1,
#if wxUSE_GADGETS #if wxUSE_GADGETS
style & wxCOLOURED ? style & wxCOLOURED ?
xmLabelWidgetClass : xmLabelGadgetClass, xmLabelWidgetClass : xmLabelGadgetClass,
formWidget, formWidget,
#else #else
xmLabelWidgetClass, formWidget, xmLabelWidgetClass, formWidget,
#endif #endif
XmNfontList, fontList, XmNfontList, fontList,
XmNlabelString, text, XmNlabelString, text,
NULL); NULL);
XmStringFree (text); XmStringFree (text);
} }
Widget frameWidget = XtVaCreateManagedWidget ("frame", Widget frameWidget = XtVaCreateManagedWidget ("frame",
xmFrameWidgetClass, formWidget, xmFrameWidgetClass, formWidget,
XmNshadowType, XmSHADOW_IN, XmNshadowType, XmSHADOW_IN,
// XmNmarginHeight, 0, // XmNmarginHeight, 0,
// XmNmarginWidth, 0, // XmNmarginWidth, 0,
NULL); NULL);
m_frameWidget = (WXWidget) frameWidget; m_frameWidget = (WXWidget) frameWidget;
@@ -131,7 +131,7 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title,
majorDim = (n + majorDim - 1) / majorDim; majorDim = (n + majorDim - 1) / majorDim;
XtSetArg (args[0], XmNorientation, ((style & wxHORIZONTAL) == wxHORIZONTAL ? XtSetArg (args[0], XmNorientation, ((style & wxHORIZONTAL) == wxHORIZONTAL ?
XmHORIZONTAL : XmVERTICAL)); XmHORIZONTAL : XmVERTICAL));
XtSetArg (args[1], XmNnumColumns, majorDim); XtSetArg (args[1], XmNnumColumns, majorDim);
Widget radioBoxWidget = XmCreateRadioBox (frameWidget, "radioBoxWidget", args, 2); Widget radioBoxWidget = XmCreateRadioBox (frameWidget, "radioBoxWidget", args, 2);
@@ -139,19 +139,19 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title,
if (m_labelWidget) if (m_labelWidget)
XtVaSetValues ((Widget) m_labelWidget, XtVaSetValues ((Widget) m_labelWidget,
XmNtopAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_FORM,
XmNalignment, XmALIGNMENT_BEGINNING, XmNalignment, XmALIGNMENT_BEGINNING,
NULL); NULL);
XtVaSetValues (radioBoxWidget, XtVaSetValues (radioBoxWidget,
XmNtopAttachment, m_labelWidget ? XmATTACH_WIDGET : XmATTACH_FORM, XmNtopAttachment, m_labelWidget ? XmATTACH_WIDGET : XmATTACH_FORM,
XmNtopWidget, m_labelWidget ? (Widget) m_labelWidget : formWidget, XmNtopWidget, m_labelWidget ? (Widget) m_labelWidget : formWidget,
XmNbottomAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_FORM,
XmNrightAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM,
NULL); NULL);
// if (style & wxFLAT) // if (style & wxFLAT)
// XtVaSetValues (radioBoxWidget, XmNborderWidth, 1, NULL); // XtVaSetValues (radioBoxWidget, XmNborderWidth, 1, NULL);
@@ -165,14 +165,14 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title,
m_radioButtonLabels[i] = str; m_radioButtonLabels[i] = str;
m_radioButtons[i] = (WXWidget) XtVaCreateManagedWidget ((char*) (const char*) str, m_radioButtons[i] = (WXWidget) XtVaCreateManagedWidget ((char*) (const char*) str,
#if wxUSE_GADGETS #if wxUSE_GADGETS
xmToggleButtonGadgetClass, radioBoxWidget, xmToggleButtonGadgetClass, radioBoxWidget,
#else #else
xmToggleButtonWidgetClass, radioBoxWidget, xmToggleButtonWidgetClass, radioBoxWidget,
#endif #endif
XmNfontList, fontList, XmNfontList, fontList,
NULL); NULL);
XtAddCallback ((Widget) m_radioButtons[i], XmNvalueChangedCallback, (XtCallbackProc) wxRadioBoxCallback, XtAddCallback ((Widget) m_radioButtons[i], XmNvalueChangedCallback, (XtCallbackProc) wxRadioBoxCallback,
(XtCallbackProc) this); (XtCallbackProc) this);
} }
SetSelection (0); SetSelection (0);
@@ -219,8 +219,8 @@ wxString wxRadioBox::GetLabel(int item) const
XmString text; XmString text;
char *s; char *s;
XtVaGetValues (widget, XtVaGetValues (widget,
XmNlabelString, &text, XmNlabelString, &text,
NULL); NULL);
if (XmStringGetLtoR (text, XmSTRING_DEFAULT_CHARSET, &s)) if (XmStringGetLtoR (text, XmSTRING_DEFAULT_CHARSET, &s))
{ {
@@ -248,9 +248,9 @@ void wxRadioBox::SetLabel(int item, const wxString& label)
wxString label1(wxStripMenuCodes(label)); wxString label1(wxStripMenuCodes(label));
XmString text = XmStringCreateSimple ((char*) (const char*) label1); XmString text = XmStringCreateSimple ((char*) (const char*) label1);
XtVaSetValues (widget, XtVaSetValues (widget,
XmNlabelString, text, XmNlabelString, text,
XmNlabelType, XmSTRING, XmNlabelType, XmSTRING,
NULL); NULL);
XmStringFree (text); XmStringFree (text);
} }
} }
@@ -309,10 +309,10 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
if (x > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) if (x > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
XtVaSetValues ((Widget) m_formWidget, XmNleftAttachment, XmATTACH_SELF, XtVaSetValues ((Widget) m_formWidget, XmNleftAttachment, XmATTACH_SELF,
XmNx, xx, NULL); XmNx, xx, NULL);
if (y > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) if (y > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
XtVaSetValues ((Widget) m_formWidget, XmNtopAttachment, XmATTACH_SELF, 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 // Must set the actual RadioBox to be desired size MINUS label size
Dimension labelWidth = 0, labelHeight = 0, actualWidth = 0, actualHeight = 0; Dimension labelWidth = 0, labelHeight = 0, actualWidth = 0, actualHeight = 0;
@@ -345,13 +345,16 @@ void wxRadioBox::Enable(int n, bool enable)
} }
// Enable all controls // Enable all controls
void wxRadioBox::Enable(bool enable) bool wxRadioBox::Enable(bool enable)
{ {
wxControl::Enable(enable); if ( !wxControl::Enable(enable) )
return FALSE;
int i; int i;
for (i = 0; i < m_noItems; i++) for (i = 0; i < m_noItems; i++)
XtSetSensitive ((Widget) m_radioButtons[i], (Boolean) enable); XtSetSensitive ((Widget) m_radioButtons[i], (Boolean) enable);
return TRUE;
} }
bool wxRadioBox::Show(bool show) bool wxRadioBox::Show(bool show)
@@ -430,7 +433,7 @@ void wxRadioBox::ChangeFont(bool keepOriginalSize)
XtVaSetValues ((Widget) radioButton, XtVaSetValues ((Widget) radioButton,
XmNfontList, fontList, XmNfontList, fontList,
XmNtopAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_FORM,
NULL); NULL);
} }
} }
@@ -470,7 +473,7 @@ void wxRadioBox::ChangeForegroundColour()
} }
void wxRadioBoxCallback (Widget w, XtPointer clientData, void wxRadioBoxCallback (Widget w, XtPointer clientData,
XmToggleButtonCallbackStruct * cbs) XmToggleButtonCallbackStruct * cbs)
{ {
if (!cbs->set) if (!cbs->set)
return; return;

View File

@@ -40,6 +40,8 @@
#include "wx/menuitem.h" #include "wx/menuitem.h"
#include "wx/log.h" #include "wx/log.h"
#include "wx/listimpl.cpp"
#if wxUSE_DRAG_AND_DROP #if wxUSE_DRAG_AND_DROP
#include "wx/dnd.h" #include "wx/dnd.h"
#endif #endif
@@ -126,6 +128,12 @@ static int str16len(const char *s)
// implementation // implementation
// ============================================================================ // ============================================================================
// ----------------------------------------------------------------------------
// list types
// ----------------------------------------------------------------------------
WX_DEFINE_LIST(wxRectList);
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// helper functions // helper functions
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -416,7 +424,7 @@ wxWindow::~wxWindow()
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Helper function // Helper function
void wxWindow::CreateScrollbar(int orientation) void wxWindow::CreateScrollbar(wxOrientation orientation)
{ {
wxCHECK_RET( m_drawingArea, "this window can't have scrollbars" ); wxCHECK_RET( m_drawingArea, "this window can't have scrollbars" );
@@ -493,7 +501,7 @@ void wxWindow::CreateScrollbar(int orientation)
XtVaSetValues((Widget) m_scrolledWindow, XmNresizePolicy, XmRESIZE_ANY, NULL); 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" ); wxCHECK_RET( m_drawingArea, "this window can't have scrollbars" );
@@ -543,7 +551,7 @@ void wxWindow::SetFocus()
} }
// Get the window with the focus // Get the window with the focus
wxWindow *wxWindow::FindFocus() wxWindow *wxWindowBase::FindFocus()
{ {
// TODO Problems: // TODO Problems:
// (1) Can there be multiple focussed widgets in an application? // (1) Can there be multiple focussed widgets in an application?
@@ -571,12 +579,12 @@ wxWindow *wxWindow::FindFocus()
return winFocus; return winFocus;
} }
void wxWindow::Enable(bool enable) bool wxWindow::Enable(bool enable)
{ {
if ( !wxWindowBase::Enable(enable) ) if ( !wxWindowBase::Enable(enable) )
return FALSE; return FALSE;
Widget wMain = GetMainWidget(); Widget wMain = (Widget)GetMainWidget();
if ( wMain ) if ( wMain )
{ {
XtSetSensitive(wMain, enable); XtSetSensitive(wMain, enable);
@@ -630,14 +638,17 @@ void wxWindow::Lower()
XLowerWindow(XtDisplay(wTop), window); 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 wxString wxWindow::GetTitle() const
{ {
return wxGetWindowText(GetHWND()); char *title;
XtVaGetValues((Widget)GetMainWidget(), XmNtitle, &title, NULL);
return wxString(title);
} }
void wxWindow::CaptureMouse() void wxWindow::CaptureMouse()
@@ -645,7 +656,7 @@ void wxWindow::CaptureMouse()
if ( m_winCaptured ) if ( m_winCaptured )
return; return;
Widget wMain = GetMainWidget(); Widget wMain = (Widget)GetMainWidget();
if ( wMain ) if ( wMain )
XtAddGrab(wMain, TRUE, FALSE); XtAddGrab(wMain, TRUE, FALSE);
@@ -657,7 +668,7 @@ void wxWindow::ReleaseMouse()
if ( !m_winCaptured ) if ( !m_winCaptured )
return; return;
Widget wMain = GetMainWidget(); Widget wMain = (Widget)GetMainWidget();
if ( wMain ) if ( wMain )
XtRemoveGrab(wMain); XtRemoveGrab(wMain);
@@ -694,6 +705,8 @@ bool wxWindow::SetCursor(const wxCursor& cursor)
Widget w = (Widget) GetMainWidget(); Widget w = (Widget) GetMainWidget();
Window win = XtWindow(w); Window win = XtWindow(w);
XDefineCursor((Display*) dpy, win, (Cursor) x_cursor); XDefineCursor((Display*) dpy, win, (Cursor) x_cursor);
return TRUE;
} }
// Coordinates relative to the window // Coordinates relative to the window
@@ -732,7 +745,7 @@ int wxWindow::GetScrollPos(int orient) const
// can scroll. // can scroll.
int wxWindow::GetScrollRange(int orient) const int wxWindow::GetScrollRange(int orient) const
{ {
Widget scrollBar = (Widget)GetScrollbar(orient); Widget scrollBar = (Widget)GetScrollbar((wxOrientation)orient);
wxCHECK_MSG( scrollBar, 0, "no such scrollbar" ); wxCHECK_MSG( scrollBar, 0, "no such scrollbar" );
int range; int range;
@@ -742,7 +755,7 @@ int wxWindow::GetScrollRange(int orient) const
int wxWindow::GetScrollThumb(int orient) const int wxWindow::GetScrollThumb(int orient) const
{ {
Widget scrollBar = (Widget)GetScrollbar(orient); Widget scrollBar = (Widget)GetScrollbar((wxOrientation)orient);
wxCHECK_MSG( scrollBar, 0, "no such scrollbar" ); wxCHECK_MSG( scrollBar, 0, "no such scrollbar" );
int thumb; int thumb;
@@ -752,14 +765,14 @@ int wxWindow::GetScrollThumb(int orient) const
void wxWindow::SetScrollPos(int orient, int pos, bool WXUNUSED(refresh)) void wxWindow::SetScrollPos(int orient, int pos, bool WXUNUSED(refresh))
{ {
Widget scrollBar = (Widget)GetScrollbar(orient); Widget scrollBar = (Widget)GetScrollbar((wxOrientation)orient);
if ( scrollBar ) if ( scrollBar )
{ {
XtVaSetValues (scrollBar, XmNvalue, pos, NULL); XtVaSetValues (scrollBar, XmNvalue, pos, NULL);
} }
SetInternalScrollPos(orient, pos); SetInternalScrollPos((wxOrientation)orient, pos);
} }
// New function that will replace some of the above. // New function that will replace some of the above.
@@ -778,7 +791,7 @@ void wxWindow::SetScrollbar(int orient, int pos, int thumbVisible,
thumbVisible = range; thumbVisible = range;
// Save the old state to see if it changed // Save the old state to see if it changed
WXWidget oldScrollBar = GetScrollbar(orient); WXWidget oldScrollBar = GetScrollbar((wxOrientation)orient);
if (orient == wxHORIZONTAL) if (orient == wxHORIZONTAL)
{ {
@@ -806,7 +819,7 @@ void wxWindow::SetScrollbar(int orient, int pos, int thumbVisible,
CreateScrollbar(wxVERTICAL); CreateScrollbar(wxVERTICAL);
} }
} }
WXWidget newScrollBar = GetScrollbar(orient); WXWidget newScrollBar = GetScrollbar((wxOrientation)orient);
if (oldScrollBar != newScrollBar) if (oldScrollBar != newScrollBar)
{ {
@@ -827,7 +840,7 @@ void wxWindow::SetScrollbar(int orient, int pos, int thumbVisible,
NULL); NULL);
} }
SetInternalScrollPos(orient, pos); SetInternalScrollPos((wxOrientation)orient, pos);
int newW, newH; int newW, newH;
GetSize(& newW, & newH); GetSize(& newW, & newH);
@@ -1037,7 +1050,7 @@ bool wxWindow::PreResize()
} }
// Get total size // Get total size
void wxWindow::GetSize(int *x, int *y) const void wxWindow::DoGetSize(int *x, int *y) const
{ {
if (m_drawingArea) if (m_drawingArea)
{ {
@@ -1051,7 +1064,7 @@ void wxWindow::GetSize(int *x, int *y) const
*x = xx; *y = yy; *x = xx; *y = yy;
} }
void wxWindow::GetPosition(int *x, int *y) const void wxWindow::DoGetPosition(int *x, int *y) const
{ {
if (m_drawingArea) if (m_drawingArea)
{ {
@@ -1074,7 +1087,7 @@ void wxWindow::GetPosition(int *x, int *y) const
*x = xx; *y = yy; *x = xx; *y = yy;
} }
void wxWindow::ScreenToClient(int *x, int *y) const void wxWindow::DoScreenToClient(int *x, int *y) const
{ {
Widget widget = (Widget) GetClientWidget(); Widget widget = (Widget) GetClientWidget();
Display *display = XtDisplay((Widget) GetMainWidget()); Display *display = XtDisplay((Widget) GetMainWidget());
@@ -1087,7 +1100,7 @@ void wxWindow::ScreenToClient(int *x, int *y) const
XTranslateCoordinates(display, rootWindow, thisWindow, xx, yy, x, y, &childWindow); 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(); Widget widget = (Widget) GetClientWidget();
Display *display = XtDisplay(widget); Display *display = XtDisplay(widget);
@@ -1102,7 +1115,7 @@ void wxWindow::ClientToScreen(int *x, int *y) const
// Get size *available for subwindows* i.e. excluding menu bar etc. // 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(); Widget widget = (Widget) GetClientWidget();
Dimension xx, yy; Dimension xx, yy;
@@ -1257,9 +1270,9 @@ void wxWindow::SetSizeHints(int minW, int minH, int maxW, int maxH, int incW, in
int wxWindow::GetCharHeight() const 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; int direction, ascent, descent;
XCharStruct overall; XCharStruct overall;
@@ -1272,9 +1285,9 @@ int wxWindow::GetCharHeight() const
int wxWindow::GetCharWidth() const 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; int direction, ascent, descent;
XCharStruct overall; XCharStruct overall;
@@ -1291,9 +1304,9 @@ void wxWindow::GetTextExtent(const wxString& string,
{ {
wxFont *fontToUse = (wxFont *)theFont; wxFont *fontToUse = (wxFont *)theFont;
if (!fontToUse) 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()); WXFontStructPtr pFontStruct = theFont->GetFontStruct(1.0, GetXDisplay());
@@ -1378,13 +1391,14 @@ void wxWindow::Clear()
void wxWindow::ClearUpdateRects() void wxWindow::ClearUpdateRects()
{ {
wxNode* node = m_updateRects.First(); wxRectList::Node* node = m_updateRects.GetFirst();
while (node) while (node)
{ {
wxRect* rect = (wxRect*) node->Data(); wxRect* rect = node->GetData();
delete rect; delete rect;
node = node->Next(); node = node->GetNext();
} }
m_updateRects.Clear(); m_updateRects.Clear();
} }
@@ -1666,7 +1680,7 @@ bool wxWindow::DetachWidget(WXWidget widget)
// Get the underlying X window // Get the underlying X window
WXWindow wxWindow::GetXWindow() const WXWindow wxWindow::GetXWindow() const
{ {
Widget wMain = GetMainWidget(); Widget wMain = (Widget)GetMainWidget();
if ( wMain ) if ( wMain )
return (WXWindow) XtWindow(wMain); return (WXWindow) XtWindow(wMain);
else else
@@ -1676,7 +1690,7 @@ WXWindow wxWindow::GetXWindow() const
// Get the underlying X display // Get the underlying X display
WXDisplay *wxWindow::GetXDisplay() const WXDisplay *wxWindow::GetXDisplay() const
{ {
Widget wMain = GetMainWidget(); Widget wMain = (Widget)GetMainWidget();
if ( wMain ) if ( wMain )
return (WXDisplay*) XtDisplay(wMain); return (WXDisplay*) XtDisplay(wMain);
else else
@@ -1740,17 +1754,11 @@ static void wxCanvasRepaintProc(Widget drawingArea,
XEvent * event = cbs->event; XEvent * event = cbs->event;
wxWindow * win = (wxWindow *) clientData; wxWindow * win = (wxWindow *) clientData;
Display * display = (Display *) win->GetXDisplay();
switch (event->type) switch (event->type)
{ {
case Expose: 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 (event -> xexpose.count == 0)
{ {
#if 0 #if 0
@@ -1762,6 +1770,11 @@ static void wxCanvasRepaintProc(Widget drawingArea,
win->DoPaint(); win->DoPaint();
win->ClearUpdateRects(); win->ClearUpdateRects();
} }
else
{
win->AddUpdateRect(event->xexpose.x, event->xexpose.y,
event->xexpose.width, event->xexpose.height);
}
break; break;
} }
} }
@@ -1863,17 +1876,17 @@ static void wxCanvasInputEvent(Widget drawingArea,
if (local_event.xbutton.button == Button1) if (local_event.xbutton.button == Button1)
{ {
eventType = wxEVT_LEFT_DOWN; eventType = wxEVT_LEFT_DOWN;
canvas->m_button1Pressed = TRUE; canvas->SetButton1(TRUE);
} }
else if (local_event.xbutton.button == Button2) else if (local_event.xbutton.button == Button2)
{ {
eventType = wxEVT_MIDDLE_DOWN; eventType = wxEVT_MIDDLE_DOWN;
canvas->m_button2Pressed = TRUE; canvas->SetButton2(TRUE);
} }
else if (local_event.xbutton.button == Button3) else if (local_event.xbutton.button == Button3)
{ {
eventType = wxEVT_RIGHT_DOWN; eventType = wxEVT_RIGHT_DOWN;
canvas->m_button3Pressed = TRUE; canvas->SetButton3(TRUE);
} }
} }
else if (local_event.xany.type == ButtonRelease) else if (local_event.xany.type == ButtonRelease)
@@ -1881,22 +1894,21 @@ static void wxCanvasInputEvent(Widget drawingArea,
if (local_event.xbutton.button == Button1) if (local_event.xbutton.button == Button1)
{ {
eventType = wxEVT_LEFT_UP; eventType = wxEVT_LEFT_UP;
canvas->m_button1Pressed = FALSE; canvas->SetButton1(FALSE);
} }
else if (local_event.xbutton.button == Button2) else if (local_event.xbutton.button == Button2)
{ {
eventType = wxEVT_MIDDLE_UP; eventType = wxEVT_MIDDLE_UP;
canvas->m_button2Pressed = FALSE; canvas->SetButton2(FALSE);
} }
else if (local_event.xbutton.button == Button3) else if (local_event.xbutton.button == Button3)
{ {
eventType = wxEVT_RIGHT_UP; eventType = wxEVT_RIGHT_UP;
canvas->m_button3Pressed = FALSE; canvas->SetButton3(FALSE);
} }
} }
wxMouseEvent wxevent (eventType); wxMouseEvent wxevent (eventType);
wxevent.m_eventHandle = (char *) &local_event;
wxevent.m_leftDown = ((eventType == wxEVT_LEFT_DOWN) wxevent.m_leftDown = ((eventType == wxEVT_LEFT_DOWN)
|| (event_left_is_down (&local_event) || (event_left_is_down (&local_event)
@@ -1923,15 +1935,21 @@ static void wxCanvasInputEvent(Widget drawingArea,
// get button and time-stamp // get button and time-stamp
int button = 0; int button = 0;
if (wxevent.LeftDown()) button = 1; if (wxevent.LeftDown())
else if (wxevent.MiddleDown()) button = 2; button = 1;
else if (wxevent.RightDown()) button = 3; else if (wxevent.MiddleDown())
button = 2;
else if (wxevent.RightDown())
button = 3;
long ts = wxevent.GetTimestamp(); long ts = wxevent.GetTimestamp();
// check, if single or double click // 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 // I have a dclick
canvas->m_lastButton = 0; canvas->SetLastClick(0, ts);
switch ( eventType ) switch ( eventType )
{ {
case wxEVT_LEFT_DOWN: case wxEVT_LEFT_DOWN:
@@ -1952,8 +1970,7 @@ static void wxCanvasInputEvent(Widget drawingArea,
else else
{ {
// not fast enough or different button // not fast enough or different button
canvas->m_lastTS = ts; canvas->SetLastClick(button, ts);
canvas->m_lastButton = button;
} }
} }
} }
@@ -2084,7 +2101,7 @@ static void wxPanelItemEventHandler(Widget wid,
{ {
// Widget can be a label or the actual widget. // Widget can be a label or the actual widget.
wxWindow *window = wxGetWindowFromTable(drawingArea); wxWindow *window = wxGetWindowFromTable(wid);
if (window) if (window)
{ {
wxMouseEvent wxevent(0); wxMouseEvent wxevent(0);
@@ -2108,7 +2125,6 @@ static void wxScrollBarCallback(Widget scrollbar,
XtPointer clientData, XtPointer clientData,
XmScaleCallbackStruct *cbs) XmScaleCallbackStruct *cbs)
{ {
Widget scrolledWindow = XtParent (scrollbar);
wxWindow *win = wxGetWindowFromTable(scrollbar); wxWindow *win = wxGetWindowFromTable(scrollbar);
int orientation = (int) clientData; int orientation = (int) clientData;
@@ -2185,21 +2201,23 @@ void wxUniversalRepaintProc(Widget w, XtPointer WXUNUSED(c_data), XEvent *event,
switch(event -> type) switch(event -> type)
{ {
case Expose : case Expose:
{ {
window = (Window) win -> GetXWindow(); window = (Window) win -> GetXWindow();
display = (Display *) win -> GetXDisplay(); 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) if (event -> xexpose.count == 0)
{ {
win->DoPaint(); win->DoPaint();
win->ClearUpdateRects(); win->ClearUpdateRects();
} }
else
{
win->AddUpdateRect(event->xexpose.x, event->xexpose.y,
event->xexpose.width, event->xexpose.height);
}
break; break;
} }
} }
@@ -2243,7 +2261,7 @@ void wxWindow::CanvasSetSize (int x, int y, int w, int h, int sizeFlags)
if (managed) if (managed)
XtUnmanageChild (m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow); 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; int xx = x; int yy = y;
AdjustForParentClientOrigin(xx, yy, sizeFlags); AdjustForParentClientOrigin(xx, yy, sizeFlags);
@@ -2295,7 +2313,9 @@ void wxWindow::CanvasSetSize (int x, int y, int w, int h, int sizeFlags)
w -= (spacing + wsbar); w -= (spacing + wsbar);
// XtVaSetValues ((Widget) m_drawingArea, XmNwidth, w, NULL); #if 0
XtVaSetValues(drawingArea, XmNwidth, w, NULL);
#endif // 0
} }
if (h > -1) if (h > -1)
{ {
@@ -2326,14 +2346,15 @@ void wxWindow::CanvasSetSize (int x, int y, int w, int h, int sizeFlags)
h -= (spacing + wsbar); h -= (spacing + wsbar);
// XtVaSetValues ((Widget) m_drawingArea, XmNheight, h, NULL); #if 0
XtVaSetValues(drawingArea, XmNheight, h, NULL);
#endif // 0
} }
} }
if (managed) if (managed)
XtManageChild (m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow); 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 #if 0
int ww, hh; int ww, hh;
@@ -2341,7 +2362,7 @@ void wxWindow::CanvasSetSize (int x, int y, int w, int h, int sizeFlags)
wxSizeEvent sizeEvent(wxSize(ww, hh), GetId()); wxSizeEvent sizeEvent(wxSize(ww, hh), GetId());
sizeEvent.SetEventObject(this); sizeEvent.SetEventObject(this);
GetEventHandler()->ProcessEvent(sizeEvent); GetEventHandler()->ProcessEvent(sizeEvent);
#endif // 0 #endif // 0
} }
@@ -2349,12 +2370,12 @@ void wxWindow::CanvasSetClientSize (int w, int h)
{ {
Widget drawingArea = (Widget) m_drawingArea; Widget drawingArea = (Widget) m_drawingArea;
XtVaSetValues((Widget) m_drawingArea, XmNresizePolicy, XmRESIZE_ANY, NULL); XtVaSetValues(drawingArea, XmNresizePolicy, XmRESIZE_ANY, NULL);
if (w > -1) if (w > -1)
XtVaSetValues ((Widget) m_drawingArea, XmNwidth, w, NULL); XtVaSetValues(drawingArea, XmNwidth, w, NULL);
if (h > -1) if (h > -1)
XtVaSetValues ((Widget) m_drawingArea, XmNheight, h, NULL); XtVaSetValues(drawingArea, XmNheight, h, NULL);
#if 0 #if 0
// TODO: is this necessary? // TODO: is this necessary?
@@ -2370,16 +2391,16 @@ void wxWindow::CanvasSetClientSize (int w, int h)
} }
#endif // 0 #endif // 0
XtVaSetValues((Widget) m_drawingArea, XmNresizePolicy, XmRESIZE_NONE, NULL); XtVaSetValues(drawingArea, XmNresizePolicy, XmRESIZE_NONE, NULL);
#if 0 #if 0
allowRepainting = TRUE; allowRepainting = TRUE;
DoRefresh (); DoRefresh ();
wxSizeEvent sizeEvent(wxSize(w, h), GetId()); wxSizeEvent sizeEvent(wxSize(w, h), GetId());
sizeEvent.SetEventObject(this); sizeEvent.SetEventObject(this);
GetEventHandler()->ProcessEvent(sizeEvent); GetEventHandler()->ProcessEvent(sizeEvent);
#endif // 0 #endif // 0
} }
@@ -2443,9 +2464,9 @@ bool wxTranslateMouseEvent(wxMouseEvent& wxevent, wxWindow *win, Widget widget,
if (xevent->xany.type == LeaveNotify) if (xevent->xany.type == LeaveNotify)
{ {
win->m_button1Pressed = FALSE; win->SetButton1(FALSE);
win->m_button2Pressed = FALSE; win->SetButton2(FALSE);
win->m_button3Pressed = FALSE; win->SetButton3(FALSE);
return FALSE; return FALSE;
} }
else if (xevent->xany.type == MotionNotify) else if (xevent->xany.type == MotionNotify)
@@ -2457,17 +2478,17 @@ bool wxTranslateMouseEvent(wxMouseEvent& wxevent, wxWindow *win, Widget widget,
if (xevent->xbutton.button == Button1) if (xevent->xbutton.button == Button1)
{ {
eventType = wxEVT_LEFT_DOWN; eventType = wxEVT_LEFT_DOWN;
win->m_button1Pressed = TRUE; win->SetButton1(TRUE);
} }
else if (xevent->xbutton.button == Button2) else if (xevent->xbutton.button == Button2)
{ {
eventType = wxEVT_MIDDLE_DOWN; eventType = wxEVT_MIDDLE_DOWN;
win->m_button2Pressed = TRUE; win->SetButton2(TRUE);
} }
else if (xevent->xbutton.button == Button3) else if (xevent->xbutton.button == Button3)
{ {
eventType = wxEVT_RIGHT_DOWN; eventType = wxEVT_RIGHT_DOWN;
win->m_button3Pressed = TRUE; win->SetButton3(TRUE);
} }
} }
else if (xevent->xany.type == ButtonRelease) else if (xevent->xany.type == ButtonRelease)
@@ -2475,23 +2496,25 @@ bool wxTranslateMouseEvent(wxMouseEvent& wxevent, wxWindow *win, Widget widget,
if (xevent->xbutton.button == Button1) if (xevent->xbutton.button == Button1)
{ {
eventType = wxEVT_LEFT_UP; eventType = wxEVT_LEFT_UP;
win->m_button1Pressed = FALSE; win->SetButton1(FALSE);
} }
else if (xevent->xbutton.button == Button2) else if (xevent->xbutton.button == Button2)
{ {
eventType = wxEVT_MIDDLE_UP; eventType = wxEVT_MIDDLE_UP;
win->m_button2Pressed = FALSE; win->SetButton2(FALSE);
} }
else if (xevent->xbutton.button == Button3) else if (xevent->xbutton.button == Button3)
{ {
eventType = wxEVT_RIGHT_UP; eventType = wxEVT_RIGHT_UP;
win->m_button3Pressed = FALSE; win->SetButton3(FALSE);
} }
else return FALSE; else return FALSE;
} }
else return FALSE; else
{
return FALSE;
}
wxevent.m_eventHandle = (char *)xevent;
wxevent.SetEventType(eventType); wxevent.SetEventType(eventType);
Position x1, y1; Position x1, y1;
@@ -2713,16 +2736,24 @@ void wxWindow::DoChangeBackgroundColour(WXWidget widget, wxColour& backgroundCol
NULL); NULL);
} }
void wxWindow::SetBackgroundColour(const wxColour& col) bool wxWindow::SetBackgroundColour(const wxColour& col)
{ {
m_backgroundColour = col; if ( !wxWindowBase::SetBackgroundColour(col) )
return FALSE;
ChangeBackgroundColour(); 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(); ChangeForegroundColour();
return TRUE;
} }
void wxWindow::ChangeFont(bool keepOriginalSize) void wxWindow::ChangeFont(bool keepOriginalSize)
@@ -2731,7 +2762,7 @@ void wxWindow::ChangeFont(bool keepOriginalSize)
// to its original size! We therefore have to set the size // to its original size! We therefore have to set the size
// back again. TODO: a better way in Motif? // back again. TODO: a better way in Motif?
Widget w = (Widget) GetLabelWidget(); // Usually the main widget Widget w = (Widget) GetLabelWidget(); // Usually the main widget
if (w && m_windowFont.Ok()) if (w && m_font.Ok())
{ {
int width, height, width1, height1; int width, height, width1, height1;
GetSize(& width, & height); GetSize(& width, & height);
@@ -2739,7 +2770,7 @@ void wxWindow::ChangeFont(bool keepOriginalSize)
// lesstif 0.87 hangs here // lesstif 0.87 hangs here
#ifndef LESSTIF_VERSION #ifndef LESSTIF_VERSION
XtVaSetValues (w, XtVaSetValues (w,
XmNfontList, (XmFontList) m_windowFont.GetFontList(1.0, XtDisplay(w)), XmNfontList, (XmFontList) m_font.GetFontList(1.0, XtDisplay(w)),
NULL); NULL);
#endif #endif
@@ -2765,20 +2796,4 @@ wxWindow *wxGetActiveWindow()
// wxNoOptimize: switch off size optimization // wxNoOptimize: switch off size optimization
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
int wxNoOptimize::m_count = 0; int wxNoOptimize::ms_count = 0;
wxNoOptimize::wxNoOptimize()
{
m_count ++;
}
wxNoOptimize::~wxNoOptimize()
{
m_count --;
}
bool wxNoOptimize::CanOptimize()
{
return (m_count == 0);
}