Implemented wxToplevelWindowMotif.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@18600 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Mattia Barbon
2003-01-06 16:36:23 +00:00
parent f58d1d9978
commit 798a4529fe
9 changed files with 298 additions and 808 deletions

View File

@@ -614,6 +614,7 @@ stattext.cpp Motif
toolbar.cpp Motif toolbar.cpp Motif
textctrl.cpp Motif textctrl.cpp Motif
timer.cpp Motif timer.cpp Motif
toplevel.cpp Motif
utils.cpp Motif utils.cpp Motif
window.cpp Motif window.cpp Motif
@@ -1197,6 +1198,7 @@ stattext.h MotifH
textctrl.h MotifH textctrl.h MotifH
timer.h MotifH timer.h MotifH
toolbar.h MotifH toolbar.h MotifH
toplevel.h MotifH
window.h MotifH window.h MotifH
app.h X11H app.h X11H

View File

@@ -21,6 +21,7 @@
#include "wx/hash.h" #include "wx/hash.h"
#include "wx/string.h" #include "wx/string.h"
#include "wx/dialog.h" #include "wx/dialog.h"
#include "wx/panel.h"
class WXDLLEXPORT wxTabView; class WXDLLEXPORT wxTabView;

View File

@@ -26,6 +26,7 @@ class WXDLLEXPORT wxDialog : public wxDialogBase
public: public:
wxDialog(); wxDialog();
#if WXWIN_COMPATIBILITY_2
// Constructor with a modal flag, but no window id - the old convention // Constructor with a modal flag, but no window id - the old convention
wxDialog(wxWindow *parent, wxDialog(wxWindow *parent,
const wxString& title, bool modal, const wxString& title, bool modal,
@@ -36,6 +37,7 @@ public:
long modalStyle = modal ? wxDIALOG_MODAL : wxDIALOG_MODELESS ; long modalStyle = modal ? wxDIALOG_MODAL : wxDIALOG_MODELESS ;
Create(parent, -1, title, wxPoint(x, y), wxSize(width, height), style|modalStyle, name); Create(parent, -1, title, wxPoint(x, y), wxSize(width, height), style|modalStyle, name);
} }
#endif
// Constructor with no modal flag - the new convention. // Constructor with no modal flag - the new convention.
wxDialog(wxWindow *parent, wxWindowID id, wxDialog(wxWindow *parent, wxWindowID id,
@@ -59,17 +61,9 @@ public:
virtual bool Destroy(); virtual bool Destroy();
bool Show(bool show); virtual bool Show(bool show = TRUE);
void Iconize(bool iconize);
void Raise();
void Lower();
virtual bool IsIconized() const;
virtual bool IsTopLevel() const { return TRUE; }
void SetTitle(const wxString& title); void SetTitle(const wxString& title);
wxString GetTitle() const ;
void SetModal(bool flag); void SetModal(bool flag);
@@ -91,8 +85,6 @@ public:
void OnApply(wxCommandEvent& event); void OnApply(wxCommandEvent& event);
void OnCancel(wxCommandEvent& event); void OnCancel(wxCommandEvent& event);
void OnPaint(wxPaintEvent &event);
// Responds to colour changes // Responds to colour changes
void OnSysColourChanged(wxSysColourChangedEvent& event); void OnSysColourChanged(wxSysColourChangedEvent& event);
@@ -100,13 +92,17 @@ public:
void OnCharHook(wxKeyEvent& event); void OnCharHook(wxKeyEvent& event);
void OnCloseWindow(wxCloseEvent& event); void OnCloseWindow(wxCloseEvent& event);
// Responds to size changes private:
void OnSize(wxSizeEvent& event); virtual bool DoCreate( wxWindow* parent, wxWindowID id,
const wxString& title,
const wxPoint& pos,
const wxSize& size,
long style,
const wxString& name );
virtual void DoDestroy();
public:
//// Motif-specific //// Motif-specific
bool m_modalShowing; bool m_modalShowing;
wxString m_dialogTitle;
protected: protected:
virtual void DoSetSize(int x, int y, virtual void DoSetSize(int x, int y,

View File

@@ -50,7 +50,6 @@ public:
// Set title // Set title
void SetTitle(const wxString& title); void SetTitle(const wxString& title);
wxString GetTitle() const { return m_title; }
// Set icon // Set icon
virtual void SetIcon(const wxIcon& icon); virtual void SetIcon(const wxIcon& icon);
@@ -66,22 +65,6 @@ public:
virtual void PositionToolBar(); virtual void PositionToolBar();
#endif // wxUSE_TOOLBAR #endif // wxUSE_TOOLBAR
// Iconize
virtual void Iconize(bool iconize);
virtual bool IsIconized() const;
// Is the frame maximized? Returns FALSE under Motif (but TRUE for
// wxMDIChildFrame due to the tabbed implementation).
virtual bool IsMaximized() const;
virtual void Maximize(bool maximize);
virtual void Raise();
virtual void Lower();
virtual void Restore();
// Implementation only from now on // Implementation only from now on
// ------------------------------- // -------------------------------
@@ -97,15 +80,18 @@ public:
WXWidget GetClientAreaWidget() const { return m_clientArea; } WXWidget GetClientAreaWidget() const { return m_clientArea; }
WXWidget GetTopWidget() const { return m_frameShell; } WXWidget GetTopWidget() const { return m_frameShell; }
virtual WXWidget GetMainWidget() const { return m_frameWidget; } virtual WXWidget GetMainWidget() const { return m_mainWidget; }
// The widget that can have children on it // The widget that can have children on it
WXWidget GetClientWidget() const; WXWidget GetClientWidget() const;
bool GetVisibleStatus() const { return m_visibleStatus; } bool GetVisibleStatus() const { return m_visibleStatus; }
void SetVisibleStatus( bool status ) { m_visibleStatus = status; }
bool PreResize(); bool PreResize();
protected: // for generic/mdig.h
virtual void DoGetClientSize(int *width, int *height) const;
private:
// common part of all ctors // common part of all ctors
void Init(); void Init();
@@ -114,14 +100,11 @@ protected:
//// Motif-specific //// Motif-specific
WXWidget m_frameShell; WXWidget m_frameShell;
WXWidget m_frameWidget;
WXWidget m_workArea; WXWidget m_workArea;
WXWidget m_clientArea; WXWidget m_clientArea;
wxString m_title;
bool m_visibleStatus; bool m_visibleStatus;
bool m_iconized; bool m_iconized;
virtual void DoGetClientSize(int *width, int *height) const;
virtual void DoGetSize(int *width, int *height) const; virtual void DoGetSize(int *width, int *height) const;
virtual void DoGetPosition(int *x, int *y) const; virtual void DoGetPosition(int *x, int *y) const;
virtual void DoSetSize(int x, int y, virtual void DoSetSize(int x, int y,
@@ -130,6 +113,14 @@ protected:
virtual void DoSetClientSize(int width, int height); virtual void DoSetClientSize(int width, int height);
private: private:
virtual bool DoCreate( wxWindow* parent, wxWindowID id,
const wxString& title,
const wxPoint& pos,
const wxSize& size,
long style,
const wxString& name );
virtual void DoDestroy();
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
DECLARE_DYNAMIC_CLASS(wxFrame) DECLARE_DYNAMIC_CLASS(wxFrame)
}; };

View File

@@ -173,6 +173,9 @@ protected:
#elif defined(__WXPM__) #elif defined(__WXPM__)
#include "wx/os2/toplevel.h" #include "wx/os2/toplevel.h"
#define wxTopLevelWindowNative wxTopLevelWindowOS2 #define wxTopLevelWindowNative wxTopLevelWindowOS2
#elif defined(__WXMOTIF__)
#include "wx/motif/toplevel.h"
#define wxTopLevelWindowNative wxTopLevelWindowMotif
#endif #endif
#ifdef __WXUNIVERSAL__ #ifdef __WXUNIVERSAL__

View File

@@ -22,7 +22,6 @@
#include "wx/dialog.h" #include "wx/dialog.h"
#include "wx/utils.h" #include "wx/utils.h"
#include "wx/frame.h"
#include "wx/app.h" #include "wx/app.h"
#include "wx/settings.h" #include "wx/settings.h"
@@ -54,14 +53,6 @@
#include "wx/motif/private.h" #include "wx/motif/private.h"
static void wxCloseDialogCallback(Widget widget, XtPointer client_data, XmAnyCallbackStruct *cbs);
static void wxDialogBoxEventHandler (Widget wid,
XtPointer client_data,
XEvent* event,
Boolean *continueToDispatch);
static void wxUnmapBulletinBoard(Widget dialog, wxDialog *client,XtPointer call);
// A stack of modal_showing flags, since we can't rely // A stack of modal_showing flags, since we can't rely
// on accessing wxDialog::m_modalShowing within // on accessing wxDialog::m_modalShowing within
// wxDialog::Show in case a callback has deleted the wxDialog. // wxDialog::Show in case a callback has deleted the wxDialog.
@@ -70,15 +61,14 @@ static wxList wxModalShowingStack;
// Lists to keep track of windows, so we can disable/enable them // Lists to keep track of windows, so we can disable/enable them
// for modal dialogs // for modal dialogs
wxList wxModalDialogs; wxList wxModalDialogs;
wxList wxModelessWindows; // Frames and modeless dialogs extern wxList wxModelessWindows; // Frames and modeless dialogs
extern wxList wxPendingDelete; extern wxList wxPendingDelete;
#define wxUSE_INVISIBLE_RESIZE 1 #define wxUSE_INVISIBLE_RESIZE 1
IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxPanel) IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxTopLevelWindow)
BEGIN_EVENT_TABLE(wxDialog, wxPanel) BEGIN_EVENT_TABLE(wxDialog, wxTopLevelWindow)
EVT_SIZE(wxDialog::OnSize)
EVT_BUTTON(wxID_OK, wxDialog::OnOK) EVT_BUTTON(wxID_OK, wxDialog::OnOK)
EVT_BUTTON(wxID_APPLY, wxDialog::OnApply) EVT_BUTTON(wxID_APPLY, wxDialog::OnApply)
EVT_BUTTON(wxID_CANCEL, wxDialog::OnCancel) EVT_BUTTON(wxID_CANCEL, wxDialog::OnCancel)
@@ -101,86 +91,26 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id,
long style, long style,
const wxString& name) const wxString& name)
{ {
m_windowStyle = style; SetExtraStyle(GetExtraStyle() | wxTOPLEVEL_EX_DIALOG);
if( !wxTopLevelWindow::Create( parent, id, title, pos, size, style,
name ) )
return FALSE;
m_modalShowing = FALSE; m_modalShowing = FALSE;
m_dialogTitle = title;
m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
m_foregroundColour = *wxBLACK; m_foregroundColour = *wxBLACK;
SetName(name); Widget dialogShell = (Widget) m_mainWidget;
if (!parent)
wxTopLevelWindows.Append(this);
if (parent) parent->AddChild(this);
if ( id == -1 )
m_windowId = (int)NewControlId();
else
m_windowId = id;
Widget parentWidget = (Widget) 0;
if (parent)
parentWidget = (Widget) parent->GetTopWidget();
if (!parent)
parentWidget = (Widget) wxTheApp->GetTopLevelWidget();
wxASSERT_MSG( (parentWidget != (Widget) 0), "Could not find a suitable parent shell for dialog." );
Arg args[2];
XtSetArg (args[0], XmNdefaultPosition, False);
XtSetArg (args[1], XmNautoUnmanage, False);
Widget dialogShell = XmCreateBulletinBoardDialog(parentWidget, (char*) (const char*) name, args, 2);
m_mainWidget = (WXWidget) dialogShell;
// We don't want margins, since there is enough elsewhere.
XtVaSetValues(dialogShell,
XmNmarginHeight, 0,
XmNmarginWidth, 0,
XmNresizePolicy, XmRESIZE_NONE,
NULL) ;
Widget shell = XtParent(dialogShell) ; Widget shell = XtParent(dialogShell) ;
if (!title.IsNull())
{ SetTitle( title );
XmString str = XmStringCreateSimple((char*) (const char*)title);
XtVaSetValues(dialogShell,
XmNdialogTitle, str,
NULL);
XmStringFree(str);
}
m_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); m_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
ChangeFont(FALSE); ChangeFont(FALSE);
wxAddWindowToTable(dialogShell, this);
// Intercept CLOSE messages from the window manager
Atom WM_DELETE_WINDOW = XmInternAtom(XtDisplay(shell), "WM_DELETE_WINDOW", False);
/* Remove and add WM_DELETE_WINDOW so ours is only handler */
/* Why do we have to do this for wxDialog, but not wxFrame? */
XmRemoveWMProtocols(shell, &WM_DELETE_WINDOW, 1);
XmAddWMProtocols(shell, &WM_DELETE_WINDOW, 1);
XmActivateWMProtocol(shell, WM_DELETE_WINDOW);
// Modified Steve Hammes for Motif 2.0
#if (XmREVISION > 1 || XmVERSION > 1)
XmAddWMProtocolCallback(shell, WM_DELETE_WINDOW, (XtCallbackProc) wxCloseDialogCallback, (XtPointer)this);
#elif XmREVISION == 1
XmAddWMProtocolCallback(shell, WM_DELETE_WINDOW, (XtCallbackProc) wxCloseDialogCallback, (caddr_t)this);
#else
XmAddWMProtocolCallback(shell, WM_DELETE_WINDOW, (void (*)())wxCloseDialogCallback, (caddr_t)this);
#endif
XtTranslations ptr ;
XtOverrideTranslations(dialogShell,
ptr = XtParseTranslationTable("<Configure>: resize()"));
XtFree((char *)ptr);
// Can't remember what this was about... but I think it's necessary. // Can't remember what this was about... but I think it's necessary.
if (wxUSE_INVISIBLE_RESIZE) if (wxUSE_INVISIBLE_RESIZE)
{ {
if (pos.x > -1) if (pos.x > -1)
@@ -196,40 +126,6 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id,
XtVaSetValues(dialogShell, XmNheight, size.y, NULL); XtVaSetValues(dialogShell, XmNheight, size.y, NULL);
} }
// This patch come from Torsten Liermann lier@lier1.muc.de
if (XmIsMotifWMRunning(shell))
{
int decor = 0 ;
if (m_windowStyle & wxRESIZE_BORDER)
decor |= MWM_DECOR_RESIZEH ;
if (m_windowStyle & wxSYSTEM_MENU)
decor |= MWM_DECOR_MENU;
if ((m_windowStyle & wxCAPTION) ||
(m_windowStyle & wxTINY_CAPTION_HORIZ) ||
(m_windowStyle & wxTINY_CAPTION_VERT))
decor |= MWM_DECOR_TITLE;
if (m_windowStyle & wxTHICK_FRAME)
decor |= MWM_DECOR_BORDER;
if (m_windowStyle & wxMINIMIZE_BOX)
decor |= MWM_DECOR_MINIMIZE;
if (m_windowStyle & wxMAXIMIZE_BOX)
decor |= MWM_DECOR_MAXIMIZE;
XtVaSetValues(shell,XmNmwmDecorations,decor,NULL) ;
}
// This allows non-Motif window managers to support at least the
// no-decorations case.
else
{
if ((m_windowStyle & wxCAPTION) != wxCAPTION)
XtVaSetValues((Widget) shell,XmNoverrideRedirect,TRUE,NULL);
}
XtRealizeWidget(dialogShell);
XtAddCallback(dialogShell,XmNunmapCallback,
(XtCallbackProc)wxUnmapBulletinBoard,this) ;
// Positioning of the dialog doesn't work properly unless the dialog // Positioning of the dialog doesn't work properly unless the dialog
// is managed, so we manage without mapping to the screen. // is managed, so we manage without mapping to the screen.
// To show, we map the shell (actually it's parent). // To show, we map the shell (actually it's parent).
@@ -244,17 +140,54 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id,
XtAddEventHandler(dialogShell,ExposureMask,FALSE, XtAddEventHandler(dialogShell,ExposureMask,FALSE,
wxUniversalRepaintProc, (XtPointer) this); wxUniversalRepaintProc, (XtPointer) this);
XtAddEventHandler(dialogShell,
ButtonPressMask | ButtonReleaseMask | PointerMotionMask | KeyPressMask,
FALSE,
wxDialogBoxEventHandler,
(XtPointer)this);
ChangeBackgroundColour(); ChangeBackgroundColour();
return TRUE; return TRUE;
} }
bool wxDialog::DoCreate( wxWindow* parent, wxWindowID id,
const wxString& title,
const wxPoint& pos,
const wxSize& size,
long style,
const wxString& name )
{
Widget parentWidget = (Widget) 0;
if( parent )
parentWidget = (Widget) parent->GetTopWidget();
if( !parent )
parentWidget = (Widget) wxTheApp->GetTopLevelWidget();
wxASSERT_MSG( (parentWidget != (Widget) 0),
"Could not find a suitable parent shell for dialog." );
Arg args[2];
XtSetArg (args[0], XmNdefaultPosition, False);
XtSetArg (args[1], XmNautoUnmanage, False);
Widget dialogShell =
XmCreateBulletinBoardDialog( parentWidget, (char*)name.c_str(),
args, 2);
m_mainWidget = (WXWidget) dialogShell;
// We don't want margins, since there is enough elsewhere.
XtVaSetValues( dialogShell,
XmNmarginHeight, 0,
XmNmarginWidth, 0,
XmNresizePolicy, XmRESIZE_NONE,
NULL ) ;
XtTranslations ptr ;
XtOverrideTranslations(dialogShell,
ptr = XtParseTranslationTable("<Configure>: resize()"));
XtFree((char *)ptr);
XtRealizeWidget(dialogShell);
wxAddWindowToTable( (Widget)m_mainWidget, this );
return TRUE;
}
void wxDialog::SetModal(bool flag) void wxDialog::SetModal(bool flag)
{ {
if ( flag ) if ( flag )
@@ -273,44 +206,24 @@ wxDialog::~wxDialog()
m_isBeingDeleted = TRUE; m_isBeingDeleted = TRUE;
if (m_mainWidget) if (m_mainWidget)
{
XtRemoveEventHandler((Widget) m_mainWidget, ExposureMask, FALSE, XtRemoveEventHandler((Widget) m_mainWidget, ExposureMask, FALSE,
wxUniversalRepaintProc, (XtPointer) this); wxUniversalRepaintProc, (XtPointer) this);
}
m_modalShowing = FALSE; m_modalShowing = FALSE;
if (!wxUSE_INVISIBLE_RESIZE && m_mainWidget) if (!wxUSE_INVISIBLE_RESIZE && m_mainWidget)
{ {
XtUnmapWidget((Widget) m_mainWidget); XtUnmapWidget((Widget) m_mainWidget);
} }
}
wxTopLevelWindows.DeleteObject(this); void wxDialog::DoDestroy()
{
if ( (GetWindowStyleFlag() & wxDIALOG_MODAL) != wxDIALOG_MODAL ) if( m_mainWidget )
wxModelessWindows.DeleteObject(this);
// If this is the last top-level window, exit.
if (wxTheApp && (wxTopLevelWindows.Number() == 0))
{ {
wxTheApp->SetTopWindow(NULL); wxDeleteWindowFromTable( (Widget)m_mainWidget );
XtDestroyWidget( (Widget)m_mainWidget );
if (wxTheApp->GetExitOnFrameDelete())
{
wxTheApp->ExitMainLoop();
}
}
// This event-flushing code used to be in wxWindow::PostDestroyChildren (wx_dialog.cpp)
// but I think this should work, if we destroy the children first.
// Note that this might need to be done for wxFrame also.
DestroyChildren();
// The idea about doing it here is that if you have to remove the
// XtDestroyWidget from ~wxWindow, at least top-level windows
// will still be deleted (and destroy children implicitly).
if (GetMainWidget())
{
DetachWidget(GetMainWidget()); // Removes event handlers
XtDestroyWidget((Widget) GetMainWidget());
SetMainWidget((WXWidget) NULL);
} }
} }
@@ -331,63 +244,6 @@ void wxDialog::OnCharHook(wxKeyEvent& event)
event.Skip(); event.Skip();
} }
void wxDialog::Iconize(bool WXUNUSED(iconize))
{
// Can't iconize a dialog in Motif, apparently
// TODO: try using the parent of m_mainShell.
// XtVaSetValues((Widget) m_mainWidget, XmNiconic, iconize, NULL);
}
// Default resizing behaviour - if only ONE subwindow,
// resize to client rectangle size
void wxDialog::OnSize(wxSizeEvent& WXUNUSED(event))
{
// if we're using constraints - do use them
#if wxUSE_CONSTRAINTS
if ( GetAutoLayout() ) {
Layout();
return;
}
#endif
// do we have _exactly_ one child?
wxWindow *child = NULL;
for ( wxNode *node = GetChildren().First(); node; node = node->Next() )
{
wxWindow *win = (wxWindow *)node->Data();
if ( !win->IsKindOf(CLASSINFO(wxFrame)) &&
!win->IsKindOf(CLASSINFO(wxDialog)) )
{
if ( child )
return; // it's our second subwindow - nothing to do
child = win;
}
}
if ( child ) {
// we have exactly one child - set it's size to fill the whole frame
int clientW, clientH;
GetClientSize(&clientW, &clientH);
int x = 0;
int y = 0;
child->SetSize(x, y, clientW, clientH);
}
}
bool wxDialog::IsIconized() const
{
/*
Boolean iconic;
XtVaGetValues((Widget) m_mainWidget, XmNiconic, &iconic, NULL);
return iconic;
*/
return FALSE;
}
void wxDialog::DoSetSize(int x, int y, int width, int height, int sizeFlags) void wxDialog::DoSetSize(int x, int y, int width, int height, int sizeFlags)
{ {
XtVaSetValues((Widget) m_mainWidget, XmNresizePolicy, XmRESIZE_ANY, NULL); XtVaSetValues((Widget) m_mainWidget, XmNresizePolicy, XmRESIZE_ANY, NULL);
@@ -402,60 +258,24 @@ void wxDialog::DoSetClientSize(int width, int height)
void wxDialog::SetTitle(const wxString& title) void wxDialog::SetTitle(const wxString& title)
{ {
m_dialogTitle = title; wxTopLevelWindow::SetTitle( title );
if (!title.IsNull())
if( !title.empty() )
{ {
XmString str = XmStringCreateSimple((char*) (const char*) title); wxXmString str( title );
XtVaSetValues((Widget) m_mainWidget, XtVaSetValues( (Widget)m_mainWidget,
XmNtitle, (char*) (const char*) title, XmNtitle, title.c_str(),
XmNdialogTitle, str, // Roberto Cocchi XmNdialogTitle, str(), // Roberto Cocchi
XmNiconName, (char*) (const char*) title, XmNiconName, title.c_str(),
NULL); NULL );
XmStringFree(str);
} }
} }
wxString wxDialog::GetTitle() const bool wxDialog::Show( bool show )
{ {
return m_dialogTitle; if( !wxTopLevelWindowMotif::Show( show ) )
} return FALSE;
void wxDialog::Raise()
{
Window parent_window = XtWindow((Widget) m_mainWidget),
next_parent = XtWindow((Widget) m_mainWidget),
root = RootWindowOfScreen(XtScreen((Widget) m_mainWidget));
// search for the parent that is child of ROOT, because the WM may
// reparent twice and notify only the next parent (like FVWM)
while (next_parent != root) {
Window *theChildren; unsigned int n;
parent_window = next_parent;
XQueryTree(XtDisplay((Widget) m_mainWidget), parent_window, &root,
&next_parent, &theChildren, &n);
XFree(theChildren); // not needed
}
XRaiseWindow(XtDisplay((Widget) m_mainWidget), parent_window);
}
void wxDialog::Lower()
{
Window parent_window = XtWindow((Widget) m_mainWidget),
next_parent = XtWindow((Widget) m_mainWidget),
root = RootWindowOfScreen(XtScreen((Widget) m_mainWidget));
// search for the parent that is child of ROOT, because the WM may
// reparent twice and notify only the next parent (like FVWM)
while (next_parent != root) {
Window *theChildren; unsigned int n;
parent_window = next_parent;
XQueryTree(XtDisplay((Widget) m_mainWidget), parent_window, &root,
&next_parent, &theChildren, &n);
XFree(theChildren); // not needed
}
XLowerWindow(XtDisplay((Widget) m_mainWidget), parent_window);
}
bool wxDialog::Show(bool show)
{
m_isShown = show; m_isShown = show;
if (show) if (show)
@@ -463,9 +283,10 @@ bool wxDialog::Show(bool show)
if (!wxUSE_INVISIBLE_RESIZE) if (!wxUSE_INVISIBLE_RESIZE)
XtMapWidget(XtParent((Widget) m_mainWidget)); XtMapWidget(XtParent((Widget) m_mainWidget));
else else
XtManageChild((Widget) m_mainWidget) ; XtManageChild((Widget)m_mainWidget) ;
XRaiseWindow(XtDisplay((Widget) m_mainWidget), XtWindow((Widget) m_mainWidget)); XRaiseWindow( XtDisplay( (Widget)m_mainWidget ),
XtWindow( (Widget)m_mainWidget) );
} }
else else
@@ -473,7 +294,7 @@ bool wxDialog::Show(bool show)
if (!wxUSE_INVISIBLE_RESIZE) if (!wxUSE_INVISIBLE_RESIZE)
XtUnmapWidget(XtParent((Widget) m_mainWidget)); XtUnmapWidget(XtParent((Widget) m_mainWidget));
else else
XtUnmanageChild((Widget) m_mainWidget) ; XtUnmanageChild((Widget)m_mainWidget) ;
XFlush(XtDisplay((Widget) wxTheApp->GetTopLevelWidget())); XFlush(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()));
XSync(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()), FALSE); XSync(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()), FALSE);
@@ -531,7 +352,8 @@ int wxDialog::ShowModal()
XSync(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()), FALSE); XSync(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()), FALSE);
while (XtAppPending((XtAppContext) wxTheApp->GetAppContext())) while (XtAppPending((XtAppContext) wxTheApp->GetAppContext()))
{ {
XFlush(XtDisplay((Widget) wxTheApp->GetTopLevelWidget())); // MBN: is this necessary? why?
// XFlush(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()));
XtAppNextEvent((XtAppContext) wxTheApp->GetAppContext(), &event); XtAppNextEvent((XtAppContext) wxTheApp->GetAppContext(), &event);
wxTheApp->ProcessXEvent((WXEvent*) &event); wxTheApp->ProcessXEvent((WXEvent*) &event);
@@ -624,11 +446,6 @@ void wxDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
closing.DeleteObject(this); closing.DeleteObject(this);
} }
void wxDialog::OnPaint(wxPaintEvent &WXUNUSED(event))
{
// added for compatiblity only
}
// Destroy the window (delayed, if a managed window) // Destroy the window (delayed, if a managed window)
bool wxDialog::Destroy() bool wxDialog::Destroy()
{ {
@@ -643,78 +460,6 @@ void wxDialog::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(event))
Refresh(); Refresh();
} }
// Handle a close event from the window manager
static void wxCloseDialogCallback( Widget WXUNUSED(widget), XtPointer client_data,
XmAnyCallbackStruct *WXUNUSED(cbs))
{
wxDialog *dialog = (wxDialog *)client_data;
wxCloseEvent closeEvent(wxEVT_CLOSE_WINDOW, dialog->GetId());
closeEvent.SetEventObject(dialog);
// May delete the dialog (with delayed deletion)
dialog->GetEventHandler()->ProcessEvent(closeEvent);
}
void wxDialogBoxEventHandler(Widget wid,
XtPointer WXUNUSED(client_data),
XEvent* event,
Boolean* continueToDispatch)
{
wxDialog *dialog = (wxDialog *)wxGetWindowFromTable(wid);
if (dialog)
{
wxMouseEvent wxevent(wxEVT_NULL);
if (wxTranslateMouseEvent(wxevent, dialog, wid, event))
{
wxevent.SetEventObject(dialog);
wxevent.SetId(dialog->GetId());
dialog->GetEventHandler()->ProcessEvent(wxevent);
}
else
{
// An attempt to implement OnCharHook by calling OnCharHook first;
// if this returns TRUE, set continueToDispatch to False
// (don't continue processing).
// Otherwise set it to True and call OnChar.
wxKeyEvent keyEvent(wxEVT_CHAR);
if (wxTranslateKeyEvent(keyEvent, dialog, wid, event))
{
keyEvent.SetEventObject(dialog);
keyEvent.SetId(dialog->GetId());
keyEvent.SetEventType(wxEVT_CHAR_HOOK);
if (dialog->GetEventHandler()->ProcessEvent(keyEvent))
{
*continueToDispatch = False;
return;
}
else
{
// For simplicity, OnKeyDown is the same as OnChar
// TODO: filter modifier key presses from OnChar
keyEvent.SetEventType(wxEVT_KEY_DOWN);
// Only process OnChar if OnKeyDown didn't swallow it
if (!dialog->GetEventHandler()->ProcessEvent (keyEvent))
{
keyEvent.SetEventType(wxEVT_CHAR);
dialog->GetEventHandler()->ProcessEvent(keyEvent);
}
}
}
}
}
*continueToDispatch = True;
}
static void wxUnmapBulletinBoard(Widget WXUNUSED(dialog), wxDialog *WXUNUSED(client), XtPointer WXUNUSED(call) )
{
/* This gets called when the dialog is being shown, which
* defeats modal showing.
client->m_modalShowing = FALSE ;
client->m_isShown = FALSE;
*/
}
void wxDialog::ChangeFont(bool keepOriginalSize) void wxDialog::ChangeFont(bool keepOriginalSize)
{ {
wxWindow::ChangeFont(keepOriginalSize); wxWindow::ChangeFont(keepOriginalSize);
@@ -731,4 +476,3 @@ void wxDialog::ChangeForegroundColour()
if (GetMainWidget()) if (GetMainWidget())
DoChangeForegroundColour(GetMainWidget(), m_foregroundColour); DoChangeForegroundColour(GetMainWidget(), m_foregroundColour);
} }

View File

@@ -229,6 +229,7 @@ ALL_SOURCES = \
motif/textctrl.cpp \ motif/textctrl.cpp \
motif/timer.cpp \ motif/timer.cpp \
motif/toolbar.cpp \ motif/toolbar.cpp \
motif/toplevel.cpp \
motif/utils.cpp \ motif/utils.cpp \
motif/window.cpp \ motif/window.cpp \
unix/dialup.cpp \ unix/dialup.cpp \
@@ -561,6 +562,7 @@ ALL_HEADERS = \
motif/textctrl.h \ motif/textctrl.h \
motif/timer.h \ motif/timer.h \
motif/toolbar.h \ motif/toolbar.h \
motif/toplevel.h \
motif/window.h \ motif/window.h \
generic/accel.h \ generic/accel.h \
generic/calctrl.h \ generic/calctrl.h \
@@ -859,6 +861,7 @@ GUIOBJS = \
textctrl.o \ textctrl.o \
timer.o \ timer.o \
toolbar.o \ toolbar.o \
toplevel.o \
utils.o \ utils.o \
window.o window.o

View File

@@ -28,17 +28,14 @@
#define XtScreen XTSCREEN #define XtScreen XTSCREEN
#endif #endif
# include "wx/frame.h" #include "wx/frame.h"
#include "wx/statusbr.h" #include "wx/statusbr.h"
#include "wx/toolbar.h" #include "wx/toolbar.h"
#include "wx/menuitem.h"
#include "wx/menu.h" #include "wx/menu.h"
#include "wx/dcclient.h"
#include "wx/dialog.h"
#include "wx/settings.h" #include "wx/settings.h"
#include "wx/app.h"
#include "wx/utils.h" #include "wx/utils.h"
#include "wx/log.h" #include "wx/log.h"
#include "wx/app.h"
#ifdef __VMS__ #ifdef __VMS__
#pragma message disable nosimpint #pragma message disable nosimpint
@@ -80,15 +77,8 @@
// private functions // private functions
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
static void wxFrameEventHandler(Widget wid,
XtPointer WXUNUSED(client_data),
XEvent* event,
Boolean* continueToDispatch);
static void wxCloseFrameCallback(Widget, XtPointer, XmAnyCallbackStruct *cbs);
static void wxFrameFocusProc(Widget workArea, XtPointer clientData,
XmAnyCallbackStruct *cbs);
static void wxFrameMapProc(Widget frameShell, XtPointer clientData, static void wxFrameMapProc(Widget frameShell, XtPointer clientData,
XCrossingEvent * event); XCrossingEvent* event);
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// globals // globals
@@ -99,7 +89,7 @@ extern wxList wxPendingDelete;
// TODO: this should be tidied so that any frame can be the // TODO: this should be tidied so that any frame can be the
// top frame // top frame
static bool wxTopLevelUsed = FALSE; // static bool wxTopLevelUsed = FALSE;
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxWin macros // wxWin macros
@@ -126,10 +116,10 @@ void wxFrame::Init()
//// Motif-specific //// Motif-specific
m_frameShell = (WXWidget) NULL; m_frameShell = (WXWidget) NULL;
m_frameWidget = (WXWidget) NULL;; m_mainWidget = (WXWidget) NULL;;
m_workArea = (WXWidget) NULL;; m_workArea = (WXWidget) NULL;;
m_clientArea = (WXWidget) NULL;; m_clientArea = (WXWidget) NULL;;
m_visibleStatus = TRUE; // m_visibleStatus = TRUE;
} }
bool wxFrame::Create(wxWindow *parent, bool wxFrame::Create(wxWindow *parent,
@@ -140,26 +130,15 @@ bool wxFrame::Create(wxWindow *parent,
long style, long style,
const wxString& name) const wxString& name)
{ {
if ( parent ) if( !wxTopLevelWindow::Create( parent, id, title, pos, size, style,
parent->AddChild(this); name ) )
else return FALSE;
wxTopLevelWindows.Append(this);
wxModelessWindows.Append(this); m_backgroundColour =
wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE);
SetName(name);
m_windowStyle = style;
m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE);
m_foregroundColour = *wxBLACK; m_foregroundColour = *wxBLACK;
m_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); m_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
if ( id > -1 )
m_windowId = id;
else
m_windowId = (int)NewControlId();
int x = pos.x, y = pos.y; int x = pos.x, y = pos.y;
int width = size.x, height = size.y; int width = size.x, height = size.y;
@@ -187,98 +166,15 @@ bool wxFrame::Create(wxWindow *parent,
if (y < 10) y = 10; if (y < 10) y = 10;
} }
// VZ: what does this do?? SetTitle( title );
if (wxTopLevelUsed)
{
// Change suggested by Matthew Flatt
m_frameShell = (WXWidget)XtAppCreateShell
(
name,
wxTheApp->GetClassName(),
topLevelShellWidgetClass,
(Display*) wxGetDisplay(),
NULL,
0
);
}
else
{
m_frameShell = wxTheApp->GetTopLevelWidget();
wxTopLevelUsed = TRUE;
}
XtVaSetValues((Widget) m_frameShell,
// Allows menu to resize
XmNallowShellResize, True,
XmNdeleteResponse, XmDO_NOTHING,
XmNmappedWhenManaged, False,
XmNiconic, (style & wxICONIZE) ? TRUE : FALSE,
NULL);
if (!title.IsEmpty())
XtVaSetValues((Widget) m_frameShell,
XmNtitle, title.c_str(),
NULL);
m_frameWidget = (WXWidget) XtVaCreateManagedWidget("main_window",
xmMainWindowWidgetClass, (Widget) m_frameShell,
XmNresizePolicy, XmRESIZE_NONE,
NULL);
m_workArea = (WXWidget) XtVaCreateWidget("form",
xmFormWidgetClass, (Widget) m_frameWidget,
XmNresizePolicy, XmRESIZE_NONE,
NULL);
m_clientArea = (WXWidget) XtVaCreateWidget("client",
xmBulletinBoardWidgetClass, (Widget) m_workArea,
XmNmarginWidth, 0,
XmNmarginHeight, 0,
XmNrightAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
XmNtopAttachment, XmATTACH_FORM,
XmNbottomAttachment, XmATTACH_FORM,
// XmNresizePolicy, XmRESIZE_ANY,
NULL);
wxLogTrace(wxTRACE_Messages, wxLogTrace(wxTRACE_Messages,
"Created frame (0x%08x) with work area 0x%08x and client " "Created frame (0x%08x) with work area 0x%08x and client "
"area 0x%08x", m_frameWidget, m_workArea, m_clientArea); "area 0x%08x", m_mainWidget, m_workArea, m_clientArea);
XtAddEventHandler((Widget) m_clientArea, ExposureMask,FALSE, XtAddEventHandler((Widget) m_clientArea, ExposureMask,FALSE,
wxUniversalRepaintProc, (XtPointer) this); wxUniversalRepaintProc, (XtPointer) this);
XtAddEventHandler((Widget) m_clientArea,
ButtonPressMask | ButtonReleaseMask | PointerMotionMask | KeyPressMask,
FALSE,
wxFrameEventHandler,
(XtPointer)this);
XtVaSetValues((Widget) m_frameWidget,
XmNworkWindow, (Widget) m_workArea,
NULL);
XtManageChild((Widget) m_clientArea);
XtManageChild((Widget) m_workArea);
wxAddWindowToTable((Widget) m_workArea, this);
wxAddWindowToTable((Widget) m_clientArea, this);
XtTranslations ptr;
XtOverrideTranslations((Widget) m_workArea,
ptr = XtParseTranslationTable("<Configure>: resize()"));
XtFree((char *)ptr);
XtAddCallback((Widget) m_workArea, XmNfocusCallback,
(XtCallbackProc)wxFrameFocusProc, (XtPointer)this);
/* Part of show-&-hide fix */
XtAddEventHandler((Widget) m_frameShell, StructureNotifyMask,
False, (XtEventHandler)wxFrameMapProc,
(XtPointer)m_workArea);
if (x > -1) if (x > -1)
XtVaSetValues((Widget) m_frameShell, XmNx, x, NULL); XtVaSetValues((Widget) m_frameShell, XmNx, x, NULL);
if (y > -1) if (y > -1)
@@ -288,51 +184,8 @@ bool wxFrame::Create(wxWindow *parent,
if (height > -1) if (height > -1)
XtVaSetValues((Widget) m_frameShell, XmNheight, height, NULL); XtVaSetValues((Widget) m_frameShell, XmNheight, height, NULL);
m_mainWidget = m_frameWidget;
ChangeFont(FALSE); ChangeFont(FALSE);
// This patch comes from Torsten Liermann lier@lier1.muc.de
if (XmIsMotifWMRunning( (Widget) m_frameShell ))
{
int decor = 0;
if (style & wxRESIZE_BORDER)
decor |= MWM_DECOR_RESIZEH;
if (style & wxSYSTEM_MENU)
decor |= MWM_DECOR_MENU;
if ((style & wxCAPTION) ||
(style & wxTINY_CAPTION_HORIZ) ||
(style & wxTINY_CAPTION_VERT))
decor |= MWM_DECOR_TITLE;
if (style & wxTHICK_FRAME)
decor |= MWM_DECOR_BORDER;
if (style & wxMINIMIZE_BOX)
decor |= MWM_DECOR_MINIMIZE;
if (style & wxMAXIMIZE_BOX)
decor |= MWM_DECOR_MAXIMIZE;
XtVaSetValues((Widget) m_frameShell,XmNmwmDecorations,decor,NULL);
}
// This allows non-Motif window managers to support at least the
// no-decorations case.
else
{
if (style == 0)
XtVaSetValues((Widget) m_frameShell,XmNoverrideRedirect,TRUE,NULL);
}
XtRealizeWidget((Widget) m_frameShell);
// Intercept CLOSE messages from the window manager
Atom WM_DELETE_WINDOW = XmInternAtom(XtDisplay((Widget) m_frameShell), "WM_DELETE_WINDOW", False);
#if (XmREVISION > 1 || XmVERSION > 1)
XmAddWMProtocolCallback((Widget) m_frameShell, WM_DELETE_WINDOW, (XtCallbackProc) wxCloseFrameCallback, (XtPointer)this);
#else
#if XmREVISION == 1
XmAddWMProtocolCallback((Widget) m_frameShell, WM_DELETE_WINDOW, (XtCallbackProc) wxCloseFrameCallback, (caddr_t)this);
#else
XmAddWMProtocolCallback((Widget) m_frameShell, WM_DELETE_WINDOW, (void (*)())wxCloseFrameCallback, (caddr_t)this);
#endif
#endif
ChangeBackgroundColour(); ChangeBackgroundColour();
PreResize(); PreResize();
@@ -345,6 +198,87 @@ bool wxFrame::Create(wxWindow *parent,
return TRUE; return TRUE;
} }
bool wxFrame::DoCreate( wxWindow* parent, wxWindowID id,
const wxString& title,
const wxPoint& pos,
const wxSize& size,
long style,
const wxString& name )
{
static bool wxTopLevelUsed = FALSE; /* this is global */
WXWidget frameShell;
if (wxTopLevelUsed)
{
// Change suggested by Matthew Flatt
frameShell = (WXWidget)XtAppCreateShell( name,
wxTheApp->GetClassName(),
topLevelShellWidgetClass,
(Display*) wxGetDisplay(),
NULL, 0 );
}
else
{
frameShell = wxTheApp->GetTopLevelWidget();
wxTopLevelUsed = TRUE;
}
XtVaSetValues((Widget) frameShell,
// Allows menu to resize
XmNallowShellResize, True,
XmNdeleteResponse, XmDO_NOTHING,
XmNmappedWhenManaged, False,
XmNiconic, (style & wxICONIZE) ? TRUE : FALSE,
NULL);
m_frameShell = frameShell;
m_mainWidget = (WXWidget) XtVaCreateManagedWidget("main_window",
xmMainWindowWidgetClass, (Widget) frameShell,
XmNresizePolicy, XmRESIZE_NONE,
NULL);
m_workArea = (WXWidget) XtVaCreateWidget("form",
xmFormWidgetClass, (Widget) m_mainWidget,
XmNresizePolicy, XmRESIZE_NONE,
NULL);
m_clientArea = (WXWidget) XtVaCreateWidget("client",
xmBulletinBoardWidgetClass, (Widget) m_workArea,
XmNmarginWidth, 0,
XmNmarginHeight, 0,
XmNrightAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
XmNtopAttachment, XmATTACH_FORM,
XmNbottomAttachment, XmATTACH_FORM,
NULL);
XtVaSetValues((Widget) m_mainWidget,
XmNworkWindow, (Widget) m_workArea,
NULL);
XtManageChild((Widget) m_clientArea);
XtManageChild((Widget) m_workArea);
XtTranslations ptr = XtParseTranslationTable( "<Configure>: resize()" );
XtOverrideTranslations( (Widget) m_workArea, ptr );
XtFree( (char *)ptr );
/* Part of show-&-hide fix */
XtAddEventHandler( (Widget)frameShell, StructureNotifyMask,
False, (XtEventHandler)wxFrameMapProc,
(XtPointer)this );
XtRealizeWidget((Widget) frameShell);
wxAddWindowToTable( (Widget)m_workArea, this);
wxAddWindowToTable( (Widget)m_clientArea, this);
wxModelessWindows.Append( this );
return TRUE;
}
wxFrame::~wxFrame() wxFrame::~wxFrame()
{ {
m_isBeingDeleted = TRUE; m_isBeingDeleted = TRUE;
@@ -353,10 +287,6 @@ wxFrame::~wxFrame()
{ {
XtRemoveEventHandler((Widget) m_clientArea, ExposureMask, FALSE, XtRemoveEventHandler((Widget) m_clientArea, ExposureMask, FALSE,
wxUniversalRepaintProc, (XtPointer) this); wxUniversalRepaintProc, (XtPointer) this);
XtRemoveEventHandler((Widget) m_clientArea, ButtonPressMask | ButtonReleaseMask | PointerMotionMask | KeyPressMask,
FALSE,
wxFrameEventHandler, (XtPointer) this);
wxDeleteWindowFromTable((Widget) m_clientArea);
} }
if (GetMainWidget()) if (GetMainWidget())
@@ -374,58 +304,42 @@ wxFrame::~wxFrame()
m_frameMenuBar = NULL; m_frameMenuBar = NULL;
} }
wxTopLevelWindows.DeleteObject(this);
wxModelessWindows.DeleteObject(this);
if (m_frameStatusBar) if (m_frameStatusBar)
{ {
delete m_frameStatusBar; delete m_frameStatusBar;
m_frameStatusBar = NULL; m_frameStatusBar = NULL;
} }
}
if (m_frameToolBar) void wxFrame::DoDestroy()
{
Widget frameShell = (Widget)GetShellWidget();
XtRemoveEventHandler( frameShell, StructureNotifyMask,
False, (XtEventHandler)wxFrameMapProc,
(XtPointer)this );
if( m_clientArea )
{ {
delete m_frameToolBar; wxDeleteWindowFromTable( (Widget)m_clientArea );
m_frameToolBar = NULL; XtDestroyWidget( (Widget)m_clientArea );
} }
DestroyChildren(); if( m_workArea )
if (m_workArea)
{ {
wxDeleteWindowFromTable((Widget) m_workArea); XtVaSetValues( (Widget)m_mainWidget,
XmNworkWindow, (Widget)NULL,
NULL );
XtDestroyWidget ((Widget) m_workArea); wxDeleteWindowFromTable( (Widget)m_workArea );
XtDestroyWidget( (Widget)m_workArea );
} }
// We need to destroy the base class icons here before we stop if( m_mainWidget )
// the event loop. This is a hack until we have a real top level XtDestroyWidget( (Widget)m_mainWidget );
// window (which would be responsible for killing the event loop).
m_icons.m_icons.Empty();
if (m_frameWidget) if( frameShell )
{ XtDestroyWidget( frameShell );
wxDeleteWindowFromTable((Widget) m_frameWidget);
XtDestroyWidget ((Widget) m_frameWidget);
}
if (m_frameShell)
XtDestroyWidget ((Widget) m_frameShell);
SetMainWidget((WXWidget) NULL);
/* Check if it's the last top-level window */
if (wxTheApp && (wxTopLevelWindows.Number() == 0))
{
wxTheApp->SetTopWindow(NULL);
if (wxTheApp->GetExitOnFrameDelete())
{
// Signal to the app that we're going to close
wxTheApp->ExitMainLoop();
}
}
} }
// Get size *available for subwindows* i.e. excluding menu bar, toolbar etc. // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
@@ -451,28 +365,6 @@ void wxFrame::DoGetClientSize(int *x, int *y) const
yy -= tbh; yy -= tbh;
} }
#endif // wxUSE_TOOLBAR #endif // wxUSE_TOOLBAR
/*
if (GetMenuBar() != (wxMenuBar*) NULL)
{
// it seems that if a frame holds a panel, the menu bar size
// gets automatically taken care of --- grano@cs.helsinki.fi 4.4.95
bool hasSubPanel = FALSE;
for(wxNode* node = GetChildren().First(); node; node = node->Next())
{
wxWindow *win = (wxWindow *)node->Data();
hasSubPanel = (win->IsKindOf(CLASSINFO(wxPanel)) && !win->IsKindOf(CLASSINFO(wxDialog)));
if (hasSubPanel)
break;
}
if (! hasSubPanel) {
Dimension ys;
XtVaGetValues((Widget) GetMenuBarWidget(), XmNheight, &ys, NULL);
yy -= ys;
}
}
*/
*x = xx; *y = yy; *x = xx; *y = yy;
} }
@@ -553,91 +445,54 @@ void wxFrame::DoSetSize(int x, int y, int width, int height, int WXUNUSED(sizeFl
if (y > -1) if (y > -1)
XtVaSetValues((Widget) m_frameShell, XmNy, y, NULL); XtVaSetValues((Widget) m_frameShell, XmNy, y, NULL);
if (width > -1) if (width > -1)
XtVaSetValues((Widget) m_frameWidget, XmNwidth, width, NULL); XtVaSetValues((Widget) m_mainWidget, XmNwidth, width, NULL);
if (height > -1) if (height > -1)
XtVaSetValues((Widget) m_frameWidget, XmNheight, height, NULL); XtVaSetValues((Widget) m_mainWidget, XmNheight, height, NULL);
if (!(height == -1 && width == -1)) if (!(height == -1 && width == -1))
{ {
PreResize(); PreResize();
wxSizeEvent sizeEvent(wxSize(width, height), GetId());
sizeEvent.SetEventObject(this);
GetEventHandler()->ProcessEvent(sizeEvent);
} }
} }
bool wxFrame::Show(bool show) bool wxFrame::Show( bool show )
{ {
if (!m_frameShell) if( !wxTopLevelWindowMotif::Show( show ) )
return wxWindow::Show(show); return FALSE;
m_visibleStatus = show; /* show-&-hide fix */
m_isShown = show; m_isShown = show;
if (show) {
XtMapWidget((Widget) m_frameShell); Widget shell = (Widget)GetShellWidget();
XRaiseWindow(XtDisplay((Widget) m_frameShell), XtWindow((Widget) m_frameShell)); if (!shell)
} else { return wxWindow::Show(show);
XtUnmapWidget((Widget) m_frameShell);
// XmUpdateDisplay(wxTheApp->topLevel); // Experimental: may be responsible for crashes SetVisibleStatus(show);
if (show)
{
XtMapWidget (shell);
XRaiseWindow (XtDisplay(shell), XtWindow(shell));
} }
else
{
XtUnmapWidget(shell);
}
return TRUE; return TRUE;
} }
void wxFrame::Iconize(bool iconize)
{
if (!iconize)
Show(TRUE);
if (m_frameShell)
XtVaSetValues((Widget) m_frameShell, XmNiconic, (Boolean)iconize, NULL);
}
void wxFrame::Restore()
{
if ( m_frameShell )
XtVaSetValues((Widget) m_frameShell, XmNiconic, FALSE, NULL);
}
void wxFrame::Maximize(bool maximize)
{
Show(TRUE);
if ( maximize )
Restore();
}
bool wxFrame::IsIconized() const
{
if (!m_frameShell)
return FALSE;
Boolean iconic;
XtVaGetValues((Widget) m_frameShell, XmNiconic, &iconic, NULL);
return iconic;
}
// Is it maximized?
bool wxFrame::IsMaximized() const
{
// No maximizing in Motif (?)
return FALSE;
}
void wxFrame::SetTitle(const wxString& title) void wxFrame::SetTitle(const wxString& title)
{ {
if (title == m_title) wxString oldTitle = GetTitle();
if( title == oldTitle )
return; return;
m_title = title; wxTopLevelWindow::SetTitle( title );
if (!title.IsNull()) if( !title.empty() )
XtVaSetValues((Widget) m_frameShell, XtVaSetValues( (Widget)m_frameShell,
XmNtitle, title.c_str(), XmNtitle, title.c_str(),
XmNiconName, title.c_str(), XmNiconName, title.c_str(),
NULL); NULL );
} }
void wxFrame::DoSetIcon(const wxIcon& icon) void wxFrame::DoSetIcon(const wxIcon& icon)
@@ -740,8 +595,7 @@ void wxFrame::OnActivate(wxActivateEvent& event)
{ {
// Find a child that's a subwindow, but not a dialog box. // Find a child that's a subwindow, but not a dialog box.
wxWindow *child = (wxWindow *)node->Data(); wxWindow *child = (wxWindow *)node->Data();
if (!child->IsKindOf(CLASSINFO(wxFrame)) && if (!child->IsTopLevel())
!child->IsKindOf(CLASSINFO(wxDialog)))
{ {
child->SetFocus(); child->SetFocus();
return; return;
@@ -765,98 +619,33 @@ wxToolBar* wxFrame::CreateToolBar(long style,
void wxFrame::PositionToolBar() void wxFrame::PositionToolBar()
{ {
if (GetToolBar()) wxToolBar* tb = GetToolBar();
if (tb)
{ {
int cw, ch; int cw, ch;
GetClientSize(& cw, &ch); GetClientSize(& cw, &ch);
int tw, th; int tw, th;
GetToolBar()->GetSize(& tw, & th); tb->GetSize(& tw, & th);
if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL) if (tb->GetWindowStyleFlag() & wxTB_VERTICAL)
{ {
// Use the 'real' position. wxSIZE_NO_ADJUSTMENTS // Use the 'real' position. wxSIZE_NO_ADJUSTMENTS
// means, pretend we don't have toolbar/status bar, so we // means, pretend we don't have toolbar/status bar, so we
// have the original client size. // have the original client size.
GetToolBar()->SetSize(0, 0, tw, ch + th, wxSIZE_NO_ADJUSTMENTS); th = ch + th;
} }
else else
{ {
// Use the 'real' position // Use the 'real' position
GetToolBar()->SetSize(0, 0, cw, th, wxSIZE_NO_ADJUSTMENTS); tw = cw;
} }
tb->SetSize(0, 0, tw, th, wxSIZE_NO_ADJUSTMENTS);
} }
} }
#endif // wxUSE_TOOLBAR #endif // wxUSE_TOOLBAR
void wxFrame::Raise()
{
Window parent_window = XtWindow((Widget) m_frameShell),
next_parent = XtWindow((Widget) m_frameShell),
root = RootWindowOfScreen(XtScreen((Widget) m_frameShell));
// search for the parent that is child of ROOT, because the WM may
// reparent twice and notify only the next parent (like FVWM)
while (next_parent != root) {
Window *theChildren; unsigned int n;
parent_window = next_parent;
XQueryTree(XtDisplay((Widget) m_frameShell), parent_window, &root,
&next_parent, &theChildren, &n);
XFree(theChildren); // not needed
}
XRaiseWindow(XtDisplay((Widget) m_frameShell), parent_window);
}
void wxFrame::Lower()
{
Window parent_window = XtWindow((Widget) m_frameShell),
next_parent = XtWindow((Widget) m_frameShell),
root = RootWindowOfScreen(XtScreen((Widget) m_frameShell));
// search for the parent that is child of ROOT, because the WM may
// reparent twice and notify only the next parent (like FVWM)
while (next_parent != root) {
Window *theChildren; unsigned int n;
parent_window = next_parent;
XQueryTree(XtDisplay((Widget) m_frameShell), parent_window, &root,
&next_parent, &theChildren, &n);
XFree(theChildren); // not needed
}
XLowerWindow(XtDisplay((Widget) m_frameShell), parent_window);
}
void wxFrameFocusProc(Widget WXUNUSED(workArea), XtPointer WXUNUSED(clientData),
XmAnyCallbackStruct *WXUNUSED(cbs))
{
// wxDebugMsg("focus proc from frame %ld\n",(long)frame);
// TODO
// wxFrame *frame = (wxFrame *)clientData;
// frame->GetEventHandler()->OnSetFocus();
}
/* MATTEW: Used to insure that hide-&-show within an event cycle works */
static void wxFrameMapProc(Widget frameShell, XtPointer clientData,
XCrossingEvent * event)
{
wxFrame *frame = (wxFrame *)wxGetWindowFromTable((Widget)clientData);
if (frame) {
XEvent *e = (XEvent *)event;
if (e->xany.type == MapNotify)
{
// Iconize fix
XtVaSetValues(frameShell, XmNiconic, (Boolean)False, NULL);
if (!frame->GetVisibleStatus())
{
/* We really wanted this to be hidden! */
XtUnmapWidget((Widget) frame->GetShellWidget());
}
}
else if (e->xany.type == UnmapNotify)
// Iconize fix
XtVaSetValues(frameShell, XmNiconic, (Boolean)True, NULL);
}
}
//// Motif-specific //// Motif-specific
bool wxFrame::PreResize() bool wxFrame::PreResize()
{ {
@@ -893,64 +682,25 @@ void wxFrame::ChangeForegroundColour()
DoChangeForegroundColour(GetClientWidget(), m_foregroundColour); DoChangeForegroundColour(GetClientWidget(), m_foregroundColour);
} }
void wxCloseFrameCallback(Widget WXUNUSED(widget), XtPointer client_data, XmAnyCallbackStruct *WXUNUSED(cbs)) /* MATTEW: Used to insure that hide-&-show within an event cycle works */
static void wxFrameMapProc( Widget frameShell, XtPointer clientData,
XCrossingEvent* event )
{ {
wxFrame *frame = (wxFrame *)client_data; wxFrame *tli = (wxFrame*)clientData;
wxCloseEvent closeEvent(wxEVT_CLOSE_WINDOW, frame->GetId()); XEvent *e = (XEvent *)event;
closeEvent.SetEventObject(frame);
// May delete the frame (with delayed deletion) if( e->xany.type == MapNotify )
frame->GetEventHandler()->ProcessEvent(closeEvent); {
} // Iconize fix
XtVaSetValues( frameShell, XmNiconic, (Boolean)False, NULL );
static void wxFrameEventHandler(Widget wid, if( !tli->GetVisibleStatus() )
XtPointer WXUNUSED(client_data), {
XEvent* event, /* We really wanted this to be hidden! */
Boolean* continueToDispatch) XtUnmapWidget( frameShell );
{ }
wxFrame *frame = (wxFrame *)wxGetWindowFromTable(wid); }
if (frame) else if( e->xany.type == UnmapNotify )
{ // Iconize fix
wxMouseEvent wxevent(wxEVT_NULL); XtVaSetValues( frameShell, XmNiconic, (Boolean)True, NULL );
if (wxTranslateMouseEvent(wxevent, frame, wid, event))
{
wxevent.SetEventObject(frame);
wxevent.SetId(frame->GetId());
frame->GetEventHandler()->ProcessEvent(wxevent);
}
else
{
// An attempt to implement OnCharHook by calling OnCharHook first;
// if this returns TRUE, set continueToDispatch to False
// (don't continue processing).
// Otherwise set it to True and call OnChar.
wxKeyEvent keyEvent(wxEVT_CHAR);
if (wxTranslateKeyEvent(keyEvent, frame, wid, event))
{
keyEvent.SetEventObject(frame);
keyEvent.SetId(frame->GetId());
keyEvent.SetEventType(wxEVT_CHAR_HOOK);
if (frame->GetEventHandler()->ProcessEvent(keyEvent))
{
*continueToDispatch = False;
return;
}
else
{
// For simplicity, OnKeyDown is the same as OnChar
// TODO: filter modifier key presses from OnChar
keyEvent.SetEventType(wxEVT_KEY_DOWN);
// Only process OnChar if OnKeyDown didn't swallow it
if (!frame->GetEventHandler()->ProcessEvent (keyEvent))
{
keyEvent.SetEventType(wxEVT_CHAR);
frame->GetEventHandler()->ProcessEvent(keyEvent);
}
}
}
}
}
*continueToDispatch = True;
} }

View File

@@ -509,7 +509,7 @@ void wxMDIChildFrame::DoGetPosition(int *x, int *y) const
bool wxMDIChildFrame::Show(bool show) bool wxMDIChildFrame::Show(bool show)
{ {
m_visibleStatus = show; /* show-&-hide fix */ SetVisibleStatus( show );
return wxWindow::Show(show); return wxWindow::Show(show);
} }
@@ -543,7 +543,7 @@ void wxMDIChildFrame::SetIcons(const wxIconBundle& icons)
void wxMDIChildFrame::SetTitle(const wxString& title) void wxMDIChildFrame::SetTitle(const wxString& title)
{ {
m_title = title; wxTopLevelWindow::SetTitle( title );
wxMDIClientWindow* clientWindow = GetMDIParentFrame()->GetClientWindow(); wxMDIClientWindow* clientWindow = GetMDIParentFrame()->GetClientWindow();
int pageNo = clientWindow->FindPagePosition(this); int pageNo = clientWindow->FindPagePosition(this);
if (pageNo > -1) if (pageNo > -1)