#include "wx/scrolwin.h"
#include "wx/layout.h"
#include "wx/menuitem.h"
+ #include "wx/module.h"
#endif
-#include "wx/module.h"
#include "wx/fontutil.h"
#include "wx/univ/renderer.h"
{
wxCHECK_MSG( parent, false, wxT("can't create wxWindow without parent") );
+ // Get default border
+ wxBorder border = GetBorder(style);
+ style &= ~wxBORDER_MASK;
+ style |= border;
+
CreateBase(parent, id, pos, size, style, wxDefaultValidator, name);
parent->AddChild(this);
if (pos2.y == wxDefaultCoord)
pos2.y = 0;
+ AdjustForParentClientOrigin(pos2.x, pos2.y);
+
#if wxUSE_TWO_WINDOWS
bool need_two_windows =
- ((( wxSUNKEN_BORDER | wxRAISED_BORDER | wxSIMPLE_BORDER | wxHSCROLL | wxVSCROLL ) & m_windowStyle) != 0);
+ ((( wxSUNKEN_BORDER | wxBORDER_THEME | wxRAISED_BORDER | wxSIMPLE_BORDER | wxHSCROLL | wxVSCROLL ) & m_windowStyle) != 0);
#else
bool need_two_windows = false;
#endif
}
#endif
- if (HasFlag( wxSUNKEN_BORDER) || HasFlag( wxRAISED_BORDER))
+ if (HasFlag(wxSUNKEN_BORDER) || HasFlag(wxRAISED_BORDER) || HasFlag(wxBORDER_THEME))
{
pos2.x = 2;
pos2.y = 2;
}
// Destroy the window
- Window xwindow = (Window) m_mainWindow;
- wxDeleteWindowFromTable( xwindow );
- XDestroyWindow( wxGlobalDisplay(), xwindow );
- m_mainWindow = NULL;
+ if ( m_mainWindow )
+ {
+ Window xwindow = (Window) m_mainWindow;
+ wxDeleteWindowFromTable( xwindow );
+ XDestroyWindow( wxGlobalDisplay(), xwindow );
+ m_mainWindow = NULL;
+ }
}
// ---------------------------------------------------------------------------
if (dx < 0) s_x += -dx;
if (dy < 0) s_y += -dy;
- if (dx > 0) d_x = dx + offset.x;
- if (dy > 0) d_y = dy + offset.y;
+ if (dx > 0) d_x += dx + offset.x;
+ if (dy > 0) d_y += dy + offset.y;
XCopyArea( xdisplay, xwindow, xwindow, xgc, s_x, s_y, w, h, d_x, d_y );
Window thisWindow = (Window) m_clientWindow;
Window childWindow;
- int xx = *x;
- int yy = *y;
- XTranslateCoordinates(display, rootWindow, thisWindow, xx, yy, x, y, &childWindow);
+ int xx = x ? *x : 0;
+ int yy = y ? *y : 0;
+ XTranslateCoordinates(display, rootWindow, thisWindow,
+ xx, yy, x ? x : &xx, y ? y : &yy,
+ &childWindow);
}
void wxWindowX11::DoClientToScreen(int *x, int *y) const
Window thisWindow = (Window) m_clientWindow;
Window childWindow;
- int xx = *x;
- int yy = *y;
- XTranslateCoordinates(display, thisWindow, rootWindow, xx, yy, x, y, &childWindow);
+ int xx = x ? *x : 0;
+ int yy = y ? *y : 0;
+ XTranslateCoordinates(display, thisWindow, rootWindow,
+ xx, yy, x ? x : &xx, y ? y : &yy,
+ &childWindow);
}
XCharStruct overall;
int slen = string.length();
- XTextExtents((XFontStruct*) pFontStruct, (char*) string.c_str(), slen,
+ XTextExtents((XFontStruct*) pFontStruct, (const char*) string.c_str(), slen,
&direction, &ascent, &descent2, &overall);
if ( x )
if (m_clearRegion.IsEmpty()) return;
wxClientDC dc( (wxWindow*)this );
- dc.SetClippingRegion( m_clearRegion );
+ dc.SetDeviceClippingRegion( m_clearRegion );
wxEraseEvent erase_event( GetId(), &dc );
erase_event.SetEventObject( this );
- if (!GetEventHandler()->ProcessEvent(erase_event) )
+ if (!HandleWindowEvent(erase_event) )
{
Display *xdisplay = wxGlobalDisplay();
Window xwindow = (Window) GetClientAreaWindow();
wxPaintEvent paint_event( GetId() );
paint_event.SetEventObject( this );
- GetEventHandler()->ProcessEvent( paint_event );
+ HandleWindowEvent( paint_event );
m_updateRegion.Clear();
wxNcPaintEvent nc_paint_event( GetId() );
nc_paint_event.SetEventObject( this );
- GetEventHandler()->ProcessEvent( nc_paint_event );
+ HandleWindowEvent( nc_paint_event );
m_updateNcArea = false;
}
{
wxSysColourChangedEvent event2;
event.SetEventObject(win);
- win->GetEventHandler()->ProcessEvent(event2);
+ win->HandleWindowEvent(event2);
}
node = node->GetNext();
// This calls the UI-update mechanism (querying windows for
// menu/toolbar/control state information)
- if (wxUpdateUIEvent::CanUpdate((wxWindow*) this))
+ if (wxUpdateUIEvent::CanUpdate((wxWindow*) this) && IsShownOnScreen())
UpdateWindowUI(wxUPDATE_UI_FROMIDLE);
// Set the input focus if couldn't do it before
// TranslateXXXEvent() functions
// ----------------------------------------------------------------------------
-bool wxTranslateMouseEvent(wxMouseEvent& wxevent, wxWindow *win, Window window, XEvent *xevent)
+bool wxTranslateMouseEvent(wxMouseEvent& wxevent,
+ wxWindow *win,
+ Window WXUNUSED(window),
+ XEvent *xevent)
{
switch (XEventGetType(xevent))
{
eventType = wxEVT_RIGHT_DOWN;
button = 3;
}
+ else if ( xevent->xbutton.button == Button4 ||
+ xevent->xbutton.button == Button5 )
+ {
+ // this is the same value as used under wxMSW
+ static const int WHEEL_DELTA = 120;
+
+ eventType = wxEVT_MOUSEWHEEL;
+ button = xevent->xbutton.button;
+
+ wxevent.m_linesPerAction = 3;
+ wxevent.m_wheelDelta = WHEEL_DELTA;
+
+ // Button 4 means mousewheel up, 5 means down
+ wxevent.m_wheelRotation = button == Button4 ? WHEEL_DELTA
+ : -WHEEL_DELTA;
+ }
// check for a double click
// TODO: where can we get this value from?
// position.
wxWindow* wxFindWindowAtPointer(wxPoint& pt)
{
- return wxFindWindowAtPoint(wxGetMousePosition());
+ pt = wxGetMousePosition();
+ return wxFindWindowAtPoint(pt);
}
void wxGetMouseState(int& rootX, int& rootY, unsigned& maskReturn)
class wxWinModule : public wxModule
{
public:
- bool OnInit();
- void OnExit();
+ wxWinModule()
+ {
+ // we must be cleaned up before the display is closed
+ AddDependency(wxClassInfo::FindClass(_T("wxX11DisplayModule")));
+ }
+
+ virtual bool OnInit();
+ virtual void OnExit();
private:
DECLARE_DYNAMIC_CLASS(wxWinModule)