More X11 code

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14097 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart 2002-02-10 01:03:45 +00:00
parent 6cecceddd8
commit b513212d2e
9 changed files with 657 additions and 619 deletions

View File

@ -66,6 +66,11 @@ extern int wxComputeColours (Display *display, wxColour * back, wxColour * fore)
extern void wxDoChangeForegroundColour(WXWidget widget, wxColour& foregroundColour);
extern void wxDoChangeBackgroundColour(WXWidget widget, wxColour& backgroundColour, bool changeArmColour = FALSE);
extern Window wxGetWindowParent(Window window);
// For convenience
inline Display* wxGlobalDisplay() { return (Display*) wxGetDisplay(); }
#define wxNO_COLORS 0x00
#define wxBACK_COLORS 0x01
#define wxFORE_COLORS 0x02

View File

@ -1,44 +1,49 @@
/////////////////////////////////////////////////////////////////////////////
// Name: timer.h
// Purpose: wxTimer class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
// Author: Vaclav Slavik
// Id: $Id$
// Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_TIMER_H_
#define _WX_TIMER_H_
#ifndef __WX_TIMER_H__
#define __WX_TIMER_H__
#ifdef __GNUG__
#pragma interface "timer.h"
#pragma interface "timer.h"
#endif
//-----------------------------------------------------------------------------
// wxTimer
//-----------------------------------------------------------------------------
class wxTimerDesc;
class WXDLLEXPORT wxTimer : public wxTimerBase
{
friend void wxTimerCallback(wxTimer * timer);
public:
wxTimer() { Init(); }
wxTimer(wxEvtHandler *owner, int id = -1) : wxTimerBase(owner, id)
{ Init(); }
{ Init(); }
~wxTimer();
virtual bool Start(int milliseconds = -1, bool oneShot = FALSE);
virtual bool Start(int millisecs = -1, bool oneShot = FALSE);
virtual void Stop();
virtual bool IsRunning() const { return m_id != 0; }
virtual bool IsRunning() const;
// implementation
static void NotifyTimers();
protected:
void Init();
long m_id;
private:
DECLARE_DYNAMIC_CLASS(wxTimer)
wxTimerDesc *m_desc;
DECLARE_ABSTRACT_CLASS(wxTimer)
};
#endif
// _WX_TIMER_H_
#endif // __WX_TIMER_H__

View File

@ -62,6 +62,9 @@ public:
virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
virtual bool IsFullScreen() const { return m_fsIsShowing; }
virtual void SetTitle( const wxString& title);
virtual wxString GetTitle() const;
// implementation from now on
// --------------------------
@ -92,6 +95,7 @@ protected:
wxRect m_fsOldSize;
bool m_fsIsMaximized;
bool m_fsIsShowing;
wxString m_title;
};
// list of all frames and modeless dialogs

View File

@ -50,10 +50,6 @@ public:
long style = 0,
const wxString& name = wxPanelNameStr);
// implement base class pure virtuals
virtual void SetTitle( const wxString& title);
virtual wxString GetTitle() const;
virtual void Raise();
virtual void Lower();
@ -185,15 +181,6 @@ protected:
// Responds to colour changes: passes event on to children.
void OnSysColourChanged(wxSysColourChangedEvent& event);
// Motif-specific
// CanvasXXXSiize functions
void CanvasGetSize(int* width, int* height) const; // If have drawing area
void CanvasGetClientSize(int *width, int *height) const;
void CanvasGetPosition(int *x, int *y) const; // If have drawing area
void CanvasSetClientSize(int width, int size);
void CanvasSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
void SetMainWindow(WXWindow w) { m_mainWidget = w; }
bool CanAddEventHandler() const { return m_canAddEventHandler; }
@ -217,11 +204,6 @@ public:
virtual void ChangeForegroundColour();
protected:
// Adds the widget to the hash table and adds event handlers.
bool AttachWindow(wxWindow* parent, WXWindow mainWidget,
int x, int y, int width, int height);
bool DetachWindow(WXWindow widget);
// How to implement accelerators. If we find a key event, translate to
// wxWindows wxKeyEvent form. Find a widget for the window. Now find a
// wxWindow for the widget. If there isn't one, go up the widget hierarchy
@ -294,6 +276,9 @@ protected:
// by system
int m_scrollPosX;
int m_scrollPosY;
// Window border size
int m_borderSize;
// implement the base class pure virtuals
virtual void DoClientToScreen( int *x, int *y ) const;

View File

@ -21,8 +21,6 @@
#include "wx/brush.h"
#include "wx/cursor.h"
#include "wx/icon.h"
#include "wx/palette.h"
#include "wx/dc.h"
#include "wx/dialog.h"
#include "wx/msgdlg.h"
#include "wx/log.h"
@ -73,8 +71,6 @@ typedef int (*XErrorHandlerFunc)(Display *, XErrorEvent *);
XErrorHandlerFunc gs_pfnXErrorHandler = 0;
static Window XGetParent(Window window);
static int wxXErrorHandler(Display *dpy, XErrorEvent *xevent)
{
// just forward to the default handler for now
@ -298,7 +294,7 @@ void wxApp::ProcessXEvent(WXEvent* _event)
// TODO: may need to translate coordinates from actualWindow
// to window, if the receiving window != wxWindow window
while (window && !(win = wxGetWindowFromTable(window)))
window = XGetParent(window);
window = wxGetParentWindow(window);
// TODO: shouldn't all the ProcessEvents below
// be win->GetEventHandler()->ProcessEvent?
@ -306,6 +302,9 @@ void wxApp::ProcessXEvent(WXEvent* _event)
{
case KeyPress:
{
if (win && !win->IsEnabled())
return;
if (CheckForAccelerator(_event))
{
// Do nothing! We intercepted and processed the event as an
@ -321,10 +320,10 @@ void wxApp::ProcessXEvent(WXEvent* _event)
// We didn't process wxEVT_KEY_DOWN, so send
// wxEVT_CHAR
if (!win->ProcessEvent( keyEvent ))
if (!win->GetEventHandler()->ProcessEvent( keyEvent ))
{
keyEvent.SetEventType(wxEVT_CHAR);
win->ProcessEvent( keyEvent );
win->GetEventHandler()->ProcessEvent( keyEvent );
}
// We intercepted and processed the key down event
@ -335,12 +334,15 @@ void wxApp::ProcessXEvent(WXEvent* _event)
}
case KeyRelease:
{
if (win && !win->IsEnabled())
return;
if (win)
{
wxKeyEvent keyEvent(wxEVT_KEY_UP);
wxTranslateKeyEvent(keyEvent, win, window, event);
win->ProcessEvent( keyEvent );
win->GetEventHandler()->ProcessEvent( keyEvent );
}
return;
}
@ -349,6 +351,23 @@ void wxApp::ProcessXEvent(WXEvent* _event)
HandlePropertyChange(_event);
return;
}
case ClientMessage:
{
Atom wm_delete_window = XInternAtom(wxGlobalDisplay(), "WM_DELETE_WINDOW", True);;
Atom wm_protocols = XInternAtom(wxGlobalDisplay(), "WM_PROTOCOLS", True);;
if (event->xclient.message_type == wm_protocols)
{
if (event->xclient.data.l[0] == wm_delete_window)
{
if (win)
{
win->Close(FALSE);
}
}
}
return;
}
case ResizeRequest:
{
/* Terry Gitnick <terryg@scientech.com> - 1/21/98
@ -372,7 +391,7 @@ void wxApp::ProcessXEvent(WXEvent* _event)
wxSizeEvent sizeEvent(sz, win->GetId());
sizeEvent.SetEventObject(win);
win->ProcessEvent( sizeEvent );
win->GetEventHandler()->ProcessEvent( sizeEvent );
}
return;
@ -399,11 +418,14 @@ void wxApp::ProcessXEvent(WXEvent* _event)
case ButtonRelease:
case MotionNotify:
{
if (win && !win->IsEnabled())
return;
if (win)
{
wxMouseEvent wxevent;
wxTranslateMouseEvent(wxevent, win, window, event);
win->ProcessEvent( wxevent );
win->GetEventHandler()->ProcessEvent( wxevent );
}
return;
}
@ -413,7 +435,7 @@ void wxApp::ProcessXEvent(WXEvent* _event)
{
wxFocusEvent focusEvent(wxEVT_SET_FOCUS, win->GetId());
focusEvent.SetEventObject(win);
win->ProcessEvent(focusEvent);
win->GetEventHandler()->ProcessEvent(focusEvent);
}
break;
}
@ -423,10 +445,16 @@ void wxApp::ProcessXEvent(WXEvent* _event)
{
wxFocusEvent focusEvent(wxEVT_KILL_FOCUS, win->GetId());
focusEvent.SetEventObject(win);
win->ProcessEvent(focusEvent);
win->GetEventHandler()->ProcessEvent(focusEvent);
}
break;
}
case DestroyNotify:
{
// Do we want to process this (for top-level windows)?
// But we want to be able to veto closes, anyway
break;
}
default:
{
break;
@ -622,7 +650,7 @@ WXColormap wxApp::GetMainColormap(WXDisplay* display)
return (WXColormap) c;
}
static Window XGetParent(Window window)
Window wxGetWindowParent(Window window)
{
Window parent, root = 0;
unsigned int noChildren = 0;
@ -646,7 +674,7 @@ bool wxApp::CheckForAccelerator(WXEvent* event)
// Find the first wxWindow that corresponds to this event window
while (window && !(win = wxGetWindowFromTable(window)))
window = XGetParent(window);
window = wxGetWindowParent(window);
if (!window || !win)
return FALSE;

View File

@ -28,6 +28,7 @@
#if wxUSE_THREADS
#include "wx/thread.h"
#endif
#include "wx/timer.h"
#include "wx/x11/private.h"
#include "X11/Xlib.h"
@ -162,6 +163,7 @@ int wxEventLoop::Run()
// anything else to do
while ( ! Pending() )
{
wxTimer::NotifyTimers(); // TODO: is this the correct place for it?
if (!m_impl->SendIdleEvent())
{
#if 0 // wxUSE_THREADS

View File

@ -1,100 +1,214 @@
/////////////////////////////////////////////////////////////////////////////
// Name: timer.cpp
// Name: x11/timer.cpp
// Purpose: wxTimer implementation
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
// Author: Vaclav Slavik
// Id: $Id$
// Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "timer.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#include "wx/timer.h"
#include "wx/app.h"
#include "wx/list.h"
#ifdef __VMS__
#pragma message disable nosimpint
#endif
#ifdef __VMS__
#pragma message enable nosimpint
#endif
#if wxUSE_TIMER
#include "wx/log.h"
#include "wx/module.h"
#include "wx/x11/private.h"
IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxObject)
// ----------------------------------------------------------------------------
// helper structures and wxTimerScheduler
// ----------------------------------------------------------------------------
static wxList wxTimerList(wxKEY_INTEGER);
void wxTimerCallback (wxTimer * timer)
class wxTimerDesc
{
// Check to see if it's still on
if (!wxTimerList.Find((long)timer))
return;
public:
wxTimerDesc(wxTimer *t) :
timer(t), running(FALSE), next(NULL), prev(NULL),
shotTime(0), deleteFlag(NULL) {}
if (timer->m_id == 0)
return; // Avoid to process spurious timer events
wxTimer *timer;
bool running;
wxTimerDesc *next, *prev;
unsigned long shotTime;
volatile bool *deleteFlag; // see comment in ~wxTimer
};
// TODO
#if 0
if (!timer->m_oneShot)
timer->m_id = XtAppAddTimeOut((XtAppContext) wxTheApp->GetAppContext(),
timer->m_milli,
(XtTimerCallbackProc) wxTimerCallback,
(XtPointer) timer);
else
#endif
timer->m_id = 0;
class wxTimerScheduler
{
public:
wxTimerScheduler() : m_timers(NULL) {}
timer->Notify();
void QueueTimer(wxTimerDesc *desc, unsigned long when = 0);
void RemoveTimer(wxTimerDesc *desc);
void NotifyTimers();
private:
wxTimerDesc *m_timers;
};
void wxTimerScheduler::QueueTimer(wxTimerDesc *desc, unsigned long when)
{
if ( desc->running )
return; // already scheduled
if ( when == 0 )
when = wxGetLocalTimeMillis() + desc->timer->GetInterval();
desc->shotTime = when;
desc->running = TRUE;
wxLogTrace("mgl_timer", "queued timer %p at tick %i",
desc->timer, when);
if ( m_timers )
{
wxTimerDesc *d = m_timers;
while ( d->next && d->next->shotTime < when ) d = d->next;
desc->next = d->next;
desc->prev = d;
if ( d->next )
d->next->prev = desc;
d->next = desc;
}
else
{
m_timers = desc;
desc->prev = desc->next = NULL;
}
}
void wxTimerScheduler::RemoveTimer(wxTimerDesc *desc)
{
desc->running = FALSE;
if ( desc == m_timers )
m_timers = desc->next;
if ( desc->prev )
desc->prev->next = desc->next;
if ( desc->next )
desc->next->prev = desc->prev;
desc->prev = desc->next = NULL;
}
void wxTimerScheduler::NotifyTimers()
{
if ( m_timers )
{
bool oneShot;
volatile bool timerDeleted;
unsigned long now = wxGetLocalTimeMillis();
wxTimerDesc *desc;
while ( m_timers && m_timers->shotTime <= now )
{
desc = m_timers;
oneShot = desc->timer->IsOneShot();
RemoveTimer(desc);
timerDeleted = FALSE;
desc->deleteFlag = &timerDeleted;
desc->timer->Notify();
if ( !timerDeleted )
{
wxLogTrace("mgl_timer", "notified timer %p sheduled for %i",
desc->timer, desc->shotTime);
desc->deleteFlag = NULL;
if ( !oneShot )
QueueTimer(desc, now + desc->timer->GetInterval());
}
}
}
}
// ----------------------------------------------------------------------------
// wxTimer
// ----------------------------------------------------------------------------
IMPLEMENT_ABSTRACT_CLASS(wxTimer,wxObject)
wxTimerScheduler *gs_scheduler = NULL;
void wxTimer::Init()
{
m_id = 0;
m_milli = 1000;
if ( !gs_scheduler )
gs_scheduler = new wxTimerScheduler;
m_desc = new wxTimerDesc(this);
}
wxTimer::~wxTimer()
{
wxTimer::Stop();
wxTimerList.DeleteObject(this);
wxLogTrace("mgl_timer", "destroying timer %p...", this);
if ( IsRunning() )
Stop();
// NB: this is a hack: wxTimerScheduler must have some way of knowing
// that wxTimer object was deleted under its hands -- this may
// happen if somebody is really nasty and deletes the timer
// from wxTimer::Notify()
if ( m_desc->deleteFlag != NULL )
*m_desc->deleteFlag = TRUE;
delete m_desc;
wxLogTrace("mgl_timer", " ...done destroying timer %p...", this);
}
bool wxTimer::Start(int milliseconds, bool mode)
bool wxTimer::IsRunning() const
{
Stop();
return m_desc->running;
}
(void)wxTimerBase::Start(milliseconds, mode);
bool wxTimer::Start(int millisecs, bool oneShot)
{
wxLogTrace("mgl_timer", "started timer %p: %i ms, oneshot=%i",
this, millisecs, oneShot);
if (!wxTimerList.Find((long)this))
wxTimerList.Append((long)this, this);
// TODO
#if 0
m_id = XtAppAddTimeOut((XtAppContext) wxTheApp->GetAppContext(),
m_milli,
(XtTimerCallbackProc) wxTimerCallback,
(XtPointer) this);
#endif
if ( !wxTimerBase::Start(millisecs, oneShot) )
return FALSE;
gs_scheduler->QueueTimer(m_desc);
return TRUE;
}
void wxTimer::Stop()
{
if (m_id > 0)
{
// TODO
#if 0
XtRemoveTimeOut (m_id);
#endif
m_id = 0;
}
m_milli = 0 ;
if ( !m_desc->running ) return;
gs_scheduler->RemoveTimer(m_desc);
}
/*static*/ void wxTimer::NotifyTimers()
{
if ( gs_scheduler )
gs_scheduler->NotifyTimers();
}
// A module to deallocate memory properly:
class wxTimerModule: public wxModule
{
DECLARE_DYNAMIC_CLASS(wxTimerModule)
public:
wxTimerModule() {}
bool OnInit() { return TRUE; }
void OnExit() { delete gs_scheduler; gs_scheduler = NULL; }
};
IMPLEMENT_DYNAMIC_CLASS(wxTimerModule, wxModule)
#endif //wxUSE_TIMER

View File

@ -38,6 +38,14 @@
#endif //WX_PRECOMP
#include "wx/x11/private.h"
#include "X11/Xatom.h"
#include "X11/Xutil.h"
// Set the window manager decorations according to the
// given wxWindows style
static bool SetWMDecorations(Widget w, long style);
static bool MWMIsRunning(Window w);
// ----------------------------------------------------------------------------
// globals
@ -98,9 +106,13 @@ bool wxTopLevelWindowX11::Create(wxWindow *parent,
m_windowId = id == -1 ? NewControlId() : id;
wxTopLevelWindows.Append(this);
Atom wm_delete_window = XInternAtom(wxGlobalDisplay(), "WM_DELETE_WINDOW", False);
if ( parent )
parent->AddChild(this);
XSetWMProtocols(wxGlobalDisplay(), (Window) GetMainWindow(), &wm_delete_window, 1);
SetWMDecorations((Window) GetMainWindow(), style);
SetTitle(title);
if ( GetExtraStyle() & wxTOPLEVEL_EX_DIALOG )
{
@ -141,9 +153,7 @@ bool wxTopLevelWindowX11::Show(bool show)
if ( !wxWindowBase::Show(show) )
return FALSE;
// TODO
return TRUE;
return wxWindowX11::Show(show);
}
// ----------------------------------------------------------------------------
@ -163,18 +173,27 @@ bool wxTopLevelWindowX11::IsMaximized() const
void wxTopLevelWindowX11::Iconize(bool iconize)
{
// TODO
if (!m_iconized && GetMainWindow())
{
if (XIconifyWindow(wxGlobalDisplay(),
(Window) GetMainWindow(), DefaultScreen(wxGlobalDisplay())) != 0)
m_iconized = TRUE;
}
}
bool wxTopLevelWindowX11::IsIconized() const
{
// TODO
return m_iconized;
}
void wxTopLevelWindowX11::Restore()
{
// TODO
// This is the way to deiconify the window, according to the X FAQ
if (m_iconized && GetMainWindow())
{
XMapWindow(wxGlobalDisplay(), (Window) GetMainWindow());
m_iconized = FALSE;
}
}
// ----------------------------------------------------------------------------
@ -216,5 +235,157 @@ void wxTopLevelWindowX11::SetIcon(const wxIcon& icon)
// this sets m_icon
wxTopLevelWindowBase::SetIcon(icon);
// TODO
if (icon.Ok() && GetMainWindow())
{
XWMHints *wmHints = XAllocWMHints();
wmHints.icon_pixmap = (Pixmap) icon.GetPixmap();
wmHints.flags = IconPixmapHint;
if (icon.GetMask())
{
wmHints.flags |= IconMaskHint;
wmHints.icon_mask = (Pixmap) icon.GetMask()->GetPixmap();
}
XSetWMHints(wxGlobalDisplay(), (Window) GetMainWindow(),
wmHints);
XFree(wmHints);
}
}
void wxTopLevelWindowX11::SetTitle(const wxString& title)
{
m_title = title;
if (GetMainWindow())
{
XStoreName(wxGlobalDisplay(), (Window) GetMainWindow(),
(const char*) title);
XSetIconName(wxGlobalDisplay(), (Window) GetMainWindow(),
(const char*) title);
#if 0
XTextProperty textProperty;
textProperty.value = (unsigned char*) title;
textProperty.encoding = XA_STRING;
textProperty.format = 8;
textProperty.nitems = 1;
XSetTextProperty(wxGlobalDisplay(), (Window) GetMainWindow(),
& textProperty, WM_NAME);
#endif
}
}
wxString wxTopLevelWindowX11::GetTitle() const
{
return m_title;
}
#ifndef MWM_DECOR_BORDER
/* bit definitions for MwmHints.flags */
#define MWM_HINTS_FUNCTIONS (1L << 0)
#define MWM_HINTS_DECORATIONS (1L << 1)
#define MWM_HINTS_INPUT_MODE (1L << 2)
#define MWM_HINTS_STATUS (1L << 3)
#define MWM_DECOR_ALL (1L << 0)
#define MWM_DECOR_BORDER (1L << 1)
#define MWM_DECOR_RESIZEH (1L << 2)
#define MWM_DECOR_TITLE (1L << 3)
#define MWM_DECOR_MENU (1L << 4)
#define MWM_DECOR_MINIMIZE (1L << 5)
#define MWM_DECOR_MAXIMIZE (1L << 6)
#endif
struct MwmHints {
long flags;
long functions;
long decorations;
long input_mode;
};
#define PROP_MOTIF_WM_HINTS_ELEMENTS 5
// Set the window manager decorations according to the
// given wxWindows style
static bool SetWMDecorations(Widget w, long style)
{
if (!MWMIsRunning(w))
return FALSE;
Atom mwm_wm_hints = XInternAtom(wxGlobalDisplay(),"_MOTIF_WM_HINTS", False);
MwmHints hints;
hints.flags = 0;
hints.decorations = 0;
if (style & wxRESIZE_BORDER)
{
hints.flags |= MWM_HINTS_DECORATIONS;
hints.decorations |= MWM_DECOR_RESIZEH;
}
if (style & wxSYSTEM_MENU)
{
hints.flags |= MWM_HINTS_DECORATIONS;
hints.decorations |= MWM_DECOR_MENU;
}
if ((style & wxCAPTION) ||
(style & wxTINY_CAPTION_HORIZ) ||
(style & wxTINY_CAPTION_VERT))
{
hints.flags |= MWM_HINTS_DECORATIONS;
hints.decorations |= MWM_DECOR_TITLE;
}
if (style & wxTHICK_FRAME)
{
hints.flags |= MWM_HINTS_DECORATIONS;
hints.decorations |= MWM_DECOR_BORDER;
}
if (style & wxTHICK_FRAME)
{
hints.flags |= MWM_HINTS_DECORATIONS;
hints.decorations |= MWM_DECOR_BORDER;
}
if (style & wxMINIMIZE_BOX)
{
hints.flags |= MWM_HINTS_DECORATIONS;
hints.decorations |= MWM_DECOR_MINIMIZE;
}
if (style & wxMAXIMIZE_BOX)
{
hints.flags |= MWM_HINTS_DECORATIONS;
hints.decorations |= MWM_DECOR_MAXIMIZE;
}
XChangeProperty(wxGlobalDisplay(),
w,
mwm_wm_hints, mem_wm_hints,
32, PropModeReplace,
(unsigned char *) &hints, PROP_MOTIF_WM_HINTS_ELEMENTS);
return TRUE;
}
static bool MWMIsRunning(Window w)
{
Atom motifWmInfo = XInternAtom(dpy, "_MOTIF_WM_INFO", False);
unsigned long length, bytesafter;
unsigned char value[20];
int ret, type, format;
type = format = length = 0;
value = 0;
ret = XGetWindowProperty(wxGlobalDisplay(), w, motifWmInfo,
0L, 2, False, motifWmInfo,
&type, &format, &length, &bytesafter, &value);
return (ret == Success);
}

View File

@ -99,6 +99,7 @@ void wxWindowX11::Init()
InitBase();
// X11-specific
// TODO: prune those that are no longer needed
m_needsRefresh = TRUE;
m_mainWidget = (WXWindow) 0;
@ -133,6 +134,8 @@ void wxWindowX11::Init()
m_lastTS = 0;
m_lastButton = 0;
m_canAddEventHandler = FALSE;
m_borderSize = 0;
}
// real construction (Init() must have been called before!)
@ -146,25 +149,68 @@ bool wxWindowX11::Create(wxWindow *parent, wxWindowID id,
CreateBase(parent, id, pos, size, style, wxDefaultValidator, name);
parent->AddChild(this);
if (parent)
parent->AddChild(this);
m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
m_foregroundColour = *wxBLACK;
// 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;
}
// TODO: create XWindow
int w = size.GetWidth();
int h = size.GetHeight();
int x = size.GetX();
int y = size.GetY();
int h = size.GetHeight();
if (w == -1) w = 10;
if (h == -1) h = 10;
if (x == -1) x = 0;
if (y == -1) y = 0;
#if 0
wxAddWindowToTable((Window) m_drawingArea, this);
wxAddWindowToTable((Window) m_scrolledWindow, this);
#endif
int innerWidth = w - 2*m_borderSize;
int innerHeight = h - 2*m_borderSize;
int screen = DefaultScreen(wxGlobalDisplay());
Window parentWindow;
if (parent)
parentWindow = (Window) parent->GetClientWindow();
else
parentWindow = RootWindow(wxGlobalDisplay(), screen);
Widget window = XCreateSimpleWindow(wxGlobalDisplay(),
x, y, innerWidth, innerHeight, borderWidth,
m_backgroundColour.AllocColour(wxGlobalDisplay()),
m_foregroundColour.AllocColour(wxGlobalDisplay()));
// Select event types wanted
XSelectInput(wxGlobalDisplay(), window,
ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |
ButtonMotionMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask |
KeymapStateMask | FocusChangeMask | ColormapChangeMask | StructureNotifyMask |
PropertyChangeMask);
m_mainWindow = (WXWindow) window;
wxAddWindowToTable(window, (wxWindow*) this);
// If a subwindow, show.
if (parent && !parent->IsKindOf(CLASSINFO(wxTopLevelWindowX11)) && parent->IsShown())
{
m_isShown = TRUE;
XMapWindow(wxGlobalDisplay(), window);
}
// Without this, the cursor may not be restored properly (e.g. in splitter
// sample).
@ -256,8 +302,10 @@ wxWindowX11::~wxWindowX11()
// Destroy the window
if (GetMainWindow())
{
// TODO
// XtDestroyWidget((Widget) GetMainWidget());
XSelectInput(wxGlobalDisplay(), (Window) GetMainWindow(),
NoEventMask);
wxDeleteWindowFromTable((Window) GetMainWindow());
XDestroyWindow((Window) GetMainWindow());
SetMainWindow((WXWindow) NULL);
}
}
@ -400,63 +448,47 @@ void wxWindowX11::DestroyScrollbar(wxOrientation orientation)
void wxWindowX11::SetFocus()
{
// TODO
#if 0
Widget wMain = (Widget) GetMainWidget();
XmProcessTraversal(wMain, XmTRAVERSE_CURRENT);
XmProcessTraversal((Widget) GetMainWidget(), XmTRAVERSE_CURRENT);
#endif
Window wMain = (Window) GetMainWidget();
if (wMain)
{
XSetInputFocus(wxGlobalDisplay(), wMain, RevertToParent, CurrentTime);
XWMHints wmhints;
wmhints.flags = InputHint;
wmhints.input = True;
XSetWMHints(wxGlobalDisplay(), wMain, &wmhints)
}
}
// Get the window with the focus
wxWindow *wxWindowBase::FindFocus()
{
// TODO
return NULL;
#if 0
Window wFocus = (Window) 0;
int revert = 0;
// TODO Problems:
// (1) Can there be multiple focussed widgets in an application?
// In which case we need to find the top-level window that's
// currently active.
// (2) The widget with the focus may not be in the widget table
// depending on which widgets I put in the table
wxWindow *winFocus = (wxWindow *)NULL;
for ( wxWindowList::Node *node = wxTopLevelWindows.GetFirst();
node;
node = node->GetNext() )
XGetInputFocus(wxGlobalDisplay(), & wFocus, & revert);
if (wFocus)
{
wxWindow *win = node->GetData();
Widget w = XmGetFocusWidget ((Widget) win->GetTopWidget());
if (w != (Widget) NULL)
wxWindow *win = NULL;
do
{
winFocus = wxGetWindowFromTable(w);
if ( winFocus )
break;
}
win = wxGetWindowFromTable(wFocus);
wFocus = wxGetWindowParent(wFocus);
} while (wFocus && !win);
return win;
}
return winFocus;
#endif
return NULL;
}
// Enabling/disabling handled by event loop, and not sending events
// if disabled.
bool wxWindowX11::Enable(bool enable)
{
if ( !wxWindowBase::Enable(enable) )
return FALSE;
// TODO
#if 0
Widget wMain = (Widget)GetMainWidget();
if ( wMain )
{
XtSetSensitive(wMain, enable);
XmUpdateDisplay(wMain);
}
#endif
return TRUE;
}
@ -468,9 +500,13 @@ bool wxWindowX11::Show(bool show)
Window xwin = (Window) GetXWindow();
Display *xdisp = (Display*) GetXDisplay();
if (show)
{
XMapWindow(xdisp, xwin);
}
else
{
XUnmapWindow(xdisp, xwin);
}
return TRUE;
}
@ -480,7 +516,7 @@ void wxWindowX11::Raise()
{
Window window = (Window) GetTopWindow();
if (window)
XRaiseWindow((Display*) wxGetDisplay(), window);
XRaiseWindow(wxGlobalDisplay(), window);
}
// Lower the window to the bottom of the Z order
@ -488,25 +524,7 @@ void wxWindowX11::Lower()
{
Window window = (Window) GetTopWindow();
if (window)
XLowerWindow((Display*) wxGetDisplay(), window);
}
void wxWindowX11::SetTitle(const wxString& title)
{
// TODO
// XtVaSetValues((Widget)GetMainWidget(), XmNtitle, title.c_str(), NULL);
}
wxString wxWindowX11::GetTitle() const
{
// TODO
return wxEmptyString;
#if 0
char *title;
XtVaGetValues((Widget)GetMainWidget(), XmNtitle, &title, NULL);
return wxString(title);
#endif
XLowerWindow(wxGlobalDisplay(), window);
}
void wxWindowX11::DoCaptureMouse()
@ -515,14 +533,23 @@ void wxWindowX11::DoCaptureMouse()
if ( m_winCaptured )
return;
// TODO
#if 0
Widget wMain = (Widget)GetMainWidget();
if ( wMain )
XtAddGrab(wMain, TRUE, FALSE);
#endif
// TODO: should we also call XGrabButton, XGrabKeyboard?
if (GetMainWindow())
{
int res = XGrabPointer(wxGlobalDisplay(), (Window) GetMainWindow(),
FALSE,
ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask,
GrabModeAsync,
GrabModeAsync,
None,
None, /* cursor */ // TODO: This may need to be set to the cursor of this window
CurrentTime);
m_winCaptured = TRUE;
if (res == GrabSuccess)
{
m_winCaptured = TRUE;
}
}
}
void wxWindowX11::DoReleaseMouse()
@ -531,12 +558,11 @@ void wxWindowX11::DoReleaseMouse()
if ( !m_winCaptured )
return;
// TODO
#if 0
Widget wMain = (Widget)GetMainWidget();
// TODO: should we also call XUngrabButton, XUngrabKeyboard?
if ( wMain )
XtRemoveGrab(wMain);
#endif
XUngrabPointer(wxGlobalDisplay(), wMain);
m_winCaptured = FALSE;
}
@ -582,7 +608,7 @@ void wxWindowX11::WarpPointer (int x, int y)
{
Window wClient = (Window) GetClientWindow();
XWarpPointer((Display*) wxGetDisplay(), None, wClient, 0, 0, 0, 0, x, y);
XWarpPointer(wxGlobalDisplay(), None, wClient, 0, 0, 0, 0, x, y);
}
// ---------------------------------------------------------------------------
@ -761,7 +787,7 @@ void wxWindowX11::ScrollWindow(int dx, int dy, const wxRect *rect)
dc.SetLogicalFunction (wxCOPY);
Window window = (Window) GetMainWindow();
Display* display = (Display*) wxGetDisplay();
Display* display = wxGlobalDisplay();
XCopyArea(display, window, window, (GC) dc.GetGC(),
x1, y1, w1, h1, x2, y2);
@ -936,50 +962,50 @@ bool wxWindowX11::PreResize()
// Get total size
void wxWindowX11::DoGetSize(int *x, int *y) const
{
// TODO
#if 0
if (m_drawingArea)
Window window = (Window) GetTopWindow();
if (window)
{
CanvasGetSize(x, y);
return;
XWindowAttributes attr;
Status status = XGetWindowAttributes(wxGlobalDisplay(), window, & attr);
wxASSERT(status);
if (status)
{
*x = attr.width + 2*m_borderSize;
*y = attr.height + 2*m_borderSize;
}
}
Widget widget = (Widget) GetTopWidget();
Dimension xx, yy;
XtVaGetValues(widget, XmNwidth, &xx, XmNheight, &yy, NULL);
if(x) *x = xx; if(y) *y = yy;
#endif
}
void wxWindowX11::DoGetPosition(int *x, int *y) const
{
// TODO
#if 0
if (m_drawingArea)
Window window = (Window) GetTopWindow();
if (window)
{
CanvasGetPosition(x, y);
return;
XWindowAttributes attr;
Status status = XGetWindowAttributes(wxGlobalDisplay(), window, & attr);
wxASSERT(status);
if (status)
{
*x = attr.x;
*y = attr.y;
// We may be faking the client origin. So a window that's really at (0, 30)
// may appear (to wxWin apps) to be at (0, 0).
if (GetParent())
{
wxPoint pt(GetParent()->GetClientAreaOrigin());
*x -= pt.x;
*y -= pt.y;
}
}
}
Widget widget = (Widget) GetTopWidget();
Position xx, yy;
XtVaGetValues(widget, XmNx, &xx, XmNy, &yy, NULL);
// We may be faking the client origin. So a window that's really at (0, 30)
// may appear (to wxWin apps) to be at (0, 0).
if (GetParent())
{
wxPoint pt(GetParent()->GetClientAreaOrigin());
xx -= pt.x;
yy -= pt.y;
}
if(x) *x = xx; if(y) *y = yy;
#endif
}
void wxWindowX11::DoScreenToClient(int *x, int *y) const
{
Display *display = (Display*) wxGetDisplay();
Display *display = wxGlobalDisplay();
Window rootWindow = RootWindowOfScreen(DefaultScreenOfDisplay(display));
Window thisWindow = (Window) GetClientWindow();
@ -991,7 +1017,7 @@ void wxWindowX11::DoScreenToClient(int *x, int *y) const
void wxWindowX11::DoClientToScreen(int *x, int *y) const
{
Display *display = (Display*) wxGetDisplay();
Display *display = wxGlobalDisplay();
Window rootWindow = RootWindowOfScreen(DefaultScreenOfDisplay(display));
Window thisWindow = (Window) GetClientWindow();
@ -1005,96 +1031,76 @@ void wxWindowX11::DoClientToScreen(int *x, int *y) const
// Get size *available for subwindows* i.e. excluding menu bar etc.
void wxWindowX11::DoGetClientSize(int *x, int *y) const
{
// TODO
#if 0
Widget widget = (Widget) GetClientWidget();
Dimension xx, yy;
XtVaGetValues(widget, XmNwidth, &xx, XmNheight, &yy, NULL);
if(x) *x = xx; if(y) *y = yy;
#endif
Window window = (Window) GetClientWindow();
if (window)
{
XWindowAttributes attr;
Status status = XGetWindowAttributes(wxGlobalDisplay(), window, & attr);
wxASSERT(status);
if (status)
{
*x = attr.width ;
*y = attr.height ;
}
}
}
void wxWindowX11::DoSetSize(int x, int y, int width, int height, int sizeFlags)
{
// TODO
#if 0
// A bit of optimization to help sort out the flickers.
int oldX, oldY, oldW, oldH;
GetSize(& oldW, & oldH);
GetPosition(& oldX, & oldY);
if (!GetMainWindow())
return;
if ( !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) )
XWindowChanges windowChanges;
int valueMask = 0;
if (x != -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
{
if ( x == -1 )
x = oldX;
if ( y == -1 )
y = oldY;
windowChanges.x = x;
valueMask |= CWX;
}
if ( width == -1 )
width = oldW;
if ( height == -1 )
height = oldH;
bool nothingChanged = (x == oldX) && (y == oldY) &&
(width == oldW) && (height == oldH);
if (!wxNoOptimize::CanOptimize())
if (y != -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
{
nothingChanged = FALSE;
windowChanges.y = y;
valueMask |= CWY;
}
if ( !nothingChanged )
if (width != -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
{
if (m_drawingArea)
{
CanvasSetSize(x, y, width, height, sizeFlags);
return;
}
Widget widget = (Widget) GetTopWidget();
if (!widget)
return;
bool managed = XtIsManaged( widget );
if (managed)
XtUnmanageChild(widget);
int xx = x;
int yy = y;
AdjustForParentClientOrigin(xx, yy, sizeFlags);
DoMoveWindow(xx, yy, width, height);
if (managed)
XtManageChild(widget);
windowChanges.width = width - m_borderSize*2;
valueMask |= CWWidth;
}
#endif
if (height != -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
{
windowChanges.height = height - m_borderSize*2;
valueMask |= CWHeight;
}
AdjustForParentClientOrigin(valueMask.x, valueMask.y, sizeFlags);
XConfigureWindow(wxGlobalDisplay(), (Window) GetMainWindow(),
valueMask, & windowChanges);
}
void wxWindowX11::DoSetClientSize(int width, int height)
{
// TODO
#if 0
if (m_drawingArea)
{
CanvasSetClientSize(width, height);
if (!GetMainWindow())
return;
XWindowChanges windowChanges;
int valueMask = 0;
if (width != -1)
{
windowChanges.width = width ;
valueMask |= CWWidth;
}
Widget widget = (Widget) GetTopWidget();
if (width > -1)
XtVaSetValues(widget, XmNwidth, width, NULL);
if (height > -1)
XtVaSetValues(widget, XmNheight, height, NULL);
wxSizeEvent sizeEvent(wxSize(width, height), GetId());
sizeEvent.SetEventObject(this);
GetEventHandler()->ProcessEvent(sizeEvent);
#endif
if (height != -1)
{
windowChanges.height = height ;
valueMask |= CWHeight;
}
XConfigureWindow(wxGlobalDisplay(), (Window) GetMainWindow(),
valueMask, & windowChanges);
}
// For implementation purposes - sometimes decorations make the client area
@ -1117,48 +1123,39 @@ void wxWindowX11::AdjustForParentClientOrigin(int& x, int& y, int sizeFlags)
void wxWindowX11::SetSizeHints(int minW, int minH, int maxW, int maxH, int incW, int incH)
{
// TODO
#if 0
m_minWidth = minW;
m_minHeight = minH;
m_maxWidth = maxW;
m_maxHeight = maxH;
wxFrame *frame = wxDynamicCast(this, wxFrame);
if ( !frame )
XSizeHints sizeHints;
sizeHints.flags = 0;
if (minW > -1 && minH > -1)
{
// TODO what about dialogs?
return;
sizeHints.flags |= PMinSize;
sizeHints.min_width = minW;
sizeHints.min_height = minH;
}
if (maxW > -1 && maxH > -1)
{
sizeHints.flags |= PMaxSize;
sizeHints.max_width = maxW;
sizeHints.max_height = maxH;
}
if (incW > -1 && incH > -1)
{
sizeHints.flags |= PResizeInc;
sizeHints.width_inc = incW;
sizeHints.height_inc = incH;
}
Widget widget = (Widget) frame->GetShellWidget();
if (minW > -1)
XtVaSetValues(widget, XmNminWidth, minW, NULL);
if (minH > -1)
XtVaSetValues(widget, XmNminHeight, minH, NULL);
if (maxW > -1)
XtVaSetValues(widget, XmNmaxWidth, maxW, NULL);
if (maxH > -1)
XtVaSetValues(widget, XmNmaxHeight, maxH, NULL);
if (incW > -1)
XtVaSetValues(widget, XmNwidthInc, incW, NULL);
if (incH > -1)
XtVaSetValues(widget, XmNheightInc, incH, NULL);
#endif
XSetWMNormalHints(wxGlobalDisplay(), (Window) GetMainWindow(), & sizeHints)
}
void wxWindowX11::DoMoveWindow(int x, int y, int width, int height)
{
// TODO
#if 0
XtVaSetValues((Widget)GetTopWidget(),
XmNx, x,
XmNy, y,
XmNwidth, width,
XmNheight, height,
NULL);
#endif
DoSetSize(x, y, width, height);
}
// ---------------------------------------------------------------------------
@ -1238,7 +1235,7 @@ void wxWindowX11::GetTextExtent(const wxString& string,
void wxWindowX11::Refresh(bool eraseBack, const wxRect *rect)
{
m_needsRefresh = TRUE;
Display *display = (Display*) wxGetDisplay();
Display *display = wxGlobalDisplay();
Window thisWindow = (Window) GetMainWindow();
XExposeEvent dummyEvent;
@ -1451,72 +1448,6 @@ void wxDeleteWindowFromTable(Window w)
// add/remove window from the table
// ----------------------------------------------------------------------------
// Add to hash table, add event handler
bool wxWindowX11::AttachWindow (wxWindow* WXUNUSED(parent), WXWindow mainWidget,
int x, int y, int width, int height)
{
wxAddWindowToTable((Window ) mainWidget, (wxWindow*) this);
// TODO
#if 0
if (CanAddEventHandler())
{
XtAddEventHandler((Widget) mainWidget,
ButtonPressMask | ButtonReleaseMask | PointerMotionMask, // | KeyPressMask,
False,
wxPanelItemEventHandler,
(XtPointer) this);
}
if (!formWidget)
{
XtTranslations ptr;
XtOverrideTranslations ((Widget) mainWidget,
ptr = XtParseTranslationTable ("<Configure>: resize()"));
XtFree ((char *) ptr);
}
// Some widgets have a parent form widget, e.g. wxRadioBox
if (formWidget)
{
if (!wxAddWindowToTable((Widget) formWidget, this))
return FALSE;
XtTranslations ptr;
XtOverrideTranslations ((Widget) formWidget,
ptr = XtParseTranslationTable ("<Configure>: resize()"));
XtFree ((char *) ptr);
}
#endif
if (x == -1)
x = 0;
if (y == -1)
y = 0;
SetSize (x, y, width, height);
return TRUE;
}
// Remove event handler, remove from hash table
bool wxWindowX11::DetachWindow(WXWindow widget)
{
// TODO
#if 0
if (CanAddEventHandler())
{
XtRemoveEventHandler((Widget) widget,
ButtonPressMask | ButtonReleaseMask | PointerMotionMask, // | KeyPressMask,
False,
wxPanelItemEventHandler,
(XtPointer)this);
}
#endif
wxDeleteWindowFromTable((Window) widget);
return TRUE;
}
// ----------------------------------------------------------------------------
// X11-specific accessors
// ----------------------------------------------------------------------------
@ -1632,213 +1563,6 @@ static void wxScrollBarCallback(Widget scrollbar,
}
#endif
// ----------------------------------------------------------------------------
// CanvaseXXXSize() functions
// ----------------------------------------------------------------------------
// SetSize, but as per old wxCanvas (with drawing widget etc.)
void wxWindowX11::CanvasSetSize (int x, int y, int w, int h, int sizeFlags)
{
// TODO
#if 0
// A bit of optimization to help sort out the flickers.
int oldX, oldY, oldW, oldH;
GetSize(& oldW, & oldH);
GetPosition(& oldX, & oldY);
bool useOldPos = FALSE;
bool useOldSize = FALSE;
if ((x == -1) && (x == -1) && ((sizeFlags & wxSIZE_ALLOW_MINUS_ONE) == 0))
useOldPos = TRUE;
else if (x == oldX && y == oldY)
useOldPos = TRUE;
if ((w == -1) && (h == -1))
useOldSize = TRUE;
else if (w == oldW && h == oldH)
useOldSize = TRUE;
if (!wxNoOptimize::CanOptimize())
{
useOldSize = FALSE; useOldPos = FALSE;
}
if (useOldPos && useOldSize)
return;
Widget drawingArea = (Widget) m_drawingArea;
bool managed = XtIsManaged(m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow);
if (managed)
XtUnmanageChild (m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow);
XtVaSetValues(drawingArea, XmNresizePolicy, XmRESIZE_ANY, NULL);
int xx = x; int yy = y;
AdjustForParentClientOrigin(xx, yy, sizeFlags);
if (!useOldPos)
{
if (x > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
{
XtVaSetValues (m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow,
XmNx, xx, NULL);
}
if (y > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
{
XtVaSetValues (m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow,
XmNy, yy, NULL);
}
}
if (!useOldSize)
{
if (w > -1)
{
if (m_borderWidget)
{
XtVaSetValues ((Widget) m_borderWidget, XmNwidth, w, NULL);
short thick, margin;
XtVaGetValues ((Widget) m_borderWidget,
XmNshadowThickness, &thick,
XmNmarginWidth, &margin,
NULL);
w -= 2 * (thick + margin);
}
XtVaSetValues ((Widget) m_scrolledWindow, XmNwidth, w, NULL);
Dimension spacing;
Widget sbar;
XtVaGetValues ((Widget) m_scrolledWindow,
XmNspacing, &spacing,
XmNverticalScrollBar, &sbar,
NULL);
Dimension wsbar;
if (sbar)
XtVaGetValues (sbar, XmNwidth, &wsbar, NULL);
else
wsbar = 0;
w -= (spacing + wsbar);
#if 0
XtVaSetValues(drawingArea, XmNwidth, w, NULL);
#endif // 0
}
if (h > -1)
{
if (m_borderWidget)
{
XtVaSetValues ((Widget) m_borderWidget, XmNheight, h, NULL);
short thick, margin;
XtVaGetValues ((Widget) m_borderWidget,
XmNshadowThickness, &thick,
XmNmarginHeight, &margin,
NULL);
h -= 2 * (thick + margin);
}
XtVaSetValues ((Widget) m_scrolledWindow, XmNheight, h, NULL);
Dimension spacing;
Widget sbar;
XtVaGetValues ((Widget) m_scrolledWindow,
XmNspacing, &spacing,
XmNhorizontalScrollBar, &sbar,
NULL);
Dimension wsbar;
if (sbar)
XtVaGetValues (sbar, XmNheight, &wsbar, NULL);
else
wsbar = 0;
h -= (spacing + wsbar);
#if 0
XtVaSetValues(drawingArea, XmNheight, h, NULL);
#endif // 0
}
}
if (managed)
XtManageChild (m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow);
XtVaSetValues(drawingArea, XmNresizePolicy, XmRESIZE_NONE, NULL);
#endif
// 0
}
void wxWindowX11::CanvasSetClientSize (int w, int h)
{
// TODO
#if 0
Widget drawingArea = (Widget) m_drawingArea;
XtVaSetValues(drawingArea, XmNresizePolicy, XmRESIZE_ANY, NULL);
if (w > -1)
XtVaSetValues(drawingArea, XmNwidth, w, NULL);
if (h > -1)
XtVaSetValues(drawingArea, XmNheight, h, NULL);
XtVaSetValues(drawingArea, XmNresizePolicy, XmRESIZE_NONE, NULL);
#endif // 0
}
void wxWindowX11::CanvasGetClientSize (int *w, int *h) const
{
// TODO
#if 0
// Must return the same thing that was set via SetClientSize
Dimension xx, yy;
XtVaGetValues ((Widget) m_drawingArea, XmNwidth, &xx, XmNheight, &yy, NULL);
*w = xx;
*h = yy;
#endif
}
void wxWindowX11::CanvasGetSize (int *w, int *h) const
{
// TODO
#if 0
Dimension xx, yy;
if ((Widget) m_borderWidget)
XtVaGetValues ((Widget) m_borderWidget, XmNwidth, &xx, XmNheight, &yy, NULL);
else if ((Widget) m_scrolledWindow)
XtVaGetValues ((Widget) m_scrolledWindow, XmNwidth, &xx, XmNheight, &yy, NULL);
else
XtVaGetValues ((Widget) m_drawingArea, XmNwidth, &xx, XmNheight, &yy, NULL);
*w = xx;
*h = yy;
#endif
}
void wxWindowX11::CanvasGetPosition (int *x, int *y) const
{
// TODO
#if 0
Position xx, yy;
XtVaGetValues (m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow, XmNx, &xx, XmNy, &yy, NULL);
// We may be faking the client origin.
// So a window that's really at (0, 30) may appear
// (to wxWin apps) to be at (0, 0).
if (GetParent())
{
wxPoint pt(GetParent()->GetClientAreaOrigin());
xx -= pt.x;
yy -= pt.y;
}
*x = xx;
*y = yy;
#endif
}
// ----------------------------------------------------------------------------
// TranslateXXXEvent() functions
// ----------------------------------------------------------------------------
@ -1898,7 +1622,7 @@ bool wxTranslateMouseEvent(wxMouseEvent& wxevent, wxWindow *win, Window window,
// check for a double click
// TODO: where can we get this value from?
//long dclickTime = XtGetMultiClickTime((Display*) wxGetDisplay());
//long dclickTime = XtGetMultiClickTime(wxGlobalDisplay());
long dclickTime = 200;
long ts = wxevent.GetTimestamp();
@ -2227,7 +1951,7 @@ wxWindow* wxFindWindowAtPointer(wxPoint& pt)
// Get the current mouse position.
wxPoint wxGetMousePosition()
{
Display *display = (Display*) wxGetDisplay();
Display *display = wxGlobalDisplay();
Window rootWindow = RootWindowOfScreen (DefaultScreenOfDisplay(display));
Window rootReturn, childReturn;
int rootX, rootY, winX, winY;