libyui-mga  1.0.7
YMGAWidgetExtensionFactory.cc
1 /*
2  Copyright 2013 by Angelo Naselli <anaselli at linux dot it>
3 
4  This library is free software; you can redistribute it and/or modify
5  it under the terms of the GNU Lesser General Public License as
6  published by the Free Software Foundation; either version 2.1 of the
7  License, or (at your option) version 3.0 of the License. This library
8  is distributed in the hope that it will be useful, but WITHOUT ANY
9  WARRANTY; without even the implied warranty of MERCHANTABILITY or
10  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
11  License for more details. You should have received a copy of the GNU
12  Lesser General Public License along with this library; if not, write
13  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
14  Floor, Boston, MA 02110-1301 USA
15 */
16 
17 /*-/
18 
19  File: YMGAWidgetFactory.cc
20 
21  Author: Angelo Naselli <anaselli@linux.it>
22 
23 /-*/
24 
25 
26 #include "YMGAWidgetExtensionFactory.h"
27 
28 #include "YAlignment.h"
29 #include "YPushButton.h"
30 #include "YUI.h"
31 #include "YApplication.h"
32 
33 #include "YMGAAboutDialog.h"
34 #include "YMGA_CBTable.h"
35 #include "YMGAMsgBox.h"
36 
37 #define YUILogComponent "ew"
38 #include <yui/YUILog.h>
39 
40 
42 {
43  // NOP
44 }
45 
47 {
48  // NOP
49  yuiMilestone() << "Factory removed" << std::endl;
50 }
51 
53  const std::string& appver,
54  const std::string& applicense,
55  const std::string& appauthors,
56  const std::string& appdescription,
57  const std::string& applogo,
58  const std::string& appicon,
59  const std::string& appcredits,
60  const std::string& appinfo
61  )
62 {
63  YMGAAboutDialog *ad = new YMGAAboutDialog(appname, appver, applicense, appauthors, appdescription, applogo, appicon, appcredits, appinfo);
64  return ad;
65 }
66 
67 
69  YMGAMessageBox::DLG_MODE dialog_mode )
70 {
71  YMGAMessageBox *msgBox = new YMGAMessageBox(button_number, dialog_mode);
72  return msgBox;
73 }
74 
75 YMGAMessageBox* YMGAWidgetFactory::createMessageBox ( const std::string& title, const std::string& text, bool useRichText, const std::string& btn_label )
76 {
78  msgBox->setTitle(title);
79  msgBox->setText(text, useRichText);
80  msgBox->setButtonLabel(btn_label, YMGAMessageBox::B_ONE);
81  return msgBox;
82 }
83 
84 YMGAMessageBox* YMGAWidgetFactory::createInfoBox ( const std::string& title, const std::string& text, bool useRichText, const std::string& btn_label )
85 {
87  msgBox->setTitle(title);
88  msgBox->setText(text, useRichText);
89  msgBox->setButtonLabel(btn_label, YMGAMessageBox::B_ONE);
90  return msgBox;
91 }
92 
93 YMGAMessageBox* YMGAWidgetFactory::createWarningBox ( const std::string& title, const std::string& text, bool useRichText, const std::string& btn_label )
94 {
96  msgBox->setTitle(title);
97  msgBox->setText(text, useRichText);
98  msgBox->setButtonLabel(btn_label, YMGAMessageBox::B_ONE);
99  return msgBox;
100 }
101 
102 ///< casts
103 YMGAWidgetFactory* YMGAWidgetFactory::getYMGAWidgetFactory ( YExternalWidgetFactory* instance )
104 {
105  return dynamic_cast<YMGAWidgetFactory*>(instance);
106 }
107 
108 YWidgetEvent* YMGAWidgetFactory::getYWidgetEvent(YEvent *event)
109 {
110  return dynamic_cast<YWidgetEvent*>(event);
111 }
112 
113 YKeyEvent* YMGAWidgetFactory::getYKeyEvent(YEvent *event)
114 {
115  return dynamic_cast<YKeyEvent*>(event);
116 }
117 
118 YMenuEvent* YMGAWidgetFactory::getYMenuEvent(YEvent *event)
119 {
120  return dynamic_cast<YMenuEvent*>(event);
121 }
122 
123 YCancelEvent* YMGAWidgetFactory::getYCancelEvent(YEvent *event)
124 {
125  return dynamic_cast<YCancelEvent*>(event);
126 }
127 
128 YDebugEvent* YMGAWidgetFactory::getYDebugEvent(YEvent *event)
129 {
130  return dynamic_cast<YDebugEvent*>(event);
131 }
132 
133 YTimeoutEvent* YMGAWidgetFactory::getYTimeoutEvent(YEvent *event)
134 {
135  return dynamic_cast<YTimeoutEvent*>(event);
136 }
137 
138 
YMGAMessageBox * createMessageBox(const std::string &title, const std::string &text, bool useRichText, const std::string &btn_label)
creates an messagebox dialog, use the instance to set dialog information and call show() to use it...
YMGAMessageBox * createInfoBox(const std::string &title, const std::string &text, bool useRichText, const std::string &btn_label)
creates an Info messagebox dialog, use the instance to set dialog information and call show() to use ...
YMGAMessageBox * createDialogBox(YMGAMessageBox::DLG_BUTTON button_number=YMGAMessageBox::B_ONE, YMGAMessageBox::DLG_MODE dialog_mode=YMGAMessageBox::D_NORMAL)
creates a dialog box dialog, use the instance to set dialog information and call show() to use it...
Abstract extension widget factory to create widget extensions.
void setButtonLabel(const std::string &label, DLG_BUTTON button=B_ONE)
sets the message box button name (empty string is assigned by default)
Definition: YMGAMsgBox.cc:118
Info dialog.
Definition: YMGAMsgBox.h:48
static YWidgetEvent * getYWidgetEvent(YEvent *event)
casts useful for bindings from YEvent* to YWidgetEvent*
One button dialog, or button one pressed.
Definition: YMGAMsgBox.h:39
YMGAAboutDialog * createAboutDialog(const std::string &appname, const std::string &appversion, const std::string &applicense, const std::string &appauthors, const std::string &appdescription, const std::string &applogo, const std::string &appicon=std::string(), const std::string &appcredits=std::string(), const std::string &appinfo=std::string())
creates an About Dialog providing the information passed as arguments Remember to remove this instanc...
static YCancelEvent * getYCancelEvent(YEvent *event)
casts useful for bindings from YEvent* to YCancelEvent*
static YMGAWidgetFactory * getYMGAWidgetFactory(YExternalWidgetFactory *instance)
casts useful for bindings from YExternalWidgetFactory* to YMGAWidgetFactory*
Normal dialog.
Definition: YMGAMsgBox.h:46
static YDebugEvent * getYDebugEvent(YEvent *event)
casts useful for bindings from YEvent* to YDebugEvent*
void setText(const std::string &text, bool useRichText=false)
sets the message box text information
Definition: YMGAMsgBox.cc:100
Warning dialog.
Definition: YMGAMsgBox.h:50
static YTimeoutEvent * getYTimeoutEvent(YEvent *event)
casts useful for bindings from YEvent* to YTimeoutEvent*
virtual ~YMGAWidgetFactory()
Destructor.
static YKeyEvent * getYKeyEvent(YEvent *event)
casts useful for bindings from YEvent* to YKeyEvent*
static YMenuEvent * getYMenuEvent(YEvent *event)
casts useful for bindings from YEvent* to YMenuEvent*
void setTitle(const std::string &title)
sets the message box title
Definition: YMGAMsgBox.cc:95
YMGAMessageBox * createWarningBox(const std::string &title, const std::string &text, bool useRichText, const std::string &btn_label)
creates an Warning messagebox dialog, use the instance to set dialog information and call show() to u...