libyui-ncurses  2.54.5
YNCursesUI.h
1 /*
2  Copyright (C) 2000-2012 Novell, Inc
3  This library is free software; you can redistribute it and/or modify
4  it under the terms of the GNU Lesser General Public License as
5  published by the Free Software Foundation; either version 2.1 of the
6  License, or (at your option) version 3.0 of the License. This library
7  is distributed in the hope that it will be useful, but WITHOUT ANY
8  WARRANTY; without even the implied warranty of MERCHANTABILITY or
9  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10  License for more details. You should have received a copy of the GNU
11  Lesser General Public License along with this library; if not, write
12  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
13  Floor, Boston, MA 02110-1301 USA
14 */
15 
16 
17 /*-/
18 
19  File: YNCursesUI.h
20 
21  Authors: Michael Andres <ma@suse.de>
22  Stefan Hundhammer <sh@suse.de>
23 
24 /-*/
25 
26 #ifndef YNCursesUI_h
27 #define YNCursesUI_h
28 
29 #include <iosfwd>
30 
31 #include <yui/YUI.h>
32 #include "NCApplication.h"
33 #include "NCurses.h"
34 
36 
37 
38 class YNCursesUI : public NCurses, public YUI
39 {
40 public:
41  /**
42  * Having boolean topmostConstructor to be
43  * called only when there is topmost constructor and not a plugin which
44  * inherits from YNCursesUI. Used by integration testing framework
45  **/
46  YNCursesUI( bool withThreads, bool topmostConstructor = true );
47 
48  /**
49  * Destructor
50  **/
51  ~YNCursesUI();
52 
53 
54 protected:
55  /**
56  * Create the widget factory that provides all the createXY() methods for
57  * standard (mandatory, i.e. non-optional) widgets.
58  *
59  * Reimplemented from YUI.
60  **/
61  virtual YWidgetFactory * createWidgetFactory();
62 
63  /**
64  * Create the widget factory that provides all the createXY() methods for
65  * optional ("special") widgets and the corresponding hasXYWidget()
66  * methods.
67  *
68  * Reimplemented from YUI.
69  **/
70  virtual YOptionalWidgetFactory * createOptionalWidgetFactory();
71 
72  /*
73  * Create the YApplication object that provides global methods.
74  *
75  * Reimplemented from YUI.
76  **/
77  virtual YApplication * createApplication();
78 
79 
80  virtual bool want_colors();
81  virtual void init_title();
82 
83  /**
84  * Global reference to the UI
85  **/
86  static YNCursesUI * _ui;
87 
88 public:
89 
90  /**
91  * Access the global Y2NCursesUI.
92  */
93  static YNCursesUI * ui() { return _ui; }
94 
95  /**
96  * Idle around until fd_ycp is readable
97  */
98  virtual void idleLoop( int fd_ycp );
99 
100  /**
101  * Set the (text) console font according to the current encoding etc.
102  * See the setfont(8) command and the console HowTo for details.
103  *
104  * This should really be in NCApplication, but it uses so many non-exported
105  * member variables that it's not easy to move it there.
106  **/
107  virtual void setConsoleFont( const std::string & console_magic,
108  const std::string & font,
109  const std::string & screen_map,
110  const std::string & unicode_map,
111  const std::string & lang );
112 
113  /**
114  * Fills the PackageSelector widget and runs package selection.
115  */
116  virtual YEvent * runPkgSelection( YWidget * packageSelector );
117 
118  /**
119  * Returns the package selector plugin singleton of this UI or creates it
120  * (including loading the plugin lib) if it does not exist yet.
121  **/
123 
124  /**
125  * Open a pop-up dialog to ask the user for a widget ID and then send it
126  * with sendWidgetID(). This returns the widget or 0 if not found.
127  **/
128  YWidget * askSendWidgetID();
129 
130  /**
131  * Send an event to the UI. It's used in special cases (REST API) to simulate
132  * the user actions.
133  **/
134  void sendEvent( NCursesEvent event );
135 };
136 
137 
138 /**
139  * Create a new UI if there is none yet or return the existing one if there is.
140  *
141  * This is the UI plugin's interface to the outside world, so don't change the
142  * name or signature!
143  **/
144 YUI * createUI( bool withThreads );
145 
146 
147 #endif // YNCursesUI_h
static YNCursesUI * _ui
Global reference to the UI.
Definition: YNCursesUI.h:86
virtual YWidgetFactory * createWidgetFactory()
Create the widget factory that provides all the createXY() methods for standard (mandatory, i.e.
Definition: YNCursesUI.cc:125
virtual void setConsoleFont(const std::string &console_magic, const std::string &font, const std::string &screen_map, const std::string &unicode_map, const std::string &lang)
Set the (text) console font according to the current encoding etc.
Definition: YNCursesUI.cc:344
virtual YOptionalWidgetFactory * createOptionalWidgetFactory()
Create the widget factory that provides all the createXY() methods for optional ("special") widgets a...
Definition: YNCursesUI.cc:135
YWidget * askSendWidgetID()
Open a pop-up dialog to ask the user for a widget ID and then send it with sendWidgetID().
Definition: YNCursesUI.cc:434
static YNCursesUI * ui()
Access the global Y2NCursesUI.
Definition: YNCursesUI.h:93
void sendEvent(NCursesEvent event)
Send an event to the UI.
Definition: YNCursesUI.cc:455
YNCursesUI(bool withThreads, bool topmostConstructor=true)
Having boolean topmostConstructor to be called only when there is topmost constructor and not a plugi...
Definition: YNCursesUI.cc:64
virtual void idleLoop(int fd_ycp)
Idle around until fd_ycp is readable.
Definition: YNCursesUI.cc:154
NCPackageSelectorPluginStub * packageSelectorPlugin()
Returns the package selector plugin singleton of this UI or creates it (including loading the plugin ...
Definition: YNCursesUI.cc:208
virtual YEvent * runPkgSelection(YWidget *packageSelector)
Fills the PackageSelector widget and runs package selection.
Definition: YNCursesUI.cc:226
~YNCursesUI()
Destructor.
Definition: YNCursesUI.cc:116