Added AddGrab, RemoveGrab, IsGrabbed to wxTopLevelWindowGTK
and AddGrabIfNeeded to wxHtmlHelpController, to assist with showing the help window from a modal dialog. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15880 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
68b893338a
commit
5152b0e59a
@ -65,6 +65,12 @@ public:
|
||||
virtual void SetTitle( const wxString &title );
|
||||
virtual wxString GetTitle() const { return m_title; }
|
||||
|
||||
// Experimental, to allow help windows to be
|
||||
// viewable from within modal dialogs
|
||||
virtual void AddGrab();
|
||||
virtual void RemoveGrab();
|
||||
virtual bool IsGrabbed() const { return m_grabbed; }
|
||||
|
||||
// implementation from now on
|
||||
// --------------------------
|
||||
|
||||
@ -111,6 +117,9 @@ protected:
|
||||
|
||||
// is the frame currently iconized?
|
||||
bool m_isIconized;
|
||||
// is the frame currently grabbed explicitly
|
||||
// by the application?
|
||||
bool m_grabbed;
|
||||
};
|
||||
|
||||
#endif // __GTKTOPLEVELH__
|
||||
|
@ -65,6 +65,12 @@ public:
|
||||
virtual void SetTitle( const wxString &title );
|
||||
virtual wxString GetTitle() const { return m_title; }
|
||||
|
||||
// Experimental, to allow help windows to be
|
||||
// viewable from within modal dialogs
|
||||
virtual void AddGrab();
|
||||
virtual void RemoveGrab();
|
||||
virtual bool IsGrabbed() const { return m_grabbed; }
|
||||
|
||||
// implementation from now on
|
||||
// --------------------------
|
||||
|
||||
@ -111,6 +117,9 @@ protected:
|
||||
|
||||
// is the frame currently iconized?
|
||||
bool m_isIconized;
|
||||
// is the frame currently grabbed explicitly
|
||||
// by the application?
|
||||
bool m_grabbed;
|
||||
};
|
||||
|
||||
#endif // __GTKTOPLEVELH__
|
||||
|
@ -36,26 +36,13 @@ public:
|
||||
void SetTitleFormat(const wxString& format);
|
||||
void SetTempDir(const wxString& path) { m_helpData.SetTempDir(path); }
|
||||
bool AddBook(const wxString& book, bool show_wait_msg = FALSE);
|
||||
bool Display(const wxString& x)
|
||||
{
|
||||
CreateHelpWindow(); return m_helpFrame->Display(x);
|
||||
}
|
||||
bool Display(int id)
|
||||
{
|
||||
CreateHelpWindow(); return m_helpFrame->Display(id);
|
||||
}
|
||||
bool DisplayContents()
|
||||
{
|
||||
CreateHelpWindow(); return m_helpFrame->DisplayContents();
|
||||
}
|
||||
bool DisplayIndex()
|
||||
{
|
||||
CreateHelpWindow(); return m_helpFrame->DisplayIndex();
|
||||
}
|
||||
bool KeywordSearch(const wxString& keyword)
|
||||
{
|
||||
CreateHelpWindow(); return m_helpFrame->KeywordSearch(keyword);
|
||||
}
|
||||
|
||||
bool Display(const wxString& x);
|
||||
bool Display(int id);
|
||||
bool DisplayContents();
|
||||
bool DisplayIndex();
|
||||
bool KeywordSearch(const wxString& keyword);
|
||||
|
||||
wxHtmlHelpFrame* GetFrame() { return m_helpFrame; }
|
||||
void UseConfig(wxConfigBase *config, const wxString& rootpath = wxEmptyString);
|
||||
|
||||
@ -94,6 +81,10 @@ public:
|
||||
|
||||
void OnCloseFrame(wxCloseEvent& evt);
|
||||
|
||||
// Make the help controller's frame 'modal' if
|
||||
// needed
|
||||
void AddGrabIfNeeded();
|
||||
|
||||
protected:
|
||||
virtual wxHtmlHelpFrame* CreateHelpFrame(wxHtmlHelpData *data);
|
||||
|
||||
|
@ -111,7 +111,8 @@ static gint gtk_frame_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WX
|
||||
wxapp_install_idle_handler();
|
||||
|
||||
if (win->IsEnabled() &&
|
||||
(g_openDialogs == 0 || (win->GetExtraStyle() & wxTOPLEVEL_EX_DIALOG)))
|
||||
(g_openDialogs == 0 || (win->GetExtraStyle() & wxTOPLEVEL_EX_DIALOG) ||
|
||||
win->IsGrabbed()))
|
||||
win->Close();
|
||||
|
||||
return TRUE;
|
||||
@ -302,6 +303,7 @@ void wxTopLevelWindowGTK::Init()
|
||||
m_fsIsShowing = FALSE;
|
||||
m_themeEnabled = TRUE;
|
||||
m_gdkDecor = m_gdkFunc = 0;
|
||||
m_grabbed = FALSE;
|
||||
}
|
||||
|
||||
bool wxTopLevelWindowGTK::Create( wxWindow *parent,
|
||||
@ -472,6 +474,12 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent,
|
||||
|
||||
wxTopLevelWindowGTK::~wxTopLevelWindowGTK()
|
||||
{
|
||||
if (m_grabbed)
|
||||
{
|
||||
wxASSERT_MSG( FALSE, "Window still grabbed");
|
||||
RemoveGrab();
|
||||
}
|
||||
|
||||
m_isBeingDeleted = TRUE;
|
||||
|
||||
// it may also be GtkScrolledWindow in the case of an MDI child
|
||||
@ -869,3 +877,22 @@ void wxTopLevelWindowGTK::SetIconizeState(bool iconize)
|
||||
}
|
||||
}
|
||||
|
||||
void wxTopLevelWindowGTK::AddGrab()
|
||||
{
|
||||
if (!m_grabbed)
|
||||
{
|
||||
m_grabbed = TRUE;
|
||||
gtk_grab_add( m_widget );
|
||||
gtk_main();
|
||||
gtk_grab_remove( m_widget );
|
||||
}
|
||||
}
|
||||
|
||||
void wxTopLevelWindowGTK::RemoveGrab()
|
||||
{
|
||||
if (m_grabbed)
|
||||
{
|
||||
gtk_main_quit();
|
||||
m_grabbed = FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -111,7 +111,8 @@ static gint gtk_frame_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WX
|
||||
wxapp_install_idle_handler();
|
||||
|
||||
if (win->IsEnabled() &&
|
||||
(g_openDialogs == 0 || (win->GetExtraStyle() & wxTOPLEVEL_EX_DIALOG)))
|
||||
(g_openDialogs == 0 || (win->GetExtraStyle() & wxTOPLEVEL_EX_DIALOG) ||
|
||||
win->IsGrabbed()))
|
||||
win->Close();
|
||||
|
||||
return TRUE;
|
||||
@ -302,6 +303,7 @@ void wxTopLevelWindowGTK::Init()
|
||||
m_fsIsShowing = FALSE;
|
||||
m_themeEnabled = TRUE;
|
||||
m_gdkDecor = m_gdkFunc = 0;
|
||||
m_grabbed = FALSE;
|
||||
}
|
||||
|
||||
bool wxTopLevelWindowGTK::Create( wxWindow *parent,
|
||||
@ -472,6 +474,12 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent,
|
||||
|
||||
wxTopLevelWindowGTK::~wxTopLevelWindowGTK()
|
||||
{
|
||||
if (m_grabbed)
|
||||
{
|
||||
wxASSERT_MSG( FALSE, "Window still grabbed");
|
||||
RemoveGrab();
|
||||
}
|
||||
|
||||
m_isBeingDeleted = TRUE;
|
||||
|
||||
// it may also be GtkScrolledWindow in the case of an MDI child
|
||||
@ -869,3 +877,22 @@ void wxTopLevelWindowGTK::SetIconizeState(bool iconize)
|
||||
}
|
||||
}
|
||||
|
||||
void wxTopLevelWindowGTK::AddGrab()
|
||||
{
|
||||
if (!m_grabbed)
|
||||
{
|
||||
m_grabbed = TRUE;
|
||||
gtk_grab_add( m_widget );
|
||||
gtk_main();
|
||||
gtk_grab_remove( m_widget );
|
||||
}
|
||||
}
|
||||
|
||||
void wxTopLevelWindowGTK::RemoveGrab()
|
||||
{
|
||||
if (m_grabbed)
|
||||
{
|
||||
gtk_main_quit();
|
||||
m_grabbed = FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -251,5 +251,71 @@ bool wxHtmlHelpController::Quit()
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Make the help controller's frame 'modal' if
|
||||
// needed
|
||||
void wxHtmlHelpController::AddGrabIfNeeded()
|
||||
{
|
||||
// So far, wxGTK only
|
||||
#ifdef __WXGTK__
|
||||
bool needGrab = FALSE;
|
||||
|
||||
// Check if there are any modal windows present,
|
||||
// in which case we need to add a grab.
|
||||
for ( wxWindowList::Node * node = wxTopLevelWindows.GetFirst();
|
||||
node;
|
||||
node = node->GetNext() )
|
||||
{
|
||||
wxWindow *win = node->GetData();
|
||||
wxDialog *dialog = wxDynamicCast(win, wxDialog);
|
||||
|
||||
if (dialog && dialog->IsModal())
|
||||
needGrab = TRUE;
|
||||
}
|
||||
|
||||
if (needGrab && m_helpFrame)
|
||||
m_helpFrame->AddGrab();
|
||||
#endif
|
||||
}
|
||||
|
||||
bool wxHtmlHelpController::Display(const wxString& x)
|
||||
{
|
||||
CreateHelpWindow();
|
||||
bool success = m_helpFrame->Display(x);
|
||||
AddGrabIfNeeded();
|
||||
return success;
|
||||
}
|
||||
|
||||
bool wxHtmlHelpController::Display(int id)
|
||||
{
|
||||
CreateHelpWindow();
|
||||
bool success = m_helpFrame->Display(id);
|
||||
AddGrabIfNeeded();
|
||||
return success;
|
||||
}
|
||||
|
||||
bool wxHtmlHelpController::DisplayContents()
|
||||
{
|
||||
CreateHelpWindow();
|
||||
bool success = m_helpFrame->DisplayContents();
|
||||
AddGrabIfNeeded();
|
||||
return success;
|
||||
}
|
||||
|
||||
bool wxHtmlHelpController::DisplayIndex()
|
||||
{
|
||||
CreateHelpWindow();
|
||||
bool success = m_helpFrame->DisplayIndex();
|
||||
AddGrabIfNeeded();
|
||||
return success;
|
||||
}
|
||||
|
||||
bool wxHtmlHelpController::KeywordSearch(const wxString& keyword)
|
||||
{
|
||||
CreateHelpWindow();
|
||||
bool success = m_helpFrame->KeywordSearch(keyword);
|
||||
AddGrabIfNeeded();
|
||||
return success;
|
||||
}
|
||||
|
||||
#endif // wxUSE_WXHTML_HELP
|
||||
|
||||
|
@ -1442,6 +1442,13 @@ void wxHtmlHelpFrame::OnCloseWindow(wxCloseEvent& evt)
|
||||
GetSize(&m_Cfg.w, &m_Cfg.h);
|
||||
GetPosition(&m_Cfg.x, &m_Cfg.y);
|
||||
|
||||
#ifdef __WXGTK__
|
||||
if (IsGrabbed())
|
||||
{
|
||||
RemoveGrab();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (m_Splitter && m_Cfg.navig_on) m_Cfg.sashpos = m_Splitter->GetSashPosition();
|
||||
|
||||
if (m_Config)
|
||||
|
Loading…
Reference in New Issue
Block a user