Motif bug fixes; dialog OnPaint works now; wxColourDialog tweaking

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@989 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
1998-11-11 14:39:42 +00:00
parent fb1585ae85
commit 55acd85e71
19 changed files with 183 additions and 161 deletions

View File

@@ -302,6 +302,22 @@ samples/wxsocket/*.xpm
samples/wxsocket/*.ico samples/wxsocket/*.ico
samples/wxsocket/*.rc samples/wxsocket/*.rc
samples/help/*.cpp
samples/help/*.h
samples/help/*.def
samples/help/makefile*
samples/help/*.xbm
samples/help/*.xpm
samples/help/*.ico
samples/help/*.rc
samples/help/doc/*.html
samples/help/doc/*.htm
samples/help/doc/*.class
samples/help/doc/*.db
samples/help/doc/*.tex
samples/help/doc/*.gif
samples/help/doc/*.map
samples/bombs/*.cpp samples/bombs/*.cpp
samples/bombs/*.h samples/bombs/*.h
samples/bombs/*.def samples/bombs/*.def

View File

@@ -23,6 +23,9 @@ High Priority
- Make wxDialog OnPaint work. - Make wxDialog OnPaint work.
- Optimize wxWindow OnPaint, clipping the damaged
region.
- Implementation of OnEraseBackground. How? Call OnEraseBackground - Implementation of OnEraseBackground. How? Call OnEraseBackground
just before OnPaint? Will duplicate Xlib's own erase of the background. just before OnPaint? Will duplicate Xlib's own erase of the background.
However, this is usually OK, because the default wxWindow::OnEraseBackground However, this is usually OK, because the default wxWindow::OnEraseBackground

View File

@@ -3,21 +3,16 @@
#ifdef __WXMSW__ #ifdef __WXMSW__
#include "wx/msw/helpwin.h" #include "wx/msw/helpwin.h"
#elif defined(__WXGTK__)
#include "wx/generic/helpext.h"
#else #else
#include "wx/generic/helpxlp.h" #include "wx/generic/helpext.h"
#endif #endif
#ifdef __WXMSW__ #ifdef __WXMSW__
#define wxHelpController wxWinHelpController #define wxHelpController wxWinHelpController
#define sm_classwxHelpController sm_classwxWinHelpController #define sm_classwxHelpController sm_classwxWinHelpController
#elif defined(__WXGTK__) #else
#define wxHelpController wxExtHelpController #define wxHelpController wxExtHelpController
#define sm_classwxHelpController sm_classwxExtHelpController #define sm_classwxHelpController sm_classwxExtHelpController
#else
#define wxHelpController wxXLPHelpController
#define sm_classwxHelpController sm_classwxXLPHelpController
#endif #endif
#endif #endif

View File

@@ -131,7 +131,8 @@ class WXDLLEXPORT wxPaintDC: public wxWindowDC
DECLARE_DYNAMIC_CLASS(wxPaintDC) DECLARE_DYNAMIC_CLASS(wxPaintDC)
public: public:
wxPaintDC() {} wxPaintDC() {}
wxPaintDC(wxWindow* win): wxWindowDC(win) {} wxPaintDC(wxWindow* win);
~wxPaintDC();
}; };
class WXDLLEXPORT wxClientDC: public wxWindowDC class WXDLLEXPORT wxClientDC: public wxWindowDC

View File

@@ -85,6 +85,7 @@ public:
// Is region empty? // Is region empty?
bool Empty() const; bool Empty() const;
inline bool IsEmpty() const { return Empty(); } inline bool IsEmpty() const { return Empty(); }
bool Ok() const { return (m_refData != NULL) ; }
//# Tests //# Tests
// Does the region contain the point (x,y)? // Does the region contain the point (x,y)?
@@ -100,6 +101,9 @@ public:
bool Combine(long x, long y, long width, long height, wxRegionOp op); bool Combine(long x, long y, long width, long height, wxRegionOp op);
bool Combine(const wxRegion& region, wxRegionOp op); bool Combine(const wxRegion& region, wxRegionOp op);
bool Combine(const wxRect& rect, wxRegionOp op); bool Combine(const wxRect& rect, wxRegionOp op);
// Get the internal Region handle
WXRegion GetXRegion() ;
}; };
class WXDLLEXPORT wxRegionIterator : public wxObject { class WXDLLEXPORT wxRegionIterator : public wxObject {

View File

@@ -231,7 +231,7 @@ public:
virtual void DragAcceptFiles(bool accept); virtual void DragAcceptFiles(bool accept);
// Update region access // Update region access
virtual wxRegion GetUpdateRegion() const; virtual wxRegion& GetUpdateRegion() const;
virtual bool IsExposed(int x, int y, int w, int h) const; virtual bool IsExposed(int x, int y, int w, int h) const;
virtual bool IsExposed(const wxPoint& pt) const; virtual bool IsExposed(const wxPoint& pt) const;
virtual bool IsExposed(const wxRect& rect) const; virtual bool IsExposed(const wxRect& rect) const;
@@ -486,6 +486,7 @@ public:
/// Motif-specific /// Motif-specific
void ClearUpdateRects();
void CanvasGetSize(int* width, int* height) const; // If have drawing area void CanvasGetSize(int* width, int* height) const; // If have drawing area
void CanvasGetClientSize(int *width, int *height) const; void CanvasGetClientSize(int *width, int *height) const;
void CanvasGetPosition(int *x, int *y) const; // If have drawing area void CanvasGetPosition(int *x, int *y) const; // If have drawing area
@@ -518,7 +519,6 @@ public:
virtual WXPixmap GetBackingPixmap() const { return m_backingPixmap; } virtual WXPixmap GetBackingPixmap() const { return m_backingPixmap; }
inline int GetPixmapWidth() const { return m_pixmapWidth; } inline int GetPixmapWidth() const { return m_pixmapWidth; }
inline int GetPixmapHeight() const { return m_pixmapHeight; } inline int GetPixmapHeight() const { return m_pixmapHeight; }
virtual WXRegion GetPaintRegion() const { return m_paintRegion; }
// Change properties // Change properties
virtual void ChangeFont(bool keepOriginalSize = TRUE); // Change to the current font (often overridden) virtual void ChangeFont(bool keepOriginalSize = TRUE); // Change to the current font (often overridden)
@@ -594,7 +594,6 @@ public:
int m_lastButton; // last pressed button int m_lastButton; // last pressed button
wxList m_updateRects; // List of wxRectangles representing damaged region wxList m_updateRects; // List of wxRectangles representing damaged region
bool m_isShown; bool m_isShown;
WXRegion m_paintRegion; // Clip region generated by expose event
protected: protected:
WXWidget m_mainWidget; WXWidget m_mainWidget;
WXWidget m_hScrollBar; WXWidget m_hScrollBar;

View File

@@ -41,7 +41,7 @@
// ressources // ressources
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// the application icon // the application icon
#ifdef __WXGTK__ #if defined(__WXGTK__) || defined(__WXMOTIF__)
#include "mondrian.xpm" #include "mondrian.xpm"
#endif #endif

View File

@@ -232,7 +232,7 @@ void wxGenericColourDialog::CreateWidgets(void)
int bw, bh; int bw, bh;
okButton->GetSize(&bw, &bh); okButton->GetSize(&bw, &bh);
(void) new wxButton(this, wxID_CANCEL, _("Cancel"), wxPoint(okButtonX + bw + 10, buttonY)); (void) new wxButton(this, wxID_CANCEL, _("Cancel"), wxPoint(okButtonX + bw + 20, buttonY));
(void) new wxButton(this, wxID_ADD_CUSTOM, _("Add to custom colours"), (void) new wxButton(this, wxID_ADD_CUSTOM, _("Add to custom colours"),
wxPoint(customButtonX, buttonY)); wxPoint(customButtonX, buttonY));
@@ -252,7 +252,7 @@ void wxGenericColourDialog::CreateWidgets(void)
blueSlider = new wxSlider(this, wxID_BLUE_SLIDER, 0, 0, 255, blueSlider = new wxSlider(this, wxID_BLUE_SLIDER, 0, 0, 255,
wxPoint(sliderX + 2*sliderSpacing, 10), wxSize(-1, sliderHeight), wxVERTICAL|wxSL_LABELS); wxPoint(sliderX + 2*sliderSpacing, 10), wxSize(-1, sliderHeight), wxVERTICAL|wxSL_LABELS);
SetClientSize(sliderX + 3*sliderSpacing, buttonY + 30); SetClientSize(sliderX + 3*sliderSpacing, buttonY + 40);
okButton->SetDefault(); okButton->SetDefault();
Centre(wxBOTH); Centre(wxBOTH);

View File

@@ -209,8 +209,8 @@ void wxGenericFontDialog::CreateWidgets(void)
int x=-1; int x=-1;
int y=40; int y=40;
familyChoice = new wxChoice(this, wxID_FONT_FAMILY, wxPoint(10, 10), wxSize(120, -1), 5, families); familyChoice = new wxChoice(this, wxID_FONT_FAMILY, wxPoint(10, 10), wxSize(120, -1), 5, families);
styleChoice = new wxChoice(this, wxID_FONT_STYLE, wxPoint(140, 10), wxSize(120, -1), 3, styles); styleChoice = new wxChoice(this, wxID_FONT_STYLE, wxPoint(160, 10), wxSize(120, -1), 3, styles);
weightChoice = new wxChoice(this, wxID_FONT_WEIGHT, wxPoint(270, 10), wxSize(120, -1), 3, weights); weightChoice = new wxChoice(this, wxID_FONT_WEIGHT, wxPoint(310, 10), wxSize(120, -1), 3, weights);
colourChoice = new wxChoice(this, wxID_FONT_COLOUR, wxPoint(10, 40), wxSize(190, -1), NUM_COLS, wxColourDialogNames); colourChoice = new wxChoice(this, wxID_FONT_COLOUR, wxPoint(10, 40), wxSize(190, -1), NUM_COLS, wxColourDialogNames);
#ifdef __MOTIF__ #ifdef __MOTIF__
@@ -228,8 +228,8 @@ void wxGenericFontDialog::CreateWidgets(void)
pointSizes[i] = buf; pointSizes[i] = buf;
} }
pointSizeChoice = new wxChoice(this, wxID_FONT_SIZE, wxPoint(210, y), wxSize(50, -1), 40, pointSizes); pointSizeChoice = new wxChoice(this, wxID_FONT_SIZE, wxPoint(230, y), wxSize(50, -1), 40, pointSizes);
underLineCheckBox = new wxCheckBox(this, wxID_FONT_UNDERLINE, _("Underline"), wxPoint(280, y)); underLineCheckBox = new wxCheckBox(this, wxID_FONT_UNDERLINE, _("Underline"), wxPoint(320, y));
int rectY; int rectY;
pointSizeChoice->GetPosition(&x, &rectY); //NL mod pointSizeChoice->GetPosition(&x, &rectY); //NL mod
@@ -257,7 +257,7 @@ void wxGenericFontDialog::CreateWidgets(void)
okButton->SetDefault(); okButton->SetDefault();
SetClientSize(400, by + 30); SetClientSize(450, by + 40);
Centre(wxBOTH); Centre(wxBOTH);

View File

@@ -123,6 +123,7 @@ LIB_CPP_SRC=\
generic/colrdlgg.cpp \ generic/colrdlgg.cpp \
generic/fontdlgg.cpp \ generic/fontdlgg.cpp \
generic/gridg.cpp \ generic/gridg.cpp \
generic/helpext.cpp \
generic/imaglist.cpp \ generic/imaglist.cpp \
generic/listctrl.cpp \ generic/listctrl.cpp \
generic/laywin.cpp \ generic/laywin.cpp \

View File

@@ -416,7 +416,8 @@ void wxChoiceCallback (Widget w, XtPointer clientData, XtPointer WXUNUSED(ptr))
XtVaGetValues (w, XmNuserData, &s, NULL); XtVaGetValues (w, XmNuserData, &s, NULL);
if (s) if (s)
{ {
wxCommandEvent event (wxEVT_COMMAND_CHOICE_SELECTED); wxCommandEvent event (wxEVT_COMMAND_CHOICE_SELECTED, item->GetId());
event.SetEventObject(item);
event.m_commandInt = item->FindString (s); event.m_commandInt = item->FindString (s);
// event.m_commandString = s; // event.m_commandString = s;
item->ProcessCommand (event); item->ProcessCommand (event);

View File

@@ -1992,17 +1992,17 @@ void wxWindowDC:: SetDCClipping ()
// clipping imposed on a window by a repaint. // clipping imposed on a window by a repaint.
// We'll combine it with the user region. But for now, // We'll combine it with the user region. But for now,
// just use the currently-defined user clipping region. // just use the currently-defined user clipping region.
if (m_userRegion || (m_window && m_window->GetPaintRegion()) ) if (m_userRegion || (m_window && m_window->GetUpdateRegion().Ok()) )
m_currentRegion = (WXRegion) XCreateRegion (); m_currentRegion = (WXRegion) XCreateRegion ();
else else
m_currentRegion = (WXRegion) NULL; m_currentRegion = (WXRegion) NULL;
if ((m_window && m_window->GetPaintRegion()) && m_userRegion) if ((m_window && m_window->GetUpdateRegion().Ok()) && m_userRegion)
XIntersectRegion ((Region) m_window->GetPaintRegion(), (Region) m_userRegion, (Region) m_currentRegion); XIntersectRegion ((Region) m_window->GetUpdateRegion().GetXRegion(), (Region) m_userRegion, (Region) m_currentRegion);
else if (m_userRegion) else if (m_userRegion)
XIntersectRegion ((Region) m_userRegion, (Region) m_userRegion, (Region) m_currentRegion); XIntersectRegion ((Region) m_userRegion, (Region) m_userRegion, (Region) m_currentRegion);
else if (m_window && m_window->GetPaintRegion()) else if (m_window && m_window->GetUpdateRegion().Ok())
XIntersectRegion ((Region) m_window->GetPaintRegion(), (Region) m_window->GetPaintRegion(), XIntersectRegion ((Region) m_window->GetUpdateRegion().GetXRegion(), (Region) m_window->GetUpdateRegion().GetXRegion(),
(Region) m_currentRegion); (Region) m_currentRegion);
if (m_currentRegion) if (m_currentRegion)
@@ -2225,3 +2225,56 @@ void wxWindowDC::DrawSpline( wxList *points )
wx_spline_draw_point_array( this ); wx_spline_draw_point_array( this );
}; };
/*
* wxPaintDC
*/
wxPaintDC::wxPaintDC(wxWindow* win): wxWindowDC(win)
{
wxRegion* region = NULL;
// Combine all the update rects into a region
if (win->m_updateRects.Number() > 0)
{
int i = 0;
for (i = 0; i < win->m_updateRects.Number(); i++)
{
wxRect* rect = (wxRect*) win->m_updateRects.Nth(i)->Data();
/*
cout << "wxPaintDC. wxRect: " << rect->x << ", " << rect->y << ", ";
cout << rect->width << ", " << rect->height << "\n\n";
*/
if (!region)
region = new wxRegion(*rect);
else
// TODO: is this correct? In SetDCClipping above,
// XIntersectRegion is used to combine paint and user
// regions. XIntersectRegion appears to work in that case...
region->Union(*rect);
}
}
else
{
int cw, ch;
win->GetClientSize(&cw, &ch);
region = new wxRegion(wxRect(0, 0, cw, ch));
}
win->m_updateRegion = *region;
// Set the clipping region. Any user-defined region will be combined with this
// one in SetDCClipping.
XSetRegion ((Display*) m_display, (GC) m_gc, (Region) region->GetXRegion());
delete region;
}
wxPaintDC::~wxPaintDC()
{
XSetClipMask ((Display*) m_display, (GC) m_gc, None);
if (m_window)
m_window->m_updateRegion.Clear();
}

View File

@@ -617,16 +617,9 @@ static void wxCloseDialogCallback( Widget WXUNUSED(widget), XtPointer client_dat
// TODO: Preferably, we should have a universal repaint proc. // TODO: Preferably, we should have a universal repaint proc.
// Meanwhile, use a special one for dialogs. // Meanwhile, use a special one for dialogs.
static void wxDialogBoxRepaintProc(Widget w, XtPointer WXUNUSED(c_data), XEvent *event, char *) static void wxDialogBoxRepaintProc(Widget w, XtPointer WXUNUSED(c_data), XEvent *event, char *)
{ {
Window window; Window window;
Display *display; Display *display;
/*
static XRectangle *xrect;
GC gc;
int llp = 0;
static int last_count = 0;
static int draw_count = 0;
*/
wxWindow* win = (wxWindow *)wxWidgetHashTable->Get((long)w); wxWindow* win = (wxWindow *)wxWidgetHashTable->Get((long)w);
if (!win) if (!win)
@@ -635,68 +628,31 @@ static void wxDialogBoxRepaintProc(Widget w, XtPointer WXUNUSED(c_data), XEvent
switch(event -> type) switch(event -> type)
{ {
case Expose : case Expose :
{
window = (Window) win -> GetXWindow(); window = (Window) win -> GetXWindow();
display = (Display *) win -> GetXDisplay(); display = (Display *) win -> GetXDisplay();
/* TODO
gc = (GC) panel -> GetDC() -> gc;
llp = event -> xexpose.count; wxRect* rect = new wxRect(event->xexpose.x, event->xexpose.y,
event->xexpose.width, event->xexpose.height);
win->m_updateRects.Append((wxObject*) rect);
if ((last_count == 0) && (llp == 0)) if (event -> xexpose.count == 0)
{ {
xrect = new XRectangle[1]; wxPaintEvent event(win->GetId());
xrect[0].x = event -> xexpose.x; event.SetEventObject(win);
xrect[0].y = event -> xexpose.y; win->GetEventHandler()->ProcessEvent(event);
xrect[0].width = event -> xexpose.width;
xrect[0].height = event -> xexpose.height;
XSetClipRectangles(display,gc,0,0,xrect,1,Unsorted); win->ClearUpdateRects();
// panel->DoPaint(xrect, 1);
panel->GetEventHandler()->OnPaint();
delete xrect;
} }
if ((last_count == 0) && (llp != 0))
{
xrect = new XRectangle[llp + 1];
draw_count = llp + 1;
xrect[draw_count - llp - 1].x = event -> xexpose.x;
xrect[draw_count - llp - 1].y = event -> xexpose.y;
xrect[draw_count - llp - 1].width = event -> xexpose.width;
xrect[draw_count - llp - 1].height = event -> xexpose.height;
}
if ((last_count != 0) && (llp != 0))
{
xrect[draw_count - llp - 1].x = event -> xexpose.x;
xrect[draw_count - llp - 1].y = event -> xexpose.y;
xrect[draw_count - llp - 1].width = event -> xexpose.width;
xrect[draw_count - llp - 1].height = event -> xexpose.height;
}
if ((last_count != 0) && (llp == 0))
{
xrect[draw_count - llp - 1].x = event -> xexpose.x;
xrect[draw_count - llp - 1].y = event -> xexpose.y;
xrect[draw_count - llp - 1].width = event -> xexpose.width;
xrect[draw_count - llp - 1].height = event -> xexpose.height;
XSetClipRectangles(display,gc,0,0,xrect,draw_count,Unsorted);
// panel->DoPaint(xrect,draw_count);
panel->GetEventHandler()->OnPaint();
delete xrect;
}
last_count = event -> xexpose.count;
*/
break; break;
}
default : default :
{
cout << "\n\nNew Event ! is = " << event -> type << "\n"; cout << "\n\nNew Event ! is = " << event -> type << "\n";
break; break;
} }
} }
}
static void wxDialogBoxEventHandler (Widget wid, static void wxDialogBoxEventHandler (Widget wid,
XtPointer WXUNUSED(client_data), XtPointer WXUNUSED(client_data),

View File

@@ -137,6 +137,7 @@ LIB_CPP_SRC=\
../generic/colrdlgg.cpp \ ../generic/colrdlgg.cpp \
../generic/fontdlgg.cpp \ ../generic/fontdlgg.cpp \
../generic/gridg.cpp \ ../generic/gridg.cpp \
../generic/helpext.cpp \
../generic/imaglist.cpp \ ../generic/imaglist.cpp \
../generic/listctrl.cpp \ ../generic/listctrl.cpp \
../generic/laywin.cpp \ ../generic/laywin.cpp \

View File

@@ -104,6 +104,14 @@ wxRegion::~wxRegion()
// m_refData unrefed in ~wxObject // m_refData unrefed in ~wxObject
} }
// Get the internal region handle
WXRegion wxRegion::GetXRegion()
{
wxASSERT( m_refData !=NULL );
return (WXRegion) ((wxRegionRefData*)m_refData)->m_region;
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
//# Modify region //# Modify region
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -237,7 +245,7 @@ wxRect wxRegion::GetBox() const
// Is region empty? // Is region empty?
bool wxRegion::Empty() const bool wxRegion::Empty() const
{ {
return m_refData ? XEmptyRegion(M_REGION) : FALSE; return m_refData ? XEmptyRegion(M_REGION) : TRUE;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@@ -281,6 +281,11 @@ void wxSliderCallback (Widget widget, XtPointer clientData, XmScaleCallbackStruc
XtVaGetValues (widget, XmNvalue, &event.m_commandInt, NULL); XtVaGetValues (widget, XmNvalue, &event.m_commandInt, NULL);
event.SetEventObject(slider); event.SetEventObject(slider);
slider->ProcessCommand(event); slider->ProcessCommand(event);
// Also send a wxCommandEvent for compatibility.
wxCommandEvent event2(wxEVT_COMMAND_SLIDER_UPDATED, slider->GetId());
event2.SetEventObject(slider);
slider->ProcessCommand(event2);
break; break;
} }
} }

View File

@@ -615,6 +615,13 @@ bool wxIsBusy()
return (wxBusyCursorCount > 0); return (wxBusyCursorCount > 0);
} }
const char* wxGetHomeDir( wxString *home )
{
*home = wxGetUserHome( wxString() );
if (home->IsNull()) *home = "/";
return *home;
};
char *wxGetUserHome (const wxString& user) char *wxGetUserHome (const wxString& user)
{ {
#ifdef VMS #ifdef VMS

View File

@@ -10,7 +10,7 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation // #pragma implementation
#endif #endif
#include "wx/utils.h" #include "wx/utils.h"
@@ -135,7 +135,7 @@ long wxExecute(char **argv, bool sync, wxProcess *WXUNUSED(handler))
// end VMS // end VMS
} }
long wxExecute (const wxString& command, bool sync) long wxExecute (const wxString& command, bool sync, wxProcess* WXUNUSED(process))
{ {
#ifdef VMS #ifdef VMS
return(0); return(0);

View File

@@ -135,7 +135,6 @@ wxWindow::wxWindow()
m_canAddEventHandler = FALSE; m_canAddEventHandler = FALSE;
m_scrollPosX = 0; m_scrollPosX = 0;
m_scrollPosY = 0; m_scrollPosY = 0;
m_paintRegion = (WXRegion) 0;
} }
// Destructor // Destructor
@@ -143,10 +142,6 @@ wxWindow::~wxWindow()
{ {
//// Motif-specific //// Motif-specific
if (m_paintRegion)
XDestroyRegion ((Region) m_paintRegion);
m_paintRegion = (WXRegion) 0;
if (GetMainWidget()) if (GetMainWidget())
DetachWidget(GetMainWidget()); // Removes event handlers DetachWidget(GetMainWidget()); // Removes event handlers
@@ -243,6 +238,8 @@ wxWindow::~wxWindow()
if ( m_windowValidator ) delete m_windowValidator; if ( m_windowValidator ) delete m_windowValidator;
if (m_clientObject) delete m_clientObject; if (m_clientObject) delete m_clientObject;
ClearUpdateRects();
} }
// Destroy the window (delayed, if a managed window) // Destroy the window (delayed, if a managed window)
@@ -309,7 +306,6 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id,
m_pixmapOffsetY = 0; m_pixmapOffsetY = 0;
m_scrollPosX = 0; m_scrollPosX = 0;
m_scrollPosY = 0; m_scrollPosY = 0;
m_paintRegion = (WXRegion) 0;
if (!parent) if (!parent)
return FALSE; return FALSE;
@@ -2016,9 +2012,9 @@ bool wxWindow::AcceptsFocus() const
} }
// Update region access // Update region access
wxRegion wxWindow::GetUpdateRegion() const wxRegion& wxWindow::GetUpdateRegion() const
{ {
return m_updateRegion; return (wxRegion&) m_updateRegion;
} }
bool wxWindow::IsExposed(int x, int y, int w, int h) const bool wxWindow::IsExposed(int x, int y, int w, int h) const
@@ -2138,64 +2134,30 @@ void wxCanvasRepaintProc (Widget drawingArea, XtPointer clientData,
return; return;
XEvent * event = cbs->event; XEvent * event = cbs->event;
wxWindow * canvas = (wxWindow *) clientData; wxWindow * win = (wxWindow *) clientData;
Display * display = (Display *) canvas->GetXDisplay(); Display * display = (Display *) win->GetXDisplay();
// GC gc = (GC) canvas->GetDC()->gc;
switch (event->type) switch (event->type)
{ {
case Expose: case Expose:
{ {
/* TODO wxRect* rect = new wxRect(event->xexpose.x, event->xexpose.y,
wxCanvasDC* canvasDC = canvas->GetDC(); event->xexpose.width, event->xexpose.height);
if (canvasDC)
{
if (canvasDC->onpaint_reg)
XDestroyRegion(canvasDC->onpaint_reg);
canvasDC->onpaint_reg = XCreateRegion();
}
*/
int n = canvas->m_updateRects.Number();
XRectangle* xrects = new XRectangle[n];
int i;
for (i = 0; i < canvas->m_updateRects.Number(); i++)
{
wxRect* rect = (wxRect*) canvas->m_updateRects.Nth(i)->Data();
xrects[i].x = rect->x;
xrects[i].y = rect->y;
xrects[i].width = rect->width;
xrects[i].height = rect->height;
/* TODO (?) Actually ignore it I think.
if (canvasDC)
XUnionRectWithRegion(&(xrects[i]), canvasDC->onpaint_reg,
canvasDC->onpaint_reg);
*/
}
/* TODO must clip the area being repainted. So we need a gc.
* Alternatively, wxPaintDC must do the clipping
* when it's created.
XSetClipRectangles(display, gc, 0, 0, xrects, n, Unsorted);
*/
canvas->DoPaint() ; // xrects, n);
delete[] xrects;
canvas->m_updateRects.Clear();
/* /*
if (canvasDC) cout << "Expose proc. wxRect: " << rect->x << ", " << rect->y << ", ";
{ cout << rect->width << ", " << rect->height << "\n\n";
XDestroyRegion(canvasDC->onpaint_reg);
canvasDC->onpaint_reg = NULL;
}
XGCValues gc_val;
gc_val.clip_mask = None;
XChangeGC(display, gc, GCClipMask, &gc_val);
*/ */
win->m_updateRects.Append((wxObject*) rect);
if (event -> xexpose.count == 0)
{
wxPaintEvent event(win->GetId());
event.SetEventObject(win);
win->GetEventHandler()->ProcessEvent(event);
win->ClearUpdateRects();
}
break; break;
} }
default: default:
@@ -3138,4 +3100,14 @@ void wxWindow::SetFont(const wxFont& font)
ChangeFont(); ChangeFont();
} }
void wxWindow::ClearUpdateRects()
{
wxNode* node = m_updateRects.First();
while (node)
{
wxRect* rect = (wxRect*) node->Data();
delete rect;
node = node->Next();
}
m_updateRects.Clear();
}