CreateBase(parent, id, pos, size, style, wxDefaultValidator, name);
- if (parent)
- parent->AddChild(this);
-
- m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
- m_foregroundColour = *wxBLACK;
-
-#if 0
- // TODO: How to create more interesting borders?
- // Will presumably have to create multiple windows.
- if (style & wxSIMPLE_BORDER)
- {
- m_borderSize = 1;
- } else if (style & wxSUNKEN_BORDER)
- {
- m_borderSize = 1;
- } else if (style & wxRAISED_BORDER)
- {
- m_borderSize = 1;
- }
-#endif
+ parent->AddChild(this);
int w = size.GetWidth();
int h = size.GetHeight();
if (x == -1) x = 0;
if (y == -1) y = 0;
- int screen = DefaultScreen(wxGlobalDisplay());
+ Display *xdisplay = (Display*) wxGlobalDisplay();
+ int xscreen = DefaultScreen( xdisplay );
+ Colormap cm = DefaultColormap( xdisplay, xscreen );
- Window parentWindow;
- if (parent)
- parentWindow = (Window) parent->GetMainWindow();
- else
- parentWindow = RootWindow(wxGlobalDisplay(), screen);
+ m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
+ m_backgroundColour.CalcPixel( (WXColormap) cm );
+ m_hasBgCol = TRUE;
+
+ m_foregroundColour = *wxBLACK;
+ m_foregroundColour.CalcPixel( (WXColormap) cm );
+
- Window window = XCreateSimpleWindow(wxGlobalDisplay(), parentWindow,
- x, y, w, h, 0,
- m_backgroundColour.AllocColour(wxGlobalDisplay()),
- m_foregroundColour.AllocColour(wxGlobalDisplay()));
+ Window parentWindow = (Window) parent->GetMainWindow();
+
+ Window window = XCreateSimpleWindow(
+ xdisplay, parentWindow,
+ x, y, w, h, 0,
+ m_backgroundColour.GetPixel(),
+ m_backgroundColour.GetPixel() );
+
+ m_mainWidget = (WXWindow) window;
// Select event types wanted
XSelectInput(wxGlobalDisplay(), window,
wxAddWindowToTable(window, (wxWindow*) this);
- // If a subwindow, show.
-// if (parent && !parent->IsKindOf(CLASSINFO(wxTopLevelWindowX11)) && parent->IsShown())
- {
- m_isShown = TRUE;
- XMapWindow(wxGlobalDisplay(), window);
- }
+ // Is a subwindow, so map immediately
+ m_isShown = TRUE;
+ XMapWindow(wxGlobalDisplay(), window);
// Without this, the cursor may not be restored properly (e.g. in splitter
// sample).
void wxWindowX11::SetFocus()
{
-#if 0
- Window wMain = (Window) GetMainWidget();
+ Window wMain = (Window) GetMainWindow();
if (wMain)
{
XSetInputFocus(wxGlobalDisplay(), wMain, RevertToParent, CurrentTime);
XWMHints wmhints;
wmhints.flags = InputHint;
wmhints.input = True;
- XSetWMHints(wxGlobalDisplay(), wMain, &wmhints)
+ XSetWMHints(wxGlobalDisplay(), wMain, &wmhints);
}
-#endif
}
// Get the window with the focus
if ( m_winCaptured )
return;
- // TODO: should we also call XGrabButton, XGrabKeyboard?
if (GetMainWindow())
{
int res = XGrabPointer(wxGlobalDisplay(), (Window) GetMainWindow(),
None, /* cursor */ // TODO: This may need to be set to the cursor of this window
CurrentTime);
- if (res == GrabSuccess)
+ if (res != GrabSuccess)
+ {
+ wxLogDebug("Failed to grab pointer.");
+ return;
+ }
+
+ res = XGrabButton(wxGlobalDisplay(), AnyButton, AnyModifier,
+ (Window) GetMainWindow(),
+ FALSE,
+ ButtonPressMask | ButtonReleaseMask | ButtonMotionMask,
+ GrabModeAsync,
+ GrabModeAsync,
+ None,
+ None);
+
+ if (res != GrabSuccess)
+ {
+ wxLogDebug("Failed to grab mouse buttons.");
+ XUngrabPointer(wxGlobalDisplay(), CurrentTime);
+ return;
+ }
+
+ res = XGrabKeyboard(wxGlobalDisplay(), (Window) GetMainWindow(),
+#if 0
+ ShiftMask | LockMask | ControlMask | Mod1Mask | Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask,
+#else
+ FALSE,
+#endif
+ GrabModeAsync,
+ GrabModeAsync,
+ CurrentTime);
+
+ if (res != GrabSuccess)
{
- m_winCaptured = TRUE;
+ wxLogDebug("Failed to grab keyboard.");
+ XUngrabPointer(wxGlobalDisplay(), CurrentTime);
+ XUngrabButton(wxGlobalDisplay(), AnyButton, AnyModifier,
+ (Window) GetMainWindow());
+ return;
}
+
+ m_winCaptured = TRUE;
}
}
Window wMain = (Window)GetMainWindow();
- // TODO: should we also call XUngrabButton, XUngrabKeyboard?
if ( wMain )
+ {
XUngrabPointer(wxGlobalDisplay(), wMain);
+ XUngrabButton(wxGlobalDisplay(), AnyButton, AnyModifier,
+ wMain);
+ XUngrabKeyboard(wxGlobalDisplay(), CurrentTime);
+ }
m_winCaptured = FALSE;
}
XWarpPointer( wxGlobalDisplay(), None, (Window) m_mainWidget, 0, 0, 0, 0, x, y);
}
-// ---------------------------------------------------------------------------
-// scrolling stuff
-// ---------------------------------------------------------------------------
-
-int wxWindowX11::GetScrollPos(int orient) const
-{
- return 0;
-}
-
-// This now returns the whole range, not just the number of positions that we
-// can scroll.
-int wxWindowX11::GetScrollRange(int WXUNUSED(orient)) const
-{
- return 0;
-}
-
-int wxWindowX11::GetScrollThumb(int orient) const
-{
- // TODO
- return 0;
-}
-
-void wxWindowX11::SetScrollPos(int orient, int pos, bool WXUNUSED(refresh))
-{
- // TODO
-}
-
-// New function that will replace some of the above.
-void wxWindowX11::SetScrollbar(int WXUNUSED(orient), int WXUNUSED(pos), int WXUNUSED(thumbVisible),
- int WXUNUSED(range), bool WXUNUSED(refresh))
-{
- // TODO
-}
-
// Does a physical scroll
void wxWindowX11::ScrollWindow(int dx, int dy, const wxRect *rect)
{
+#if 0
int x, y, w, h;
if (rect)
{
delete rect;
node = node->Next();
}
-
- // TODO
-
- // XmUpdateDisplay((Widget) GetMainWidget());
+#endif
}
// ---------------------------------------------------------------------------
if (window)
{
XWindowAttributes attr;
- Status status = XGetWindowAttributes(wxGlobalDisplay(), window, & attr);
+ Status status = XGetWindowAttributes( wxGlobalDisplay(), window, &attr );
wxASSERT(status);
if (status)
if (x != -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
{
+ int yy = 0;
+ AdjustForParentClientOrigin( x, yy, sizeFlags);
windowChanges.x = x;
valueMask |= CWX;
}
if (y != -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
{
+ int xx = 0;
+ AdjustForParentClientOrigin( xx, y, sizeFlags);
windowChanges.y = y;
valueMask |= CWY;
}
windowChanges.height = height /* -m_borderSize*2*/;
valueMask |= CWHeight;
}
- AdjustForParentClientOrigin( x, y, sizeFlags);
XConfigureWindow(wxGlobalDisplay(), (Window) GetMainWindow(),
valueMask, & windowChanges);
{
m_clipPaintRegion = TRUE;
- if (!m_clearRegion.IsEmpty())
+ // if (!m_clearRegion.IsEmpty())
{
wxWindowDC dc( (wxWindow*)this );
dc.SetClippingRegion( m_clearRegion );
wxRegionIterator upd( m_clearRegion );
while (upd)
{
- // XClearArea( ... , upd.GetX(), upd.GetY(), upd.GetWidth(), upd.GetHeight() );
+ XClearArea( wxGlobalDisplay(), (Window) m_mainWidget,
+ upd.GetX(), upd.GetY(), upd.GetWidth(), upd.GetHeight(), False );
upd ++;
}
}
return m_mainWidget;
}
-// ----------------------------------------------------------------------------
-// callbacks
-// ----------------------------------------------------------------------------
-
-// TODO: implement wxWindow scrollbar, presumably using wxScrollBar
-#if 0
-static void wxScrollBarCallback(Widget scrollbar,
- XtPointer clientData,
- XmScrollBarCallbackStruct *cbs)
-{
- wxWindow *win = wxGetWindowFromTable(scrollbar);
- int orientation = (int) clientData;
-
- wxEventType eventType = wxEVT_NULL;
- switch (cbs->reason)
- {
- case XmCR_INCREMENT:
- {
- eventType = wxEVT_SCROLLWIN_LINEDOWN;
- break;
- }
- case XmCR_DECREMENT:
- {
- eventType = wxEVT_SCROLLWIN_LINEUP;
- break;
- }
- case XmCR_DRAG:
- {
- eventType = wxEVT_SCROLLWIN_THUMBTRACK;
- break;
- }
- case XmCR_VALUE_CHANGED:
- {
- eventType = wxEVT_SCROLLWIN_THUMBRELEASE;
- break;
- }
- case XmCR_PAGE_INCREMENT:
- {
- eventType = wxEVT_SCROLLWIN_PAGEDOWN;
- break;
- }
- case XmCR_PAGE_DECREMENT:
- {
- eventType = wxEVT_SCROLLWIN_PAGEUP;
- break;
- }
- case XmCR_TO_TOP:
- {
- eventType = wxEVT_SCROLLWIN_TOP;
- break;
- }
- case XmCR_TO_BOTTOM:
- {
- eventType = wxEVT_SCROLLWIN_BOTTOM;
- break;
- }
- default:
- {
- // Should never get here
- wxFAIL_MSG("Unknown scroll event.");
- break;
- }
- }
-
- wxScrollWinEvent event(eventType,
- cbs->value,
- ((orientation == XmHORIZONTAL) ?
- wxHORIZONTAL : wxVERTICAL));
- event.SetEventObject( win );
- win->GetEventHandler()->ProcessEvent(event);
-}
-#endif
-
// ----------------------------------------------------------------------------
// TranslateXXXEvent() functions
// ----------------------------------------------------------------------------
bool wxWindowX11::SetBackgroundColour(const wxColour& col)
{
- if ( !wxWindowBase::SetBackgroundColour(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 );
+
+ XSetWindowAttributes attrib;
+ attrib.background_pixel = colour.GetPixel();
+
+ XChangeWindowAttributes(wxGlobalDisplay(),
+ (Window) GetMainWindow(),
+ CWBackPixel,
+ & attrib);
+
return TRUE;
}