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