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

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

View File

@@ -6,244 +6,122 @@
// Created: 01/02/97
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "dc.h"
#pragma implementation "dc.h"
#endif
#include "wx/dc.h"
#include "wx/dcmemory.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject)
IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject)
#endif
//-----------------------------------------------------------------------------
// constants
//-----------------------------------------------------------------------------
#define mm2inches 0.0393700787402
#define inches2mm 25.4
#define mm2twips 56.6929133859
#define twips2mm 0.0176388888889
#define mm2pt 2.83464566929
#define pt2mm 0.352777777778
#define mm2inches 0.0393700787402
#define inches2mm 25.4
#define mm2twips 56.6929133859
#define twips2mm 0.0176388888889
#define mm2pt 2.83464566929
#define pt2mm 0.352777777778
//-----------------------------------------------------------------------------
// wxDC
//-----------------------------------------------------------------------------
wxDC::wxDC(void)
wxDC::wxDC()
{
m_ok = FALSE;
m_optimize = FALSE;
m_colour = TRUE;
m_clipping = FALSE;
m_mm_to_pix_x = 1.0;
m_mm_to_pix_y = 1.0;
m_logicalOriginX = 0;
m_logicalOriginY = 0;
m_deviceOriginX = 0;
m_deviceOriginY = 0;
m_internalDeviceOriginX = 0;
m_internalDeviceOriginY = 0;
m_externalDeviceOriginX = 0;
m_externalDeviceOriginY = 0;
m_logicalScaleX = 1.0;
m_logicalScaleY = 1.0;
m_userScaleX = 1.0;
m_userScaleY = 1.0;
m_scaleX = 1.0;
m_scaleY = 1.0;
m_mappingMode = wxMM_TEXT;
m_needComputeScaleX = FALSE;
m_needComputeScaleY = FALSE;
m_signX = 1; // default x-axis left to right
m_signY = 1; // default y-axis top down
m_maxX = m_maxY = 0;
m_minX = m_minY = 0;
m_logicalFunction = wxCOPY;
// m_textAlignment = wxALIGN_TOP_LEFT;
m_backgroundMode = wxTRANSPARENT;
m_textForegroundColour = *wxBLACK;
m_textBackgroundColour = *wxWHITE;
m_pen = *wxBLACK_PEN;
m_font = *wxNORMAL_FONT;
m_brush = *wxTRANSPARENT_BRUSH;
m_backgroundBrush = *wxWHITE_BRUSH;
m_isInteractive = FALSE;
// m_palette = wxAPP_COLOURMAP;
};
}
wxDC::~wxDC(void)
void wxDC::DoDrawIcon( const wxIcon &icon, long x, long y)
{
};
wxCHECK_RET( Ok(), "invalid dc" );
wxCHECK_RET( icon.Ok(), "invalid icon" );
void wxDC::DrawIcon( const wxIcon &WXUNUSED(icon), long WXUNUSED(x), long WXUNUSED(y))
{
};
DoDrawBitmap(icon, x, y, TRUE);
}
void wxDC::DrawBitmap( const wxBitmap& bitmap, long x, long y, bool useMask )
void wxDC::DoDrawBitmap( const wxBitmap& bitmap, long x, long y, bool useMask )
{
if (!bitmap.Ok())
return;
wxCHECK_RET( bitmap.Ok(), "invalid bitmap" );
wxMemoryDC memDC;
memDC.SelectObject(bitmap);
/* Not sure if we need this. The mask should leave the
* masked areas as per the original background of this DC.
#if 0
// Not sure if we need this. The mask should leave the masked areas as per
// the original background of this DC.
if (useMask)
{
// There might be transparent areas, so make these
// the same colour as this DC
memDC.SetBackground(* GetBackground());
memDC.Clear();
// There might be transparent areas, so make these the same colour as this
// DC
memDC.SetBackground(* GetBackground());
memDC.Clear();
}
*/
Blit(x, y, bitmap.GetWidth(), bitmap.GetHeight(), & memDC, 0, 0, wxCOPY, useMask);
#endif // 0
Blit(x, y, bitmap.GetWidth(), bitmap.GetHeight(), &memDC, 0, 0, wxCOPY, useMask);
memDC.SelectObject(wxNullBitmap);
};
}
void wxDC::DrawPoint( wxPoint& point )
{
DrawPoint( point.x, point.y );
};
void wxDC::DrawPolygon( wxList *list, long xoffset, long yoffset, int fillStyle )
{
int n = list->Number();
wxPoint *points = new wxPoint[n];
int i = 0;
for( wxNode *node = list->First(); node; node = node->Next() )
{
wxPoint *point = (wxPoint *)node->Data();
points[i].x = point->x;
points[i++].y = point->y;
};
DrawPolygon( n, points, xoffset, yoffset, fillStyle );
delete[] points;
};
void wxDC::DrawLines( wxList *list, long xoffset, long yoffset )
{
int n = list->Number();
wxPoint *points = new wxPoint[n];
int i = 0;
for( wxNode *node = list->First(); node; node = node->Next() )
{
wxPoint *point = (wxPoint *)node->Data();
points[i].x = point->x;
points[i++].y = point->y;
};
DrawLines( n, points, xoffset, yoffset );
delete []points;
};
void wxDC::DrawSpline( long x1, long y1, long x2, long y2, long x3, long y3 )
{
wxList list;
list.Append( (wxObject*)new wxPoint(x1, y1) );
list.Append( (wxObject*)new wxPoint(x2, y2) );
list.Append( (wxObject*)new wxPoint(x3, y3) );
DrawSpline(&list);
wxNode *node = list.First();
while (node)
{
wxPoint *p = (wxPoint*)node->Data();
delete p;
node = node->Next();
};
};
void wxDC::DrawSpline( int n, wxPoint points[] )
{
wxList list;
for (int i = 0; i < n; i++) list.Append( (wxObject*)&points[i] );
DrawSpline( &list );
};
void wxDC::SetClippingRegion( long x, long y, long width, long height )
void wxDC::DoSetClippingRegion( long x, long y, long width, long height )
{
m_clipping = TRUE;
m_clipX1 = x;
m_clipY1 = y;
m_clipX2 = x + width;
m_clipY2 = y + height;
};
}
void wxDC::DestroyClippingRegion(void)
void wxDC::DestroyClippingRegion()
{
m_clipping = FALSE;
};
}
void wxDC::GetClippingBox( long *x, long *y, long *width, long *height ) const
void wxDC::DoGetSize( int* width, int* height ) const
{
if (m_clipping)
{
if (x) *x = m_clipX1;
if (y) *y = m_clipY1;
if (width) *width = (m_clipX2 - m_clipX1);
if (height) *height = (m_clipY2 - m_clipY1);
}
else
*x = *y = *width = *height = 0;
};
if ( width )
*width = m_maxX - m_minX;
if ( height )
*height = m_maxY - m_minY;
}
void wxDC::GetSize( int* width, int* height ) const
void wxDC::DoGetSizeMM( int* width, int* height ) const
{
*width = m_maxX-m_minX;
*height = m_maxY-m_minY;
};
void wxDC::GetSizeMM( int* width, int* height ) const
{
int w = 0;
int h = 0;
int w, h;
GetSize( &w, &h );
*width = int( double(w) / (m_scaleX*m_mm_to_pix_x) );
*height = int( double(h) / (m_scaleY*m_mm_to_pix_y) );
};
if ( width )
*width = int( double(w) / (m_scaleX*m_mm_to_pix_x) );
if ( height )
*height = int( double(h) / (m_scaleY*m_mm_to_pix_y) );
}
// Resolution in pixels per logical inch
wxSize wxDC::GetPPI(void) const
wxSize wxDC::GetPPI() const
{
// TODO (should probably be pure virtual)
return wxSize(0, 0);
}
void wxDC::SetTextForeground( const wxColour &col )
{
if (!Ok()) return;
m_textForegroundColour = col;
};
void wxDC::SetTextBackground( const wxColour &col )
{
if (!Ok()) return;
m_textBackgroundColour = col;
};
void wxDC::SetMapMode( int mode )
{
switch (mode)
switch (mode)
{
case wxMM_TWIPS:
SetLogicalScale( twips2mm*m_mm_to_pix_x, twips2mm*m_mm_to_pix_y );
@@ -261,151 +139,113 @@ void wxDC::SetMapMode( int mode )
case wxMM_TEXT:
SetLogicalScale( 1.0, 1.0 );
break;
};
}
if (mode != wxMM_TEXT)
{
m_needComputeScaleX = TRUE;
m_needComputeScaleY = TRUE;
};
};
}
}
void wxDC::SetUserScale( double x, double y )
{
// allow negative ? -> no
m_userScaleX = x;
m_userScaleY = y;
wxDCBase::SetUserScale(x, y);
ComputeScaleAndOrigin();
};
void wxDC::GetUserScale( double *x, double *y )
{
if (x) *x = m_userScaleX;
if (y) *y = m_userScaleY;
};
}
void wxDC::SetLogicalScale( double x, double y )
{
// allow negative ?
m_logicalScaleX = x;
m_logicalScaleY = y;
wxDCBase::SetLogicalScale(x, y);
ComputeScaleAndOrigin();
};
void wxDC::GetLogicalScale( double *x, double *y )
{
if (x) *x = m_logicalScaleX;
if (y) *y = m_logicalScaleY;
};
}
void wxDC::SetLogicalOrigin( long x, long y )
{
m_logicalOriginX = x * m_signX; // is this still correct ?
m_logicalOriginY = y * m_signY;
ComputeScaleAndOrigin();
};
void wxDC::GetLogicalOrigin( long *x, long *y )
{
if (x) *x = m_logicalOriginX;
if (y) *y = m_logicalOriginY;
};
}
void wxDC::SetDeviceOrigin( long x, long y )
{
m_externalDeviceOriginX = x;
m_externalDeviceOriginY = y;
ComputeScaleAndOrigin();
};
void wxDC::GetDeviceOrigin( long *x, long *y )
{
// if (x) *x = m_externalDeviceOriginX;
// if (y) *y = m_externalDeviceOriginY;
if (x) *x = m_deviceOriginX;
if (y) *y = m_deviceOriginY;
};
}
void wxDC::SetInternalDeviceOrigin( long x, long y )
{
m_internalDeviceOriginX = x;
m_internalDeviceOriginY = y;
ComputeScaleAndOrigin();
};
}
void wxDC::GetInternalDeviceOrigin( long *x, long *y )
{
if (x) *x = m_internalDeviceOriginX;
if (y) *y = m_internalDeviceOriginY;
};
}
void wxDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp )
{
m_signX = (xLeftRight ? 1 : -1);
m_signY = (yBottomUp ? -1 : 1);
m_signX = xLeftRight ? 1 : -1;
m_signY = yBottomUp ? -1 : 1;
ComputeScaleAndOrigin();
};
}
long wxDC::DeviceToLogicalX(long x) const
long wxDCBase::DeviceToLogicalX(long x) const
{
return XDEV2LOG(x);
};
return ((wxDC *)this)->XDEV2LOG(x);
}
long wxDC::DeviceToLogicalY(long y) const
long wxDCBase::DeviceToLogicalY(long y) const
{
return YDEV2LOG(y);
};
return ((wxDC *)this)->YDEV2LOG(y);
}
long wxDC::DeviceToLogicalXRel(long x) const
long wxDCBase::DeviceToLogicalXRel(long x) const
{
return XDEV2LOGREL(x);
};
return ((wxDC *)this)->XDEV2LOGREL(x);
}
long wxDC::DeviceToLogicalYRel(long y) const
long wxDCBase::DeviceToLogicalYRel(long y) const
{
return YDEV2LOGREL(y);
};
return ((wxDC *)this)->YDEV2LOGREL(y);
}
long wxDC::LogicalToDeviceX(long x) const
long wxDCBase::LogicalToDeviceX(long x) const
{
return XLOG2DEV(x);
};
return ((wxDC *)this)->XLOG2DEV(x);
}
long wxDC::LogicalToDeviceY(long y) const
long wxDCBase::LogicalToDeviceY(long y) const
{
return YLOG2DEV(y);
};
return ((wxDC *)this)->YLOG2DEV(y);
}
long wxDC::LogicalToDeviceXRel(long x) const
long wxDCBase::LogicalToDeviceXRel(long x) const
{
return XLOG2DEVREL(x);
};
return ((wxDC *)this)->XLOG2DEVREL(x);
}
long wxDC::LogicalToDeviceYRel(long y) const
long wxDCBase::LogicalToDeviceYRel(long y) const
{
return YLOG2DEVREL(y);
};
return ((wxDC *)this)->YLOG2DEVREL(y);
}
void wxDC::CalcBoundingBox( long x, long y )
{
if (x < m_minX) m_minX = x;
if (y < m_minY) m_minY = y;
if (x > m_maxX) m_maxX = x;
if (y > m_maxY) m_maxY = y;
};
void wxDC::ComputeScaleAndOrigin(void)
void wxDC::ComputeScaleAndOrigin()
{
// CMB: copy scale to see if it changes
double origScaleX = m_scaleX;
double origScaleY = m_scaleY;
m_scaleX = m_logicalScaleX * m_userScaleX;
m_scaleY = m_logicalScaleY * m_userScaleY;
m_deviceOriginX = m_internalDeviceOriginX + m_externalDeviceOriginX;
m_deviceOriginY = m_internalDeviceOriginY + m_externalDeviceOriginY;
// CMB: if scale has changed call SetPen to recalulate the line width
// CMB: if scale has changed call SetPen to recalulate the line width
if (m_scaleX != origScaleX || m_scaleY != origScaleY)
{
// this is a bit artificial, but we need to force wxDC to think
@@ -415,5 +255,5 @@ void wxDC::ComputeScaleAndOrigin(void)
m_pen = tempPen;
SetPen(* pen);
}
};
}

File diff suppressed because it is too large Load Diff

View File

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

View File

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