separated wxDash type from platform specific wxGTKDash type

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6635 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Ron Lee
2000-03-12 11:49:19 +00:00
parent 8f19c916dc
commit 2eca425d4b
6 changed files with 50 additions and 54 deletions

View File

@@ -21,13 +21,21 @@
#include "wx/gdiobj.h" #include "wx/gdiobj.h"
#include "wx/gdicmn.h" #include "wx/gdicmn.h"
#include <gtk/gtk.h>
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// classes // classes
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class wxPen; class wxPen;
typedef char wxDash; typedef wxInt8 wxDash;
#if GTK_CHECK_VERSION(1,2,7)
typedef gint8 wxGTKDash;
#else
typedef gchar wxGTKDash;
#endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxPen // wxPen

View File

@@ -21,13 +21,21 @@
#include "wx/gdiobj.h" #include "wx/gdiobj.h"
#include "wx/gdicmn.h" #include "wx/gdicmn.h"
#include <gtk/gtk.h>
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// classes // classes
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class wxPen; class wxPen;
typedef char wxDash; typedef wxInt8 wxDash;
#if GTK_CHECK_VERSION(1,2,7)
typedef gint8 wxGTKDash;
#else
typedef gchar wxGTKDash;
#endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxPen // wxPen

View File

@@ -1381,15 +1381,15 @@ void wxWindowDC::SetPen( const wxPen &pen )
width = (int)w; width = (int)w;
} }
static const char dotted[] = {1, 1}; static const wxGTKDash dotted[] = {1, 1};
static const char short_dashed[] = {2, 2}; static const wxGTKDash short_dashed[] = {2, 2};
static const char wxCoord_dashed[] = {2, 4}; static const wxGTKDash wxCoord_dashed[] = {2, 4};
static const char dotted_dashed[] = {3, 3, 1, 3}; static const wxGTKDash dotted_dashed[] = {3, 3, 1, 3};
// We express dash pattern in pen width unit, so we are // We express dash pattern in pen width unit, so we are
// independent of zoom factor and so on... // independent of zoom factor and so on...
int req_nb_dash; int req_nb_dash;
const char *req_dash; const wxGTKDash *req_dash;
GdkLineStyle lineStyle = GDK_LINE_SOLID; GdkLineStyle lineStyle = GDK_LINE_SOLID;
switch (m_pen.GetStyle()) switch (m_pen.GetStyle())
@@ -1398,7 +1398,7 @@ void wxWindowDC::SetPen( const wxPen &pen )
{ {
lineStyle = GDK_LINE_ON_OFF_DASH; lineStyle = GDK_LINE_ON_OFF_DASH;
req_nb_dash = m_pen.GetDashCount(); req_nb_dash = m_pen.GetDashCount();
req_dash = m_pen.GetDash(); req_dash = (wxGTKDash*)m_pen.GetDash();
break; break;
} }
case wxDOT: case wxDOT:
@@ -1438,37 +1438,27 @@ void wxWindowDC::SetPen( const wxPen &pen )
default: default:
{ {
lineStyle = GDK_LINE_SOLID; lineStyle = GDK_LINE_SOLID;
req_dash = (wxDash*)NULL; req_dash = (wxGTKDash*)NULL;
req_nb_dash = 0; req_nb_dash = 0;
break; break;
} }
} }
#if (GTK_MINOR_VERSION > 0) #if (GTK_MINOR_VERSION > 0) || (GTK_MAJOR_VERSION > 1)
if (req_dash && req_nb_dash) if (req_dash && req_nb_dash)
{ {
char *real_req_dash = new char[req_nb_dash]; wxGTKDash *real_req_dash = new wxGTKDash[req_nb_dash];
if (real_req_dash) if (real_req_dash)
{ {
for (int i = 0; i < req_nb_dash; i++) for (int i = 0; i < req_nb_dash; i++)
real_req_dash[i] = req_dash[i] * width; real_req_dash[i] = req_dash[i] * width;
#if GTK_CHECK_VERSION(1,2,7) gdk_gc_set_dashes( m_penGC, 0, real_req_dash, req_nb_dash );
gdk_gc_set_dashes( m_penGC, 0, (gint8*) real_req_dash,
req_nb_dash );
#else
gdk_gc_set_dashes( m_penGC, 0, real_req_dash,
req_nb_dash );
#endif
delete[] real_req_dash; delete[] real_req_dash;
} }
else else
{ {
// No Memory. We use non-scaled dash pattern... // No Memory. We use non-scaled dash pattern...
#if GTK_CHECK_VERSION(1,2,7) gdk_gc_set_dashes( m_penGC, 0, (wxGTKDash*)req_dash, req_nb_dash );
gdk_gc_set_dashes( m_penGC, 0, (gint8*)req_dash, req_nb_dash );
#else
gdk_gc_set_dashes( m_penGC, 0, (char*)req_dash, req_nb_dash );
#endif
} }
} }
#endif #endif

View File

@@ -33,7 +33,7 @@ public:
int m_capStyle; int m_capStyle;
wxColour m_colour; wxColour m_colour;
int m_countDashes; int m_countDashes;
wxDash *m_dash; wxGTKDash *m_dash;
}; };
wxPenRefData::wxPenRefData() wxPenRefData::wxPenRefData()
@@ -42,7 +42,7 @@ wxPenRefData::wxPenRefData()
m_style = wxSOLID; m_style = wxSOLID;
m_joinStyle = wxJOIN_ROUND; m_joinStyle = wxJOIN_ROUND;
m_capStyle = wxCAP_ROUND; m_capStyle = wxCAP_ROUND;
m_dash = (wxDash*) NULL; m_dash = (wxGTKDash*) NULL;
m_countDashes = 0; m_countDashes = 0;
} }
@@ -120,7 +120,7 @@ void wxPen::SetDashes( int number_of_dashes, const wxDash *dash )
{ {
Unshare(); Unshare();
M_PENDATA->m_countDashes = number_of_dashes; M_PENDATA->m_countDashes = number_of_dashes;
M_PENDATA->m_dash = (wxDash *)dash; /* TODO */ M_PENDATA->m_dash = (wxGTKDash *)dash; /* TODO */
} }
void wxPen::SetColour( int red, int green, int blue ) void wxPen::SetColour( int red, int green, int blue )
@@ -155,7 +155,7 @@ void wxPen::SetWidth( int width )
int wxPen::GetDashes( wxDash **ptr ) const int wxPen::GetDashes( wxDash **ptr ) const
{ {
*ptr = (M_PENDATA ? M_PENDATA->m_dash : (wxDash*) NULL); *ptr = (M_PENDATA ? (wxDash*)M_PENDATA->m_dash : (wxDash*) NULL);
return (M_PENDATA ? M_PENDATA->m_countDashes : 0); return (M_PENDATA ? M_PENDATA->m_countDashes : 0);
} }
@@ -166,7 +166,7 @@ int wxPen::GetDashCount() const
wxDash* wxPen::GetDash() const wxDash* wxPen::GetDash() const
{ {
return (M_PENDATA->m_dash); return (wxDash*)M_PENDATA->m_dash;
} }
int wxPen::GetCap() const int wxPen::GetCap() const

View File

@@ -1381,15 +1381,15 @@ void wxWindowDC::SetPen( const wxPen &pen )
width = (int)w; width = (int)w;
} }
static const char dotted[] = {1, 1}; static const wxGTKDash dotted[] = {1, 1};
static const char short_dashed[] = {2, 2}; static const wxGTKDash short_dashed[] = {2, 2};
static const char wxCoord_dashed[] = {2, 4}; static const wxGTKDash wxCoord_dashed[] = {2, 4};
static const char dotted_dashed[] = {3, 3, 1, 3}; static const wxGTKDash dotted_dashed[] = {3, 3, 1, 3};
// We express dash pattern in pen width unit, so we are // We express dash pattern in pen width unit, so we are
// independent of zoom factor and so on... // independent of zoom factor and so on...
int req_nb_dash; int req_nb_dash;
const char *req_dash; const wxGTKDash *req_dash;
GdkLineStyle lineStyle = GDK_LINE_SOLID; GdkLineStyle lineStyle = GDK_LINE_SOLID;
switch (m_pen.GetStyle()) switch (m_pen.GetStyle())
@@ -1398,7 +1398,7 @@ void wxWindowDC::SetPen( const wxPen &pen )
{ {
lineStyle = GDK_LINE_ON_OFF_DASH; lineStyle = GDK_LINE_ON_OFF_DASH;
req_nb_dash = m_pen.GetDashCount(); req_nb_dash = m_pen.GetDashCount();
req_dash = m_pen.GetDash(); req_dash = (wxGTKDash*)m_pen.GetDash();
break; break;
} }
case wxDOT: case wxDOT:
@@ -1438,37 +1438,27 @@ void wxWindowDC::SetPen( const wxPen &pen )
default: default:
{ {
lineStyle = GDK_LINE_SOLID; lineStyle = GDK_LINE_SOLID;
req_dash = (wxDash*)NULL; req_dash = (wxGTKDash*)NULL;
req_nb_dash = 0; req_nb_dash = 0;
break; break;
} }
} }
#if (GTK_MINOR_VERSION > 0) #if (GTK_MINOR_VERSION > 0) || (GTK_MAJOR_VERSION > 1)
if (req_dash && req_nb_dash) if (req_dash && req_nb_dash)
{ {
char *real_req_dash = new char[req_nb_dash]; wxGTKDash *real_req_dash = new wxGTKDash[req_nb_dash];
if (real_req_dash) if (real_req_dash)
{ {
for (int i = 0; i < req_nb_dash; i++) for (int i = 0; i < req_nb_dash; i++)
real_req_dash[i] = req_dash[i] * width; real_req_dash[i] = req_dash[i] * width;
#if GTK_CHECK_VERSION(1,2,7) gdk_gc_set_dashes( m_penGC, 0, real_req_dash, req_nb_dash );
gdk_gc_set_dashes( m_penGC, 0, (gint8*) real_req_dash,
req_nb_dash );
#else
gdk_gc_set_dashes( m_penGC, 0, real_req_dash,
req_nb_dash );
#endif
delete[] real_req_dash; delete[] real_req_dash;
} }
else else
{ {
// No Memory. We use non-scaled dash pattern... // No Memory. We use non-scaled dash pattern...
#if GTK_CHECK_VERSION(1,2,7) gdk_gc_set_dashes( m_penGC, 0, (wxGTKDash*)req_dash, req_nb_dash );
gdk_gc_set_dashes( m_penGC, 0, (gint8*)req_dash, req_nb_dash );
#else
gdk_gc_set_dashes( m_penGC, 0, (char*)req_dash, req_nb_dash );
#endif
} }
} }
#endif #endif

View File

@@ -33,7 +33,7 @@ public:
int m_capStyle; int m_capStyle;
wxColour m_colour; wxColour m_colour;
int m_countDashes; int m_countDashes;
wxDash *m_dash; wxGTKDash *m_dash;
}; };
wxPenRefData::wxPenRefData() wxPenRefData::wxPenRefData()
@@ -42,7 +42,7 @@ wxPenRefData::wxPenRefData()
m_style = wxSOLID; m_style = wxSOLID;
m_joinStyle = wxJOIN_ROUND; m_joinStyle = wxJOIN_ROUND;
m_capStyle = wxCAP_ROUND; m_capStyle = wxCAP_ROUND;
m_dash = (wxDash*) NULL; m_dash = (wxGTKDash*) NULL;
m_countDashes = 0; m_countDashes = 0;
} }
@@ -120,7 +120,7 @@ void wxPen::SetDashes( int number_of_dashes, const wxDash *dash )
{ {
Unshare(); Unshare();
M_PENDATA->m_countDashes = number_of_dashes; M_PENDATA->m_countDashes = number_of_dashes;
M_PENDATA->m_dash = (wxDash *)dash; /* TODO */ M_PENDATA->m_dash = (wxGTKDash *)dash; /* TODO */
} }
void wxPen::SetColour( int red, int green, int blue ) void wxPen::SetColour( int red, int green, int blue )
@@ -155,7 +155,7 @@ void wxPen::SetWidth( int width )
int wxPen::GetDashes( wxDash **ptr ) const int wxPen::GetDashes( wxDash **ptr ) const
{ {
*ptr = (M_PENDATA ? M_PENDATA->m_dash : (wxDash*) NULL); *ptr = (M_PENDATA ? (wxDash*)M_PENDATA->m_dash : (wxDash*) NULL);
return (M_PENDATA ? M_PENDATA->m_countDashes : 0); return (M_PENDATA ? M_PENDATA->m_countDashes : 0);
} }
@@ -166,7 +166,7 @@ int wxPen::GetDashCount() const
wxDash* wxPen::GetDash() const wxDash* wxPen::GetDash() const
{ {
return (M_PENDATA->m_dash); return (wxDash*)M_PENDATA->m_dash;
} }
int wxPen::GetCap() const int wxPen::GetCap() const