libyui-mga  1.1.0
YMGAWidgetExtensionFactory.h
1 /*
2  Copyright (C) 2013 Angelo Naselli <anaselli at linux dot it>
3 
4  This file is a YExternalWidgetFactory implementation
5 
6  This library is free software; you can redistribute it and/or modify
7  it under the terms of the GNU Lesser General Public License as
8  published by the Free Software Foundation; either version 2.1 of the
9  License, or (at your option) version 3.0 of the License. This library
10  is distributed in the hope that it will be useful, but WITHOUT ANY
11  WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
13  License for more details. You should have received a copy of the GNU
14  Lesser General Public License along with this library; if not, write
15  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
16  Floor, Boston, MA 02110-1301 USA
17 */
18 
19 /*-/
20 
21  File: YMGAWidgetFactory.h
22 
23  Author: Angelo Naselli <anaselli@linux.it>
24 
25 /-*/
26 
27 #ifndef YMGAWidgetExtensionFactory_h
28 #define YMGAWidgetExtensionFactory_h
29 
30 #include <string>
31 
32 #include <yui/YExternalWidgetFactory.h>
33 #include <yui/YTypes.h>
34 #include <yui/YEvent.h>
35 
36 
37 #include "YMGAMenuBar.h" // YMGAMenuBar
38 #include "YMGAMenuItem.h"
39 #include "YMGA_CBTable.h" // YCBTableMode
40 #include "YMGAMsgBox.h" // DLG_BUTTON, DLG_MODE
41 
42 struct stat;
43 
44 class YWidget;
45 class YMGAAboutDialog;
46 
47 /**
48  * Abstract extension widget factory to create widget extensions.
49  *
50  * Refer to the respective widget's documentation (in the header file) for
51  * documentation about the function parameters.
52  **/
53 class YMGAWidgetFactory : public YExternalWidgetFactory
54 {
55 public:
56 
57  /**
58  * creates an About Dialog providing the information passed as arguments
59  * Remember to remove this instance after.
60  * @param appname the application name
61  * @param appver the application version
62  * @param applicense the application license, short-length (e.g. GPLv2, GPLv3, LGPL, LGPLv2+, etc)
63  * @param appauthors the application authors
64  * @param appdescription a brief description of the application
65  * @param applogo the file path to the application logo
66  * @param appicon the file path to the application icon
67  * @param appcredits optional, the credits
68  * @param appinfo optional, other extra information
69  * @return YMGAAboutDialog instance
70  */
71  YMGAAboutDialog * createAboutDialog( const std::string& appname,
72  const std::string& appversion,
73  const std::string& applicense,
74  const std::string& appauthors,
75  const std::string& appdescription,
76  const std::string& applogo,
77  const std::string& appicon = std::string(),
78  const std::string& appcredits = std::string(),
79  const std::string& appinfo = std::string()
80  );
81 
82  /**
83  * creates a check boxed table
84  * @param parent parent widget
85  * @param header_disown YTable header
86  * @param mode check box position (YCBTableCheckBoxOnFirstColumn, YCBTableCheckBoxOnLastColumn)
87  * @return YMGA_CBTable widget instance
88  **/
89  virtual YMGA_CBTable * createCBTable ( YWidget * parent, YTableHeader * header_disown, YCBTableMode mode = YCBTableCheckBoxOnFirstColumn ) = 0;
90 
91 
92  /**
93  * creates a menu bar
94  * @param parent parent widget
95  * @return YMGAMenuBar widget instance
96  **/
97  virtual YMGAMenuBar * createMenuBar ( YWidget * parent ) = 0;
98 
99  /**
100  * creates a dialog box dialog, use the instance to set dialog information and call show() to use it.
101  * Remember to remove this instance after.
102  * @param button_number one button (such as "ok" for instance) B_ONE or two buttons (such as "ok" and "cancel") B_TWO
103  * @param dialog_mode dialog type (D_NORMAL, D_INFO, D_WARNING)
104  * @return YMGAMessageBox dialog instance
105  **/
108 
109  /**
110  * creates an messagebox dialog, use the instance to set dialog information and call show() to use it.
111  * Remember to remove this instance after.
112  * @param title dialog title
113  * @param text dialog content text
114  * @param useRichText set text using rich text if true
115  * @param btn_label button label (such as Ok, for instance)
116  * @return YMGAMessageBox dialog instance
117  **/
118  YMGAMessageBox* createMessageBox ( const std::string& title, const std::string& text, bool useRichText, const std::string& btn_label );
119 
120  /**
121  * creates an Info messagebox dialog, use the instance to set dialog information and call show() to use it.
122  * Remember to remove this instance after.
123  * @param title dialog title
124  * @param text dialog content text
125  * @param useRichText set text using rich text if true
126  * @param btn_label button label (such as Ok, for instance)
127  * @return YMGAMessageBox dialog instance
128  **/
129  YMGAMessageBox* createInfoBox ( const std::string& title, const std::string& text, bool useRichText, const std::string& btn_label );
130 
131  /**
132  * creates an Warning messagebox dialog, use the instance to set dialog information and call show() to use it.
133  * Remember to remove this instance after.
134  * @param title dialog title
135  * @param text dialog content text
136  * @param useRichText set text using rich text if true
137  * @param btn_label button label (such as Ok, for instance)
138  * @return YMGAMessageBox dialog instance
139  **/
140  YMGAMessageBox* createWarningBox ( const std::string& title, const std::string& text, bool useRichText, const std::string& btn_label );
141 
142 
143  /**
144  * casts useful for bindings from YExternalWidgetFactory* to YMGAWidgetFactory*
145  *
146  **/
147  static YMGAWidgetFactory* getYMGAWidgetFactory ( YExternalWidgetFactory* instance );
148 
149  // event conversions
150  /**
151  * casts useful for bindings from YEvent* to YWidgetEvent*
152  *
153  **/
154  static YWidgetEvent* getYWidgetEvent ( YEvent *event );
155 
156  /**
157  * casts useful for bindings from YEvent* to YKeyEvent*
158  *
159  **/
160  static YKeyEvent* getYKeyEvent ( YEvent *event );
161 
162  /**
163  * casts useful for bindings from YEvent* to YMenuEvent*
164  *
165  **/
166  static YMenuEvent* getYMenuEvent ( YEvent *event );
167 
168  /**
169  * casts useful for bindings from YEvent* to YCancelEvent*
170  *
171  **/
172  static YCancelEvent* getYCancelEvent ( YEvent *event );
173 
174  /**
175  * casts useful for bindings from YEvent* to YDebugEvent*
176  *
177  **/
178  static YDebugEvent* getYDebugEvent ( YEvent *event );
179 
180  /**
181  * casts useful for bindings from YEvent* to YTimeoutEvent*
182  *
183  **/
184  static YTimeoutEvent* getYTimeoutEvent ( YEvent *event );
185 
186  /**
187  * useful cast for bindings from YItem* to YMGAMenuItem*
188  * it just performs a dynamic_cast
189  */
190  static YMGAMenuItem* toYMGAMenuItem( YItem* item );
191 
192  /**
193  * useful cast for bindings from YItem* to YMenuSeparator*
194  * it just performs a dynamic_cast
195  */
196  static YMenuSeparator* toYMenuSeparator( YItem* item );
197 
198 protected:
199 
200  friend class YExternalWidgets;
201 
202  /**
203  * Constructor.
204  *
205  * Use YExternalWidgets::widgetExtensionFactory() to get the singleton for this class.
206  **/
208 
209  /**
210  * Destructor.
211  **/
212  virtual ~YMGAWidgetFactory();
213 
214 }; // class YMGAWidgetFactory
215 
216 
217 #endif // YMGAWidgetExtensionFactory_h
YMGAWidgetFactory::createDialogBox
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.
Definition: YMGAWidgetExtensionFactory.cc:68
YMGAWidgetFactory::YMGAWidgetFactory
YMGAWidgetFactory()
Constructor.
Definition: YMGAWidgetExtensionFactory.cc:41
YMGAWidgetFactory::createMessageBox
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.
Definition: YMGAWidgetExtensionFactory.cc:75
YMGAWidgetFactory::getYWidgetEvent
static YWidgetEvent * getYWidgetEvent(YEvent *event)
casts useful for bindings from YEvent* to YWidgetEvent*
Definition: YMGAWidgetExtensionFactory.cc:108
YMGAWidgetFactory::createInfoBox
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 ...
Definition: YMGAWidgetExtensionFactory.cc:84
YMGAWidgetFactory::createMenuBar
virtual YMGAMenuBar * createMenuBar(YWidget *parent)=0
creates a menu bar
YMGAMenuBar
Definition: YMGAMenuBar.h:34
YMGAWidgetFactory::toYMGAMenuItem
static YMGAMenuItem * toYMGAMenuItem(YItem *item)
useful cast for bindings from YItem* to YMGAMenuItem* it just performs a dynamic_cast
Definition: YMGAWidgetExtensionFactory.cc:138
YMGAMessageBox::B_ONE
@ B_ONE
One button dialog, or button one pressed.
Definition: YMGAMsgBox.h:39
YMGAWidgetFactory
Abstract extension widget factory to create widget extensions.
Definition: YMGAWidgetExtensionFactory.h:53
YMGAMessageBox::DLG_MODE
DLG_MODE
Definition: YMGAMsgBox.h:44
YMGAWidgetFactory::createAboutDialog
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...
Definition: YMGAWidgetExtensionFactory.cc:52
YMGAWidgetFactory::getYCancelEvent
static YCancelEvent * getYCancelEvent(YEvent *event)
casts useful for bindings from YEvent* to YCancelEvent*
Definition: YMGAWidgetExtensionFactory.cc:123
YMGAMessageBox
Definition: YMGAMsgBox.h:34
YMGAMenuItem
New Menu Item class for menu items.
Definition: YMGAMenuItem.h:35
YMGAWidgetFactory::createWarningBox
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...
YMenuSeparator
YMenuSeparator class for menu separator.
Definition: YMGAMenuItem.h:129
YMGAMessageBox::D_NORMAL
@ D_NORMAL
Normal dialog.
Definition: YMGAMsgBox.h:46
YMGAWidgetFactory::~YMGAWidgetFactory
virtual ~YMGAWidgetFactory()
Destructor.
Definition: YMGAWidgetExtensionFactory.cc:46
YMGA_CBTable
See document of YMGA_CBTable Table: Selection list with multiple columns.
Definition: YMGA_CBTable.h:114
YMGAWidgetFactory::toYMenuSeparator
static YMenuSeparator * toYMenuSeparator(YItem *item)
useful cast for bindings from YItem* to YMenuSeparator* it just performs a dynamic_cast
Definition: YMGAWidgetExtensionFactory.cc:143
YMGAWidgetFactory::getYMGAWidgetFactory
static YMGAWidgetFactory * getYMGAWidgetFactory(YExternalWidgetFactory *instance)
casts useful for bindings from YExternalWidgetFactory* to YMGAWidgetFactory*
Definition: YMGAWidgetExtensionFactory.cc:103
YMGAAboutDialog
Definition: YMGAAboutDialog.h:27
YMGAWidgetFactory::getYTimeoutEvent
static YTimeoutEvent * getYTimeoutEvent(YEvent *event)
casts useful for bindings from YEvent* to YTimeoutEvent*
Definition: YMGAWidgetExtensionFactory.cc:133
YMGAWidgetFactory::createCBTable
virtual YMGA_CBTable * createCBTable(YWidget *parent, YTableHeader *header_disown, YCBTableMode mode=YCBTableCheckBoxOnFirstColumn)=0
creates a check boxed table
YMGAWidgetFactory::getYDebugEvent
static YDebugEvent * getYDebugEvent(YEvent *event)
casts useful for bindings from YEvent* to YDebugEvent*
Definition: YMGAWidgetExtensionFactory.cc:128
YMGAWidgetFactory::getYMenuEvent
static YMenuEvent * getYMenuEvent(YEvent *event)
casts useful for bindings from YEvent* to YMenuEvent*
Definition: YMGAWidgetExtensionFactory.cc:118
YMGAWidgetFactory::getYKeyEvent
static YKeyEvent * getYKeyEvent(YEvent *event)
casts useful for bindings from YEvent* to YKeyEvent*
Definition: YMGAWidgetExtensionFactory.cc:113
YMGAMessageBox::DLG_BUTTON
DLG_BUTTON
Definition: YMGAMsgBox.h:37