- wxBookCtrl renamed to wxBookCtrlBase, wxBookCtrl is reserved for most native
book control (for now wxChoicebook for MSSmartphone, wxNotebook for others).
Necessary event macros, types and styles mapped accordingly.
+- new wxBrush::IsHatch() checking for brush type replaces IS_HATCH macro
Unix:
\helpref{wxBrush::SetStyle}{wxbrushsetstyle}, \helpref{wxBrush::SetColour}{wxbrushsetcolour},\rtfsp
\helpref{wxBrush::SetStipple}{wxbrushsetstipple}
+\membersection{wxBrush::IsHatch}\label{wxbrushishatch}
+
+\constfunc{bool}{IsHatch}{\void}
+
+Returns true if the style of the brush is any of hatched fills.
+
+\wxheading{See also}
+
+\helpref{wxBrush::GetStyle}{wxbrushgetstyle}
+
\membersection{wxBrush::Ok}\label{wxbrushok}
\constfunc{bool}{Ok}{\void}
For other changes (such as additional features, bug fixes, etc.) see the changes.txt file located in the docs directory of your wxWidgets directory.
-\subsection{Incompatable changes since 2.4.x}
+\subsection{Incompatable changes since 2.4.x}\label{incompatiblesince24}
-\subsubsection{New window repainting behaviour}
+\subsubsection{New window repainting behaviour}\label{newwindowrepainting}
Windows are no longer fully repainted when resized, use new style wxFULL\_REPAINT\_ON\_RESIZE to force this (wxNO\_FULL\_REPAINT\_ON\_RESIZE still exists but doesn't do anything any more, this behaviour is default now).
-\subsubsection{Window class member changes}
+\subsubsection{Window class member changes}\label{windowclassmemberchanges}
wxWindow::m\_font and m\_backgroundColour/m\_foregroundColour are no longer always set, use GetFont(), GetBack/ForegroundColour() to access them, and they will be dynamically determined if necessary.
-\subsubsection{Sizers Internal Overhaul}
+\subsubsection{Sizers Internal Overhaul}\label{sizersinternaloverhaul}
The Sizers have had some fundamental internal changes in the 2.5.2 and 2.5.3 releases intended to make them do more of the "Right Thing" but also be as backwards compatible as possible. First a bit about how things used to work:
control is sized to a blending of the min size and best size.
This can be done by calling SetBestFittingSize.
-\subsubsection{Massive wxURL Rewrite}
+\subsubsection{Massive wxURL Rewrite}\label{wxurlrewrite}
wxURL has undergone some radical changes.
* ConvertFromURI has been replaced by wxURI::Unescape.
-\subsubsection{Less drastic incompatable changes since 2.4.x}
+\subsubsection{Less drastic incompatable changes since 2.4.x}\label{24incompatiblelessdrastic}
- no initialization/cleanup can be done in wxApp/~wxApp because they are
now called much earlier/later than before; please move any exiting code
- wxSizer::Add/Insert returns pointer to wxSizerItem just added so conditions
writeen with if(Add(..)==true) will not work. Use if(Add(..)) instead.
-\subsection{Depreciated changes since 2.4.x}
+- New wxBrush::IsHatch() checking for brush type replaces IS_HATCH macro.
+
+\subsection{Depreciated changes since 2.4.x}\label{depreciatedsince24}
- wxURL::GetInputStream() and similar functionality has been depreciated in
favor of other ways of connecting, such as though sockets or wxFileSystem.
// Created: 2003/07/03
// RCS-ID: $Id$
// Copyright: (c) 2003 David Elliott
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_BRUSH_H__
int GetStyle() const;
wxBitmap *GetStipple() const;
+ bool IsHatch() const
+ { return (GetStyle()>=wxBDIAGONAL_HATCH) && (GetStyle()<=wxVERTICAL_HATCH); }
+
virtual bool Ok() const
{ return (m_refData != NULL); }
wxCAP_BUTT
};
-/* VZ: why doesn't it start with "wx"? FIXME */
-#define IS_HATCH(s) ((s)>=wxBDIAGONAL_HATCH && (s)<=wxVERTICAL_HATCH)
+#if WXWIN_COMPATIBILITY_2_4
+ #define IS_HATCH(s) ((s)>=wxBDIAGONAL_HATCH && (s)<=wxVERTICAL_HATCH)
+#else
+ /* use wxBrush::IsHatch() instead thought wxMotif still uses it in src/motif/dcclient.cpp */
+#endif
/* Logical ops */
typedef enum
{
- wxCLEAR, wxROP_BLACK = wxCLEAR, wxBLIT_BLACKNESS = wxCLEAR, /* 0 */
- wxXOR, wxROP_XORPEN = wxXOR, wxBLIT_SRCINVERT = wxXOR, /* src XOR dst */
- wxINVERT, wxROP_NOT = wxINVERT, wxBLIT_DSTINVERT = wxINVERT, /* NOT dst */
- wxOR_REVERSE, wxROP_MERGEPENNOT = wxOR_REVERSE, wxBLIT_00DD0228 = wxOR_REVERSE, /* src OR (NOT dst) */
- wxAND_REVERSE, wxROP_MASKPENNOT = wxAND_REVERSE, wxBLIT_SRCERASE = wxAND_REVERSE, /* src AND (NOT dst) */
- wxCOPY, wxROP_COPYPEN = wxCOPY, wxBLIT_SRCCOPY = wxCOPY, /* src */
- wxAND, wxROP_MASKPEN = wxAND, wxBLIT_SRCAND = wxAND, /* src AND dst */
- wxAND_INVERT, wxROP_MASKNOTPEN = wxAND_INVERT, wxBLIT_00220326 = wxAND_INVERT, /* (NOT src) AND dst */
- wxNO_OP, wxROP_NOP = wxNO_OP, wxBLIT_00AA0029 = wxNO_OP, /* dst */
- wxNOR, wxROP_NOTMERGEPEN = wxNOR, wxBLIT_NOTSRCERASE = wxNOR, /* (NOT src) AND (NOT dst) */
- wxEQUIV, wxROP_NOTXORPEN = wxEQUIV, wxBLIT_00990066 = wxEQUIV, /* (NOT src) XOR dst */
- wxSRC_INVERT, wxROP_NOTCOPYPEN = wxSRC_INVERT, wxBLIT_NOTSCRCOPY = wxSRC_INVERT, /* (NOT src) */
- wxOR_INVERT, wxROP_MERGENOTPEN = wxOR_INVERT, wxBLIT_MERGEPAINT = wxOR_INVERT, /* (NOT src) OR dst */
- wxNAND, wxROP_NOTMASKPEN = wxNAND, wxBLIT_007700E6 = wxNAND, /* (NOT src) OR (NOT dst) */
- wxOR, wxROP_MERGEPEN = wxOR, wxBLIT_SRCPAINT = wxOR, /* src OR dst */
- wxSET, wxROP_WHITE = wxSET, wxBLIT_WHITENESS = wxSET /* 1 */
+ wxCLEAR, wxROP_BLACK = wxCLEAR, wxBLIT_BLACKNESS = wxCLEAR, /* 0 */
+ wxXOR, wxROP_XORPEN = wxXOR, wxBLIT_SRCINVERT = wxXOR, /* src XOR dst */
+ wxINVERT, wxROP_NOT = wxINVERT, wxBLIT_DSTINVERT = wxINVERT, /* NOT dst */
+ wxOR_REVERSE, wxROP_MERGEPENNOT = wxOR_REVERSE, wxBLIT_00DD0228 = wxOR_REVERSE, /* src OR (NOT dst) */
+ wxAND_REVERSE, wxROP_MASKPENNOT = wxAND_REVERSE, wxBLIT_SRCERASE = wxAND_REVERSE, /* src AND (NOT dst) */
+ wxCOPY, wxROP_COPYPEN = wxCOPY, wxBLIT_SRCCOPY = wxCOPY, /* src */
+ wxAND, wxROP_MASKPEN = wxAND, wxBLIT_SRCAND = wxAND, /* src AND dst */
+ wxAND_INVERT, wxROP_MASKNOTPEN = wxAND_INVERT, wxBLIT_00220326 = wxAND_INVERT, /* (NOT src) AND dst */
+ wxNO_OP, wxROP_NOP = wxNO_OP, wxBLIT_00AA0029 = wxNO_OP, /* dst */
+ wxNOR, wxROP_NOTMERGEPEN = wxNOR, wxBLIT_NOTSRCERASE = wxNOR, /* (NOT src) AND (NOT dst) */
+ wxEQUIV, wxROP_NOTXORPEN = wxEQUIV, wxBLIT_00990066 = wxEQUIV, /* (NOT src) XOR dst */
+ wxSRC_INVERT, wxROP_NOTCOPYPEN = wxSRC_INVERT, wxBLIT_NOTSCRCOPY = wxSRC_INVERT, /* (NOT src) */
+ wxOR_INVERT, wxROP_MERGENOTPEN = wxOR_INVERT, wxBLIT_MERGEPAINT = wxOR_INVERT, /* (NOT src) OR dst */
+ wxNAND, wxROP_NOTMASKPEN = wxNAND, wxBLIT_007700E6 = wxNAND, /* (NOT src) OR (NOT dst) */
+ wxOR, wxROP_MERGEPEN = wxOR, wxBLIT_SRCPAINT = wxOR, /* src OR dst */
+ wxSET, wxROP_WHITE = wxSET, wxBLIT_WHITENESS = wxSET /* 1 */
} form_ops_t;
/* Flood styles */
/* These are, by design, not compatable with unicode characters.
If you want to get a unicode character from a key event, use
wxKeyEvent::GetUnicodeKey instead. */
- WXK_START = 300,
+ WXK_START = 300,
WXK_LBUTTON,
WXK_RBUTTON,
WXK_CANCEL,
{
public:
wxBrush() { }
-
+
wxBrush( const wxColour &colour, int style = wxSOLID );
wxBrush( const wxBitmap &stippleBitmap );
~wxBrush();
-
+
wxBrush( const wxBrush &brush )
: wxGDIObject()
{ Ref(brush); }
wxBrush& operator = ( const wxBrush& brush ) { Ref(brush); return *this; }
-
+
bool Ok() const { return m_refData != NULL; }
-
+
bool operator == ( const wxBrush& brush ) const;
bool operator != (const wxBrush& brush) const { return !(*this == brush); }
wxColour &GetColour() const;
wxBitmap *GetStipple() const;
+ bool IsHatch() const
+ { return (GetStyle()>=wxBDIAGONAL_HATCH) && (GetStyle()<=wxVERTICAL_HATCH); }
+
void SetColour( const wxColour& col );
void SetColour( unsigned char r, unsigned char g, unsigned char b );
void SetStyle( int style );
// ref counting code
virtual wxObjectRefData *CreateRefData() const;
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
-
+
DECLARE_DYNAMIC_CLASS(wxBrush)
};
{
public:
wxBrush() { }
-
+
wxBrush( const wxColour &colour, int style = wxSOLID );
wxBrush( const wxBitmap &stippleBitmap );
~wxBrush();
-
+
wxBrush( const wxBrush &brush )
: wxGDIObject()
{ Ref(brush); }
wxBrush& operator = ( const wxBrush& brush ) { Ref(brush); return *this; }
-
+
bool Ok() const { return m_refData != NULL; }
-
+
bool operator == ( const wxBrush& brush ) const;
bool operator != (const wxBrush& brush) const { return !(*this == brush); }
wxColour &GetColour() const;
wxBitmap *GetStipple() const;
+ bool IsHatch() const
+ { return (GetStyle()>=wxBDIAGONAL_HATCH) && (GetStyle()<=wxVERTICAL_HATCH); }
+
void SetColour( const wxColour& col );
void SetColour( unsigned char r, unsigned char g, unsigned char b );
void SetStyle( int style );
// ref counting code
virtual wxObjectRefData *CreateRefData() const;
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
-
+
DECLARE_DYNAMIC_CLASS(wxBrush)
};
class WXDLLEXPORT wxBrush;
-typedef enum
+typedef enum
{
- kwxMacBrushColour ,
- kwxMacBrushTheme ,
- kwxMacBrushThemeBackground
+ kwxMacBrushColour ,
+ kwxMacBrushTheme ,
+ kwxMacBrushThemeBackground
} wxMacBrushKind ;
// Brush
class WXDLLEXPORT wxBrush: public wxGDIObject
{
- DECLARE_DYNAMIC_CLASS(wxBrush)
+ DECLARE_DYNAMIC_CLASS(wxBrush)
public:
- wxBrush();
- wxBrush(short macThemeBrush ) ;
- wxBrush(const wxColour& col, int style = wxSOLID);
- wxBrush(const wxBitmap& stipple);
- wxBrush(const wxBrush& brush)
- : wxGDIObject()
- { Ref(brush); }
- ~wxBrush();
-
- virtual void SetColour(const wxColour& col) ;
- virtual void SetColour(unsigned char r, unsigned char g, unsigned char b) ;
- virtual void SetStyle(int style) ;
- virtual void SetStipple(const wxBitmap& stipple) ;
- virtual void MacSetTheme(short macThemeBrush) ;
- virtual void MacSetThemeBackground(unsigned long macThemeBackground , WXRECTPTR extent) ;
-
- wxBrush& operator = (const wxBrush& brush)
- { if (*this == brush) return (*this); Ref(brush); return *this; }
- bool operator == (const wxBrush& brush)
- { return m_refData == brush.m_refData; }
- bool operator != (const wxBrush& brush)
- { return m_refData != brush.m_refData; }
-
- wxMacBrushKind MacGetBrushKind() const ;
-
- unsigned long MacGetThemeBackground(WXRECTPTR extent) const ;
- short MacGetTheme() const ;
- wxColour& GetColour() const ;
- int GetStyle() const ;
- wxBitmap *GetStipple() const ;
-
- virtual bool Ok() const { return (m_refData != NULL) ; }
+ wxBrush();
+ wxBrush(short macThemeBrush ) ;
+ wxBrush(const wxColour& col, int style = wxSOLID);
+ wxBrush(const wxBitmap& stipple);
+ wxBrush(const wxBrush& brush)
+ : wxGDIObject()
+ { Ref(brush); }
+ ~wxBrush();
+
+ virtual void SetColour(const wxColour& col) ;
+ virtual void SetColour(unsigned char r, unsigned char g, unsigned char b) ;
+ virtual void SetStyle(int style) ;
+ virtual void SetStipple(const wxBitmap& stipple) ;
+ virtual void MacSetTheme(short macThemeBrush) ;
+ virtual void MacSetThemeBackground(unsigned long macThemeBackground , WXRECTPTR extent) ;
+
+ wxBrush& operator = (const wxBrush& brush)
+ { if (*this == brush) return (*this); Ref(brush); return *this; }
+ bool operator == (const wxBrush& brush)
+ { return m_refData == brush.m_refData; }
+ bool operator != (const wxBrush& brush)
+ { return m_refData != brush.m_refData; }
+
+ wxMacBrushKind MacGetBrushKind() const ;
+
+ unsigned long MacGetThemeBackground(WXRECTPTR extent) const ;
+ short MacGetTheme() const ;
+ wxColour& GetColour() const ;
+ int GetStyle() const ;
+ wxBitmap *GetStipple() const ;
+
+ bool IsHatch() const
+ { return (GetStyle()>=wxBDIAGONAL_HATCH) && (GetStyle()<=wxVERTICAL_HATCH); }
+
+ virtual bool Ok() const { return (m_refData != NULL) ; }
// Implementation
- // Useful helper: create the brush resource
- bool RealizeResource();
+ // Useful helper: create the brush resource
+ bool RealizeResource();
- // When setting properties, we must make sure we're not changing
- // another object
- void Unshare();
+ // When setting properties, we must make sure we're not changing
+ // another object
+ void Unshare();
};
#endif
class WXDLLEXPORT wxBrush;
-typedef enum
+typedef enum
{
- kwxMacBrushColour ,
- kwxMacBrushTheme ,
- kwxMacBrushThemeBackground
+ kwxMacBrushColour ,
+ kwxMacBrushTheme ,
+ kwxMacBrushThemeBackground
} wxMacBrushKind ;
// Brush
class WXDLLEXPORT wxBrush: public wxGDIObject
{
- DECLARE_DYNAMIC_CLASS(wxBrush)
+ DECLARE_DYNAMIC_CLASS(wxBrush)
public:
- wxBrush();
- wxBrush(short macThemeBrush ) ;
- wxBrush(const wxColour& col, int style = wxSOLID);
- wxBrush(const wxBitmap& stipple);
- wxBrush(const wxBrush& brush)
- : wxGDIObject()
- { Ref(brush); }
- ~wxBrush();
-
- virtual void SetColour(const wxColour& col) ;
- virtual void SetColour(unsigned char r, unsigned char g, unsigned char b) ;
- virtual void SetStyle(int style) ;
- virtual void SetStipple(const wxBitmap& stipple) ;
- virtual void SetMacTheme(short macThemeBrush) ;
- virtual void SetMacThemeBackground(unsigned long macThemeBackground , WXRECTPTR extent) ;
-
- wxBrush& operator = (const wxBrush& brush)
- { if (*this == brush) return (*this); Ref(brush); return *this; }
- bool operator == (const wxBrush& brush)
- { return m_refData == brush.m_refData; }
- bool operator != (const wxBrush& brush)
- { return m_refData != brush.m_refData; }
-
- wxMacBrushKind MacGetBrushKind() const ;
-
- unsigned long GetMacThemeBackground(WXRECTPTR extent) const ;
- short GetMacTheme() const ;
- wxColour& GetColour() const ;
- int GetStyle() const ;
- wxBitmap *GetStipple() const ;
-
- virtual bool Ok() const { return (m_refData != NULL) ; }
+ wxBrush();
+ wxBrush(short macThemeBrush ) ;
+ wxBrush(const wxColour& col, int style = wxSOLID);
+ wxBrush(const wxBitmap& stipple);
+ wxBrush(const wxBrush& brush)
+ : wxGDIObject()
+ { Ref(brush); }
+ ~wxBrush();
+
+ virtual void SetColour(const wxColour& col) ;
+ virtual void SetColour(unsigned char r, unsigned char g, unsigned char b) ;
+ virtual void SetStyle(int style) ;
+ virtual void SetStipple(const wxBitmap& stipple) ;
+ virtual void SetMacTheme(short macThemeBrush) ;
+ virtual void SetMacThemeBackground(unsigned long macThemeBackground , WXRECTPTR extent) ;
+
+ wxBrush& operator = (const wxBrush& brush)
+ { if (*this == brush) return (*this); Ref(brush); return *this; }
+ bool operator == (const wxBrush& brush)
+ { return m_refData == brush.m_refData; }
+ bool operator != (const wxBrush& brush)
+ { return m_refData != brush.m_refData; }
+
+ wxMacBrushKind MacGetBrushKind() const ;
+
+ unsigned long GetMacThemeBackground(WXRECTPTR extent) const ;
+ short GetMacTheme() const ;
+ wxColour& GetColour() const ;
+ int GetStyle() const ;
+ wxBitmap *GetStipple() const ;
+
+ bool IsHatch() const
+ { return (GetStyle()>=wxBDIAGONAL_HATCH) && (GetStyle()<=wxVERTICAL_HATCH); }
+
+ virtual bool Ok() const { return (m_refData != NULL) ; }
// Implementation
- // Useful helper: create the brush resource
- bool RealizeResource();
+ // Useful helper: create the brush resource
+ bool RealizeResource();
- // When setting properties, we must make sure we're not changing
- // another object
- void Unshare();
+ // When setting properties, we must make sure we're not changing
+ // another object
+ void Unshare();
};
#endif
wxColour &GetColour() const;
wxBitmap *GetStipple() const;
+ bool IsHatch() const
+ { return (GetStyle()>=wxBDIAGONAL_HATCH) && (GetStyle()<=wxVERTICAL_HATCH); }
+
void SetColour(const wxColour& col);
void SetColour(unsigned char r, unsigned char g, unsigned char b);
void SetStyle(int style);
void SetStipple(const wxBitmap& stipple);
-
+
// implementation:
void* GetMaskPattern() const;
int GetStyle() const;
wxBitmap *GetStipple() const;
+ bool IsHatch() const
+ { return (GetStyle()>=wxBDIAGONAL_HATCH) && (GetStyle()<=wxVERTICAL_HATCH); }
+
bool Ok() const { return m_refData != NULL; }
// return the HBRUSH for this brush
inline wxBitmap* GetStipple(void) const { return (M_BRUSHDATA ? & M_BRUSHDATA->m_vStipple : 0); };
inline int GetPS(void) const { return (M_BRUSHDATA ? M_BRUSHDATA->m_hBrush : 0); };
+ bool IsHatch() const
+ { return (GetStyle()>=wxBDIAGONAL_HATCH) && (GetStyle()<=wxVERTICAL_HATCH); }
+
inline virtual bool Ok(void) const { return (m_refData != NULL) ; }
//
//
bool RealizeResource(void);
WXHANDLE GetResourceHandle(void) ;
- bool FreeResource(bool bForce = FALSE);
+ bool FreeResource(bool bForce = false);
bool IsFree(void) const;
void Unshare(void);
}; // end of CLASS wxBrush
// Author: William Osborne
// Modified by:
// Created: 10/13/04
-// RCS-ID: $Id:
+// RCS-ID: $Id:
// Copyright: (c) William Osborne
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
int GetStyle() const;
wxBitmap *GetStipple() const;
+ bool IsHatch() const
+ { return (GetStyle()>=wxBDIAGONAL_HATCH) && (GetStyle()<=wxVERTICAL_HATCH); }
+
bool Ok() const { return m_refData != NULL; }
// return the HBRUSH for this brush
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart, Robert Roebling
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_BRUSH_H_
{
public:
wxBrush() { }
-
+
wxBrush( const wxColour &colour, int style = wxSOLID );
wxBrush( const wxBitmap &stippleBitmap );
~wxBrush();
-
+
wxBrush( const wxBrush &brush ) { Ref(brush); }
wxBrush& operator = ( const wxBrush& brush ) { Ref(brush); return *this; }
-
+
bool Ok() const { return m_refData != NULL; }
-
+
bool operator == ( const wxBrush& brush ) const;
bool operator != (const wxBrush& brush) const { return !(*this == brush); }
wxColour &GetColour() const;
wxBitmap *GetStipple() const;
+ bool IsHatch() const
+ { return (GetStyle()>=wxBDIAGONAL_HATCH) && (GetStyle()<=wxVERTICAL_HATCH); }
+
void SetColour( const wxColour& col );
void SetColour( unsigned char r, unsigned char g, unsigned char b );
void SetStyle( int style );
// ref counting code
virtual wxObjectRefData *CreateRefData() const;
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
-
+
DECLARE_DYNAMIC_CLASS(wxBrush)
};
g_return_if_fail (drawable != NULL);
g_return_if_fail (src != NULL);
g_return_if_fail (gc != NULL);
-
+
#ifdef __WXGTK20__
gint src_width, src_height;
gdk_drawable_get_size(src, &src_width, &src_height);
GdkWindowPrivate *drawable_private;
GdkWindowPrivate *src_private;
GdkGCPrivate *gc_private;
-
+
drawable_private = (GdkWindowPrivate*) drawable;
src_private = (GdkWindowPrivate*) src;
if (drawable_private->destroyed || src_private->destroyed)
gint src_height = src_private->height;
gc_private = (GdkGCPrivate*) gc;
-
+
if (width == -1) width = src_width;
if (height == -1) height = src_height;
-
+
XCopyPlane( drawable_private->xdisplay,
src_private->xwindow,
drawable_private->xwindow,
// This really could wait until the first call to
// wxGetPoolGC, but we will make the first allocation
// now when other initialization is being performed.
-
+
// Set initial pool size.
wxGCPoolSize = GC_POOL_ALLOC_SIZE;
-
+
// Allocate initial pool.
wxGCPool = (wxGC *)malloc(wxGCPoolSize * sizeof(wxGC));
if (wxGCPool == NULL)
wxFAIL_MSG( wxT("Cannot allocate GC pool") );
return;
}
-
+
// Zero initial pool.
memset(wxGCPool, 0, wxGCPoolSize * sizeof(wxGC));
}
static GdkGC* wxGetPoolGC( GdkWindow *window, wxPoolGCType type )
{
wxGC *pptr;
-
+
// Look for an available GC.
for (int i = 0; i < wxGCPoolSize; i++)
{
wxGCPool[i].m_gc = gdk_gc_new( window );
gdk_gc_set_exposures( wxGCPool[i].m_gc, FALSE );
wxGCPool[i].m_type = type;
- wxGCPool[i].m_used = FALSE;
+ wxGCPool[i].m_used = false;
}
if ((!wxGCPool[i].m_used) && (wxGCPool[i].m_type == type))
{
- wxGCPool[i].m_used = TRUE;
+ wxGCPool[i].m_used = true;
return wxGCPool[i].m_gc;
}
}
wxGCPool = pptr;
memset(&wxGCPool[wxGCPoolSize], 0,
GC_POOL_ALLOC_SIZE*sizeof(wxGC));
-
- // Initialize entry we will return.
+
+ // Initialize entry we will return.
wxGCPool[wxGCPoolSize].m_gc = gdk_gc_new( window );
gdk_gc_set_exposures( wxGCPool[wxGCPoolSize].m_gc, FALSE );
wxGCPool[wxGCPoolSize].m_type = type;
- wxGCPool[wxGCPoolSize].m_used = TRUE;
-
+ wxGCPool[wxGCPoolSize].m_used = true;
+
// Set new value of pool size.
wxGCPoolSize += GC_POOL_ALLOC_SIZE;
-
+
// Return newly allocated entry.
return wxGCPool[wxGCPoolSize-GC_POOL_ALLOC_SIZE].m_gc;
}
-
+
// The realloc failed. Fall through to error.
wxFAIL_MSG( wxT("No GC available") );
{
if (wxGCPool[i].m_gc == gc)
{
- wxGCPool[i].m_used = FALSE;
+ wxGCPool[i].m_used = false;
return;
}
}
m_textGC = (GdkGC *) NULL;
m_bgGC = (GdkGC *) NULL;
m_cmap = (GdkColormap *) NULL;
- m_isMemDC = FALSE;
- m_isScreenDC = FALSE;
+ m_isMemDC = false;
+ m_isScreenDC = false;
m_owner = (wxWindow *)NULL;
#ifdef __WXGTK20__
m_context = (PangoContext *)NULL;
m_bgGC = (GdkGC *) NULL;
m_cmap = (GdkColormap *) NULL;
m_owner = (wxWindow *)NULL;
- m_isMemDC = FALSE;
- m_isScreenDC = FALSE;
+ m_isMemDC = false;
+ m_isScreenDC = false;
m_font = window->GetFont();
GtkWidget *widget = window->m_wxwindow;
if (!m_window)
{
// Don't report problems as per MSW.
- m_ok = TRUE;
+ m_ok = true;
return;
}
wxWindowDC::~wxWindowDC()
{
Destroy();
-
+
#ifdef __WXGTK20__
if (m_layout)
g_object_unref( G_OBJECT( m_layout ) );
void wxWindowDC::SetUpDC()
{
- m_ok = TRUE;
+ m_ok = true;
wxASSERT_MSG( !m_penGC, wxT("GCs already created") );
m_owner->GetSize(width, height);
}
-extern bool wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y,
+extern bool wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y,
const wxColour & col, int style);
bool wxWindowDC::DoFloodFill(wxCoord x, wxCoord y,
wxImage image = bitmap.ConvertToImage();
col->Set(image.GetRed(0, 0), image.GetGreen(0, 0), image.GetBlue(0, 0));
- return TRUE;
+ return true;
}
void wxWindowDC::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 )
return;
}
- for (int i = 0; i < n; i++)
+ for (int i = 0; i < n; i++)
{
wxCoord x1 = XLOG2DEV(points[i].x + xoffset);
wxCoord y1 = YLOG2DEV(points[i].y + yoffset);
}
*/
gdk_draw_polygon( m_window, m_penGC, FALSE, gdkpoints, n );
-
+
}
}
void wxWindowDC::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y )
{
// VZ: egcs 1.0.3 refuses to compile this without cast, no idea why
- DoDrawBitmap( (const wxBitmap&)icon, x, y, (bool)TRUE );
+ DoDrawBitmap( (const wxBitmap&)icon, x, y, true );
}
void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap,
return;
}
- // scale bitmap if required
+ // scale bitmap if required
wxBitmap use_bitmap = bitmap;
if ((w != ww) || (h != hh))
use_bitmap = use_bitmap.Rescale( 0, 0, ww, hh, ww, hh );
-
+
#if !GTK_CHECK_VERSION(2,2,0)
// NB: We can't render pixbufs with GTK+ < 2.2, we need to use pixmaps code.
// Pixbufs-based bitmaps with alpha channel don't have a mask, so we
// and also creates the mask as a side-effect:
use_bitmap.GetPixmap();
#endif
-
+
// apply mask if any
GdkBitmap *mask = (GdkBitmap *) NULL;
if (use_bitmap.GetMask()) mask = use_bitmap.GetMask()->GetBitmap();
GdkBitmap *new_mask = (GdkBitmap*) NULL;
-
+
if (useMask && mask)
{
if (!m_currentClippingRegion.IsNull())
gdk_draw_rectangle( new_mask, gc, TRUE, 0, 0, ww, hh );
gdk_gc_unref( gc );
}
-
+
if (is_mono)
{
if (new_mask)
gdk_gc_set_foreground( gc, m_textForegroundColour.GetColor() );
gdk_gc_set_background( gc, m_textBackgroundColour.GetColor() );
gdk_wx_draw_bitmap( bitmap, gc, use_bitmap.GetBitmap(), 0, 0, 0, 0, -1, -1 );
-
+
gdk_draw_drawable( m_window, m_textGC, bitmap, 0, 0, xx, yy, -1, -1 );
-
+
gdk_bitmap_unref( bitmap );
gdk_gc_unref( gc );
#else
gdk_gc_set_clip_region( m_penGC, m_currentClippingRegion.GetRegion() );
}
}
-
+
if (new_mask)
gdk_bitmap_unref( new_mask );
}
bool useMask,
wxCoord xsrcMask, wxCoord ysrcMask )
{
- wxCHECK_MSG( Ok(), FALSE, wxT("invalid window dc") );
+ wxCHECK_MSG( Ok(), false, wxT("invalid window dc") );
- wxCHECK_MSG( source, FALSE, wxT("invalid source dc") );
+ wxCHECK_MSG( source, false, wxT("invalid source dc") );
- if (!m_window) return FALSE;
+ if (!m_window) return false;
// transform the source DC coords to the device ones
xsrc = source->XLOG2DEV(xsrc);
wxClientDC *srcDC = (wxClientDC*)source;
wxMemoryDC *memDC = (wxMemoryDC*)source;
- bool use_bitmap_method = FALSE;
- bool is_mono = FALSE;
+ bool use_bitmap_method = false;
+ bool is_mono = false;
// TODO: use the mask origin when drawing transparently
if (xsrcMask == -1 && ysrcMask == -1)
if (srcDC->m_isMemDC)
{
- if (!memDC->m_selected.Ok()) return FALSE;
+ if (!memDC->m_selected.Ok()) return false;
is_mono = (memDC->m_selected.GetDepth() == 1);
// we HAVE TO use the direct way for memory dcs
// that have mask since the XCopyArea doesn't know
// about masks
- use_bitmap_method = TRUE;
+ use_bitmap_method = true;
}
else if (is_mono)
{
// we HAVE TO use the direct way for memory dcs
// that are bitmaps because XCopyArea doesn't cope
// with different bit depths
- use_bitmap_method = TRUE;
+ use_bitmap_method = true;
}
else if ((xsrc == 0) && (ysrc == 0) &&
(width == memDC->m_selected.GetWidth()) &&
// in the memory dc is copied in which case XCopyArea
// wouldn't be able able to boost performace by reducing
// the area to be scaled
- use_bitmap_method = TRUE;
+ use_bitmap_method = true;
}
else
{
- use_bitmap_method = FALSE;
+ use_bitmap_method = false;
}
}
wxRegion tmp( xx,yy,ww,hh );
tmp.Intersect( m_currentClippingRegion );
if (tmp.IsEmpty())
- return TRUE;
+ return true;
}
int old_logical_func = m_logicalFunction;
wxCoord cy = yy;
wxCoord cw = ww;
wxCoord ch = hh;
-
+
// interpret userscale of src too
double xsc,ysc;
memDC->GetUserScale(&xsc,&ysc);
wxRegion tmp( xx,yy,ww,hh );
tmp.Intersect( m_currentClippingRegion );
tmp.GetBox(cx,cy,cw,ch);
-
+
// Scale and clipped bitmap
use_bitmap = memDC->m_selected.Rescale(cx-xx,cy-yy,cw,ch,bm_ww,bm_hh);
}
if (use_bitmap.GetMask()) mask = use_bitmap.GetMask()->GetBitmap();
GdkBitmap *new_mask = (GdkBitmap*) NULL;
-
+
if (useMask && mask)
{
if (!m_currentClippingRegion.IsNull())
gdk_gc_set_foreground( gc, m_textForegroundColour.GetColor() );
gdk_gc_set_background( gc, m_textBackgroundColour.GetColor() );
gdk_wx_draw_bitmap( bitmap, gc, use_bitmap.GetBitmap(), 0, 0, 0, 0, -1, -1 );
-
+
gdk_draw_drawable( m_window, m_textGC, bitmap, xsrc, ysrc, cx, cy, cw, ch );
-
+
gdk_bitmap_unref( bitmap );
gdk_gc_unref( gc );
#else
gdk_gc_set_clip_region( m_penGC, m_currentClippingRegion.GetRegion() );
}
}
-
+
if (new_mask)
gdk_bitmap_unref( new_mask );
}
tmp.Intersect( m_currentClippingRegion );
wxCoord cx,cy,cw,ch;
tmp.GetBox(cx,cy,cw,ch);
-
- // rescale bitmap
+
+ // rescale bitmap
wxBitmap bitmap = memDC->m_selected.Rescale( cx-xx, cy-yy, cw, ch, ww, hh );
// draw scaled bitmap
}
else
{
- // No scaling and not a memory dc with a mask either
+ // No scaling and not a memory dc with a mask either
// copy including child window contents
gdk_gc_set_subwindow( m_penGC, GDK_INCLUDE_INFERIORS );
}
SetLogicalFunction( old_logical_func );
-
- return TRUE;
+
+ return true;
}
void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y )
wxCHECK_RET( Ok(), wxT("invalid window dc") );
if (!m_window) return;
-
+
if (text.empty()) return;
#ifndef __WXGTK20__
#endif
size_t datalen = strlen((const char*)data);
pango_layout_set_text( m_layout, (const char*) data, datalen);
-
+
if (underlined)
{
PangoAttrList *attrs = pango_attr_list_new();
{
// If there is a user or actually any scale applied to
// the device context, scale the font.
-
+
// scale font description
gint oldSize = pango_font_description_get_size( m_fontdesc );
double size = oldSize;
size = size * m_scaleY;
pango_font_description_set_size( m_fontdesc, (gint)size );
-
+
// actually apply scaled font
pango_layout_set_font_description( m_layout, m_fontdesc );
-
+
pango_layout_get_pixel_size( m_layout, &w, &h );
if ( m_backgroundMode == wxSOLID )
{
gdk_draw_rectangle(m_window, m_textGC, TRUE, x, y, w, h);
gdk_gc_set_foreground(m_textGC, m_textForegroundColour.GetColor());
}
-
+
// Draw layout.
gdk_draw_layout( m_window, m_textGC, x, y, m_layout );
-
+
// reset unscaled size
pango_font_description_set_size( m_fontdesc, oldSize );
-
+
// actually apply unscaled font
pango_layout_set_font_description( m_layout, m_fontdesc );
}
// undo underline attributes setting:
pango_layout_set_attributes(m_layout, NULL);
}
-
+
wxCoord width = w;
wxCoord height = h;
-
+
#else // GTK+ 1.x
wxCoord width = gdk_string_width( font, text.mbc_str() );
wxCoord height = font->ascent + font->descent;
#ifdef __WXGTK20__
// implement later without GdkFont for GTK 2.0
GetTextExtent(text, &w, &h, NULL,NULL, &m_font);
-
+
#else
GdkFont *font = m_font.GetInternalFont( m_scaleY );
y4 = h*dx;
double x3 = x4 + x2,
y3 = y4 + y2;
-
+
// calc max and min
wxCoord maxX = (wxCoord)(dmax(x2, dmax(x3, x4)) + 0.5),
maxY = (wxCoord)(dmax(y2, dmax(y3, y4)) + 0.5),
m_textForegroundColour.Green(),
m_textForegroundColour.Blue() );
image = image.Rotate( rad, wxPoint(0,0) );
-
+
int i_angle = (int) angle;
i_angle = i_angle % 360;
int xoffset = 0;
int yoffset = 0;
if ((i_angle >= 0.0) && (i_angle < 180.0))
yoffset = image.GetHeight();
-
+
if ((i_angle >= 0) && (i_angle < 90))
yoffset -= (int)( cos(rad)*h );
if ((i_angle >= 90) && (i_angle < 180))
- xoffset -= (int)( sin(rad)*h );
+ xoffset -= (int)( sin(rad)*h );
if ((i_angle >= 180) && (i_angle < 270))
yoffset -= (int)( cos(rad)*h );
if ((i_angle >= 270) && (i_angle < 360))
xoffset -= (int)( sin(rad)*h );
-
+
int i_x = x - xoffset;
int i_y = y - yoffset;
-
+
src = image;
DoDrawBitmap( src, i_x, i_y, true );
if ( externalLeading )
*externalLeading = 0;
- if (string.IsEmpty())
+ if (string.empty())
{
return;
}
-
+
#ifdef __WXGTK20__
// Set new font description
if (theFont)
pango_layout_set_font_description( m_layout, theFont->GetNativeFontInfo()->description );
-
+
// Set layout's text
#if wxUSE_UNICODE
const wxCharBuffer data = wxConvUTF8.cWC2MB( string );
}
pango_layout_set_text( m_layout, dataUTF8, strlen(dataUTF8) );
-
+
int w,h;
pango_layout_get_pixel_size( m_layout, &w, &h );
-
+
if (width)
- *width = (wxCoord) w;
+ *width = (wxCoord) w;
if (height)
*height = (wxCoord) h;
if (descent)
pango_layout_iter_free(iter);
*descent = h - PANGO_PIXELS(baseline);
}
-
+
// Reset old font description
if (theFont)
pango_layout_set_font_description( m_layout, m_fontdesc );
wxFont fontToUse = m_font;
if (theFont)
fontToUse = *theFont;
-
+
GdkFont *font = fontToUse.GetInternalFont( m_scaleY );
if ( !font )
return;
void wxWindowDC::SetFont( const wxFont &font )
{
m_font = font;
-
+
#ifdef __WXGTK20__
if (m_font.Ok())
{
if (m_fontdesc)
pango_font_description_free( m_fontdesc );
-
+
m_fontdesc = pango_font_description_copy( m_font.GetNativeFontInfo()->description );
-
-
+
+
if (m_owner)
{
PangoContext *oldContext = m_context;
-
+
// We might want to use the X11 context for faster
// rendering on screen
if (m_font.GetNoAntiAliasing())
m_context = m_owner->GtkGetPangoX11Context();
else
m_context = m_owner->GtkGetPangoDefaultContext();
-
+
// If we switch back/forth between different contexts
// we also have to create a new layout. I think so,
- // at least, and it doesn't hurt to do it.
+ // at least, and it doesn't hurt to do it.
if (oldContext != m_context)
{
if (m_layout)
g_object_unref( G_OBJECT( m_layout ) );
-
+
m_layout = pango_layout_new( m_context );
}
}
-
+
pango_layout_set_font_description( m_layout, m_fontdesc );
}
#endif
gdk_gc_set_stipple( m_textGC, m_brush.GetStipple()->GetMask()->GetBitmap() );
}
- if (IS_HATCH(m_brush.GetStyle()))
+ if (m_brush.IsHatch())
{
gdk_gc_set_fill( m_brushGC, GDK_STIPPLED );
int num = m_brush.GetStyle() - wxBDIAGONAL_HATCH;
}
}
- if (IS_HATCH(m_backgroundBrush.GetStyle()))
+ if (m_backgroundBrush.IsHatch())
{
gdk_gc_set_fill( m_bgGC, GDK_STIPPLED );
int num = m_backgroundBrush.GetStyle() - wxBDIAGONAL_HATCH;
wxSize sz = win->GetSize();
m_paintClippingRegion = win->GetUpdateRegion();
wxLimitRegionToSize(m_paintClippingRegion, sz);
-
+
GdkRegion *region = m_paintClippingRegion.GetRegion();
if ( region )
{
bool wxDCModule::OnInit()
{
wxInitGCPool();
- return TRUE;
+ return true;
}
void wxDCModule::OnExit()
g_return_if_fail (drawable != NULL);
g_return_if_fail (src != NULL);
g_return_if_fail (gc != NULL);
-
+
#ifdef __WXGTK20__
gint src_width, src_height;
gdk_drawable_get_size(src, &src_width, &src_height);
GdkWindowPrivate *drawable_private;
GdkWindowPrivate *src_private;
GdkGCPrivate *gc_private;
-
+
drawable_private = (GdkWindowPrivate*) drawable;
src_private = (GdkWindowPrivate*) src;
if (drawable_private->destroyed || src_private->destroyed)
gint src_height = src_private->height;
gc_private = (GdkGCPrivate*) gc;
-
+
if (width == -1) width = src_width;
if (height == -1) height = src_height;
-
+
XCopyPlane( drawable_private->xdisplay,
src_private->xwindow,
drawable_private->xwindow,
// This really could wait until the first call to
// wxGetPoolGC, but we will make the first allocation
// now when other initialization is being performed.
-
+
// Set initial pool size.
wxGCPoolSize = GC_POOL_ALLOC_SIZE;
-
+
// Allocate initial pool.
wxGCPool = (wxGC *)malloc(wxGCPoolSize * sizeof(wxGC));
if (wxGCPool == NULL)
wxFAIL_MSG( wxT("Cannot allocate GC pool") );
return;
}
-
+
// Zero initial pool.
memset(wxGCPool, 0, wxGCPoolSize * sizeof(wxGC));
}
static GdkGC* wxGetPoolGC( GdkWindow *window, wxPoolGCType type )
{
wxGC *pptr;
-
+
// Look for an available GC.
for (int i = 0; i < wxGCPoolSize; i++)
{
wxGCPool[i].m_gc = gdk_gc_new( window );
gdk_gc_set_exposures( wxGCPool[i].m_gc, FALSE );
wxGCPool[i].m_type = type;
- wxGCPool[i].m_used = FALSE;
+ wxGCPool[i].m_used = false;
}
if ((!wxGCPool[i].m_used) && (wxGCPool[i].m_type == type))
{
- wxGCPool[i].m_used = TRUE;
+ wxGCPool[i].m_used = true;
return wxGCPool[i].m_gc;
}
}
wxGCPool = pptr;
memset(&wxGCPool[wxGCPoolSize], 0,
GC_POOL_ALLOC_SIZE*sizeof(wxGC));
-
- // Initialize entry we will return.
+
+ // Initialize entry we will return.
wxGCPool[wxGCPoolSize].m_gc = gdk_gc_new( window );
gdk_gc_set_exposures( wxGCPool[wxGCPoolSize].m_gc, FALSE );
wxGCPool[wxGCPoolSize].m_type = type;
- wxGCPool[wxGCPoolSize].m_used = TRUE;
-
+ wxGCPool[wxGCPoolSize].m_used = true;
+
// Set new value of pool size.
wxGCPoolSize += GC_POOL_ALLOC_SIZE;
-
+
// Return newly allocated entry.
return wxGCPool[wxGCPoolSize-GC_POOL_ALLOC_SIZE].m_gc;
}
-
+
// The realloc failed. Fall through to error.
wxFAIL_MSG( wxT("No GC available") );
{
if (wxGCPool[i].m_gc == gc)
{
- wxGCPool[i].m_used = FALSE;
+ wxGCPool[i].m_used = false;
return;
}
}
m_textGC = (GdkGC *) NULL;
m_bgGC = (GdkGC *) NULL;
m_cmap = (GdkColormap *) NULL;
- m_isMemDC = FALSE;
- m_isScreenDC = FALSE;
+ m_isMemDC = false;
+ m_isScreenDC = false;
m_owner = (wxWindow *)NULL;
#ifdef __WXGTK20__
m_context = (PangoContext *)NULL;
m_bgGC = (GdkGC *) NULL;
m_cmap = (GdkColormap *) NULL;
m_owner = (wxWindow *)NULL;
- m_isMemDC = FALSE;
- m_isScreenDC = FALSE;
+ m_isMemDC = false;
+ m_isScreenDC = false;
m_font = window->GetFont();
GtkWidget *widget = window->m_wxwindow;
if (!m_window)
{
// Don't report problems as per MSW.
- m_ok = TRUE;
+ m_ok = true;
return;
}
wxWindowDC::~wxWindowDC()
{
Destroy();
-
+
#ifdef __WXGTK20__
if (m_layout)
g_object_unref( G_OBJECT( m_layout ) );
void wxWindowDC::SetUpDC()
{
- m_ok = TRUE;
+ m_ok = true;
wxASSERT_MSG( !m_penGC, wxT("GCs already created") );
m_owner->GetSize(width, height);
}
-extern bool wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y,
+extern bool wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y,
const wxColour & col, int style);
bool wxWindowDC::DoFloodFill(wxCoord x, wxCoord y,
wxImage image = bitmap.ConvertToImage();
col->Set(image.GetRed(0, 0), image.GetGreen(0, 0), image.GetBlue(0, 0));
- return TRUE;
+ return true;
}
void wxWindowDC::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 )
return;
}
- for (int i = 0; i < n; i++)
+ for (int i = 0; i < n; i++)
{
wxCoord x1 = XLOG2DEV(points[i].x + xoffset);
wxCoord y1 = YLOG2DEV(points[i].y + yoffset);
}
*/
gdk_draw_polygon( m_window, m_penGC, FALSE, gdkpoints, n );
-
+
}
}
void wxWindowDC::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y )
{
// VZ: egcs 1.0.3 refuses to compile this without cast, no idea why
- DoDrawBitmap( (const wxBitmap&)icon, x, y, (bool)TRUE );
+ DoDrawBitmap( (const wxBitmap&)icon, x, y, true );
}
void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap,
return;
}
- // scale bitmap if required
+ // scale bitmap if required
wxBitmap use_bitmap = bitmap;
if ((w != ww) || (h != hh))
use_bitmap = use_bitmap.Rescale( 0, 0, ww, hh, ww, hh );
-
+
#if !GTK_CHECK_VERSION(2,2,0)
// NB: We can't render pixbufs with GTK+ < 2.2, we need to use pixmaps code.
// Pixbufs-based bitmaps with alpha channel don't have a mask, so we
// and also creates the mask as a side-effect:
use_bitmap.GetPixmap();
#endif
-
+
// apply mask if any
GdkBitmap *mask = (GdkBitmap *) NULL;
if (use_bitmap.GetMask()) mask = use_bitmap.GetMask()->GetBitmap();
GdkBitmap *new_mask = (GdkBitmap*) NULL;
-
+
if (useMask && mask)
{
if (!m_currentClippingRegion.IsNull())
gdk_draw_rectangle( new_mask, gc, TRUE, 0, 0, ww, hh );
gdk_gc_unref( gc );
}
-
+
if (is_mono)
{
if (new_mask)
gdk_gc_set_foreground( gc, m_textForegroundColour.GetColor() );
gdk_gc_set_background( gc, m_textBackgroundColour.GetColor() );
gdk_wx_draw_bitmap( bitmap, gc, use_bitmap.GetBitmap(), 0, 0, 0, 0, -1, -1 );
-
+
gdk_draw_drawable( m_window, m_textGC, bitmap, 0, 0, xx, yy, -1, -1 );
-
+
gdk_bitmap_unref( bitmap );
gdk_gc_unref( gc );
#else
gdk_gc_set_clip_region( m_penGC, m_currentClippingRegion.GetRegion() );
}
}
-
+
if (new_mask)
gdk_bitmap_unref( new_mask );
}
bool useMask,
wxCoord xsrcMask, wxCoord ysrcMask )
{
- wxCHECK_MSG( Ok(), FALSE, wxT("invalid window dc") );
+ wxCHECK_MSG( Ok(), false, wxT("invalid window dc") );
- wxCHECK_MSG( source, FALSE, wxT("invalid source dc") );
+ wxCHECK_MSG( source, false, wxT("invalid source dc") );
- if (!m_window) return FALSE;
+ if (!m_window) return false;
// transform the source DC coords to the device ones
xsrc = source->XLOG2DEV(xsrc);
wxClientDC *srcDC = (wxClientDC*)source;
wxMemoryDC *memDC = (wxMemoryDC*)source;
- bool use_bitmap_method = FALSE;
- bool is_mono = FALSE;
+ bool use_bitmap_method = false;
+ bool is_mono = false;
// TODO: use the mask origin when drawing transparently
if (xsrcMask == -1 && ysrcMask == -1)
if (srcDC->m_isMemDC)
{
- if (!memDC->m_selected.Ok()) return FALSE;
+ if (!memDC->m_selected.Ok()) return false;
is_mono = (memDC->m_selected.GetDepth() == 1);
// we HAVE TO use the direct way for memory dcs
// that have mask since the XCopyArea doesn't know
// about masks
- use_bitmap_method = TRUE;
+ use_bitmap_method = true;
}
else if (is_mono)
{
// we HAVE TO use the direct way for memory dcs
// that are bitmaps because XCopyArea doesn't cope
// with different bit depths
- use_bitmap_method = TRUE;
+ use_bitmap_method = true;
}
else if ((xsrc == 0) && (ysrc == 0) &&
(width == memDC->m_selected.GetWidth()) &&
// in the memory dc is copied in which case XCopyArea
// wouldn't be able able to boost performace by reducing
// the area to be scaled
- use_bitmap_method = TRUE;
+ use_bitmap_method = true;
}
else
{
- use_bitmap_method = FALSE;
+ use_bitmap_method = false;
}
}
wxRegion tmp( xx,yy,ww,hh );
tmp.Intersect( m_currentClippingRegion );
if (tmp.IsEmpty())
- return TRUE;
+ return true;
}
int old_logical_func = m_logicalFunction;
wxCoord cy = yy;
wxCoord cw = ww;
wxCoord ch = hh;
-
+
// interpret userscale of src too
double xsc,ysc;
memDC->GetUserScale(&xsc,&ysc);
wxRegion tmp( xx,yy,ww,hh );
tmp.Intersect( m_currentClippingRegion );
tmp.GetBox(cx,cy,cw,ch);
-
+
// Scale and clipped bitmap
use_bitmap = memDC->m_selected.Rescale(cx-xx,cy-yy,cw,ch,bm_ww,bm_hh);
}
if (use_bitmap.GetMask()) mask = use_bitmap.GetMask()->GetBitmap();
GdkBitmap *new_mask = (GdkBitmap*) NULL;
-
+
if (useMask && mask)
{
if (!m_currentClippingRegion.IsNull())
gdk_gc_set_foreground( gc, m_textForegroundColour.GetColor() );
gdk_gc_set_background( gc, m_textBackgroundColour.GetColor() );
gdk_wx_draw_bitmap( bitmap, gc, use_bitmap.GetBitmap(), 0, 0, 0, 0, -1, -1 );
-
+
gdk_draw_drawable( m_window, m_textGC, bitmap, xsrc, ysrc, cx, cy, cw, ch );
-
+
gdk_bitmap_unref( bitmap );
gdk_gc_unref( gc );
#else
gdk_gc_set_clip_region( m_penGC, m_currentClippingRegion.GetRegion() );
}
}
-
+
if (new_mask)
gdk_bitmap_unref( new_mask );
}
tmp.Intersect( m_currentClippingRegion );
wxCoord cx,cy,cw,ch;
tmp.GetBox(cx,cy,cw,ch);
-
- // rescale bitmap
+
+ // rescale bitmap
wxBitmap bitmap = memDC->m_selected.Rescale( cx-xx, cy-yy, cw, ch, ww, hh );
// draw scaled bitmap
}
else
{
- // No scaling and not a memory dc with a mask either
+ // No scaling and not a memory dc with a mask either
// copy including child window contents
gdk_gc_set_subwindow( m_penGC, GDK_INCLUDE_INFERIORS );
}
SetLogicalFunction( old_logical_func );
-
- return TRUE;
+
+ return true;
}
void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y )
wxCHECK_RET( Ok(), wxT("invalid window dc") );
if (!m_window) return;
-
+
if (text.empty()) return;
#ifndef __WXGTK20__
#endif
size_t datalen = strlen((const char*)data);
pango_layout_set_text( m_layout, (const char*) data, datalen);
-
+
if (underlined)
{
PangoAttrList *attrs = pango_attr_list_new();
{
// If there is a user or actually any scale applied to
// the device context, scale the font.
-
+
// scale font description
gint oldSize = pango_font_description_get_size( m_fontdesc );
double size = oldSize;
size = size * m_scaleY;
pango_font_description_set_size( m_fontdesc, (gint)size );
-
+
// actually apply scaled font
pango_layout_set_font_description( m_layout, m_fontdesc );
-
+
pango_layout_get_pixel_size( m_layout, &w, &h );
if ( m_backgroundMode == wxSOLID )
{
gdk_draw_rectangle(m_window, m_textGC, TRUE, x, y, w, h);
gdk_gc_set_foreground(m_textGC, m_textForegroundColour.GetColor());
}
-
+
// Draw layout.
gdk_draw_layout( m_window, m_textGC, x, y, m_layout );
-
+
// reset unscaled size
pango_font_description_set_size( m_fontdesc, oldSize );
-
+
// actually apply unscaled font
pango_layout_set_font_description( m_layout, m_fontdesc );
}
// undo underline attributes setting:
pango_layout_set_attributes(m_layout, NULL);
}
-
+
wxCoord width = w;
wxCoord height = h;
-
+
#else // GTK+ 1.x
wxCoord width = gdk_string_width( font, text.mbc_str() );
wxCoord height = font->ascent + font->descent;
#ifdef __WXGTK20__
// implement later without GdkFont for GTK 2.0
GetTextExtent(text, &w, &h, NULL,NULL, &m_font);
-
+
#else
GdkFont *font = m_font.GetInternalFont( m_scaleY );
y4 = h*dx;
double x3 = x4 + x2,
y3 = y4 + y2;
-
+
// calc max and min
wxCoord maxX = (wxCoord)(dmax(x2, dmax(x3, x4)) + 0.5),
maxY = (wxCoord)(dmax(y2, dmax(y3, y4)) + 0.5),
m_textForegroundColour.Green(),
m_textForegroundColour.Blue() );
image = image.Rotate( rad, wxPoint(0,0) );
-
+
int i_angle = (int) angle;
i_angle = i_angle % 360;
int xoffset = 0;
int yoffset = 0;
if ((i_angle >= 0.0) && (i_angle < 180.0))
yoffset = image.GetHeight();
-
+
if ((i_angle >= 0) && (i_angle < 90))
yoffset -= (int)( cos(rad)*h );
if ((i_angle >= 90) && (i_angle < 180))
- xoffset -= (int)( sin(rad)*h );
+ xoffset -= (int)( sin(rad)*h );
if ((i_angle >= 180) && (i_angle < 270))
yoffset -= (int)( cos(rad)*h );
if ((i_angle >= 270) && (i_angle < 360))
xoffset -= (int)( sin(rad)*h );
-
+
int i_x = x - xoffset;
int i_y = y - yoffset;
-
+
src = image;
DoDrawBitmap( src, i_x, i_y, true );
if ( externalLeading )
*externalLeading = 0;
- if (string.IsEmpty())
+ if (string.empty())
{
return;
}
-
+
#ifdef __WXGTK20__
// Set new font description
if (theFont)
pango_layout_set_font_description( m_layout, theFont->GetNativeFontInfo()->description );
-
+
// Set layout's text
#if wxUSE_UNICODE
const wxCharBuffer data = wxConvUTF8.cWC2MB( string );
}
pango_layout_set_text( m_layout, dataUTF8, strlen(dataUTF8) );
-
+
int w,h;
pango_layout_get_pixel_size( m_layout, &w, &h );
-
+
if (width)
- *width = (wxCoord) w;
+ *width = (wxCoord) w;
if (height)
*height = (wxCoord) h;
if (descent)
pango_layout_iter_free(iter);
*descent = h - PANGO_PIXELS(baseline);
}
-
+
// Reset old font description
if (theFont)
pango_layout_set_font_description( m_layout, m_fontdesc );
wxFont fontToUse = m_font;
if (theFont)
fontToUse = *theFont;
-
+
GdkFont *font = fontToUse.GetInternalFont( m_scaleY );
if ( !font )
return;
void wxWindowDC::SetFont( const wxFont &font )
{
m_font = font;
-
+
#ifdef __WXGTK20__
if (m_font.Ok())
{
if (m_fontdesc)
pango_font_description_free( m_fontdesc );
-
+
m_fontdesc = pango_font_description_copy( m_font.GetNativeFontInfo()->description );
-
-
+
+
if (m_owner)
{
PangoContext *oldContext = m_context;
-
+
// We might want to use the X11 context for faster
// rendering on screen
if (m_font.GetNoAntiAliasing())
m_context = m_owner->GtkGetPangoX11Context();
else
m_context = m_owner->GtkGetPangoDefaultContext();
-
+
// If we switch back/forth between different contexts
// we also have to create a new layout. I think so,
- // at least, and it doesn't hurt to do it.
+ // at least, and it doesn't hurt to do it.
if (oldContext != m_context)
{
if (m_layout)
g_object_unref( G_OBJECT( m_layout ) );
-
+
m_layout = pango_layout_new( m_context );
}
}
-
+
pango_layout_set_font_description( m_layout, m_fontdesc );
}
#endif
gdk_gc_set_stipple( m_textGC, m_brush.GetStipple()->GetMask()->GetBitmap() );
}
- if (IS_HATCH(m_brush.GetStyle()))
+ if (m_brush.IsHatch())
{
gdk_gc_set_fill( m_brushGC, GDK_STIPPLED );
int num = m_brush.GetStyle() - wxBDIAGONAL_HATCH;
}
}
- if (IS_HATCH(m_backgroundBrush.GetStyle()))
+ if (m_backgroundBrush.IsHatch())
{
gdk_gc_set_fill( m_bgGC, GDK_STIPPLED );
int num = m_backgroundBrush.GetStyle() - wxBDIAGONAL_HATCH;
wxSize sz = win->GetSize();
m_paintClippingRegion = win->GetUpdateRegion();
wxLimitRegionToSize(m_paintClippingRegion, sz);
-
+
GdkRegion *region = m_paintClippingRegion.GetRegion();
if ( region )
{
bool wxDCModule::OnInit()
{
wxInitGCPool();
- return TRUE;
+ return true;
}
void wxDCModule::OnExit()
class wxMacFastPortSetter
{
public :
- wxMacFastPortSetter( const wxDC *dc )
+ wxMacFastPortSetter( const wxDC *dc )
{
- wxASSERT( dc->Ok() ) ;
- m_swapped = QDSwapPort( (GrafPtr) dc->m_macPort , &m_oldPort ) ;
- m_clipRgn = NewRgn() ;
- GetClip( m_clipRgn ) ;
- m_dc = dc ;
- dc->MacSetupPort( NULL ) ;
+ wxASSERT( dc->Ok() ) ;
+ m_swapped = QDSwapPort( (GrafPtr) dc->m_macPort , &m_oldPort ) ;
+ m_clipRgn = NewRgn() ;
+ GetClip( m_clipRgn ) ;
+ m_dc = dc ;
+ dc->MacSetupPort( NULL ) ;
}
~wxMacFastPortSetter()
{
// SetPort( (GrafPtr) m_dc->m_macPort ) ;
SetClip( m_clipRgn ) ;
if ( m_swapped )
- SetPort( m_oldPort ) ;
- m_dc->MacCleanupPort( NULL ) ;
- DisposeRgn( m_clipRgn ) ;
+ SetPort( m_oldPort ) ;
+ m_dc->MacCleanupPort( NULL ) ;
+ DisposeRgn( m_clipRgn ) ;
}
private :
bool m_swapped ;
m_formerClip = NewRgn() ;
m_newClip = NewRgn() ;
GetClip( m_formerClip ) ;
-
+
if ( win )
{
int x = 0 , y = 0;
}
}
-wxMacWindowClipper::~wxMacWindowClipper()
+wxMacWindowClipper::~wxMacWindowClipper()
{
SetPort( m_newPort ) ;
SetClip( m_formerClip ) ;
GetThemeDrawingState( &m_themeDrawingState ) ;
}
-wxMacWindowStateSaver::~wxMacWindowStateSaver()
+wxMacWindowStateSaver::~wxMacWindowStateSaver()
{
SetPort( m_newPort ) ;
SetThemeDrawingState( m_themeDrawingState , true ) ;
wxDC::wxDC()
{
- m_ok = FALSE;
- m_colour = TRUE;
+ m_ok = false;
+ m_colour = true;
m_mm_to_pix_x = mm2pt;
m_mm_to_pix_y = mm2pt;
m_internalDeviceOriginX = 0;
m_userScaleY = 1.0;
m_scaleX = 1.0;
m_scaleY = 1.0;
- m_needComputeScaleX = FALSE;
- m_needComputeScaleY = FALSE;
+ m_needComputeScaleX = false;
+ m_needComputeScaleY = false;
m_macPort = NULL ;
m_macMask = NULL ;
- m_ok = FALSE ;
+ m_ok = false ;
m_macFontInstalled = false ;
m_macBrushInstalled = false ;
m_macPenInstalled = false ;
m_font = *wxNORMAL_FONT;
m_brush = *wxWHITE_BRUSH;
#ifdef __WXDEBUG__
- // needed to debug possible errors with two active drawing methods at the same time on
+ // needed to debug possible errors with two active drawing methods at the same time on
// the same DC
m_macCurrentPortStateHelper = NULL ;
#endif
}
else
{
- m_clipping = TRUE;
+ m_clipping = true;
m_clipX1 = xx;
m_clipY1 = yy;
m_clipX2 = xx + ww;
}
else
{
- m_clipping = TRUE;
+ m_clipping = true;
m_clipX1 = xx;
m_clipY1 = yy;
m_clipX2 = xx + ww;
}
if (mode != wxMM_TEXT)
{
- m_needComputeScaleX = TRUE;
- m_needComputeScaleY = TRUE;
+ m_needComputeScaleX = true;
+ m_needComputeScaleY = true;
}
}
wxCHECK_MSG(Ok(), false, wxT("wxDC::DoBlit Illegal dc"));
wxCHECK_MSG(source->Ok(), false, wxT("wxDC::DoBlit Illegal source DC"));
if ( logical_func == wxNO_OP )
- return TRUE ;
+ return true ;
if (xsrcMask == -1 && ysrcMask == -1)
{
xsrcMask = xsrc; ysrcMask = ysrc;
if ( mode == kUnsupportedMode )
{
wxFAIL_MSG(wxT("unsupported blitting mode" ));
- return FALSE ;
+ return false ;
}
CGrafPtr sourcePort = (CGrafPtr) source->m_macPort ;
PixMapHandle bmappixels = GetGWorldPixMap( sourcePort ) ;
m_macPenInstalled = false ;
m_macBrushInstalled = false ;
m_macFontInstalled = false ;
- return TRUE;
+ return true;
}
#ifndef FixedToInt
UniCharCount chars = str.Length() ;
UniChar* ubuf = NULL ;
#if SIZEOF_WCHAR_T == 4
- wxMBConvUTF16BE converter ;
+ wxMBConvUTF16BE converter ;
#if wxUSE_UNICODE
- size_t unicharlen = converter.WC2MB( NULL , str.wc_str() , 0 ) ;
- ubuf = (UniChar*) malloc( unicharlen + 2 ) ;
- converter.WC2MB( (char*) ubuf , str.wc_str(), unicharlen + 2 ) ;
+ size_t unicharlen = converter.WC2MB( NULL , str.wc_str() , 0 ) ;
+ ubuf = (UniChar*) malloc( unicharlen + 2 ) ;
+ converter.WC2MB( (char*) ubuf , str.wc_str(), unicharlen + 2 ) ;
#else
const wxWCharBuffer wchar = str.wc_str( wxConvLocal ) ;
- size_t unicharlen = converter.WC2MB( NULL , wchar.data() , 0 ) ;
- ubuf = (UniChar*) malloc( unicharlen + 2 ) ;
- converter.WC2MB( (char*) ubuf , wchar.data() , unicharlen + 2 ) ;
+ size_t unicharlen = converter.WC2MB( NULL , wchar.data() , 0 ) ;
+ ubuf = (UniChar*) malloc( unicharlen + 2 ) ;
+ converter.WC2MB( (char*) ubuf , wchar.data() , unicharlen + 2 ) ;
#endif
chars = unicharlen / 2 ;
#else
int iAngle = int( angle );
int drawX = XLOG2DEVMAC(x) ;
int drawY = YLOG2DEVMAC(y) ;
-
+
ATSUTextMeasurement textBefore ;
ATSUTextMeasurement textAfter ;
ATSUTextMeasurement ascent ;
ATSUTextMeasurement descent ;
-
-
+
+
if ( abs(iAngle) > 0 )
{
Fixed atsuAngle = IntToFixed( iAngle ) ;
}
status = ::ATSUMeasureText( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd,
&textBefore , &textAfter, &ascent , &descent );
-
+
drawX += (int)(sin(angle/RAD2DEG) * FixedToInt(ascent));
drawY += (int)(cos(angle/RAD2DEG) * FixedToInt(ascent));
status = ::ATSUDrawText( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd,
else
#endif
{
- wxCharBuffer text = linetext.mb_str(wxConvLocal) ;
+ wxCharBuffer text = linetext.mb_str(wxConvLocal) ;
::DrawText( text , 0 , strlen(text) ) ;
}
}
MacInstallFont() ;
FontInfo fi ;
::GetFontInfo( &fi ) ;
-#if TARGET_CARBON
+#if TARGET_CARBON
bool useGetThemeText = ( GetThemeTextDimensions != (void*) kUnresolvedCFragSymbolAddress ) ;
if ( UMAGetSystemVersion() < 0x1000 || IsKindOf(CLASSINFO( wxPrinterDC ) ) || ((wxFont*)&m_font)->GetNoAntiAliasing() )
useGetThemeText = false ;
}
else
{
- wxCharBuffer text = linetext.mb_str(wxConvLocal) ;
+ wxCharBuffer text = linetext.mb_str(wxConvLocal) ;
curwidth = ::TextWidth( text , 0 , strlen(text) ) ;
}
if ( curwidth > *width )
if (text.Length() == 0)
return false;
-
+
wxMacFastPortSetter helper(this) ;
MacInstallFont() ;
-#if TARGET_CARBON
+#if TARGET_CARBON
bool useGetThemeText = ( GetThemeTextDimensions != (void*) kUnresolvedCFragSymbolAddress ) ;
if ( UMAGetSystemVersion() < 0x1000 || IsKindOf(CLASSINFO( wxPrinterDC ) ) || ((wxFont*)&m_font)->GetNoAntiAliasing() )
useGetThemeText = false ;
widths[i] = XDEV2LOGREL(bounds.h);
}
}
- else
+ else
#endif
{
wxCharBuffer buff = text.mb_str(wxConvLocal);
for (size_t i=0; i<text.Length(); i++)
widths[i] = XDEV2LOGREL(measurements[i+1]);
- delete [] measurements;
+ delete [] measurements;
}
return true;
{
int index = 0; // solid pattern by default
switch(penStyle)
- {
+ {
// hatches
case wxBDIAGONAL_HATCH: index = 1; break;
case wxFDIAGONAL_HATCH: index = 2; break;
case wxSHORT_DASH: index = 9; break;
case wxDOT_DASH: index = 10; break;
}
- *pattern = gPatterns[index];
+ *pattern = gPatterns[index];
}
void wxDC::MacInstallPen() const
if ( penWidth == 0 )
penWidth = 1 ;
::PenSize(penWidth, penWidth);
-
+
int penStyle = m_pen.GetStyle();
Pattern pat;
if (penStyle == wxUSER_DASH)
- {
+ {
// FIXME: there should be exactly 8 items in the dash
wxDash* dash ;
int number = m_pen.GetDashes(&dash) ;
int brushStyle = background.GetStyle();
if (brushStyle == wxSOLID)
::BackPat(GetQDGlobalsWhite(&whiteColor));
- else if (IS_HATCH(brushStyle))
+ else if (background.IsHatch())
{
Pattern pat ;
wxMacGetPattern(brushStyle, &pat);
{
::PenPat(GetQDGlobalsBlack(&blackColor));
}
- else if (IS_HATCH(brushStyle))
+ else if (m_brush.IsHatch())
{
Pattern pat ;
wxMacGetPattern(brushStyle, &pat);
class wxMacFastPortSetter
{
public :
- wxMacFastPortSetter( const wxDC *dc )
+ wxMacFastPortSetter( const wxDC *dc )
{
- wxASSERT( dc->Ok() ) ;
- GetPort( &m_oldPort ) ;
- SetPort( (GrafPtr) dc->m_macPort ) ;
- m_clipRgn = NewRgn() ;
- GetClip( m_clipRgn ) ;
- m_dc = dc ;
- dc->MacSetupPort( NULL ) ;
+ wxASSERT( dc->Ok() ) ;
+ GetPort( &m_oldPort ) ;
+ SetPort( (GrafPtr) dc->m_macPort ) ;
+ m_clipRgn = NewRgn() ;
+ GetClip( m_clipRgn ) ;
+ m_dc = dc ;
+ dc->MacSetupPort( NULL ) ;
}
~wxMacFastPortSetter()
{
SetPort( (GrafPtr) m_dc->m_macPort ) ;
SetClip( m_clipRgn ) ;
- SetPort( m_oldPort ) ;
- m_dc->MacCleanupPort( NULL ) ;
- DisposeRgn( m_clipRgn ) ;
+ SetPort( m_oldPort ) ;
+ m_dc->MacCleanupPort( NULL ) ;
+ DisposeRgn( m_clipRgn ) ;
}
private :
RgnHandle m_clipRgn ;
#endif
-wxMacWindowClipper::wxMacWindowClipper( const wxWindow* win )
+wxMacWindowClipper::wxMacWindowClipper( const wxWindow* win )
{
m_formerClip = NewRgn() ;
m_newClip = NewRgn() ;
GetClip( m_formerClip ) ;
-
+
if ( win )
{
#if 0
wxWindow *parent = win->GetParent() ;
parent->MacWindowToRootWindow( &x,&y ) ;
wxSize size = parent->GetSize() ;
- SetRectRgn( insidergn , parent->MacGetLeftBorderSize() , parent->MacGetTopBorderSize() ,
- size.x - parent->MacGetRightBorderSize(),
+ SetRectRgn( insidergn , parent->MacGetLeftBorderSize() , parent->MacGetTopBorderSize() ,
+ size.x - parent->MacGetRightBorderSize(),
size.y - parent->MacGetBottomBorderSize()) ;
CopyRgn( (RgnHandle) parent->MacGetVisibleRegion(false).GetWXHRGN() , m_newClip ) ;
SectRgn( m_newClip , insidergn , m_newClip ) ;
CopyRgn( (RgnHandle) ((wxWindow*)win)->MacGetVisibleRegion().GetWXHRGN() , m_newClip ) ;
OffsetRgn( m_newClip , x , y ) ;
SetClip( m_newClip ) ;
-#endif
+#endif
}
}
-wxMacWindowClipper::~wxMacWindowClipper()
+wxMacWindowClipper::~wxMacWindowClipper()
{
SetClip( m_formerClip ) ;
DisposeRgn( m_newClip ) ;
wxDC::wxDC()
{
- m_ok = FALSE;
- m_colour = TRUE;
+ m_ok = false;
+ m_colour = true;
m_mm_to_pix_x = mm2pt;
m_mm_to_pix_y = mm2pt;
m_internalDeviceOriginX = 0;
m_userScaleY = 1.0;
m_scaleX = 1.0;
m_scaleY = 1.0;
- m_needComputeScaleX = FALSE;
- m_needComputeScaleY = FALSE;
+ m_needComputeScaleX = false;
+ m_needComputeScaleY = false;
m_macPort = NULL ;
m_macMask = NULL ;
- m_ok = FALSE ;
+ m_ok = false ;
m_macFontInstalled = false ;
m_macBrushInstalled = false ;
m_macPenInstalled = false ;
m_font = *wxNORMAL_FONT;
m_brush = *wxWHITE_BRUSH;
#ifdef __WXDEBUG__
- // needed to debug possible errors with two active drawing methods at the same time on
+ // needed to debug possible errors with two active drawing methods at the same time on
// the same DC
m_macCurrentPortStateHelper = NULL ;
#endif
}
else
{
- m_clipping = TRUE;
+ m_clipping = true;
m_clipX1 = xx;
m_clipY1 = yy;
m_clipX2 = xx + ww;
}
else
{
- m_clipping = TRUE;
+ m_clipping = true;
m_clipX1 = xx;
m_clipY1 = yy;
m_clipX2 = xx + ww;
}
if (mode != wxMM_TEXT)
{
- m_needComputeScaleX = TRUE;
- m_needComputeScaleY = TRUE;
+ m_needComputeScaleX = true;
+ m_needComputeScaleY = true;
}
}
wxCHECK_MSG(Ok(), false, wxT("wxDC::DoBlit Illegal dc"));
wxCHECK_MSG(source->Ok(), false, wxT("wxDC::DoBlit Illegal source DC"));
if ( logical_func == wxNO_OP )
- return TRUE ;
+ return true ;
if (xsrcMask == -1 && ysrcMask == -1)
{
xsrcMask = xsrc; ysrcMask = ysrc;
if ( mode == kUnsupportedMode )
{
wxFAIL_MSG(wxT("unsupported blitting mode" ));
- return FALSE ;
+ return false ;
}
CGrafPtr sourcePort = (CGrafPtr) source->m_macPort ;
PixMapHandle bmappixels = GetGWorldPixMap( sourcePort ) ;
m_macPenInstalled = false ;
m_macBrushInstalled = false ;
m_macFontInstalled = false ;
- return TRUE;
+ return true;
}
#ifndef FixedToInt
if ( str.Length() == 0 )
return ;
-
+
wxMacFastPortSetter helper(this) ;
MacInstallFont() ;
int iAngle = int( angle );
int drawX = XLOG2DEVMAC(x) ;
int drawY = YLOG2DEVMAC(y) ;
-
+
ATSUTextMeasurement textBefore ;
ATSUTextMeasurement textAfter ;
ATSUTextMeasurement ascent ;
ATSUTextMeasurement descent ;
-
-
+
+
if ( abs(iAngle) > 0 )
{
Fixed atsuAngle = IntToFixed( iAngle ) ;
}
status = ::ATSUMeasureText( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd,
&textBefore , &textAfter, &ascent , &descent );
-
+
drawX += (int)(sin(angle/RAD2DEG) * FixedToInt(ascent));
drawY += (int)(cos(angle/RAD2DEG) * FixedToInt(ascent));
status = ::ATSUDrawText( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd,
else
#endif
{
- wxCharBuffer text = linetext.mb_str(wxConvLocal) ;
+ wxCharBuffer text = linetext.mb_str(wxConvLocal) ;
::DrawText( text , 0 , strlen(text) ) ;
if ( m_backgroundMode != wxTRANSPARENT )
{
else
#endif
{
- wxCharBuffer text = linetext.mb_str(wxConvLocal) ;
+ wxCharBuffer text = linetext.mb_str(wxConvLocal) ;
if ( m_backgroundMode != wxTRANSPARENT )
{
Rect frame = { yy - fi.ascent + line*(fi.descent + fi.ascent + fi.leading) ,xx , yy - fi.ascent + (line+1)*(fi.descent + fi.ascent + fi.leading) , xx + 10000 } ;
MacInstallFont() ;
FontInfo fi ;
::GetFontInfo( &fi ) ;
-#if TARGET_CARBON
+#if TARGET_CARBON
bool useGetThemeText = ( GetThemeTextDimensions != (void*) kUnresolvedCFragSymbolAddress ) ;
if ( UMAGetSystemVersion() < 0x1000 || IsKindOf(CLASSINFO( wxPrinterDC ) ) || ((wxFont*)&m_font)->GetNoAntiAliasing() )
useGetThemeText = false ;
else
#endif
{
- wxCharBuffer text = linetext.mb_str(wxConvLocal) ;
+ wxCharBuffer text = linetext.mb_str(wxConvLocal) ;
curwidth = ::TextWidth( text , 0 , strlen(text) ) ;
}
if ( curwidth > *width )
}
i++ ;
}
-
+
wxString linetext = strtext.Mid( laststop , i - laststop ) ;
#endif // 0
wxString linetext = strtext ;
else
#endif
{
- wxCharBuffer text = linetext.mb_str(wxConvLocal) ;
+ wxCharBuffer text = linetext.mb_str(wxConvLocal) ;
curwidth = ::TextWidth( text , 0 , strlen(text) ) ;
}
if ( curwidth > *width )
if (text.Length() == 0)
return false;
-
+
wxMacFastPortSetter helper(this) ;
MacInstallFont() ;
-#if TARGET_CARBON
+#if TARGET_CARBON
bool useGetThemeText = ( GetThemeTextDimensions != (void*) kUnresolvedCFragSymbolAddress ) ;
if ( UMAGetSystemVersion() < 0x1000 || IsKindOf(CLASSINFO( wxPrinterDC ) ) || ((wxFont*)&m_font)->GetNoAntiAliasing() )
useGetThemeText = false ;
widths[i] = XDEV2LOGREL(bounds.h);
}
}
- else
+ else
#endif
{
wxCharBuffer buff = text.mb_str(wxConvLocal);
for (size_t i=0; i<text.Length(); i++)
widths[i] = XDEV2LOGREL(measurements[i+1]);
- delete [] measurements;
+ delete [] measurements;
}
return true;
{
int index = 0; // solid pattern by default
switch(penStyle)
- {
+ {
// hatches
case wxBDIAGONAL_HATCH: index = 1; break;
case wxFDIAGONAL_HATCH: index = 2; break;
case wxSHORT_DASH: index = 9; break;
case wxDOT_DASH: index = 10; break;
}
- *pattern = gPatterns[index];
+ *pattern = gPatterns[index];
}
void wxDC::MacInstallPen() const
if ( penWidth == 0 )
penWidth = 1 ;
::PenSize(penWidth, penWidth);
-
+
int penStyle = m_pen.GetStyle();
Pattern pat;
if (penStyle == wxUSER_DASH)
- {
+ {
// FIXME: there should be exactly 8 items in the dash
wxDash* dash ;
int number = m_pen.GetDashes(&dash) ;
int brushStyle = background.GetStyle();
if (brushStyle == wxSOLID)
::BackPat(GetQDGlobalsWhite(&whiteColor));
- else if (IS_HATCH(brushStyle))
+ else if (background.IsHatch())
{
Pattern pat ;
wxMacGetPattern(brushStyle, &pat);
{
::PenPat(GetQDGlobalsBlack(&blackColor));
}
- else if (IS_HATCH(brushStyle))
+ else if (m_brush.IsHatch())
{
Pattern pat ;
wxMacGetPattern(brushStyle, &pat);
// macros
// ----------------------------------------------------------------------------
- IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxWindowDC)
- IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC)
- IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC)
+IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxWindowDC)
+IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC)
+IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC)
+
+#ifndef IS_HATCH
+ // IS_HATCH exists for WXWIN_COMPATIBILITY_2_4 only
+ // but wxMotif needs it for its internals here
+ #define IS_HATCH(s) ((s)>=wxBDIAGONAL_HATCH && (s)<=wxVERTICAL_HATCH)
+#endif
// ----------------------------------------------------------------------------
// prototypes
m_window = window;
m_font = window->GetFont();
- m_ok = TRUE;
+ m_ok = true;
m_display = window->GetXDisplay();
m_pixmap = window->GetXWindow();
m_clipRegion = (WXRegion) 0;
}
-extern bool wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y,
+extern bool wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y,
const wxColour & col, int style);
bool wxWindowDC::DoFloodFill(wxCoord x, wxCoord y,
{
return wxDoFloodFill(this, x, y, col, style);
}
-
+
bool wxWindowDC::DoGetPixel( wxCoord x1, wxCoord y1, wxColour *col ) const
{
// Generic (and therefore rather inefficient) method.
memdc.SelectObject(wxNullBitmap);
wxImage image = bitmap.ConvertToImage();
col->Set(image.GetRed(0, 0), image.GetGreen(0, 0), image.GetBlue(0, 0));
- return TRUE;
+ return true;
}
void wxWindowDC::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 )
bool wxWindowDC::CanDrawBitmap() const
{
- wxCHECK_MSG( Ok(), FALSE, "invalid dc" );
+ wxCHECK_MSG( Ok(), false, "invalid dc" );
- return TRUE;
+ return true;
}
-// TODO: use scaled Blit e.g. as per John Price's implementation
+// TODO: use scaled Blit e.g. as per John Price's implementation
// in Contrib/Utilities
bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest,
wxCoord width, wxCoord height,
int rop, bool useMask,
wxCoord xsrcMask, wxCoord ysrcMask )
{
- wxCHECK_MSG( Ok(), FALSE, "invalid dc" );
+ wxCHECK_MSG( Ok(), false, "invalid dc" );
wxWindowDC* sourceDC = wxDynamicCast(source, wxWindowDC);
if( m_textForegroundColour.GetPixel() <= -1 )
CalculatePixel( m_textForegroundColour,
- m_textForegroundColour, TRUE);
-
+ m_textForegroundColour, true);
+
int pixel = m_textForegroundColour.GetPixel();
if (pixel > -1)
SetForegroundPixelWithLogicalFunction(pixel);
Pixmap sourcePixmap = (Pixmap) NULL;
double scaleX, scaleY;
GetUserScale(& scaleX, & scaleY);
- bool retVal = FALSE;
+ bool retVal = false;
/* TODO: use the mask origin when drawing transparently */
if (xsrcMask == -1 && ysrcMask == -1)
} else
{ //XGCValues values;
- //XGetGCValues((Display*)m_display, (GC)m_gc, GCForeground, &values);
+ //XGetGCValues((Display*)m_display, (GC)m_gc, GCForeground, &values);
if (m_window && m_window->GetBackingPixmap())
{
SetLogicalFunction(orig);
- retVal = TRUE;
+ retVal = true;
}
if (scaledBitmap) delete scaledBitmap;
if (!sameColour || !GetOptimization())
{
int pixel = CalculatePixel(m_textForegroundColour,
- m_currentColour, FALSE);
+ m_currentColour, false);
// Set the GC to the required colour
if (pixel > -1)
if( m_textForegroundColour.GetPixel() <= -1 )
CalculatePixel( m_textForegroundColour,
- m_textForegroundColour, TRUE);
-
+ m_textForegroundColour, true);
+
foregroundPixel = m_textForegroundColour.GetPixel();
}
bool wxWindowDC::CanGetTextExtent() const
{
- return TRUE;
+ return true;
}
void wxWindowDC::DoGetTextExtent( const wxString &string, wxCoord *width, wxCoord *height,
bool roundToWhite) const
{
const unsigned char wp = (unsigned char)255;
-
+
int pixel = -1;
if(!m_colour) // Mono display
{
pixel = m_backgroundPixel;
else
{
- pixel = CalculatePixel(m_pen.GetColour(), m_currentColour, FALSE);
+ pixel = CalculatePixel(m_pen.GetColour(), m_currentColour, false);
}
// Finally, set the GC to the required colour
// determine whether fill style should be solid or
// transparent
int style = stippleDepth == 1 ?
- (m_backgroundMode == wxSOLID ?
+ (m_backgroundMode == wxSOLID ?
FillOpaqueStippled : FillStippled) :
FillTiled;
XSetFillStyle ((Display*) m_display, (GC) m_gc, style);
// must test m_logicalFunction, because it involves background!
if (!sameColour || !GetOptimization() || m_logicalFunction == wxXOR)
{
- int pixel = CalculatePixel(m_brush.GetColour(), m_currentColour, TRUE);
-
+ int pixel = CalculatePixel(m_brush.GetColour(), m_currentColour, true);
+
if (pixel > -1)
SetForegroundPixelWithLogicalFunction(pixel);
}
wxPaintDC::wxPaintDC(wxWindow* win) : wxWindowDC(win)
{
// Set the clipping region.to the update region
- SetDCClipping((WXRegion)NULL);
+ SetDCClipping((WXRegion)NULL);
}
wxPaintDC::~wxPaintDC()
wxGCPool[i].m_gc = XCreateGC( wxGlobalDisplay(), window, 0, NULL );
XSetGraphicsExposures( wxGlobalDisplay(), wxGCPool[i].m_gc, FALSE );
wxGCPool[i].m_type = type;
- wxGCPool[i].m_used = FALSE;
+ wxGCPool[i].m_used = false;
}
if ((!wxGCPool[i].m_used) && (wxGCPool[i].m_type == type))
{
- wxGCPool[i].m_used = TRUE;
+ wxGCPool[i].m_used = true;
return wxGCPool[i].m_gc;
}
}
{
if (wxGCPool[i].m_gc == gc)
{
- wxGCPool[i].m_used = FALSE;
+ wxGCPool[i].m_used = false;
return;
}
}
m_textGC = (WXGC *) NULL;
m_bgGC = (WXGC *) NULL;
m_cmap = (WXColormap *) NULL;
- m_isMemDC = FALSE;
- m_isScreenDC = FALSE;
+ m_isMemDC = false;
+ m_isScreenDC = false;
m_owner = (wxWindow *)NULL;
-
+
#if wxUSE_UNICODE
m_context = (PangoContext *)NULL;
m_fontdesc = (PangoFontDescription *)NULL;
m_bgGC = (WXGC *) NULL;
m_cmap = (WXColormap *) NULL;
m_owner = (wxWindow *)NULL;
- m_isMemDC = FALSE;
- m_isScreenDC = FALSE;
+ m_isMemDC = false;
+ m_isScreenDC = false;
m_font = window->GetFont();
m_window = (WXWindow*) window->GetMainWindow();
if (!m_window)
{
// don't report problems
- m_ok = TRUE;
+ m_ok = true;
return;
}
m_display = (WXDisplay *) wxGlobalDisplay();
-
+
#if wxUSE_UNICODE
m_context = wxTheApp->GetPangoContext();
m_fontdesc = window->GetFont().GetNativeFontInfo()->description;
void wxWindowDC::SetUpDC()
{
- m_ok = TRUE;
+ m_ok = true;
wxASSERT_MSG( !m_penGC, wxT("GCs already created") );
/* m_bgGC */
XSetForeground( (Display*) m_display, (GC) m_bgGC, bg_col );
XSetBackground( (Display*) m_display, (GC) m_bgGC, bg_col );
-
+
XSetFillStyle( (Display*) m_display, (GC) m_bgGC, FillSolid );
/* ROPs */
{
int xscreen = DefaultScreen( (Display*) m_display );
Window xroot = RootWindow( (Display*) m_display, xscreen );
-
+
hatch_bitmap = hatches;
hatch_bitmap[0] = XCreateBitmapFromData( (Display*) m_display, xroot, bdiag_bits, bdiag_width, bdiag_height );
hatch_bitmap[1] = XCreateBitmapFromData( (Display*) m_display, xroot, cdiag_bits, cdiag_width, cdiag_height );
m_owner->GetSize(width, height);
}
-extern bool wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y,
+extern bool wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y,
const wxColour & col, int style);
bool wxWindowDC::DoFloodFill(wxCoord x, wxCoord y,
memdc.SelectObject(wxNullBitmap);
wxImage image(bitmap.ConvertToImage());
col->Set(image.GetRed(0, 0), image.GetGreen(0, 0), image.GetBlue(0, 0));
- return TRUE;
+ return true;
}
void wxWindowDC::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 )
points[1].x = x2;
points[1].y = y2;
DrawLines( 2, points, 0, 0 );
-
- // XDrawLine( (Display*) m_display, (Window) m_window,
+
+ // XDrawLine( (Display*) m_display, (Window) m_window,
// (GC) m_penGC, XLOG2DEV(x1), YLOG2DEV(y1), XLOG2DEV(x2), YLOG2DEV(y2) );
}
XSetTSOrigin( (Display*) m_display, (GC) m_textGC,
m_deviceOriginX % m_brush.GetStipple()->GetWidth(),
m_deviceOriginY % m_brush.GetStipple()->GetHeight() );
-
+
XFillArc( (Display*) m_display, (Window) m_window,
(GC) m_brushGC, xxc-r, yyc-r, 2*r,2*r, alpha1, alpha2 );
-
+
XSetTSOrigin( (Display*) m_display, (GC) m_textGC, 0, 0 );
} else
if (IS_15_PIX_HATCH(m_brush.GetStyle()))
{
XSetTSOrigin( (Display*) m_display, (GC) m_brushGC,
m_deviceOriginX % 15, m_deviceOriginY % 15 );
-
+
XFillArc( (Display*) m_display, (Window) m_window,
(GC) m_brushGC, xxc-r, yyc-r, 2*r,2*r, alpha1, alpha2 );
-
+
XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, 0, 0 );
} else
if (IS_16_PIX_HATCH(m_brush.GetStyle()))
{
XSetTSOrigin( (Display*) m_display, (GC) m_brushGC,
m_deviceOriginX % 16, m_deviceOriginY % 16 );
-
+
XFillArc( (Display*) m_display, (Window) m_window,
(GC) m_brushGC, xxc-r, yyc-r, 2*r,2*r, alpha1, alpha2 );
-
+
XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, 0, 0 );
} else
if (m_brush.GetStyle() == wxSTIPPLE)
XSetTSOrigin( (Display*) m_display, (GC) m_brushGC,
m_deviceOriginX % m_brush.GetStipple()->GetWidth(),
m_deviceOriginY % m_brush.GetStipple()->GetHeight() );
-
+
XFillArc( (Display*) m_display, (Window) m_window,
(GC) m_brushGC, xxc-r, yyc-r, 2*r,2*r, alpha1, alpha2 );
-
+
XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, 0, 0 );
}
else
{
XDrawArc( (Display*) m_display, (Window) m_window,
(GC) m_penGC, xxc-r, yyc-r, 2*r,2*r, alpha1, alpha2 );
-
+
XDrawLine( (Display*) m_display, (Window) m_window,
(GC) m_penGC, xx1, yy1, xxc, yyc );
-
+
XDrawLine( (Display*) m_display, (Window) m_window,
(GC) m_penGC, xxc, yyc, xx2, yy2 );
}
XSetTSOrigin( (Display*) m_display, (GC) m_textGC,
m_deviceOriginX % m_brush.GetStipple()->GetWidth(),
m_deviceOriginY % m_brush.GetStipple()->GetHeight() );
-
+
XFillArc( (Display*) m_display, (Window) m_window,
(GC) m_textGC, xx, yy, ww, hh, start, end );
-
+
XSetTSOrigin( (Display*) m_display, (GC) m_textGC, 0, 0 );
} else
if (IS_15_PIX_HATCH(m_brush.GetStyle()))
{
XSetTSOrigin( (Display*) m_display, (GC) m_brushGC,
m_deviceOriginX % 15, m_deviceOriginY % 15 );
-
+
XFillArc( (Display*) m_display, (Window) m_window,
(GC) m_brushGC, xx, yy, ww, hh, start, end );
-
+
XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, 0, 0 );
} else
if (IS_16_PIX_HATCH(m_brush.GetStyle()))
{
XSetTSOrigin( (Display*) m_display, (GC) m_brushGC,
m_deviceOriginX % 16, m_deviceOriginY % 16 );
-
+
XFillArc( (Display*) m_display, (Window) m_window,
(GC) m_brushGC, xx, yy, ww, hh, start, end );
-
+
XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, 0, 0 );
} else
if (m_brush.GetStyle() == wxSTIPPLE)
XSetTSOrigin( (Display*) m_display, (GC) m_brushGC,
m_deviceOriginX % m_brush.GetStipple()->GetWidth(),
m_deviceOriginY % m_brush.GetStipple()->GetHeight() );
-
+
XFillArc( (Display*) m_display, (Window) m_window,
(GC) m_brushGC, xx, yy, ww, hh, start, end );
-
+
XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, 0, 0 );
}
else
{
xpoints[i].x = XLOG2DEV (points[i].x + xoffset);
xpoints[i].y = YLOG2DEV (points[i].y + yoffset);
-
+
CalcBoundingBox( points[i].x + xoffset, points[i].y + yoffset );
}
XDrawLines( (Display*) m_display, (Window) m_window, (GC) m_penGC, xpoints, n, 0 );
{
xpoints[i].x = XLOG2DEV (points[i].x + xoffset);
xpoints[i].y = YLOG2DEV (points[i].y + yoffset);
-
+
CalcBoundingBox (points[i].x + xoffset, points[i].y + yoffset);
}
{
if (m_brush.GetStyle() != wxTRANSPARENT)
{
-
+
if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask()))
{
XSetTSOrigin( (Display*) m_display, (GC) m_textGC,
m_deviceOriginX % m_brush.GetStipple()->GetWidth(),
m_deviceOriginY % m_brush.GetStipple()->GetHeight() );
-
+
XFillPolygon( (Display*) m_display, (Window) m_window,
(GC) m_textGC, xpoints, n, Complex, 0);
-
+
XSetTSOrigin( (Display*) m_display, (GC) m_textGC, 0, 0 );
} else
if (IS_15_PIX_HATCH(m_brush.GetStyle()))
{
XSetTSOrigin( (Display*) m_display, (GC) m_brushGC,
m_deviceOriginX % 15, m_deviceOriginY % 15 );
-
+
XFillPolygon( (Display*) m_display, (Window) m_window,
(GC) m_brushGC, xpoints, n, Complex, 0);
-
+
XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, 0, 0 );
} else
if (IS_16_PIX_HATCH(m_brush.GetStyle()))
{
XSetTSOrigin( (Display*) m_display, (GC) m_brushGC,
m_deviceOriginX % 16, m_deviceOriginY % 16 );
-
+
XFillPolygon( (Display*) m_display, (Window) m_window,
(GC) m_brushGC, xpoints, n, Complex, 0);
-
+
XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, 0, 0 );
} else
if (m_brush.GetStyle() == wxSTIPPLE)
XSetTSOrigin( (Display*) m_display, (GC) m_brushGC,
m_deviceOriginX % m_brush.GetStipple()->GetWidth(),
m_deviceOriginY % m_brush.GetStipple()->GetHeight() );
-
+
XFillPolygon( (Display*) m_display, (Window) m_window,
(GC) m_brushGC, xpoints, n, Complex, 0);
-
+
XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, 0, 0 );
}
else
// CMB: handle -ve width and/or height
if (ww < 0) { ww = -ww; xx = xx - ww; }
if (hh < 0) { hh = -hh; yy = yy - hh; }
-
+
if (m_window)
{
if (m_brush.GetStyle() != wxTRANSPARENT)
XSetTSOrigin( (Display*) m_display, (GC) m_textGC,
m_deviceOriginX % m_brush.GetStipple()->GetWidth(),
m_deviceOriginY % m_brush.GetStipple()->GetHeight() );
-
+
XFillRectangle( (Display*) m_display, (Window) m_window,
(GC) m_textGC, xx, yy, ww, hh );
-
+
XSetTSOrigin( (Display*) m_display, (GC) m_textGC, 0, 0 );
} else
if (IS_15_PIX_HATCH(m_brush.GetStyle()))
{
XSetTSOrigin( (Display*) m_display, (GC) m_brushGC,
m_deviceOriginX % 15, m_deviceOriginY % 15 );
-
+
XFillRectangle( (Display*) m_display, (Window) m_window,
(GC) m_brushGC, xx, yy, ww, hh );
-
+
XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, 0, 0 );
} else
if (IS_16_PIX_HATCH(m_brush.GetStyle()))
{
XSetTSOrigin( (Display*) m_display, (GC) m_brushGC,
m_deviceOriginX % 16, m_deviceOriginY % 16 );
-
+
XFillRectangle( (Display*) m_display, (Window) m_window,
(GC) m_brushGC, xx, yy, ww, hh );
-
+
XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, 0, 0 );
} else
if (m_brush.GetStyle() == wxSTIPPLE)
XSetTSOrigin( (Display*) m_display, (GC) m_brushGC,
m_deviceOriginX % m_brush.GetStipple()->GetWidth(),
m_deviceOriginY % m_brush.GetStipple()->GetHeight() );
-
+
XFillRectangle( (Display*) m_display, (Window) m_window,
(GC) m_brushGC, xx, yy, ww, hh );
-
+
XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, 0, 0 );
}
else
void wxWindowDC::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius )
{
wxCHECK_RET( Ok(), wxT("invalid window dc") );
-
+
if (radius < 0.0) radius = - radius * ((width < height) ? width : height);
-
+
wxCoord xx = XLOG2DEV(x);
wxCoord yy = YLOG2DEV(y);
wxCoord ww = m_signX * XLOG2DEVREL(width);
wxCoord hh = m_signY * YLOG2DEVREL(height);
wxCoord rr = XLOG2DEVREL((wxCoord)radius);
-
+
// CMB: handle -ve width and/or height
if (ww < 0) { ww = -ww; xx = xx - ww; }
if (hh < 0) { hh = -hh; yy = yy - hh; }
-
+
// CMB: if radius is zero use DrawRectangle() instead to avoid
// X drawing errors with small radii
if (rr == 0)
(GC) m_penGC, x, y, width, height);
return;
}
-
+
// CMB: draw nothing if transformed w or h is 0
if (ww == 0 || hh == 0) return;
-
+
// CMB: adjust size if outline is drawn otherwise the result is
// 1 pixel too wide and high
if (m_pen.GetStyle() != wxTRANSPARENT)
ww--;
hh--;
}
-
+
if (m_window)
{
// CMB: ensure dd is not larger than rectangle otherwise we
if (dd > ww) dd = ww;
if (dd > hh) dd = hh;
rr = dd / 2;
-
+
if (m_brush.GetStyle() != wxTRANSPARENT)
{
if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask()))
{
- XSetTSOrigin( (Display*) m_display, (GC) m_textGC,
- m_deviceOriginX % m_brush.GetStipple()->GetWidth(),
+ XSetTSOrigin( (Display*) m_display, (GC) m_textGC,
+ m_deviceOriginX % m_brush.GetStipple()->GetWidth(),
m_deviceOriginY % m_brush.GetStipple()->GetHeight() );
XFillRectangle( (Display*) m_display, (Window) m_window, (GC) m_textGC, xx+rr, yy, ww-dd+1, hh );
XFillRectangle( (Display*) m_display, (Window) m_window, (GC) m_textGC, xx, yy+rr, ww, hh-dd+1 );
} else
if (m_brush.GetStyle() == wxSTIPPLE)
{
- XSetTSOrigin( (Display*) m_display, (GC) m_brushGC,
+ XSetTSOrigin( (Display*) m_display, (GC) m_brushGC,
m_deviceOriginX % m_brush.GetStipple()->GetWidth(),
m_deviceOriginY % m_brush.GetStipple()->GetHeight() );
XFillRectangle( (Display*) m_display, (Window) m_window, (GC) m_brushGC, xx+rr, yy, ww-dd+1, hh );
XDrawArc( (Display*) m_display, (Window) m_window, (GC) m_penGC, xx, yy+hh-dd, dd, dd, 180*64, 90*64 );
}
}
-
+
// this ignores the radius
CalcBoundingBox( x, y );
CalcBoundingBox( x + width, y + height );
XSetTSOrigin( (Display*) m_display, (GC) m_textGC,
m_deviceOriginX % m_brush.GetStipple()->GetWidth(),
m_deviceOriginY % m_brush.GetStipple()->GetHeight() );
-
+
XFillArc( (Display*) m_display, (Window) m_window,
(GC) m_textGC, xx, yy, ww, hh, 0, 360*64 );
-
+
XSetTSOrigin( (Display*) m_display, (GC) m_textGC, 0, 0 );
} else
if (IS_15_PIX_HATCH(m_brush.GetStyle()))
{
XSetTSOrigin( (Display*) m_display, (GC) m_brushGC,
m_deviceOriginX % 15, m_deviceOriginY % 15 );
-
+
XFillArc( (Display*) m_display, (Window) m_window,
(GC) m_brushGC, xx, yy, ww, hh, 0, 360*64 );
-
+
XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, 0, 0 );
} else
if (IS_16_PIX_HATCH(m_brush.GetStyle()))
{
XSetTSOrigin( (Display*) m_display, (GC) m_brushGC,
m_deviceOriginX % 16, m_deviceOriginY % 16 );
-
+
XFillArc( (Display*) m_display, (Window) m_window,
(GC) m_brushGC, xx, yy, ww, hh, 0, 360*64 );
-
+
XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, 0, 0 );
} else
if (m_brush.GetStyle() == wxSTIPPLE)
XSetTSOrigin( (Display*) m_display, (GC) m_brushGC,
m_deviceOriginX % m_brush.GetStipple()->GetWidth(),
m_deviceOriginY % m_brush.GetStipple()->GetHeight() );
-
+
XFillArc( (Display*) m_display, (Window) m_window,
(GC) m_brushGC, xx, yy, ww, hh, 0, 360*64 );
-
+
XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, 0, 0 );
}
else
void wxWindowDC::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y)
{
- DoDrawBitmap(icon, x, y, TRUE);
+ DoDrawBitmap(icon, x, y, true);
}
#if wxUSE_NANOX
wxCHECK_RET( Ok(), wxT("invalid window dc") );
wxCHECK_RET( bitmap.Ok(), wxT("invalid bitmap") );
-
+
bool is_mono = (bitmap.GetBitmap() != NULL);
/* scale/translate size and position */
GrCopyArea(bufPixmap, gc, 0, 0, w, h, (Window) m_window,
0, 0, GR_MODE_COPY);
#endif
-
+
// Copy src to buffer using selected raster op (none selected
// in DrawBitmap, so just use Gxcopy)
GrCopyArea(bufPixmap, gc, 0, 0, w, h, pixmap,
GrSetGCForeground(gc, BLACK);
GrCopyArea(bufPixmap, gc, 0, 0, w, h, maskPixmap,
0, 0, GR_MODE_AND);
-
+
// set unmasked area in dest to BLACK
GrSetGCBackground(gc, BLACK);
GrSetGCForeground(gc, WHITE);
wxCHECK_RET( Ok(), wxT("invalid window dc") );
wxCHECK_RET( bitmap.Ok(), wxT("invalid bitmap") );
-
+
bool is_mono = (bitmap.GetBitmap() != NULL);
// scale/translate size and position
// apply mask if any
WXPixmap mask = NULL;
if (use_bitmap.GetMask()) mask = use_bitmap.GetMask()->GetBitmap();
-
+
if (useMask && mask)
{
WXPixmap new_mask = NULL;
XSetClipMask( (Display*) m_display, (GC) m_penGC, (Pixmap) mask );
XSetClipOrigin( (Display*) m_display, (GC) m_penGC, xx, yy );
}
-
+
if (new_mask)
XFreePixmap( (Display*) m_display, (Pixmap) new_mask );
}
of the source dc, but scales correctly on the target dc and
knows about possible mask information in a memory dc. */
- wxCHECK_MSG( Ok(), FALSE, wxT("invalid window dc") );
+ wxCHECK_MSG( Ok(), false, wxT("invalid window dc") );
- wxCHECK_MSG( source, FALSE, wxT("invalid source dc") );
+ wxCHECK_MSG( source, false, wxT("invalid source dc") );
- if (!m_window) return FALSE;
+ if (!m_window) return false;
// transform the source DC coords to the device ones
xsrc = source->XLOG2DEV(xsrc);
wxClientDC *srcDC = (wxClientDC*)source;
wxMemoryDC *memDC = (wxMemoryDC*)source;
- bool use_bitmap_method = FALSE;
- bool is_mono = FALSE;
+ bool use_bitmap_method = false;
+ bool is_mono = false;
- // TODO: use the mask origin when drawing transparently
+ // TODO: use the mask origin when drawing transparently
if (xsrcMask == -1 && ysrcMask == -1)
{
xsrcMask = xsrc;
ysrcMask = ysrc;
}
-
+
if (srcDC->m_isMemDC)
{
- if (!memDC->m_selected.Ok()) return FALSE;
+ if (!memDC->m_selected.Ok()) return false;
/* we use the "XCopyArea" way to copy a memory dc into
y different window if the memory dc BOTH
/* we HAVE TO use the direct way for memory dcs
that have mask since the XCopyArea doesn't know
about masks */
- use_bitmap_method = TRUE;
+ use_bitmap_method = true;
}
else if (memDC->m_selected.GetDepth() == 1)
{
/* we HAVE TO use the direct way for memory dcs
that are bitmaps because XCopyArea doesn't cope
with different bit depths */
- is_mono = TRUE;
- use_bitmap_method = TRUE;
+ is_mono = true;
+ use_bitmap_method = true;
}
else if ((xsrc == 0) && (ysrc == 0) &&
(width == memDC->m_selected.GetWidth()) &&
in the memory dc is copied in which case XCopyArea
wouldn't be able able to boost performace by reducing
the area to be scaled */
- use_bitmap_method = TRUE;
+ use_bitmap_method = true;
}
else
{
- use_bitmap_method = FALSE;
+ use_bitmap_method = false;
}
}
wxRegion tmp( xx,yy,ww,hh );
tmp.Intersect( m_currentClippingRegion );
if (tmp.IsEmpty())
- return TRUE;
+ return true;
}
int old_logical_func = m_logicalFunction;
XSetClipMask( (Display*) m_display, (GC) m_penGC, (Pixmap) mask );
XSetClipOrigin( (Display*) m_display, (GC) m_penGC, xx, yy );
}
-
+
if (new_mask)
XFreePixmap( (Display*) m_display, (Pixmap) new_mask );
}
bitmap = image;
// draw scaled bitmap
- XCopyArea( (Display*) m_display, (Window) bitmap.GetPixmap(), (Window) m_window,
+ XCopyArea( (Display*) m_display, (Window) bitmap.GetPixmap(), (Window) m_window,
(GC) m_penGC, 0, 0, width, height, xx, yy );
}
else
// copy including child window contents
XSetSubwindowMode( (Display*) m_display, (GC) m_penGC, IncludeInferiors );
- XCopyArea( (Display*) m_display, (Window) srcDC->GetWindow(), (Window) m_window,
+ XCopyArea( (Display*) m_display, (Window) srcDC->GetWindow(), (Window) m_window,
(GC) m_penGC, xsrc, ysrc, width, height, xx, yy );
XSetSubwindowMode( (Display*) m_display, (GC) m_penGC, ClipByChildren );
}
}
SetLogicalFunction( old_logical_func );
-
- return TRUE;
+
+ return true;
}
void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y )
#if wxUSE_UNICODE
PangoLayout *layout = pango_layout_new(m_context);
pango_layout_set_font_description(layout, m_fontdesc);
-
+
const wxCharBuffer data = wxConvUTF8.cWC2MB( text );
pango_layout_set_text(layout, (const char*) data, strlen( (const char*) data ));
-
+
// Measure layout.
int w,h;
pango_layout_get_pixel_size(layout, &w, &h);
wxCoord width = w;
wxCoord height = h;
-
+
// Draw layout.
x11_draw_layout( (Drawable) m_window, (GC) m_textGC, x, y, layout, m_textForegroundColour );
-
+
g_object_unref( G_OBJECT( layout ) );
-
+
CalcBoundingBox (x + width, y + height);
CalcBoundingBox (x, y);
#else
XFontStruct *xfont = (XFontStruct*) m_font.GetFontStruct( m_scaleY, m_display );
wxCHECK_RET( xfont, wxT("invalid font") );
-
+
// First draw a rectangle representing the text background, if a text
// background is specified
if (m_textBackgroundColour.Ok () && (m_backgroundMode != wxTRANSPARENT))
if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
#endif
{
- XDrawString( (Display*) m_display, (Window) m_window,
+ XDrawString( (Display*) m_display, (Window) m_window,
(GC) m_textGC, x, y + XFontStructGetAscent(xfont), text.c_str(), text.Len() );
}
width = wxCoord(width / m_scaleX);
height = wxCoord(height / m_scaleY);
-
+
CalcBoundingBox (x + width, y + height);
CalcBoundingBox (x, y);
#endif
{
wxCHECK_RET( Ok(), wxT("invalid dc") );
- if (string.IsEmpty())
+ if (string.empty())
{
if (width) (*width) = 0;
if (height) (*height) = 0;
return;
}
-
+
#if wxUSE_UNICODE
PangoLayout *layout = pango_layout_new( m_context );
pango_layout_set_font_description( layout, font->GetNativeFontInfo()->description );
else
pango_layout_set_font_description(layout, m_fontdesc);
-
+
const wxCharBuffer data = wxConvUTF8.cWC2MB( string );
pango_layout_set_text(layout, (const char*) data, strlen( (const char*) data ));
-
+
// Measure text.
int w,h;
pango_layout_get_pixel_size(layout, &w, &h);
-
- if (width) (*width) = (wxCoord) w;
+
+ if (width) (*width) = (wxCoord) w;
if (height) (*height) = (wxCoord) h;
if (descent)
{
(*descent) = 0;
}
if (externalLeading) (*externalLeading) = 0; // ??
-
+
g_object_unref( G_OBJECT( layout ) );
#else
wxFont fontToUse = m_font;
XFontStruct *xfont = (XFontStruct*) fontToUse.GetFontStruct( m_scaleY, m_display );
wxCHECK_RET( xfont, wxT("invalid font") );
-
+
int direction, ascent, descent2;
XCharStruct overall;
wxCoord wxWindowDC::GetCharWidth() const
{
wxCHECK_MSG( Ok(), 0, wxT("invalid dc") );
-
+
#if wxUSE_UNICODE
PangoLayout *layout = pango_layout_new( m_context );
-
+
if (!m_fontdesc)
{
char *crash = NULL;
*crash = 0;
}
-
+
pango_layout_set_font_description(layout, m_fontdesc);
pango_layout_set_text(layout, "H", 1 );
int w,h;
pango_layout_get_pixel_size(layout, &w, &h);
g_object_unref( G_OBJECT( layout ) );
-
+
return w;
#else
wxCHECK_MSG( m_font.Ok(), 0, wxT("invalid font") );
int direction, ascent, descent;
XCharStruct overall;
-
+
XTextExtents( xfont, "H", 1, &direction, &ascent, &descent, &overall );
-
+
return (wxCoord)(overall.width / m_scaleX);
#endif
}
wxCoord wxWindowDC::GetCharHeight() const
{
wxCHECK_MSG( Ok(), 0, wxT("invalid dc") );
-
+
#if wxUSE_UNICODE
PangoLayout *layout = pango_layout_new( m_context );
-
+
if (!m_fontdesc)
{
char *crash = NULL;
*crash = 0;
}
-
+
pango_layout_set_font_description(layout, m_fontdesc);
-
+
pango_layout_set_text(layout, "H", 1 );
int w,h;
pango_layout_get_pixel_size(layout, &w, &h);
g_object_unref( G_OBJECT( layout ) );
-
+
return h;
#else
wxCHECK_MSG( m_font.Ok(), 0, wxT("invalid font") );
int direction, ascent, descent;
XCharStruct overall;
-
+
XTextExtents( xfont, "H", 1, &direction, &ascent, &descent, &overall );
-
+
return (wxCoord)((ascent+descent) / m_scaleY);
#endif
}
m_brush.GetColour().CalcPixel( m_cmap );
XSetForeground( (Display*) m_display, (GC) m_brushGC, m_brush.GetColour().GetPixel() );
-
+
XSetFillStyle( (Display*) m_display, (GC) m_brushGC, FillSolid );
if ((m_brush.GetStyle() == wxSTIPPLE) && (m_brush.GetStipple()->Ok()))
XSetStipple( (Display*) m_display, (GC) m_textGC, (Pixmap) m_brush.GetStipple()->GetMask()->GetBitmap() );
}
- if (IS_HATCH(m_brush.GetStyle()))
+ if (m_brush.IsHatch())
{
XSetFillStyle( (Display*) m_display, (GC) m_brushGC, FillStippled );
int num = m_brush.GetStyle() - wxBDIAGONAL_HATCH;
}
}
- if (IS_HATCH(m_backgroundBrush.GetStyle()))
+ if (m_backgroundBrush.IsHatch())
{
XSetFillStyle( (Display*) m_display, (GC) m_bgGC, FillStippled );
int num = m_backgroundBrush.GetStyle() - wxBDIAGONAL_HATCH;
// VZ: shouldn't this be a CHECK?
if (!m_window)
return;
-
+
switch (function)
{
case wxCLEAR:
// operations (i.e. DrawText/DrawRotatedText).
// True, but mono-bitmaps use the m_textGC and they use ROPs as well.
XSetFunction( (Display*) m_display, (GC) m_textGC, x_function );
-
+
m_logicalFunction = function;
}
: wxWindowDC( window )
{
wxCHECK_RET( window, _T("NULL window in wxClientDC::wxClientDC") );
-
+
m_window = (WXWindow*) window->GetClientAreaWindow();
-
+
// Adjust the client area when the wxWindow is not using 2 X11 windows.
if (m_window == (WXWindow*) window->GetMainWindow())
{
bool wxDCModule::OnInit()
{
wxInitGCPool();
- return TRUE;
+ return true;
}
void wxDCModule::OnExit()