resizeable dialogs support
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1622 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
26f86486b0
commit
462e243784
@ -13,7 +13,7 @@
|
||||
#define _WX_DIALOG_H_
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "dialog.h"
|
||||
#pragma interface "dialog.h"
|
||||
#endif
|
||||
|
||||
#include "wx/panel.h"
|
||||
@ -21,102 +21,102 @@
|
||||
WXDLLEXPORT_DATA(extern const char*) wxDialogNameStr;
|
||||
|
||||
// Dialog boxes
|
||||
class WXDLLEXPORT wxDialog: public wxPanel
|
||||
class WXDLLEXPORT wxDialog : public wxPanel
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxDialog)
|
||||
protected:
|
||||
bool m_modalShowing;
|
||||
DECLARE_DYNAMIC_CLASS(wxDialog)
|
||||
|
||||
public:
|
||||
|
||||
wxDialog();
|
||||
|
||||
// Constructor with a modal flag, but no window id - the old convention
|
||||
inline wxDialog(wxWindow *parent,
|
||||
const wxString& title, bool modal,
|
||||
int x = -1, int y= -1, int width = 500, int height = 500,
|
||||
long style = wxDEFAULT_DIALOG_STYLE,
|
||||
const wxString& name = wxDialogNameStr)
|
||||
{
|
||||
long modalStyle = modal ? wxDIALOG_MODAL : wxDIALOG_MODELESS ;
|
||||
Create(parent, -1, title, wxPoint(x, y), wxSize(width, height), style|modalStyle, name);
|
||||
}
|
||||
|
||||
// Constructor with no modal flag - the new convention.
|
||||
inline wxDialog(wxWindow *parent, wxWindowID id,
|
||||
const wxString& title,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxDEFAULT_DIALOG_STYLE,
|
||||
const wxString& name = wxDialogNameStr)
|
||||
{
|
||||
Create(parent, id, title, pos, size, style, name);
|
||||
}
|
||||
|
||||
bool Create(wxWindow *parent, wxWindowID id,
|
||||
const wxString& title, // bool modal = FALSE, // TODO make this a window style?
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxDEFAULT_DIALOG_STYLE,
|
||||
const wxString& name = wxDialogNameStr);
|
||||
|
||||
~wxDialog();
|
||||
|
||||
virtual bool Destroy();
|
||||
|
||||
virtual void SetClientSize(int width, int height);
|
||||
|
||||
virtual void GetPosition(int *x, int *y) const;
|
||||
|
||||
bool Show(bool show);
|
||||
bool IsShown() const ;
|
||||
void Iconize(bool iconize);
|
||||
|
||||
wxDialog();
|
||||
|
||||
// Constructor with a modal flag, but no window id - the old convention
|
||||
wxDialog(wxWindow *parent,
|
||||
const wxString& title, bool modal,
|
||||
int x = -1, int y= -1, int width = 500, int height = 500,
|
||||
long style = wxDEFAULT_DIALOG_STYLE,
|
||||
const wxString& name = wxDialogNameStr)
|
||||
{
|
||||
long modalStyle = modal ? wxDIALOG_MODAL : wxDIALOG_MODELESS ;
|
||||
Create(parent, -1, title, wxPoint(x, y), wxSize(width, height),
|
||||
style | modalStyle, name);
|
||||
}
|
||||
|
||||
// Constructor with no modal flag - the new convention.
|
||||
wxDialog(wxWindow *parent, wxWindowID id,
|
||||
const wxString& title,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxDEFAULT_DIALOG_STYLE,
|
||||
const wxString& name = wxDialogNameStr)
|
||||
{
|
||||
Create(parent, id, title, pos, size, style, name);
|
||||
}
|
||||
|
||||
bool Create(wxWindow *parent, wxWindowID id,
|
||||
const wxString& title,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxDEFAULT_DIALOG_STYLE,
|
||||
const wxString& name = wxDialogNameStr);
|
||||
|
||||
~wxDialog();
|
||||
|
||||
virtual bool Destroy();
|
||||
|
||||
virtual void SetClientSize(int width, int height);
|
||||
|
||||
virtual void GetPosition(int *x, int *y) const;
|
||||
|
||||
bool Show(bool show);
|
||||
bool IsShown() const;
|
||||
void Iconize(bool iconize);
|
||||
|
||||
#if WXWIN_COMPATIBILITY
|
||||
inline bool Iconized() const { return IsIconized(); };
|
||||
bool Iconized() const { return IsIconized(); };
|
||||
#endif
|
||||
|
||||
virtual bool IsIconized() const;
|
||||
void Fit();
|
||||
|
||||
void SetTitle(const wxString& title);
|
||||
wxString GetTitle() const ;
|
||||
|
||||
void OnSize(wxSizeEvent& event);
|
||||
void OnCharHook(wxKeyEvent& event);
|
||||
void OnPaint(wxPaintEvent& event);
|
||||
void OnCloseWindow(wxCloseEvent& event);
|
||||
|
||||
void SetModal(bool flag);
|
||||
|
||||
virtual void Centre(int direction = wxBOTH);
|
||||
virtual bool IsModal() const { return ((GetWindowStyleFlag() & wxDIALOG_MODAL) == wxDIALOG_MODAL); }
|
||||
|
||||
// For now, same as Show(TRUE) but returns return code
|
||||
virtual int ShowModal();
|
||||
virtual void EndModal(int retCode);
|
||||
|
||||
// Standard buttons
|
||||
void OnOK(wxCommandEvent& event);
|
||||
void OnApply(wxCommandEvent& event);
|
||||
void OnCancel(wxCommandEvent& event);
|
||||
|
||||
// Responds to colour changes
|
||||
void OnSysColourChanged(wxSysColourChangedEvent& event);
|
||||
|
||||
// IMPLEMENTATION
|
||||
virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
|
||||
virtual long MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
|
||||
virtual bool MSWProcessMessage(WXMSG* pMsg);
|
||||
// virtual bool MSWOnEraseBkgnd(WXHDC pDC);
|
||||
virtual bool MSWOnClose();
|
||||
inline bool IsModalShowing() const { return m_modalShowing ; }
|
||||
virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
|
||||
WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
|
||||
|
||||
virtual bool IsIconized() const;
|
||||
void Fit();
|
||||
|
||||
void SetTitle(const wxString& title);
|
||||
wxString GetTitle() const ;
|
||||
|
||||
void OnSize(wxSizeEvent& event);
|
||||
bool OnClose();
|
||||
void OnCharHook(wxKeyEvent& event);
|
||||
void OnPaint(wxPaintEvent& event);
|
||||
void OnCloseWindow(wxCloseEvent& event);
|
||||
|
||||
void SetModal(bool flag);
|
||||
|
||||
virtual void Centre(int direction = wxBOTH);
|
||||
virtual bool IsModal() const
|
||||
{ return ((GetWindowStyleFlag() & wxDIALOG_MODAL) == wxDIALOG_MODAL); }
|
||||
|
||||
// For now, same as Show(TRUE) but returns return code
|
||||
virtual int ShowModal();
|
||||
virtual void EndModal(int retCode);
|
||||
|
||||
// Standard buttons
|
||||
void OnOK(wxCommandEvent& event);
|
||||
void OnApply(wxCommandEvent& event);
|
||||
void OnCancel(wxCommandEvent& event);
|
||||
|
||||
// Responds to colour changes
|
||||
void OnSysColourChanged(wxSysColourChangedEvent& event);
|
||||
|
||||
// IMPLEMENTATION
|
||||
virtual bool MSWProcessMessage(WXMSG* pMsg);
|
||||
virtual bool MSWOnClose();
|
||||
virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
|
||||
WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
|
||||
|
||||
bool IsModalShowing() const { return m_modalShowing; }
|
||||
|
||||
protected:
|
||||
WXHWND m_hwndOldFocus; // the window which had focus before we were shown
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
bool m_modalShowing;
|
||||
WXHWND m_hwndOldFocus; // the window which had focus before we were shown
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -40,6 +40,13 @@
|
||||
// Dummy Dialog for all wxCAPTION Dialog boxes
|
||||
//
|
||||
|
||||
wxResizeableDialog DIALOG DISCARDABLE 34, 22, 144, 75
|
||||
STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
|
||||
CAPTION ""
|
||||
BEGIN
|
||||
LTEXT "", -1,-2,-2,1,1 //necessary for __WATCOMC__
|
||||
END
|
||||
|
||||
wxCaptionDialog DIALOG DISCARDABLE 34, 22, 144, 75
|
||||
STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Dummy dialog"
|
||||
|
@ -44,25 +44,19 @@ wxList wxModelessWindows; // Frames and modeless dialogs
|
||||
extern wxList WXDLLEXPORT wxPendingDelete;
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxPanel)
|
||||
|
||||
BEGIN_EVENT_TABLE(wxDialog, wxPanel)
|
||||
EVT_SIZE(wxDialog::OnSize)
|
||||
EVT_BUTTON(wxID_OK, wxDialog::OnOK)
|
||||
EVT_BUTTON(wxID_APPLY, wxDialog::OnApply)
|
||||
EVT_BUTTON(wxID_CANCEL, wxDialog::OnCancel)
|
||||
EVT_CHAR_HOOK(wxDialog::OnCharHook)
|
||||
EVT_SYS_COLOUR_CHANGED(wxDialog::OnSysColourChanged)
|
||||
EVT_CLOSE(wxDialog::OnCloseWindow)
|
||||
END_EVENT_TABLE()
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxPanel)
|
||||
|
||||
BEGIN_EVENT_TABLE(wxDialog, wxPanel)
|
||||
EVT_SIZE(wxDialog::OnSize)
|
||||
EVT_BUTTON(wxID_OK, wxDialog::OnOK)
|
||||
EVT_BUTTON(wxID_APPLY, wxDialog::OnApply)
|
||||
EVT_BUTTON(wxID_CANCEL, wxDialog::OnCancel)
|
||||
EVT_CHAR_HOOK(wxDialog::OnCharHook)
|
||||
EVT_SYS_COLOUR_CHANGED(wxDialog::OnSysColourChanged)
|
||||
EVT_CLOSE(wxDialog::OnCloseWindow)
|
||||
END_EVENT_TABLE()
|
||||
#endif
|
||||
|
||||
long wxDialog::MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
|
||||
{
|
||||
return ::CallWindowProc(CASTWNDPROC m_oldWndProc, (HWND) GetHWND(), (UINT) nMsg, (WPARAM) wParam, (LPARAM) lParam);
|
||||
}
|
||||
|
||||
bool wxDialog::MSWProcessMessage(WXMSG* pMsg)
|
||||
{
|
||||
return (::IsDialogMessage((HWND) GetHWND(), (MSG*)pMsg) != 0);
|
||||
@ -82,65 +76,80 @@ wxDialog::wxDialog(void)
|
||||
}
|
||||
|
||||
bool wxDialog::Create(wxWindow *parent, wxWindowID id,
|
||||
const wxString& title,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxString& name)
|
||||
const wxString& title,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxString& name)
|
||||
{
|
||||
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
|
||||
SetName(name);
|
||||
|
||||
if (!parent)
|
||||
wxTopLevelWindows.Append(this);
|
||||
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
|
||||
SetName(name);
|
||||
|
||||
if (!parent)
|
||||
wxTopLevelWindows.Append(this);
|
||||
|
||||
// windowFont = wxTheFontList->FindOrCreateFont(11, wxSWISS, wxNORMAL, wxNORMAL);
|
||||
// windowFont = wxTheFontList->FindOrCreateFont(11, wxSWISS, wxNORMAL, wxNORMAL);
|
||||
|
||||
if (parent) parent->AddChild(this);
|
||||
if (parent) parent->AddChild(this);
|
||||
|
||||
if ( id == -1 )
|
||||
m_windowId = (int)NewControlId();
|
||||
else
|
||||
m_windowId = id;
|
||||
if ( id == -1 )
|
||||
m_windowId = (int)NewControlId();
|
||||
else
|
||||
m_windowId = id;
|
||||
|
||||
int x = pos.x;
|
||||
int y = pos.y;
|
||||
int width = size.x;
|
||||
int height = size.y;
|
||||
int x = pos.x;
|
||||
int y = pos.y;
|
||||
int width = size.x;
|
||||
int height = size.y;
|
||||
|
||||
if (x < 0) x = wxDIALOG_DEFAULT_X;
|
||||
if (y < 0) y = wxDIALOG_DEFAULT_Y;
|
||||
if (x < 0) x = wxDIALOG_DEFAULT_X;
|
||||
if (y < 0) y = wxDIALOG_DEFAULT_Y;
|
||||
|
||||
m_windowStyle = style;
|
||||
m_windowStyle = style;
|
||||
|
||||
m_isShown = FALSE;
|
||||
m_modalShowing = FALSE;
|
||||
m_isShown = FALSE;
|
||||
m_modalShowing = FALSE;
|
||||
|
||||
if (width < 0)
|
||||
width = 500;
|
||||
if (height < 0)
|
||||
height = 500;
|
||||
if (width < 0)
|
||||
width = 500;
|
||||
if (height < 0)
|
||||
height = 500;
|
||||
|
||||
WXDWORD extendedStyle = MakeExtendedStyle(m_windowStyle);
|
||||
if (m_windowStyle & wxSTAY_ON_TOP)
|
||||
extendedStyle |= WS_EX_TOPMOST;
|
||||
WXDWORD extendedStyle = MakeExtendedStyle(m_windowStyle);
|
||||
if (m_windowStyle & wxSTAY_ON_TOP)
|
||||
extendedStyle |= WS_EX_TOPMOST;
|
||||
|
||||
// Allows creation of dialogs with & without captions under MSWindows
|
||||
if(style & wxCAPTION){
|
||||
MSWCreate(m_windowId, (wxWindow *)parent, NULL, this, NULL, x, y, width, height, 0, "wxCaptionDialog",
|
||||
extendedStyle);
|
||||
}
|
||||
else{
|
||||
MSWCreate(m_windowId, (wxWindow *)parent, NULL, this, NULL, x, y, width, height, 0, "wxNoCaptionDialog",
|
||||
extendedStyle);
|
||||
}
|
||||
// Allows creation of dialogs with & without captions under MSWindows,
|
||||
// resizeable or not (but a resizeable dialog always has caption -
|
||||
// otherwise it would look too strange)
|
||||
const char *dlg;
|
||||
if ( style & wxTHICK_FRAME )
|
||||
dlg = "wxResizeableDialog";
|
||||
else if ( style & wxCAPTION )
|
||||
dlg = "wxCaptionDialog";
|
||||
else
|
||||
dlg = "wxNoCaptionDialog";
|
||||
MSWCreate(m_windowId, parent, NULL, this, NULL,
|
||||
x, y, width, height,
|
||||
0, // style is not used if we have dlg template
|
||||
dlg,
|
||||
extendedStyle);
|
||||
|
||||
SubclassWin(GetHWND());
|
||||
HWND hwnd = (HWND)GetHWND();
|
||||
|
||||
SetWindowText((HWND) GetHWND(), (const char *)title);
|
||||
SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
|
||||
if ( !hwnd )
|
||||
{
|
||||
wxLogError(_("Failed to created dialog."));
|
||||
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
SubclassWin(GetHWND());
|
||||
|
||||
SetWindowText(hwnd, title);
|
||||
SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void wxDialog::SetModal(bool flag)
|
||||
@ -610,10 +619,4 @@ void wxDialog::OnSysColourChanged(wxSysColourChangedEvent& event)
|
||||
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
|
||||
Refresh();
|
||||
#endif
|
||||
}
|
||||
|
||||
long wxDialog::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
|
||||
{
|
||||
return wxWindow::MSWWindowProc(message, wParam, lParam);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user