]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/gtk/hildon/notifmsg.cpp
update GTK size hints when window decorations change
[wxWidgets.git] / src / gtk / hildon / notifmsg.cpp
... / ...
CommitLineData
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
26#if wxUSE_LIBHILDON
27
28#ifndef WX_PRECOMP
29#endif //WX_PRECOMP
30
31#include "wx/notifmsg.h"
32#include "wx/toplevel.h"
33
34#include <hildon-widgets/hildon-banner.h>
35
36// ============================================================================
37// wxNotificationMessage implementation
38// ============================================================================
39
40wxString wxNotificationMessage::HildonGetMarkup() const
41{
42 const wxString& message = GetMessage(),
43 title = GetTitle();
44
45 wxString text;
46 if ( message.empty() )
47 {
48 text = title;
49 }
50 else // combine title with message in a single string
51 {
52 text << "<big><b>" << title << "</b></big>\n"
53 "\n"
54 << message;
55 }
56
57 return text;
58}
59
60GtkWidget *wxNotificationMessage::HildonGetWindow() const
61{
62 wxWindow *parent = GetParent();
63 if ( parent )
64 {
65 parent = wxGetTopLevelParent(parent);
66 if ( parent )
67 {
68 wxTopLevelWindow * const
69 tlw = wxDynamicCast(parent, wxTopLevelWindow);
70 if ( tlw )
71 return tlw->m_mainWidget;
72 }
73 }
74
75 return NULL;
76}
77
78bool wxNotificationMessage::Show(int timeout)
79{
80 if ( timeout == Timeout_Never )
81 {
82 m_banner = hildon_banner_show_animation
83 (
84 HildonGetWindow(),
85 NULL,
86 GetFullMessage() // markup not supported here
87 );
88 if ( !m_banner )
89 return false;
90 }
91 else // the message will time out
92 {
93 // we don't have any way to set the timeout interval so we just let it
94 // time out automatically
95 hildon_banner_show_information_with_markup
96 (
97 HildonGetWindow(),
98 NULL,
99 HildonGetMarkup()
100 );
101 }
102
103 return true;
104}
105
106bool wxNotificationMessage::Close()
107{
108 if ( !m_banner )
109 {
110 // either we hadn't been shown or we are using an information banner
111 // which will disappear on its own, nothing we can do about it
112 return false;
113 }
114
115 gtk_widget_destroy(m_banner);
116 m_banner = NULL;
117
118 return true;
119}
120
121wxNotificationMessage::~wxNotificationMessage()
122{
123 Close();
124}
125
126#endif // wxUSE_LIBHILDON