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:
@@ -66,6 +66,11 @@ extern int wxComputeColours (Display *display, wxColour * back, wxColour * fore)
|
|||||||
extern void wxDoChangeForegroundColour(WXWidget widget, wxColour& foregroundColour);
|
extern void wxDoChangeForegroundColour(WXWidget widget, wxColour& foregroundColour);
|
||||||
extern void wxDoChangeBackgroundColour(WXWidget widget, wxColour& backgroundColour, bool changeArmColour = FALSE);
|
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 wxNO_COLORS 0x00
|
||||||
#define wxBACK_COLORS 0x01
|
#define wxBACK_COLORS 0x01
|
||||||
#define wxFORE_COLORS 0x02
|
#define wxFORE_COLORS 0x02
|
||||||
|
@@ -1,44 +1,49 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: timer.h
|
// Name: timer.h
|
||||||
// Purpose: wxTimer class
|
// Purpose: wxTimer class
|
||||||
// Author: Julian Smart
|
// Author: Vaclav Slavik
|
||||||
// Modified by:
|
// Id: $Id$
|
||||||
// Created: 17/09/98
|
// Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
|
||||||
// RCS-ID: $Id$
|
// Licence: wxWindows licence
|
||||||
// Copyright: (c) Julian Smart
|
|
||||||
// Licence: wxWindows licence
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifndef _WX_TIMER_H_
|
|
||||||
#define _WX_TIMER_H_
|
#ifndef __WX_TIMER_H__
|
||||||
|
#define __WX_TIMER_H__
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma interface "timer.h"
|
#pragma interface "timer.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// wxTimer
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class wxTimerDesc;
|
||||||
|
|
||||||
class WXDLLEXPORT wxTimer : public wxTimerBase
|
class WXDLLEXPORT wxTimer : public wxTimerBase
|
||||||
{
|
{
|
||||||
friend void wxTimerCallback(wxTimer * timer);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wxTimer() { Init(); }
|
wxTimer() { Init(); }
|
||||||
wxTimer(wxEvtHandler *owner, int id = -1) : wxTimerBase(owner, id)
|
wxTimer(wxEvtHandler *owner, int id = -1) : wxTimerBase(owner, id)
|
||||||
{ Init(); }
|
{ Init(); }
|
||||||
~wxTimer();
|
~wxTimer();
|
||||||
|
|
||||||
virtual bool Start(int milliseconds = -1, bool oneShot = FALSE);
|
virtual bool Start(int millisecs = -1, bool oneShot = FALSE);
|
||||||
virtual void Stop();
|
virtual void Stop();
|
||||||
|
|
||||||
virtual bool IsRunning() const { return m_id != 0; }
|
virtual bool IsRunning() const;
|
||||||
|
|
||||||
|
// implementation
|
||||||
|
static void NotifyTimers();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
long m_id;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_DYNAMIC_CLASS(wxTimer)
|
wxTimerDesc *m_desc;
|
||||||
|
|
||||||
|
DECLARE_ABSTRACT_CLASS(wxTimer)
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // __WX_TIMER_H__
|
||||||
// _WX_TIMER_H_
|
|
||||||
|
@@ -62,6 +62,9 @@ public:
|
|||||||
virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
|
virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
|
||||||
virtual bool IsFullScreen() const { return m_fsIsShowing; }
|
virtual bool IsFullScreen() const { return m_fsIsShowing; }
|
||||||
|
|
||||||
|
virtual void SetTitle( const wxString& title);
|
||||||
|
virtual wxString GetTitle() const;
|
||||||
|
|
||||||
// implementation from now on
|
// implementation from now on
|
||||||
// --------------------------
|
// --------------------------
|
||||||
|
|
||||||
@@ -92,6 +95,7 @@ protected:
|
|||||||
wxRect m_fsOldSize;
|
wxRect m_fsOldSize;
|
||||||
bool m_fsIsMaximized;
|
bool m_fsIsMaximized;
|
||||||
bool m_fsIsShowing;
|
bool m_fsIsShowing;
|
||||||
|
wxString m_title;
|
||||||
};
|
};
|
||||||
|
|
||||||
// list of all frames and modeless dialogs
|
// list of all frames and modeless dialogs
|
||||||
|
@@ -50,10 +50,6 @@ public:
|
|||||||
long style = 0,
|
long style = 0,
|
||||||
const wxString& name = wxPanelNameStr);
|
const wxString& name = wxPanelNameStr);
|
||||||
|
|
||||||
// implement base class pure virtuals
|
|
||||||
virtual void SetTitle( const wxString& title);
|
|
||||||
virtual wxString GetTitle() const;
|
|
||||||
|
|
||||||
virtual void Raise();
|
virtual void Raise();
|
||||||
virtual void Lower();
|
virtual void Lower();
|
||||||
|
|
||||||
@@ -185,15 +181,6 @@ protected:
|
|||||||
// Responds to colour changes: passes event on to children.
|
// Responds to colour changes: passes event on to children.
|
||||||
void OnSysColourChanged(wxSysColourChangedEvent& event);
|
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; }
|
void SetMainWindow(WXWindow w) { m_mainWidget = w; }
|
||||||
|
|
||||||
bool CanAddEventHandler() const { return m_canAddEventHandler; }
|
bool CanAddEventHandler() const { return m_canAddEventHandler; }
|
||||||
@@ -217,11 +204,6 @@ public:
|
|||||||
virtual void ChangeForegroundColour();
|
virtual void ChangeForegroundColour();
|
||||||
|
|
||||||
protected:
|
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
|
// How to implement accelerators. If we find a key event, translate to
|
||||||
// wxWindows wxKeyEvent form. Find a widget for the window. Now find a
|
// 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
|
// wxWindow for the widget. If there isn't one, go up the widget hierarchy
|
||||||
@@ -295,6 +277,9 @@ protected:
|
|||||||
int m_scrollPosX;
|
int m_scrollPosX;
|
||||||
int m_scrollPosY;
|
int m_scrollPosY;
|
||||||
|
|
||||||
|
// Window border size
|
||||||
|
int m_borderSize;
|
||||||
|
|
||||||
// implement the base class pure virtuals
|
// implement the base class pure virtuals
|
||||||
virtual void DoClientToScreen( int *x, int *y ) const;
|
virtual void DoClientToScreen( int *x, int *y ) const;
|
||||||
virtual void DoScreenToClient( int *x, int *y ) const;
|
virtual void DoScreenToClient( int *x, int *y ) const;
|
||||||
|
@@ -21,8 +21,6 @@
|
|||||||
#include "wx/brush.h"
|
#include "wx/brush.h"
|
||||||
#include "wx/cursor.h"
|
#include "wx/cursor.h"
|
||||||
#include "wx/icon.h"
|
#include "wx/icon.h"
|
||||||
#include "wx/palette.h"
|
|
||||||
#include "wx/dc.h"
|
|
||||||
#include "wx/dialog.h"
|
#include "wx/dialog.h"
|
||||||
#include "wx/msgdlg.h"
|
#include "wx/msgdlg.h"
|
||||||
#include "wx/log.h"
|
#include "wx/log.h"
|
||||||
@@ -73,8 +71,6 @@ typedef int (*XErrorHandlerFunc)(Display *, XErrorEvent *);
|
|||||||
|
|
||||||
XErrorHandlerFunc gs_pfnXErrorHandler = 0;
|
XErrorHandlerFunc gs_pfnXErrorHandler = 0;
|
||||||
|
|
||||||
static Window XGetParent(Window window);
|
|
||||||
|
|
||||||
static int wxXErrorHandler(Display *dpy, XErrorEvent *xevent)
|
static int wxXErrorHandler(Display *dpy, XErrorEvent *xevent)
|
||||||
{
|
{
|
||||||
// just forward to the default handler for now
|
// 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
|
// TODO: may need to translate coordinates from actualWindow
|
||||||
// to window, if the receiving window != wxWindow window
|
// to window, if the receiving window != wxWindow window
|
||||||
while (window && !(win = wxGetWindowFromTable(window)))
|
while (window && !(win = wxGetWindowFromTable(window)))
|
||||||
window = XGetParent(window);
|
window = wxGetParentWindow(window);
|
||||||
|
|
||||||
// TODO: shouldn't all the ProcessEvents below
|
// TODO: shouldn't all the ProcessEvents below
|
||||||
// be win->GetEventHandler()->ProcessEvent?
|
// be win->GetEventHandler()->ProcessEvent?
|
||||||
@@ -306,6 +302,9 @@ void wxApp::ProcessXEvent(WXEvent* _event)
|
|||||||
{
|
{
|
||||||
case KeyPress:
|
case KeyPress:
|
||||||
{
|
{
|
||||||
|
if (win && !win->IsEnabled())
|
||||||
|
return;
|
||||||
|
|
||||||
if (CheckForAccelerator(_event))
|
if (CheckForAccelerator(_event))
|
||||||
{
|
{
|
||||||
// Do nothing! We intercepted and processed the event as an
|
// 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
|
// We didn't process wxEVT_KEY_DOWN, so send
|
||||||
// wxEVT_CHAR
|
// wxEVT_CHAR
|
||||||
if (!win->ProcessEvent( keyEvent ))
|
if (!win->GetEventHandler()->ProcessEvent( keyEvent ))
|
||||||
{
|
{
|
||||||
keyEvent.SetEventType(wxEVT_CHAR);
|
keyEvent.SetEventType(wxEVT_CHAR);
|
||||||
win->ProcessEvent( keyEvent );
|
win->GetEventHandler()->ProcessEvent( keyEvent );
|
||||||
}
|
}
|
||||||
|
|
||||||
// We intercepted and processed the key down event
|
// We intercepted and processed the key down event
|
||||||
@@ -335,12 +334,15 @@ void wxApp::ProcessXEvent(WXEvent* _event)
|
|||||||
}
|
}
|
||||||
case KeyRelease:
|
case KeyRelease:
|
||||||
{
|
{
|
||||||
|
if (win && !win->IsEnabled())
|
||||||
|
return;
|
||||||
|
|
||||||
if (win)
|
if (win)
|
||||||
{
|
{
|
||||||
wxKeyEvent keyEvent(wxEVT_KEY_UP);
|
wxKeyEvent keyEvent(wxEVT_KEY_UP);
|
||||||
wxTranslateKeyEvent(keyEvent, win, window, event);
|
wxTranslateKeyEvent(keyEvent, win, window, event);
|
||||||
|
|
||||||
win->ProcessEvent( keyEvent );
|
win->GetEventHandler()->ProcessEvent( keyEvent );
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -349,6 +351,23 @@ void wxApp::ProcessXEvent(WXEvent* _event)
|
|||||||
HandlePropertyChange(_event);
|
HandlePropertyChange(_event);
|
||||||
return;
|
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:
|
case ResizeRequest:
|
||||||
{
|
{
|
||||||
/* Terry Gitnick <terryg@scientech.com> - 1/21/98
|
/* Terry Gitnick <terryg@scientech.com> - 1/21/98
|
||||||
@@ -372,7 +391,7 @@ void wxApp::ProcessXEvent(WXEvent* _event)
|
|||||||
wxSizeEvent sizeEvent(sz, win->GetId());
|
wxSizeEvent sizeEvent(sz, win->GetId());
|
||||||
sizeEvent.SetEventObject(win);
|
sizeEvent.SetEventObject(win);
|
||||||
|
|
||||||
win->ProcessEvent( sizeEvent );
|
win->GetEventHandler()->ProcessEvent( sizeEvent );
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -399,11 +418,14 @@ void wxApp::ProcessXEvent(WXEvent* _event)
|
|||||||
case ButtonRelease:
|
case ButtonRelease:
|
||||||
case MotionNotify:
|
case MotionNotify:
|
||||||
{
|
{
|
||||||
|
if (win && !win->IsEnabled())
|
||||||
|
return;
|
||||||
|
|
||||||
if (win)
|
if (win)
|
||||||
{
|
{
|
||||||
wxMouseEvent wxevent;
|
wxMouseEvent wxevent;
|
||||||
wxTranslateMouseEvent(wxevent, win, window, event);
|
wxTranslateMouseEvent(wxevent, win, window, event);
|
||||||
win->ProcessEvent( wxevent );
|
win->GetEventHandler()->ProcessEvent( wxevent );
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -413,7 +435,7 @@ void wxApp::ProcessXEvent(WXEvent* _event)
|
|||||||
{
|
{
|
||||||
wxFocusEvent focusEvent(wxEVT_SET_FOCUS, win->GetId());
|
wxFocusEvent focusEvent(wxEVT_SET_FOCUS, win->GetId());
|
||||||
focusEvent.SetEventObject(win);
|
focusEvent.SetEventObject(win);
|
||||||
win->ProcessEvent(focusEvent);
|
win->GetEventHandler()->ProcessEvent(focusEvent);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -423,10 +445,16 @@ void wxApp::ProcessXEvent(WXEvent* _event)
|
|||||||
{
|
{
|
||||||
wxFocusEvent focusEvent(wxEVT_KILL_FOCUS, win->GetId());
|
wxFocusEvent focusEvent(wxEVT_KILL_FOCUS, win->GetId());
|
||||||
focusEvent.SetEventObject(win);
|
focusEvent.SetEventObject(win);
|
||||||
win->ProcessEvent(focusEvent);
|
win->GetEventHandler()->ProcessEvent(focusEvent);
|
||||||
}
|
}
|
||||||
break;
|
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:
|
default:
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
@@ -622,7 +650,7 @@ WXColormap wxApp::GetMainColormap(WXDisplay* display)
|
|||||||
return (WXColormap) c;
|
return (WXColormap) c;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Window XGetParent(Window window)
|
Window wxGetWindowParent(Window window)
|
||||||
{
|
{
|
||||||
Window parent, root = 0;
|
Window parent, root = 0;
|
||||||
unsigned int noChildren = 0;
|
unsigned int noChildren = 0;
|
||||||
@@ -646,7 +674,7 @@ bool wxApp::CheckForAccelerator(WXEvent* event)
|
|||||||
|
|
||||||
// Find the first wxWindow that corresponds to this event window
|
// Find the first wxWindow that corresponds to this event window
|
||||||
while (window && !(win = wxGetWindowFromTable(window)))
|
while (window && !(win = wxGetWindowFromTable(window)))
|
||||||
window = XGetParent(window);
|
window = wxGetWindowParent(window);
|
||||||
|
|
||||||
if (!window || !win)
|
if (!window || !win)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@@ -28,6 +28,7 @@
|
|||||||
#if wxUSE_THREADS
|
#if wxUSE_THREADS
|
||||||
#include "wx/thread.h"
|
#include "wx/thread.h"
|
||||||
#endif
|
#endif
|
||||||
|
#include "wx/timer.h"
|
||||||
#include "wx/x11/private.h"
|
#include "wx/x11/private.h"
|
||||||
#include "X11/Xlib.h"
|
#include "X11/Xlib.h"
|
||||||
|
|
||||||
@@ -162,6 +163,7 @@ int wxEventLoop::Run()
|
|||||||
// anything else to do
|
// anything else to do
|
||||||
while ( ! Pending() )
|
while ( ! Pending() )
|
||||||
{
|
{
|
||||||
|
wxTimer::NotifyTimers(); // TODO: is this the correct place for it?
|
||||||
if (!m_impl->SendIdleEvent())
|
if (!m_impl->SendIdleEvent())
|
||||||
{
|
{
|
||||||
#if 0 // wxUSE_THREADS
|
#if 0 // wxUSE_THREADS
|
||||||
|
@@ -1,100 +1,214 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: timer.cpp
|
// Name: x11/timer.cpp
|
||||||
// Purpose: wxTimer implementation
|
// Purpose: wxTimer implementation
|
||||||
// Author: Julian Smart
|
// Author: Vaclav Slavik
|
||||||
// Modified by:
|
// Id: $Id$
|
||||||
// Created: 17/09/98
|
// Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
|
||||||
// RCS-ID: $Id$
|
// Licence: wxWindows licence
|
||||||
// Copyright: (c) Julian Smart
|
|
||||||
// Licence: wxWindows licence
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma implementation "timer.h"
|
#pragma implementation "timer.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// For compilers that support precompilation, includes "wx.h".
|
||||||
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
|
#ifdef __BORLANDC__
|
||||||
|
#pragma hdrstop
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "wx/timer.h"
|
#include "wx/timer.h"
|
||||||
#include "wx/app.h"
|
|
||||||
#include "wx/list.h"
|
|
||||||
|
|
||||||
#ifdef __VMS__
|
#if wxUSE_TIMER
|
||||||
#pragma message disable nosimpint
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __VMS__
|
|
||||||
#pragma message enable nosimpint
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
#include "wx/log.h"
|
||||||
|
#include "wx/module.h"
|
||||||
#include "wx/x11/private.h"
|
#include "wx/x11/private.h"
|
||||||
|
|
||||||
IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxObject)
|
// ----------------------------------------------------------------------------
|
||||||
|
// helper structures and wxTimerScheduler
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
static wxList wxTimerList(wxKEY_INTEGER);
|
class wxTimerDesc
|
||||||
|
|
||||||
void wxTimerCallback (wxTimer * timer)
|
|
||||||
{
|
{
|
||||||
// Check to see if it's still on
|
public:
|
||||||
if (!wxTimerList.Find((long)timer))
|
wxTimerDesc(wxTimer *t) :
|
||||||
return;
|
timer(t), running(FALSE), next(NULL), prev(NULL),
|
||||||
|
shotTime(0), deleteFlag(NULL) {}
|
||||||
|
|
||||||
if (timer->m_id == 0)
|
wxTimer *timer;
|
||||||
return; // Avoid to process spurious timer events
|
bool running;
|
||||||
|
wxTimerDesc *next, *prev;
|
||||||
|
unsigned long shotTime;
|
||||||
|
volatile bool *deleteFlag; // see comment in ~wxTimer
|
||||||
|
};
|
||||||
|
|
||||||
// TODO
|
class wxTimerScheduler
|
||||||
#if 0
|
{
|
||||||
if (!timer->m_oneShot)
|
public:
|
||||||
timer->m_id = XtAppAddTimeOut((XtAppContext) wxTheApp->GetAppContext(),
|
wxTimerScheduler() : m_timers(NULL) {}
|
||||||
timer->m_milli,
|
|
||||||
(XtTimerCallbackProc) wxTimerCallback,
|
|
||||||
(XtPointer) timer);
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
timer->m_id = 0;
|
|
||||||
|
|
||||||
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()
|
void wxTimer::Init()
|
||||||
{
|
{
|
||||||
m_id = 0;
|
if ( !gs_scheduler )
|
||||||
m_milli = 1000;
|
gs_scheduler = new wxTimerScheduler;
|
||||||
|
m_desc = new wxTimerDesc(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxTimer::~wxTimer()
|
wxTimer::~wxTimer()
|
||||||
{
|
{
|
||||||
wxTimer::Stop();
|
wxLogTrace("mgl_timer", "destroying timer %p...", this);
|
||||||
wxTimerList.DeleteObject(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))
|
if ( !wxTimerBase::Start(millisecs, oneShot) )
|
||||||
wxTimerList.Append((long)this, this);
|
return FALSE;
|
||||||
// TODO
|
|
||||||
#if 0
|
gs_scheduler->QueueTimer(m_desc);
|
||||||
m_id = XtAppAddTimeOut((XtAppContext) wxTheApp->GetAppContext(),
|
|
||||||
m_milli,
|
|
||||||
(XtTimerCallbackProc) wxTimerCallback,
|
|
||||||
(XtPointer) this);
|
|
||||||
#endif
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTimer::Stop()
|
void wxTimer::Stop()
|
||||||
{
|
{
|
||||||
if (m_id > 0)
|
if ( !m_desc->running ) return;
|
||||||
{
|
|
||||||
// TODO
|
gs_scheduler->RemoveTimer(m_desc);
|
||||||
#if 0
|
}
|
||||||
XtRemoveTimeOut (m_id);
|
|
||||||
#endif
|
/*static*/ void wxTimer::NotifyTimers()
|
||||||
m_id = 0;
|
{
|
||||||
}
|
if ( gs_scheduler )
|
||||||
m_milli = 0 ;
|
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
|
||||||
|
@@ -38,6 +38,14 @@
|
|||||||
#endif //WX_PRECOMP
|
#endif //WX_PRECOMP
|
||||||
|
|
||||||
#include "wx/x11/private.h"
|
#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
|
// globals
|
||||||
@@ -99,8 +107,12 @@ bool wxTopLevelWindowX11::Create(wxWindow *parent,
|
|||||||
|
|
||||||
wxTopLevelWindows.Append(this);
|
wxTopLevelWindows.Append(this);
|
||||||
|
|
||||||
if ( parent )
|
Atom wm_delete_window = XInternAtom(wxGlobalDisplay(), "WM_DELETE_WINDOW", False);
|
||||||
parent->AddChild(this);
|
|
||||||
|
XSetWMProtocols(wxGlobalDisplay(), (Window) GetMainWindow(), &wm_delete_window, 1);
|
||||||
|
SetWMDecorations((Window) GetMainWindow(), style);
|
||||||
|
|
||||||
|
SetTitle(title);
|
||||||
|
|
||||||
if ( GetExtraStyle() & wxTOPLEVEL_EX_DIALOG )
|
if ( GetExtraStyle() & wxTOPLEVEL_EX_DIALOG )
|
||||||
{
|
{
|
||||||
@@ -141,9 +153,7 @@ bool wxTopLevelWindowX11::Show(bool show)
|
|||||||
if ( !wxWindowBase::Show(show) )
|
if ( !wxWindowBase::Show(show) )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
// TODO
|
return wxWindowX11::Show(show);
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -163,18 +173,27 @@ bool wxTopLevelWindowX11::IsMaximized() const
|
|||||||
|
|
||||||
void wxTopLevelWindowX11::Iconize(bool iconize)
|
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
|
bool wxTopLevelWindowX11::IsIconized() const
|
||||||
{
|
{
|
||||||
// TODO
|
|
||||||
return m_iconized;
|
return m_iconized;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTopLevelWindowX11::Restore()
|
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
|
// this sets m_icon
|
||||||
wxTopLevelWindowBase::SetIcon(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);
|
||||||
|
}
|
||||||
|
|
@@ -99,6 +99,7 @@ void wxWindowX11::Init()
|
|||||||
InitBase();
|
InitBase();
|
||||||
|
|
||||||
// X11-specific
|
// X11-specific
|
||||||
|
// TODO: prune those that are no longer needed
|
||||||
m_needsRefresh = TRUE;
|
m_needsRefresh = TRUE;
|
||||||
m_mainWidget = (WXWindow) 0;
|
m_mainWidget = (WXWindow) 0;
|
||||||
|
|
||||||
@@ -133,6 +134,8 @@ void wxWindowX11::Init()
|
|||||||
m_lastTS = 0;
|
m_lastTS = 0;
|
||||||
m_lastButton = 0;
|
m_lastButton = 0;
|
||||||
m_canAddEventHandler = FALSE;
|
m_canAddEventHandler = FALSE;
|
||||||
|
|
||||||
|
m_borderSize = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// real construction (Init() must have been called before!)
|
// 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);
|
CreateBase(parent, id, pos, size, style, wxDefaultValidator, name);
|
||||||
|
|
||||||
parent->AddChild(this);
|
if (parent)
|
||||||
|
parent->AddChild(this);
|
||||||
|
|
||||||
m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
|
m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
|
||||||
m_foregroundColour = *wxBLACK;
|
m_foregroundColour = *wxBLACK;
|
||||||
|
|
||||||
|
// TODO: How to create more interesting borders?
|
||||||
|
// Will presumably have to create multiple windows.
|
||||||
if (style & wxSIMPLE_BORDER)
|
if (style & wxSIMPLE_BORDER)
|
||||||
{
|
{
|
||||||
|
m_borderSize = 1;
|
||||||
} else if (style & wxSUNKEN_BORDER)
|
} else if (style & wxSUNKEN_BORDER)
|
||||||
{
|
{
|
||||||
|
m_borderSize = 1;
|
||||||
} else if (style & wxRAISED_BORDER)
|
} 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
|
int innerWidth = w - 2*m_borderSize;
|
||||||
wxAddWindowToTable((Window) m_drawingArea, this);
|
int innerHeight = h - 2*m_borderSize;
|
||||||
wxAddWindowToTable((Window) m_scrolledWindow, this);
|
|
||||||
#endif
|
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
|
// Without this, the cursor may not be restored properly (e.g. in splitter
|
||||||
// sample).
|
// sample).
|
||||||
@@ -256,8 +302,10 @@ wxWindowX11::~wxWindowX11()
|
|||||||
// Destroy the window
|
// Destroy the window
|
||||||
if (GetMainWindow())
|
if (GetMainWindow())
|
||||||
{
|
{
|
||||||
// TODO
|
XSelectInput(wxGlobalDisplay(), (Window) GetMainWindow(),
|
||||||
// XtDestroyWidget((Widget) GetMainWidget());
|
NoEventMask);
|
||||||
|
wxDeleteWindowFromTable((Window) GetMainWindow());
|
||||||
|
XDestroyWindow((Window) GetMainWindow());
|
||||||
SetMainWindow((WXWindow) NULL);
|
SetMainWindow((WXWindow) NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -400,63 +448,47 @@ void wxWindowX11::DestroyScrollbar(wxOrientation orientation)
|
|||||||
|
|
||||||
void wxWindowX11::SetFocus()
|
void wxWindowX11::SetFocus()
|
||||||
{
|
{
|
||||||
// TODO
|
Window wMain = (Window) GetMainWidget();
|
||||||
#if 0
|
if (wMain)
|
||||||
Widget wMain = (Widget) GetMainWidget();
|
{
|
||||||
XmProcessTraversal(wMain, XmTRAVERSE_CURRENT);
|
XSetInputFocus(wxGlobalDisplay(), wMain, RevertToParent, CurrentTime);
|
||||||
XmProcessTraversal((Widget) GetMainWidget(), XmTRAVERSE_CURRENT);
|
|
||||||
#endif
|
XWMHints wmhints;
|
||||||
|
wmhints.flags = InputHint;
|
||||||
|
wmhints.input = True;
|
||||||
|
XSetWMHints(wxGlobalDisplay(), wMain, &wmhints)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the window with the focus
|
// Get the window with the focus
|
||||||
wxWindow *wxWindowBase::FindFocus()
|
wxWindow *wxWindowBase::FindFocus()
|
||||||
{
|
{
|
||||||
// TODO
|
Window wFocus = (Window) 0;
|
||||||
return NULL;
|
int revert = 0;
|
||||||
#if 0
|
|
||||||
|
|
||||||
// TODO Problems:
|
XGetInputFocus(wxGlobalDisplay(), & wFocus, & revert);
|
||||||
// (1) Can there be multiple focussed widgets in an application?
|
if (wFocus)
|
||||||
// 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() )
|
|
||||||
{
|
{
|
||||||
wxWindow *win = node->GetData();
|
wxWindow *win = NULL;
|
||||||
|
do
|
||||||
Widget w = XmGetFocusWidget ((Widget) win->GetTopWidget());
|
|
||||||
|
|
||||||
if (w != (Widget) NULL)
|
|
||||||
{
|
{
|
||||||
winFocus = wxGetWindowFromTable(w);
|
win = wxGetWindowFromTable(wFocus);
|
||||||
if ( winFocus )
|
wFocus = wxGetWindowParent(wFocus);
|
||||||
break;
|
} while (wFocus && !win);
|
||||||
}
|
|
||||||
|
return win;
|
||||||
}
|
}
|
||||||
|
|
||||||
return winFocus;
|
return NULL;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Enabling/disabling handled by event loop, and not sending events
|
||||||
|
// if disabled.
|
||||||
bool wxWindowX11::Enable(bool enable)
|
bool wxWindowX11::Enable(bool enable)
|
||||||
{
|
{
|
||||||
if ( !wxWindowBase::Enable(enable) )
|
if ( !wxWindowBase::Enable(enable) )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
// TODO
|
|
||||||
#if 0
|
|
||||||
Widget wMain = (Widget)GetMainWidget();
|
|
||||||
if ( wMain )
|
|
||||||
{
|
|
||||||
XtSetSensitive(wMain, enable);
|
|
||||||
XmUpdateDisplay(wMain);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -468,9 +500,13 @@ bool wxWindowX11::Show(bool show)
|
|||||||
Window xwin = (Window) GetXWindow();
|
Window xwin = (Window) GetXWindow();
|
||||||
Display *xdisp = (Display*) GetXDisplay();
|
Display *xdisp = (Display*) GetXDisplay();
|
||||||
if (show)
|
if (show)
|
||||||
|
{
|
||||||
XMapWindow(xdisp, xwin);
|
XMapWindow(xdisp, xwin);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
XUnmapWindow(xdisp, xwin);
|
XUnmapWindow(xdisp, xwin);
|
||||||
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -480,7 +516,7 @@ void wxWindowX11::Raise()
|
|||||||
{
|
{
|
||||||
Window window = (Window) GetTopWindow();
|
Window window = (Window) GetTopWindow();
|
||||||
if (window)
|
if (window)
|
||||||
XRaiseWindow((Display*) wxGetDisplay(), window);
|
XRaiseWindow(wxGlobalDisplay(), window);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lower the window to the bottom of the Z order
|
// Lower the window to the bottom of the Z order
|
||||||
@@ -488,25 +524,7 @@ void wxWindowX11::Lower()
|
|||||||
{
|
{
|
||||||
Window window = (Window) GetTopWindow();
|
Window window = (Window) GetTopWindow();
|
||||||
if (window)
|
if (window)
|
||||||
XLowerWindow((Display*) wxGetDisplay(), window);
|
XLowerWindow(wxGlobalDisplay(), 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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWindowX11::DoCaptureMouse()
|
void wxWindowX11::DoCaptureMouse()
|
||||||
@@ -515,14 +533,23 @@ void wxWindowX11::DoCaptureMouse()
|
|||||||
if ( m_winCaptured )
|
if ( m_winCaptured )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// TODO
|
// TODO: should we also call XGrabButton, XGrabKeyboard?
|
||||||
#if 0
|
if (GetMainWindow())
|
||||||
Widget wMain = (Widget)GetMainWidget();
|
{
|
||||||
if ( wMain )
|
int res = XGrabPointer(wxGlobalDisplay(), (Window) GetMainWindow(),
|
||||||
XtAddGrab(wMain, TRUE, FALSE);
|
FALSE,
|
||||||
#endif
|
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()
|
void wxWindowX11::DoReleaseMouse()
|
||||||
@@ -531,12 +558,11 @@ void wxWindowX11::DoReleaseMouse()
|
|||||||
if ( !m_winCaptured )
|
if ( !m_winCaptured )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// TODO
|
|
||||||
#if 0
|
|
||||||
Widget wMain = (Widget)GetMainWidget();
|
Widget wMain = (Widget)GetMainWidget();
|
||||||
|
|
||||||
|
// TODO: should we also call XUngrabButton, XUngrabKeyboard?
|
||||||
if ( wMain )
|
if ( wMain )
|
||||||
XtRemoveGrab(wMain);
|
XUngrabPointer(wxGlobalDisplay(), wMain);
|
||||||
#endif
|
|
||||||
|
|
||||||
m_winCaptured = FALSE;
|
m_winCaptured = FALSE;
|
||||||
}
|
}
|
||||||
@@ -582,7 +608,7 @@ void wxWindowX11::WarpPointer (int x, int y)
|
|||||||
{
|
{
|
||||||
Window wClient = (Window) GetClientWindow();
|
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);
|
dc.SetLogicalFunction (wxCOPY);
|
||||||
|
|
||||||
Window window = (Window) GetMainWindow();
|
Window window = (Window) GetMainWindow();
|
||||||
Display* display = (Display*) wxGetDisplay();
|
Display* display = wxGlobalDisplay();
|
||||||
|
|
||||||
XCopyArea(display, window, window, (GC) dc.GetGC(),
|
XCopyArea(display, window, window, (GC) dc.GetGC(),
|
||||||
x1, y1, w1, h1, x2, y2);
|
x1, y1, w1, h1, x2, y2);
|
||||||
@@ -936,50 +962,50 @@ bool wxWindowX11::PreResize()
|
|||||||
// Get total size
|
// Get total size
|
||||||
void wxWindowX11::DoGetSize(int *x, int *y) const
|
void wxWindowX11::DoGetSize(int *x, int *y) const
|
||||||
{
|
{
|
||||||
// TODO
|
Window window = (Window) GetTopWindow();
|
||||||
#if 0
|
if (window)
|
||||||
if (m_drawingArea)
|
|
||||||
{
|
{
|
||||||
CanvasGetSize(x, y);
|
XWindowAttributes attr;
|
||||||
return;
|
Status status = XGetWindowAttributes(wxGlobalDisplay(), window, & attr);
|
||||||
}
|
wxASSERT(status);
|
||||||
|
|
||||||
Widget widget = (Widget) GetTopWidget();
|
if (status)
|
||||||
Dimension xx, yy;
|
{
|
||||||
XtVaGetValues(widget, XmNwidth, &xx, XmNheight, &yy, NULL);
|
*x = attr.width + 2*m_borderSize;
|
||||||
if(x) *x = xx; if(y) *y = yy;
|
*y = attr.height + 2*m_borderSize;
|
||||||
#endif
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWindowX11::DoGetPosition(int *x, int *y) const
|
void wxWindowX11::DoGetPosition(int *x, int *y) const
|
||||||
{
|
{
|
||||||
// TODO
|
Window window = (Window) GetTopWindow();
|
||||||
#if 0
|
if (window)
|
||||||
if (m_drawingArea)
|
|
||||||
{
|
{
|
||||||
CanvasGetPosition(x, y);
|
XWindowAttributes attr;
|
||||||
return;
|
Status status = XGetWindowAttributes(wxGlobalDisplay(), window, & attr);
|
||||||
}
|
wxASSERT(status);
|
||||||
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)
|
if (status)
|
||||||
// may appear (to wxWin apps) to be at (0, 0).
|
{
|
||||||
if (GetParent())
|
*x = attr.x;
|
||||||
{
|
*y = attr.y;
|
||||||
wxPoint pt(GetParent()->GetClientAreaOrigin());
|
|
||||||
xx -= pt.x;
|
|
||||||
yy -= pt.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(x) *x = xx; if(y) *y = yy;
|
// We may be faking the client origin. So a window that's really at (0, 30)
|
||||||
#endif
|
// may appear (to wxWin apps) to be at (0, 0).
|
||||||
|
if (GetParent())
|
||||||
|
{
|
||||||
|
wxPoint pt(GetParent()->GetClientAreaOrigin());
|
||||||
|
*x -= pt.x;
|
||||||
|
*y -= pt.y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWindowX11::DoScreenToClient(int *x, int *y) const
|
void wxWindowX11::DoScreenToClient(int *x, int *y) const
|
||||||
{
|
{
|
||||||
Display *display = (Display*) wxGetDisplay();
|
Display *display = wxGlobalDisplay();
|
||||||
Window rootWindow = RootWindowOfScreen(DefaultScreenOfDisplay(display));
|
Window rootWindow = RootWindowOfScreen(DefaultScreenOfDisplay(display));
|
||||||
Window thisWindow = (Window) GetClientWindow();
|
Window thisWindow = (Window) GetClientWindow();
|
||||||
|
|
||||||
@@ -991,7 +1017,7 @@ void wxWindowX11::DoScreenToClient(int *x, int *y) const
|
|||||||
|
|
||||||
void wxWindowX11::DoClientToScreen(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 rootWindow = RootWindowOfScreen(DefaultScreenOfDisplay(display));
|
||||||
Window thisWindow = (Window) GetClientWindow();
|
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.
|
// Get size *available for subwindows* i.e. excluding menu bar etc.
|
||||||
void wxWindowX11::DoGetClientSize(int *x, int *y) const
|
void wxWindowX11::DoGetClientSize(int *x, int *y) const
|
||||||
{
|
{
|
||||||
// TODO
|
Window window = (Window) GetClientWindow();
|
||||||
#if 0
|
|
||||||
Widget widget = (Widget) GetClientWidget();
|
if (window)
|
||||||
Dimension xx, yy;
|
{
|
||||||
XtVaGetValues(widget, XmNwidth, &xx, XmNheight, &yy, NULL);
|
XWindowAttributes attr;
|
||||||
if(x) *x = xx; if(y) *y = yy;
|
Status status = XGetWindowAttributes(wxGlobalDisplay(), window, & attr);
|
||||||
#endif
|
wxASSERT(status);
|
||||||
|
|
||||||
|
if (status)
|
||||||
|
{
|
||||||
|
*x = attr.width ;
|
||||||
|
*y = attr.height ;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWindowX11::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
void wxWindowX11::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||||
{
|
{
|
||||||
// TODO
|
if (!GetMainWindow())
|
||||||
#if 0
|
return;
|
||||||
// A bit of optimization to help sort out the flickers.
|
|
||||||
int oldX, oldY, oldW, oldH;
|
|
||||||
GetSize(& oldW, & oldH);
|
|
||||||
GetPosition(& oldX, & oldY);
|
|
||||||
|
|
||||||
if ( !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) )
|
XWindowChanges windowChanges;
|
||||||
|
int valueMask = 0;
|
||||||
|
|
||||||
|
if (x != -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
||||||
{
|
{
|
||||||
if ( x == -1 )
|
windowChanges.x = x;
|
||||||
x = oldX;
|
valueMask |= CWX;
|
||||||
if ( y == -1 )
|
|
||||||
y = oldY;
|
|
||||||
}
|
}
|
||||||
|
if (y != -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
||||||
if ( width == -1 )
|
|
||||||
width = oldW;
|
|
||||||
if ( height == -1 )
|
|
||||||
height = oldH;
|
|
||||||
|
|
||||||
bool nothingChanged = (x == oldX) && (y == oldY) &&
|
|
||||||
(width == oldW) && (height == oldH);
|
|
||||||
|
|
||||||
if (!wxNoOptimize::CanOptimize())
|
|
||||||
{
|
{
|
||||||
nothingChanged = FALSE;
|
windowChanges.y = y;
|
||||||
|
valueMask |= CWY;
|
||||||
}
|
}
|
||||||
|
if (width != -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
||||||
if ( !nothingChanged )
|
|
||||||
{
|
{
|
||||||
if (m_drawingArea)
|
windowChanges.width = width - m_borderSize*2;
|
||||||
{
|
valueMask |= CWWidth;
|
||||||
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);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
#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)
|
void wxWindowX11::DoSetClientSize(int width, int height)
|
||||||
{
|
{
|
||||||
// TODO
|
if (!GetMainWindow())
|
||||||
#if 0
|
|
||||||
if (m_drawingArea)
|
|
||||||
{
|
|
||||||
CanvasSetClientSize(width, height);
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
XWindowChanges windowChanges;
|
||||||
|
int valueMask = 0;
|
||||||
|
|
||||||
|
if (width != -1)
|
||||||
|
{
|
||||||
|
windowChanges.width = width ;
|
||||||
|
valueMask |= CWWidth;
|
||||||
}
|
}
|
||||||
|
if (height != -1)
|
||||||
Widget widget = (Widget) GetTopWidget();
|
{
|
||||||
|
windowChanges.height = height ;
|
||||||
if (width > -1)
|
valueMask |= CWHeight;
|
||||||
XtVaSetValues(widget, XmNwidth, width, NULL);
|
}
|
||||||
if (height > -1)
|
XConfigureWindow(wxGlobalDisplay(), (Window) GetMainWindow(),
|
||||||
XtVaSetValues(widget, XmNheight, height, NULL);
|
valueMask, & windowChanges);
|
||||||
|
|
||||||
wxSizeEvent sizeEvent(wxSize(width, height), GetId());
|
|
||||||
sizeEvent.SetEventObject(this);
|
|
||||||
|
|
||||||
GetEventHandler()->ProcessEvent(sizeEvent);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// For implementation purposes - sometimes decorations make the client area
|
// 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)
|
void wxWindowX11::SetSizeHints(int minW, int minH, int maxW, int maxH, int incW, int incH)
|
||||||
{
|
{
|
||||||
// TODO
|
|
||||||
#if 0
|
|
||||||
m_minWidth = minW;
|
m_minWidth = minW;
|
||||||
m_minHeight = minH;
|
m_minHeight = minH;
|
||||||
m_maxWidth = maxW;
|
m_maxWidth = maxW;
|
||||||
m_maxHeight = maxH;
|
m_maxHeight = maxH;
|
||||||
|
|
||||||
wxFrame *frame = wxDynamicCast(this, wxFrame);
|
XSizeHints sizeHints;
|
||||||
if ( !frame )
|
sizeHints.flags = 0;
|
||||||
|
|
||||||
|
if (minW > -1 && minH > -1)
|
||||||
{
|
{
|
||||||
// TODO what about dialogs?
|
sizeHints.flags |= PMinSize;
|
||||||
return;
|
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();
|
XSetWMNormalHints(wxGlobalDisplay(), (Window) GetMainWindow(), & sizeHints)
|
||||||
|
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWindowX11::DoMoveWindow(int x, int y, int width, int height)
|
void wxWindowX11::DoMoveWindow(int x, int y, int width, int height)
|
||||||
{
|
{
|
||||||
// TODO
|
DoSetSize(x, y, width, height);
|
||||||
#if 0
|
|
||||||
XtVaSetValues((Widget)GetTopWidget(),
|
|
||||||
XmNx, x,
|
|
||||||
XmNy, y,
|
|
||||||
XmNwidth, width,
|
|
||||||
XmNheight, height,
|
|
||||||
NULL);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
@@ -1238,7 +1235,7 @@ void wxWindowX11::GetTextExtent(const wxString& string,
|
|||||||
void wxWindowX11::Refresh(bool eraseBack, const wxRect *rect)
|
void wxWindowX11::Refresh(bool eraseBack, const wxRect *rect)
|
||||||
{
|
{
|
||||||
m_needsRefresh = TRUE;
|
m_needsRefresh = TRUE;
|
||||||
Display *display = (Display*) wxGetDisplay();
|
Display *display = wxGlobalDisplay();
|
||||||
Window thisWindow = (Window) GetMainWindow();
|
Window thisWindow = (Window) GetMainWindow();
|
||||||
|
|
||||||
XExposeEvent dummyEvent;
|
XExposeEvent dummyEvent;
|
||||||
@@ -1451,72 +1448,6 @@ void wxDeleteWindowFromTable(Window w)
|
|||||||
// add/remove window from the table
|
// 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
|
// X11-specific accessors
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -1632,213 +1563,6 @@ static void wxScrollBarCallback(Widget scrollbar,
|
|||||||
}
|
}
|
||||||
#endif
|
#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
|
// TranslateXXXEvent() functions
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -1898,7 +1622,7 @@ bool wxTranslateMouseEvent(wxMouseEvent& wxevent, wxWindow *win, Window window,
|
|||||||
|
|
||||||
// check for a double click
|
// check for a double click
|
||||||
// TODO: where can we get this value from?
|
// TODO: where can we get this value from?
|
||||||
//long dclickTime = XtGetMultiClickTime((Display*) wxGetDisplay());
|
//long dclickTime = XtGetMultiClickTime(wxGlobalDisplay());
|
||||||
long dclickTime = 200;
|
long dclickTime = 200;
|
||||||
long ts = wxevent.GetTimestamp();
|
long ts = wxevent.GetTimestamp();
|
||||||
|
|
||||||
@@ -2227,7 +1951,7 @@ wxWindow* wxFindWindowAtPointer(wxPoint& pt)
|
|||||||
// Get the current mouse position.
|
// Get the current mouse position.
|
||||||
wxPoint wxGetMousePosition()
|
wxPoint wxGetMousePosition()
|
||||||
{
|
{
|
||||||
Display *display = (Display*) wxGetDisplay();
|
Display *display = wxGlobalDisplay();
|
||||||
Window rootWindow = RootWindowOfScreen (DefaultScreenOfDisplay(display));
|
Window rootWindow = RootWindowOfScreen (DefaultScreenOfDisplay(display));
|
||||||
Window rootReturn, childReturn;
|
Window rootReturn, childReturn;
|
||||||
int rootX, rootY, winX, winY;
|
int rootX, rootY, winX, winY;
|
||||||
|
Reference in New Issue
Block a user