libcdos-fw
CFNotification.h
浏览该文件的文档.
1 // Copyright 2017, CDOS.
2 // All rights reserved.
3 //
4 // Author: CDOS Support Team <support_os@sari.ac.cn>
5 //
6 // CFNotification is a notification item class.
7 
12 #ifndef __CF_NOTIFICATION_H__
13 #define __CF_NOTIFICATION_H__
14 
15 #include <Gui/CFButton.h>
16 #include <Gui/CFImage.h>
17 #include <Gui/CFLabel.h>
18 #include <Core/CFDefines.h>
19 #include <Gui/CFFixed.h>
20 #include <Gui/CFBox.h>
21 
22 CF_NAMESPACE_BEGIN
23 
36 };
37 
44  kNoReason = 0,
47 };
48 
57  Glib::ustring body;
59  bool title_markup;
61  bool body_markup;
62  bool cleanable;
63 };
64 
67 const Glib::ustring kDateFormat = "%l:%M %p"; // _("%l:%M %p")
68 
75 class CFNotification : public CFButton {
76 public:
86  CFNotification(const Glib::ustring& icon_name,
87  const Glib::ustring& title,
88  const Glib::ustring& content);
89 
96  virtual ~CFNotification();
97 
103  CFImage& getIcon();
104 
113  void setIcon(const Glib::ustring& label, CFBuiltinIconSize icon_size);
114 
120  Glib::ustring getTitle();
121 
127  void setTitle(const Glib::ustring& title);
128 
136  Glib::DateTime getCreateDateTime();
137 
143  void setTime(const Glib::ustring& time);
144 
150  void setTimeout(CFUInt ms_time); // 单位毫秒
151 
157  void setReason(CFNotificationDestroyedReason reason);
158 
164  void setShowTime(bool show_time);
165 
171  CFNotificationUrgency getUrgency();
172 
178  void setUrgency(CFNotificationUrgency urgency);
179 
180 public:
187  sigc::signal<void, CFNotificationDestroyedReason> signalReason();
188 
189 protected:
190  virtual void onShow();
191 
192  virtual bool onTimeout();
193 
194  virtual void onClicked();
195 
196 private:
197  CFImage m_icon; // left
198  CFBox m_contentBox; // right
199  CFLabel m_time;
200  Glib::DateTime m_createTime;
201  CFLabel m_title;
202  CFLabel m_content;
203  CFBox m_actor; // main container
204 
205  bool m_isNeedShowTime; // member
206  CFNotificationUrgency m_urgency;
207 
208  // signal and handler
210  sigc::signal<void, CFNotificationDestroyedReason> m_reasonSignal;
211 };
212 
213 CF_NAMESPACE_END
214 
215 #endif // __CF_NOTIFICATION_H__
216 
217 /* ----------- test case ----------- */
218 // void signal_test(Cdos::NotificationDestroyedReason reason) {
219 // std::cout << reason << std::endl;
220 // }
221 // bt.signal_reason().connect(sigc::ptr_fun(signal_test));
222 // bt.set_timeout(4000);
bool cleanable
是否可清除,默认 FALSE
Definition: CFNotification.h:62
CFBox 该控件会以矩形区域来组织其所容纳的控件。
Definition: CFBox.h:34
Glib::ustring body
消息体
Definition: CFNotification.h:57
Definition: CFImage.h:10
表示通知超过了设定的过期时间
Definition: CFNotification.h:45
CFNotificationDestroyedReason
通知关闭的原因
Definition: CFNotification.h:43
Definition: CFNotification.h:55
紧急程度一般
Definition: CFNotification.h:34
CFBuiltinIconSize
cdos-fw 内建的图标尺寸
Definition: CFEnums.h:86
bool title_markup
标题是否允许标记
Definition: CFNotification.h:59
Definition: CFButton.h:8
Definition: CFLabel.h:9
CFNotificationUrgency
用以表示通知紧急程度的枚举
Definition: CFNotification.h:32
CFImage image
图标
Definition: CFNotification.h:58
bool custom_content
自定义内容
Definition: CFNotification.h:56
CFNotification 控件会以矩形区域来组织其所容纳的控件。
Definition: CFNotification.h:75
bool body_markup
C版本里与bannerMarkup相同
Definition: CFNotification.h:61
未定义,对应js里的undefine
Definition: CFNotification.h:44
紧急程度低
Definition: CFNotification.h:33
带有坐标设置的容器
表示通知被点击
Definition: CFNotification.h:46
紧急程度高
Definition: CFNotification.h:35
bool banner_markup
消息体是可以标记
Definition: CFNotification.h:60