]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/notifmsgg.cpp
Fixed player dialog listbox size and app icon on wxGTK
[wxWidgets.git] / src / generic / notifmsgg.cpp
index 2f95e1ca7659fcd420fd12561e4a9eb60ff25490..364cab307ea63640649b2a2cb58b5146fabf6055 100644 (file)
@@ -1,6 +1,6 @@
 ///////////////////////////////////////////////////////////////////////////////
 // Name:        src/generic/notifmsgg.cpp
-// Purpose:     generic implementation of wxNotificationMessage
+// Purpose:     generic implementation of wxGenericNotificationMessage
 // Author:      Vadim Zeitlin
 // Created:     2007-11-24
 // RCS-ID:      $Id$
     #pragma hdrstop
 #endif
 
-// include this before the test below, wxUSE_GENERIC_NOTIFICATION_MESSAGE is
-// defined in this header
-#include "wx/notifmsg.h"
+#ifndef wxUSE_LIBHILDON
+    #define wxUSE_LIBHILDON 0
+#endif
 
-#if wxUSE_GENERIC_NOTIFICATION_MESSAGE
+#if wxUSE_NOTIFICATION_MESSAGE && !wxUSE_LIBHILDON
 
 #ifndef WX_PRECOMP
     #include "wx/dialog.h"
     #include "wx/timer.h"
+    #include "wx/sizer.h"
+    #include "wx/statbmp.h"
 #endif //WX_PRECOMP
 
+#include "wx/artprov.h"
+
+// even if the platform has the native implementation, we still normally want
+// to use the generic one (unless it's totally unsuitable for the target UI as
+// is the case of Hildon) because it may provide more features, so include
+// wx/generic/notifmsg.h to get wxGenericNotificationMessage declaration even
+// if wx/notifmsg.h only declares wxNotificationMessage itself (if it already
+// uses the generic version, the second inclusion will do no harm)
+#include "wx/notifmsg.h"
+#include "wx/generic/notifmsg.h"
+
 // ----------------------------------------------------------------------------
 // wxNotificationMessageDialog
 // ----------------------------------------------------------------------------
@@ -43,11 +56,13 @@ class wxNotificationMessageDialog : public wxDialog
 public:
     wxNotificationMessageDialog(wxWindow *parent,
                                 const wxString& text,
-                                int timeout);
+                                int timeout,
+                                int flags);
 
     void Set(wxWindow *parent,
              const wxString& text,
-             int timeout);
+             int timeout,
+             int flags);
 
     bool IsAutomatic() const { return m_timer.IsRunning(); }
     void SetDeleteOnHide() { m_deleteOnHide = true; }
@@ -81,7 +96,8 @@ END_EVENT_TABLE()
 
 wxNotificationMessageDialog::wxNotificationMessageDialog(wxWindow *parent,
                                                          const wxString& text,
-                                                         int timeout)
+                                                         int timeout,
+                                                         int flags)
                            : wxDialog(parent, wxID_ANY, _("Notice"),
                                       wxDefaultPosition, wxDefaultSize,
                                       0 /* no caption, no border styles */),
@@ -89,18 +105,31 @@ wxNotificationMessageDialog::wxNotificationMessageDialog(wxWindow *parent,
 {
     m_deleteOnHide = false;
 
-    Set(parent, text, timeout);
+    Set(parent, text, timeout, flags);
 }
 
 void
 wxNotificationMessageDialog::Set(wxWindow * WXUNUSED(parent),
                                  const wxString& text,
-                                 int timeout)
+                                 int timeout,
+                                 int flags)
 {
-    wxSizer *sizer = CreateTextSizer(text);
-    SetSizerAndFit(sizer);
+    wxSizer * const sizerTop = new wxBoxSizer(wxHORIZONTAL);
+    if ( flags & wxICON_MASK )
+    {
+        sizerTop->Add(new wxStaticBitmap
+                          (
+                            this,
+                            wxID_ANY,
+                            wxArtProvider::GetMessageBoxIcon(flags)
+                          ),
+                      wxSizerFlags().Centre().Border());
+    }
+
+    sizerTop->Add(CreateTextSizer(text), wxSizerFlags(1).Border());
+    SetSizerAndFit(sizerTop);
 
-    if ( timeout != wxNotificationMessage::Timeout_Never )
+    if ( timeout != wxGenericNotificationMessage::Timeout_Never )
     {
         // wxTimer uses ms, timeout is in seconds
         m_timer.Start(timeout*1000, true /* one shot only */);
@@ -135,12 +164,12 @@ void wxNotificationMessageDialog::OnTimer(wxTimerEvent& WXUNUSED(event))
 }
 
 // ============================================================================
-// wxNotificationMessage implementation
+// wxGenericNotificationMessage implementation
 // ============================================================================
 
-int wxNotificationMessage::ms_timeout = 10;
+int wxGenericNotificationMessage::ms_timeout = 10;
 
-/* static */ void wxNotificationMessage::SetDefaultTimeout(int timeout)
+/* static */ void wxGenericNotificationMessage::SetDefaultTimeout(int timeout)
 {
     wxASSERT_MSG( timeout > 0,
                 "negative or zero default timeout doesn't make sense" );
@@ -148,17 +177,17 @@ int wxNotificationMessage::ms_timeout = 10;
     ms_timeout = timeout;
 }
 
-void wxNotificationMessage::Init()
+void wxGenericNotificationMessage::Init()
 {
     m_dialog = NULL;
 }
 
-wxNotificationMessage::~wxNotificationMessage()
+wxGenericNotificationMessage::~wxGenericNotificationMessage()
 {
     if ( m_dialog->IsAutomatic() )
     {
         // we want to allow the user to create an automatically hidden
-        // notification just by creating a local wxNotificationMessage object
+        // notification just by creating a local wxGenericNotificationMessage object
         // and so we shouldn't hide the notification when this object goes out
         // of scope
         m_dialog->SetDeleteOnHide();
@@ -172,7 +201,7 @@ wxNotificationMessage::~wxNotificationMessage()
     }
 }
 
-bool wxNotificationMessage::Show(int timeout)
+bool wxGenericNotificationMessage::Show(int timeout)
 {
     if ( timeout == Timeout_Auto )
     {
@@ -185,12 +214,13 @@ bool wxNotificationMessage::Show(int timeout)
                        (
                         GetParent(),
                         GetFullMessage(),
-                        timeout
+                        timeout,
+                        GetFlags()
                        );
     }
     else // update the existing dialog
     {
-        m_dialog->Set(GetParent(), GetFullMessage(), timeout);
+        m_dialog->Set(GetParent(), GetFullMessage(), timeout, GetFlags());
     }
 
     m_dialog->Show();
@@ -198,7 +228,7 @@ bool wxNotificationMessage::Show(int timeout)
     return true;
 }
 
-bool wxNotificationMessage::Close()
+bool wxGenericNotificationMessage::Close()
 {
     if ( !m_dialog )
         return false;
@@ -208,4 +238,4 @@ bool wxNotificationMessage::Close()
     return true;
 }
 
-#endif // wxUSE_GENERIC_NOTIFICATION_MESSAGE
+#endif // wxUSE_NOTIFICATION_MESSAGE && !wxUSE_LIBHILDON