]>
Commit | Line | Data |
---|---|---|
e36a1739 VZ |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: gtk/hildon/notifmsg.cpp | |
3 | // Purpose: Hildon implementation of wxNotificationMessage | |
4 | // Author: Vadim Zeitlin | |
5 | // Created: 2007-11-21 | |
6 | // RCS-ID: $Id$ | |
7 | // Copyright: (c) 2007 Vadim Zeitlin <vadim@wxwindows.org> | |
8 | // Licence: wxWindows licence | |
9 | /////////////////////////////////////////////////////////////////////////////// | |
10 | ||
11 | // ============================================================================ | |
12 | // declarations | |
13 | // ============================================================================ | |
14 | ||
15 | // ---------------------------------------------------------------------------- | |
16 | // headers | |
17 | // ---------------------------------------------------------------------------- | |
18 | ||
19 | // for compilers that support precompilation, includes "wx.h". | |
20 | #include "wx/wxprec.h" | |
21 | ||
22 | #ifdef __BORLANDC__ | |
23 | #pragma hdrstop | |
24 | #endif | |
25 | ||
426d19f1 | 26 | #if wxUSE_LIBHILDON || wxUSE_LIBHILDON2 |
e36a1739 VZ |
27 | |
28 | #ifndef WX_PRECOMP | |
29 | #endif //WX_PRECOMP | |
30 | ||
31 | #include "wx/notifmsg.h" | |
32 | #include "wx/toplevel.h" | |
33 | ||
426d19f1 JS |
34 | #if wxUSE_LIBHILDON |
35 | #include <hildon-widgets/hildon-banner.h> | |
36 | #endif // wxUSE_LIBHILDON | |
37 | ||
38 | #if wxUSE_LIBHILDON2 | |
39 | #include <hildon/hildon.h> | |
40 | #endif // wxUSE_LIBHILDON2 | |
e36a1739 VZ |
41 | |
42 | // ============================================================================ | |
43 | // wxNotificationMessage implementation | |
44 | // ============================================================================ | |
45 | ||
46 | wxString wxNotificationMessage::HildonGetMarkup() const | |
47 | { | |
48 | const wxString& message = GetMessage(), | |
49 | title = GetTitle(); | |
50 | ||
51 | wxString text; | |
52 | if ( message.empty() ) | |
53 | { | |
54 | text = title; | |
55 | } | |
56 | else // combine title with message in a single string | |
57 | { | |
58 | text << "<big><b>" << title << "</b></big>\n" | |
59 | "\n" | |
60 | << message; | |
61 | } | |
62 | ||
63 | return text; | |
64 | } | |
65 | ||
66 | GtkWidget *wxNotificationMessage::HildonGetWindow() const | |
67 | { | |
68 | wxWindow *parent = GetParent(); | |
69 | if ( parent ) | |
70 | { | |
71 | parent = wxGetTopLevelParent(parent); | |
72 | if ( parent ) | |
73 | { | |
74 | wxTopLevelWindow * const | |
75 | tlw = wxDynamicCast(parent, wxTopLevelWindow); | |
76 | if ( tlw ) | |
77 | return tlw->m_mainWidget; | |
78 | } | |
79 | } | |
80 | ||
81 | return NULL; | |
82 | } | |
83 | ||
84 | bool wxNotificationMessage::Show(int timeout) | |
85 | { | |
86 | if ( timeout == Timeout_Never ) | |
87 | { | |
88 | m_banner = hildon_banner_show_animation | |
89 | ( | |
90 | HildonGetWindow(), | |
91 | NULL, | |
92 | GetFullMessage() // markup not supported here | |
93 | ); | |
94 | if ( !m_banner ) | |
95 | return false; | |
96 | } | |
97 | else // the message will time out | |
98 | { | |
99 | // we don't have any way to set the timeout interval so we just let it | |
100 | // time out automatically | |
101 | hildon_banner_show_information_with_markup | |
102 | ( | |
103 | HildonGetWindow(), | |
104 | NULL, | |
105 | HildonGetMarkup() | |
106 | ); | |
107 | } | |
108 | ||
109 | return true; | |
110 | } | |
111 | ||
112 | bool wxNotificationMessage::Close() | |
113 | { | |
114 | if ( !m_banner ) | |
115 | { | |
116 | // either we hadn't been shown or we are using an information banner | |
117 | // which will disappear on its own, nothing we can do about it | |
118 | return false; | |
119 | } | |
120 | ||
121 | gtk_widget_destroy(m_banner); | |
122 | m_banner = NULL; | |
123 | ||
124 | return true; | |
125 | } | |
126 | ||
127 | wxNotificationMessage::~wxNotificationMessage() | |
128 | { | |
129 | Close(); | |
130 | } | |
131 | ||
426d19f1 | 132 | #endif // wxUSE_LIBHILDON || wxUSE_LIBHILDON2 |