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:
Vadim Zeitlin
1999-02-06 23:27:08 +00:00
parent 26f86486b0
commit 462e243784
3 changed files with 169 additions and 159 deletions

View File

@@ -24,25 +24,24 @@ WXDLLEXPORT_DATA(extern const char*) wxDialogNameStr;
class WXDLLEXPORT wxDialog : public wxPanel class WXDLLEXPORT wxDialog : public wxPanel
{ {
DECLARE_DYNAMIC_CLASS(wxDialog) DECLARE_DYNAMIC_CLASS(wxDialog)
protected:
bool m_modalShowing;
public:
public:
wxDialog(); wxDialog();
// Constructor with a modal flag, but no window id - the old convention // Constructor with a modal flag, but no window id - the old convention
inline wxDialog(wxWindow *parent, wxDialog(wxWindow *parent,
const wxString& title, bool modal, const wxString& title, bool modal,
int x = -1, int y= -1, int width = 500, int height = 500, int x = -1, int y= -1, int width = 500, int height = 500,
long style = wxDEFAULT_DIALOG_STYLE, long style = wxDEFAULT_DIALOG_STYLE,
const wxString& name = wxDialogNameStr) const wxString& name = wxDialogNameStr)
{ {
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);
} }
// Constructor with no modal flag - the new convention. // Constructor with no modal flag - the new convention.
inline wxDialog(wxWindow *parent, wxWindowID id, wxDialog(wxWindow *parent, wxWindowID id,
const wxString& title, const wxString& title,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
@@ -53,7 +52,7 @@ public:
} }
bool Create(wxWindow *parent, wxWindowID id, bool Create(wxWindow *parent, wxWindowID id,
const wxString& title, // bool modal = FALSE, // TODO make this a window style? const wxString& title,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_DIALOG_STYLE, long style = wxDEFAULT_DIALOG_STYLE,
@@ -72,7 +71,7 @@ public:
void Iconize(bool iconize); void Iconize(bool iconize);
#if WXWIN_COMPATIBILITY #if WXWIN_COMPATIBILITY
inline bool Iconized() const { return IsIconized(); }; bool Iconized() const { return IsIconized(); };
#endif #endif
virtual bool IsIconized() const; virtual bool IsIconized() const;
@@ -82,6 +81,7 @@ public:
wxString GetTitle() const ; wxString GetTitle() const ;
void OnSize(wxSizeEvent& event); void OnSize(wxSizeEvent& event);
bool OnClose();
void OnCharHook(wxKeyEvent& event); void OnCharHook(wxKeyEvent& event);
void OnPaint(wxPaintEvent& event); void OnPaint(wxPaintEvent& event);
void OnCloseWindow(wxCloseEvent& event); void OnCloseWindow(wxCloseEvent& event);
@@ -89,7 +89,8 @@ public:
void SetModal(bool flag); void SetModal(bool flag);
virtual void Centre(int direction = wxBOTH); virtual void Centre(int direction = wxBOTH);
virtual bool IsModal() const { return ((GetWindowStyleFlag() & wxDIALOG_MODAL) == wxDIALOG_MODAL); } virtual bool IsModal() const
{ return ((GetWindowStyleFlag() & wxDIALOG_MODAL) == wxDIALOG_MODAL); }
// For now, same as Show(TRUE) but returns return code // For now, same as Show(TRUE) but returns return code
virtual int ShowModal(); virtual int ShowModal();
@@ -104,16 +105,15 @@ public:
void OnSysColourChanged(wxSysColourChangedEvent& event); void OnSysColourChanged(wxSysColourChangedEvent& event);
// IMPLEMENTATION // 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 MSWProcessMessage(WXMSG* pMsg);
// virtual bool MSWOnEraseBkgnd(WXHDC pDC);
virtual bool MSWOnClose(); virtual bool MSWOnClose();
inline bool IsModalShowing() const { return m_modalShowing ; }
virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
WXUINT message, WXWPARAM wParam, WXLPARAM lParam); WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
bool IsModalShowing() const { return m_modalShowing; }
protected: protected:
bool m_modalShowing;
WXHWND m_hwndOldFocus; // the window which had focus before we were shown WXHWND m_hwndOldFocus; // the window which had focus before we were shown
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()

View File

@@ -40,6 +40,13 @@
// Dummy Dialog for all wxCAPTION Dialog boxes // 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 wxCaptionDialog DIALOG DISCARDABLE 34, 22, 144, 75
STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "Dummy dialog" CAPTION "Dummy dialog"

View File

@@ -55,14 +55,8 @@ BEGIN_EVENT_TABLE(wxDialog, wxPanel)
EVT_SYS_COLOUR_CHANGED(wxDialog::OnSysColourChanged) EVT_SYS_COLOUR_CHANGED(wxDialog::OnSysColourChanged)
EVT_CLOSE(wxDialog::OnCloseWindow) EVT_CLOSE(wxDialog::OnCloseWindow)
END_EVENT_TABLE() END_EVENT_TABLE()
#endif #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) bool wxDialog::MSWProcessMessage(WXMSG* pMsg)
{ {
return (::IsDialogMessage((HWND) GetHWND(), (MSG*)pMsg) != 0); return (::IsDialogMessage((HWND) GetHWND(), (MSG*)pMsg) != 0);
@@ -125,19 +119,34 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id,
if (m_windowStyle & wxSTAY_ON_TOP) if (m_windowStyle & wxSTAY_ON_TOP)
extendedStyle |= WS_EX_TOPMOST; extendedStyle |= WS_EX_TOPMOST;
// Allows creation of dialogs with & without captions under MSWindows // Allows creation of dialogs with & without captions under MSWindows,
if(style & wxCAPTION){ // resizeable or not (but a resizeable dialog always has caption -
MSWCreate(m_windowId, (wxWindow *)parent, NULL, this, NULL, x, y, width, height, 0, "wxCaptionDialog", // otherwise it would look too strange)
extendedStyle); const char *dlg;
} if ( style & wxTHICK_FRAME )
else{ dlg = "wxResizeableDialog";
MSWCreate(m_windowId, (wxWindow *)parent, NULL, this, NULL, x, y, width, height, 0, "wxNoCaptionDialog", 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); extendedStyle);
HWND hwnd = (HWND)GetHWND();
if ( !hwnd )
{
wxLogError(_("Failed to created dialog."));
return FALSE;
} }
SubclassWin(GetHWND()); SubclassWin(GetHWND());
SetWindowText((HWND) GetHWND(), (const char *)title); SetWindowText(hwnd, title);
SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT)); SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
return TRUE; return TRUE;
@@ -611,9 +620,3 @@ void wxDialog::OnSysColourChanged(wxSysColourChangedEvent& event)
Refresh(); Refresh();
#endif #endif
} }
long wxDialog::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
{
return wxWindow::MSWWindowProc(message, wParam, lParam);
}