#define wxDIALOG_MODAL 0x0020
#define wxDIALOG_MODELESS 0x0000
-// Add for normal Windows frame behaviour
-#define wxFRAME_FLOAT_ON_PARENT 0x0020
+// deprecated flag, don't use any more, defined for compatibility only
+#define wxFRAME_FLOAT_ON_PARENT 0
// Context-sensitive help
#define wxFRAME_EX_CONTEXTHELP 0x00000004
// Dialog boxes
class WXDLLEXPORT wxDialog : public wxDialogBase
{
- DECLARE_DYNAMIC_CLASS(wxDialog)
-
public:
- wxDialog();
+ wxDialog() { Init(); }
// Constructor with a modal flag, but no window id - the old convention
wxDialog(wxWindow *parent,
// show modal dialog and enter modal loop
void DoShowModal();
+ // common part of all ctors
+ void Init();
+
private:
wxWindow *m_oldFocus;
+ // while we are showing a modal dialog we disable the other windows using
+ // this object
+ class wxWindowDisabler *m_windowDisabler;
+
+ DECLARE_DYNAMIC_CLASS(wxDialog)
DECLARE_EVENT_TABLE()
};
private:
wxWindowList *m_winDisabled;
-
-#ifdef __WXMSW__
- wxWindow *m_winTop;
-#endif // MSW
};
// ----------------------------------------------------------------------------
#if wxUSE_WCHAR_T
+#ifdef WC_UTF16
+
static size_t encode_utf16(wxUint32 input,wxUint16*output)
{
if (input<=0xffff) {
}
}
+#endif // WC_UTF16
+
// ----------------------------------------------------------------------------
// wxMBConv
// ----------------------------------------------------------------------------
wxWindowDisabler::wxWindowDisabler(wxWindow *winToSkip)
{
-#ifdef __WXMSW__
-#ifdef __WIN32__
- // and the top level window too
- HWND hwndFG = ::GetForegroundWindow();
- m_winTop = hwndFG ? wxFindWinFromHandle((WXHWND)hwndFG) : (wxWindow *)NULL;
-#else
- HWND hwndFG = ::GetTopWindow(0);
- m_winTop = hwndFG ? wxFindWinFromHandle((WXHWND)hwndFG) : (wxWindow *)NULL;
-#endif
-#endif // MSW
-
// remember the top level windows which were already disabled, so that we
// don't reenable them later
m_winDisabled = NULL;
}
delete m_winDisabled;
-
-#ifdef __WXMSW__
-#ifdef __WIN32__
- if ( m_winTop )
- {
- if ( !::SetForegroundWindow(GetHwndOf(m_winTop)) )
- {
- wxLogLastError(wxT("SetForegroundWindow"));
- }
- }
-#else
- if ( m_winTop )
- {
- // 16-bit SetForegroundWindow() replacement
- RECT reWin;
- GetWindowRect((HWND) m_winTop, &reWin);
- SetWindowPos ((HWND) m_winTop, HWND_TOP,
- reWin.left, reWin.top,
- reWin.right - reWin.left, reWin.bottom,
- SWP_SHOWWINDOW);
- }
-#endif
-#endif // MSW
}
// Yield to other apps/messages and disable user input to all windows except
// wxDialog construction
// ----------------------------------------------------------------------------
-wxDialog::wxDialog()
+void wxDialog::Init()
{
m_oldFocus = (wxWindow *)NULL;
+
m_isShown = FALSE;
+ m_windowDisabler = (wxWindowDisabler *)NULL;
+
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
}
long style,
const wxString& name)
{
+ Init();
+
m_oldFocus = FindFocus();
- SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
SetName(name);
wxTopLevelWindows.Append(this);
m_windowStyle = style;
- m_isShown = FALSE;
-
if (width < 0)
width = wxDIALOG_DEFAULT_WIDTH;
if (height < 0)
wxTopLevelWindows.DeleteObject(this);
- // this will call BringWindowToTop() if necessary to bring back our parent
- // window to top
+ // this will also reenable all the other windows for a modal dialog
Show(FALSE);
if ( !IsModal() )
if (oldFocus)
hwndOldFocus = (HWND) oldFocus->GetHWND();
- // inside this block, all app windows are disabled
+ // remember where the focus was
+ if ( !oldFocus )
{
- wxWindowDisabler wd(this);
+ oldFocus = parent;
+ if ( parent )
+ hwndOldFocus = GetHwndOf(parent);
+ }
- // remember where the focus was
- if ( !oldFocus )
- {
- oldFocus = parent;
- if (parent)
- hwndOldFocus = (HWND) parent->GetHWND();
- }
+ // disable all other app windows
+ wxASSERT_MSG( !m_windowDisabler, _T("disabling windows twice?") );
- // enter the modal loop
- while ( IsModalShowing() )
- {
+ m_windowDisabler = new wxWindowDisabler(this);
+
+ // enter the modal loop
+ while ( IsModalShowing() )
+ {
#if wxUSE_THREADS
- wxMutexGuiLeaveOrEnter();
+ wxMutexGuiLeaveOrEnter();
#endif // wxUSE_THREADS
- while ( !wxTheApp->Pending() && wxTheApp->ProcessIdle() )
- ;
+ while ( !wxTheApp->Pending() && wxTheApp->ProcessIdle() )
+ ;
- // a message came or no more idle processing to do
- wxTheApp->DoMessage();
- }
+ // a message came or no more idle processing to do
+ wxTheApp->DoMessage();
}
-#ifdef __WIN32__
+#if 0 //def __WIN32__
if ( parent )
::SetActiveWindow(GetHwndOf(parent));
#endif // __WIN32__
bool wxDialog::Show(bool show)
{
- // The following is required when the parent has been disabled, (modal
- // dialogs, or modeless dialogs with disabling such as wxProgressDialog).
- // Otherwise the parent disappears behind other windows when the dialog is
- // hidden.
if ( !show )
{
- wxWindow *parent = GetParent();
- if ( parent )
+ // if we had disabled other app windows, reenable them back now because
+ // if they stay disabled Windows will activate another window (one
+ // which is enabled, anyhow) and we will lose activation
+ if ( m_windowDisabler )
{
- ::BringWindowToTop(GetHwndOf(parent));
+ delete m_windowDisabler;
+ m_windowDisabler = NULL;
}
}
switch ( message )
{
+#if 0 // now that we got owner window right it doesn't seem to be needed
case WM_ACTIVATE:
switch ( LOWORD(wParam) )
{
// fall through to process it normally as well
}
break;
+#endif // 0
case WM_CLOSE:
// if we can't close, tell the system that we processed the
m_iconized = FALSE;
- // we pass NULL as parent to MSWCreate because frames with parents behave
- // very strangely under Win95 shell
- // Alteration by JACS: keep normal Windows behaviour (float on top of parent)
- // with this style.
- if ((m_windowStyle & wxFRAME_FLOAT_ON_PARENT) == 0)
- parent = NULL;
-
wxTopLevelWindows.Append(this);
MSWCreate(m_windowId, parent, wxFrameClassName, this, title,
WXDWORD extendedStyle = MakeExtendedStyle(style);
+ // make all frames appear in the win9x shell taskbar unless
+ // wxFRAME_TOOL_WINDOW is explicitly given - without giving them
+ // WS_EX_APPWINDOW style, the child (i.e. owned) frames wouldn't appear in it
#if !defined(__WIN16__) && !defined(__SC__)
if (style & wxFRAME_TOOL_WINDOW)
- extendedStyle |= WS_EX_TOOLWINDOW;
+ extendedStyle |= WS_EX_TOOLWINDOW;
+ else
+ extendedStyle |= WS_EX_APPWINDOW;
#endif
if (style & wxSTAY_ON_TOP)
wxRect itemRect;
int cy=0;
- int lastH = 0;
int itemCount = GetItemCount();
int i;
for (i = 0; i < itemCount; i++)