Updated the erase/paint event logic.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14216 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2002-02-14 21:08:45 +00:00
parent 2e8cc3e834
commit ba696cfadf
5 changed files with 52 additions and 20 deletions

View File

@@ -111,7 +111,7 @@ public:
WXDisplay *GetXDisplay() const;
void SetLastClick(int button, long timestamp)
{ m_lastButton = button; m_lastTS = timestamp; }
{ m_lastButton = button; m_lastTS = timestamp; }
int GetLastClickedButton() const { return m_lastButton; }
long GetLastClickTime() const { return m_lastTS; }
@@ -126,6 +126,9 @@ public:
// Clip to paint region?
bool GetClipPaintRegion() { return m_clipPaintRegion; }
// Return clear region
wxRegion &GetClearRegion() { return m_clearRegion; }
// sets the fore/background colour for the given widget
static void DoChangeForegroundColour(WXWindow widget, wxColour& foregroundColour);
static void DoChangeBackgroundColour(WXWindow widget, wxColour& backgroundColour, bool changeArmColour = FALSE);

View File

@@ -144,7 +144,7 @@ void wxApp::CleanUp()
// wxDebugContext, too.
if (wxDebugContext::CountObjectsLeft(TRUE) > 0)
{
wxLogDebug("There were memory leaks.\n");
wxLogDebug("There were memory leaks.");
wxDebugContext::Dump();
wxDebugContext::PrintStatistics();
}
@@ -369,6 +369,8 @@ void wxApp::ProcessXEvent(WXEvent* _event)
wxKeyEvent keyEvent(wxEVT_KEY_DOWN);
wxTranslateKeyEvent(keyEvent, win, window, event);
wxLogDebug( "OnKey from %s", win->GetName().c_str() );
// We didn't process wxEVT_KEY_DOWN, so send
// wxEVT_CHAR
if (!win->GetEventHandler()->ProcessEvent( keyEvent ))
@@ -464,9 +466,14 @@ void wxApp::ProcessXEvent(WXEvent* _event)
{
if (win)
{
// Schedule update for later
win->GetUpdateRegion().Union( event->xexpose.x, event->xexpose.y,
event->xexpose.width, event->xexpose.height);
win->GetClearRegion().Union( event->xexpose.x, event->xexpose.y,
event->xexpose.width, event->xexpose.height);
// if (event->xexpose.count == 0)
// win->Update();
}
return;
@@ -492,6 +499,8 @@ void wxApp::ProcessXEvent(WXEvent* _event)
{
if (win && event->xfocus.detail != NotifyPointer)
{
wxLogDebug( "FocusIn from %s", win->GetName().c_str() );
wxFocusEvent focusEvent(wxEVT_SET_FOCUS, win->GetId());
focusEvent.SetEventObject(win);
win->GetEventHandler()->ProcessEvent(focusEvent);
@@ -502,6 +511,8 @@ void wxApp::ProcessXEvent(WXEvent* _event)
{
if (win && event->xfocus.detail != NotifyPointer)
{
wxLogDebug( "FocusOut from %s\n", win->GetName().c_str() );
wxFocusEvent focusEvent(wxEVT_KILL_FOCUS, win->GetId());
focusEvent.SetEventObject(win);
win->GetEventHandler()->ProcessEvent(focusEvent);

View File

@@ -77,6 +77,10 @@ bool wxPopupWindow::Create( wxWindow *parent, int style )
m_mainWidget = (WXWindow) xwindow;
wxAddWindowToTable( xwindow, (wxWindow*) this );
// Set background to None which will prevent X11 from clearing the
// background comletely.
XSetWindowBackgroundPixmap( xdisplay, xwindow, None );
XSetTransientForHint( xdisplay, xwindow, xparent );
XWMHints wm_hints;

View File

@@ -135,6 +135,10 @@ bool wxTopLevelWindowX11::Create(wxWindow *parent,
wxAddWindowToTable( xwindow, (wxWindow*) this );
// Set background to None which will prevent X11 from clearing the
// background completely.
XSetWindowBackgroundPixmap( xdisplay, xwindow, None );
// Messes up window management
// XSetTransientForHint( xdisplay, xwindow, xparent );

View File

@@ -129,12 +129,10 @@ bool wxWindowX11::Create(wxWindow *parent, wxWindowID id,
m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
m_backgroundColour.CalcPixel( (WXColormap) cm );
m_hasBgCol = TRUE;
m_foregroundColour = *wxBLACK;
m_foregroundColour.CalcPixel( (WXColormap) cm );
Window parentWindow = (Window) parent->GetMainWindow();
wxSize size2(size);
@@ -149,32 +147,36 @@ bool wxWindowX11::Create(wxWindow *parent, wxWindowID id,
if (pos2.y == -1)
pos2.y = 100;
Window window = XCreateSimpleWindow(
Window xwindow = XCreateSimpleWindow(
xdisplay, parentWindow,
pos2.x, pos2.y, size2.x, size2.y, 0,
m_backgroundColour.GetPixel(),
m_backgroundColour.GetPixel() );
m_mainWidget = (WXWindow) window;
m_mainWidget = (WXWindow) xwindow;
// Select event types wanted
XSelectInput( wxGlobalDisplay(), window,
XSelectInput( xdisplay, xwindow,
ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |
ButtonMotionMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask |
KeymapStateMask | FocusChangeMask | ColormapChangeMask | StructureNotifyMask |
PropertyChangeMask);
wxAddWindowToTable(window, (wxWindow*) this);
wxAddWindowToTable( xwindow, (wxWindow*) this );
// Is a subwindow, so map immediately
m_isShown = TRUE;
XMapWindow(wxGlobalDisplay(), window);
XMapWindow( xdisplay, xwindow );
// Without this, the cursor may not be restored properly (e.g. in splitter
// sample).
SetCursor(*wxSTANDARD_CURSOR);
SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
// Set background to None which will prevent X11 from clearing the
// background comletely.
XSetWindowBackgroundPixmap( xdisplay, xwindow, None );
// Don't call this, it can have nasty repercussions for composite controls,
// for example
// SetSize(pos.x, pos.y, size.x, size.y);
@@ -226,11 +228,11 @@ void wxWindowX11::SetFocus()
if (wxWindowIsVisible(xwindow))
{
XSetInputFocus( wxGlobalDisplay(), xwindow, RevertToParent, CurrentTime );
m_needsInputFocus = FALSE;
m_needsInputFocus = FALSE;
}
else
{
m_needsInputFocus = TRUE;
m_needsInputFocus = TRUE;
}
}
@@ -994,6 +996,7 @@ void wxWindowX11::Update()
{
if (!m_updateRegion.IsEmpty())
{
// Actually send erase and paint events.
X11SendPaintEvents();
}
}
@@ -1010,7 +1013,7 @@ void wxWindowX11::X11SendPaintEvents()
{
m_clipPaintRegion = TRUE;
// if (!m_clearRegion.IsEmpty())
if (!m_clearRegion.IsEmpty())
{
wxWindowDC dc( (wxWindow*)this );
dc.SetClippingRegion( m_clearRegion );
@@ -1020,11 +1023,17 @@ void wxWindowX11::X11SendPaintEvents()
if (!GetEventHandler()->ProcessEvent(erase_event))
{
printf( "Hallo!\n" );
Window xwindow = (Window) GetMainWindow();
Display *xdisplay = wxGlobalDisplay();
GC xgc = XCreateGC( xdisplay, xwindow, 0, NULL );
XSetFillStyle( xdisplay, xgc, FillSolid );
XSetForeground( xdisplay, xgc, m_backgroundColour.GetPixel() );
wxRegionIterator upd( m_clearRegion );
while (upd)
{
XClearArea( wxGlobalDisplay(), (Window) m_mainWidget,
upd.GetX(), upd.GetY(), upd.GetWidth(), upd.GetHeight(), False );
XFillRectangle( xdisplay, xwindow, xgc,
upd.GetX(), upd.GetY(), upd.GetWidth(), upd.GetHeight() );
upd ++;
}
}
@@ -1315,16 +1324,16 @@ bool wxWindowX11::SetBackgroundColour(const wxColour& col)
{
wxWindowBase::SetBackgroundColour(col);
if (!GetMainWindow())
return FALSE;
Display *xdisplay = (Display*) wxGlobalDisplay();
int xscreen = DefaultScreen( xdisplay );
Colormap cm = DefaultColormap( xdisplay, xscreen );
wxColour colour( col );
colour.CalcPixel( (WXColormap) cm );
m_backgroundColour.CalcPixel( (WXColormap) cm );
if (!GetMainWindow())
return FALSE;
/*
XSetWindowAttributes attrib;
attrib.background_pixel = colour.GetPixel();
@@ -1332,6 +1341,7 @@ bool wxWindowX11::SetBackgroundColour(const wxColour& col)
(Window) GetMainWindow(),
CWBackPixel,
& attrib);
*/
return TRUE;
}