]> git.saurik.com Git - wxWidgets.git/commitdiff
Added wxInfoBar::Dismiss().
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 5 Oct 2009 22:56:07 +0000 (22:56 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 5 Oct 2009 22:56:07 +0000 (22:56 +0000)
Add a method to conveniently hide the info bar and update the parent layout.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62284 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/generic/infobar.h
include/wx/gtk/infobar.h
include/wx/infobar.h
interface/wx/infobar.h
src/generic/infobar.cpp
src/gtk/infobar.cpp

index db57ea31b11c605ee425775682cb04b81f357568..a858c6d0d7591a40c101a817cbd0fe00bb690d45 100644 (file)
@@ -41,6 +41,8 @@ public:
     virtual void ShowMessage(const wxString& msg,
                              int flags = wxICON_INFORMATION);
 
     virtual void ShowMessage(const wxString& msg,
                              int flags = wxICON_INFORMATION);
 
+    virtual void Dismiss();
+
     virtual void AddButton(wxWindowID btnid, const wxString& label = wxString());
 
     virtual void RemoveButton(wxWindowID btnid);
     virtual void AddButton(wxWindowID btnid, const wxString& label = wxString());
 
     virtual void RemoveButton(wxWindowID btnid);
index ed4b0a08d7b0499f2b032da0d8b98c943e6a43d3..31fe8571b59daa78a562e979f1bf6df0c073b266 100644 (file)
@@ -41,6 +41,8 @@ public:
     virtual void ShowMessage(const wxString& msg,
                              int flags = wxICON_INFORMATION);
 
     virtual void ShowMessage(const wxString& msg,
                              int flags = wxICON_INFORMATION);
 
+    virtual void Dismiss();
+
     virtual void AddButton(wxWindowID btnid,
                            const wxString& label = wxString());
 
     virtual void AddButton(wxWindowID btnid,
                            const wxString& label = wxString());
 
index 7d661283e0492bc034d74042e4b48b47720adb52..0c9207207b6e12d64f6dfb6a8ec02cf32f22dcdb 100644 (file)
@@ -36,6 +36,9 @@ public:
     virtual void ShowMessage(const wxString& msg,
                              int flags = wxICON_INFORMATION) = 0;
 
     virtual void ShowMessage(const wxString& msg,
                              int flags = wxICON_INFORMATION) = 0;
 
+    // hide the info bar
+    virtual void Dismiss() = 0;
+
     // add an extra button to the bar, near the message (replacing the default
     // close button which is only shown if no extra buttons are used)
     virtual void AddButton(wxWindowID btnid,
     // add an extra button to the bar, near the message (replacing the default
     // close button which is only shown if no extra buttons are used)
     virtual void AddButton(wxWindowID btnid,
index 91360cf2d1de163537cc3dd042ad5e82af8c1749..f79f3b110dcff767eec0d283017d4bdb26f64cb3 100644 (file)
@@ -123,9 +123,10 @@ public:
         itself closes the window whenever a button in it is clicked so if you
         wish the info bar to be hidden when the button is clicked, simply call
         @c event.Skip() in the button handler to let the base class handler do
         itself closes the window whenever a button in it is clicked so if you
         wish the info bar to be hidden when the button is clicked, simply call
         @c event.Skip() in the button handler to let the base class handler do
-        it. On the other hand, if you don't skip the event, the info bar will
-        remain opened so make sure to do it for at least some buttons to allow
-        the user to close it.
+        it (calling Dismiss() explicitly works too, of course). On the other
+        hand, if you don't skip the event, the info bar will remain opened so
+        make sure to do it for at least some buttons to allow the user to close
+        it.
 
         Notice that the generic wxInfoBar implementation handles the button
         events itself and so they are not propagated to the info bar parent and
 
         Notice that the generic wxInfoBar implementation handles the button
         events itself and so they are not propagated to the info bar parent and
@@ -143,6 +144,14 @@ public:
      */
     void AddButton(wxWindowID btnid, const wxString& label = wxString());
 
      */
     void AddButton(wxWindowID btnid, const wxString& label = wxString());
 
+    /**
+        Hide the info bar window.
+
+        This method hides the window and lays out the parent window to account
+        for its disappearance (unlike a simple Hide()).
+     */
+    void Dismiss();
+
     /**
         Remove a button previously added by AddButton().
 
     /**
         Remove a button previously added by AddButton().
 
index ae85d5d9d5654aeeb1858fa810fb8bda77e786ba..e23f356255f169f158aac73db87a12e55ff47427 100644 (file)
@@ -240,6 +240,11 @@ void wxInfoBarGeneric::ShowMessage(const wxString& msg, int flags)
     }
 }
 
     }
 }
 
+void wxInfoBarGeneric::Dismiss()
+{
+    DoHide();
+}
+
 void wxInfoBarGeneric::AddButton(wxWindowID btnid, const wxString& label)
 {
     wxSizer * const sizer = GetSizer();
 void wxInfoBarGeneric::AddButton(wxWindowID btnid, const wxString& label)
 {
     wxSizer * const sizer = GetSizer();
index 275f0199a8e3e5e210b7b2c415e9cdf431fb1ca3..1069a861475dccd9674275b4e2abcad9b541d8e2 100644 (file)
@@ -177,17 +177,26 @@ void wxInfoBar::ShowMessage(const wxString& msg, int flags)
     UpdateParent();
 }
 
     UpdateParent();
 }
 
+void wxInfoBar::Dismiss()
+{
+    if ( !UseNative() )
+    {
+        wxInfoBarGeneric::Dismiss();
+        return;
+    }
+
+    Hide();
+
+    UpdateParent();
+}
+
 void wxInfoBar::GTKResponse(int btnid)
 {
     wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, btnid);
     event.SetEventObject(this);
 
     if ( !HandleWindowEvent(event) )
 void wxInfoBar::GTKResponse(int btnid)
 {
     wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, btnid);
     event.SetEventObject(this);
 
     if ( !HandleWindowEvent(event) )
-    {
-        Hide();
-
-        UpdateParent();
-    }
+        Dismiss();
 }
 
 GtkWidget *wxInfoBar::GTKAddButton(wxWindowID btnid, const wxString& label)
 }
 
 GtkWidget *wxInfoBar::GTKAddButton(wxWindowID btnid, const wxString& label)