libyui-ncurses  2.48.3
NCApplication.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: NCApplication.h
20 
21  Author: Gabriele Mohr <gs@suse.de>
22 
23 /-*/
24 
25 #ifndef NCApplication_h
26 #define NCApplication_h
27 
28 #include <yui/YApplication.h>
29 
30 
31 class NCApplication: public YApplication
32 {
33 
34 protected:
35 
36  friend class YNCursesUI;
37 
38  /**
39  * Constructor.
40  *
41  * Use YUI::app() to get the singleton for this class.
42  **/
43  NCApplication();
44 
45  /**
46  * Destructor.
47  **/
48  virtual ~NCApplication();
49 
50 public:
51 
52  /**
53  * Set language and encoding for the locale environment ($LANG).
54  *
55  * 'language' is the ISO short code ("de_DE", "en_US", ...).
56  *
57  * 'encoding' an (optional) encoding ("utf8", ...) that will be appended if
58  * present.
59  *
60  * Reimplemented from YApplication.
61  **/
62  virtual void setLanguage( const std::string & language,
63  const std::string & encoding = std::string() );
64 
65  /**
66  * Open a directory selection box and prompt the user for an existing
67  * directory.
68  *
69  * 'startDir' is the initial directory that is displayed.
70  *
71  * 'headline' is an explanatory text for the directory selection box.
72  * Graphical UIs may omit that if no window manager is running.
73  *
74  * Returns the selected directory name
75  * or an empty std::string if the user canceled the operation.
76  *
77  * Implemented from YApplication.
78  **/
79  virtual std::string askForExistingDirectory( const std::string & startDir,
80  const std::string & headline );
81 
82  /**
83  * Open a file selection box and prompt the user for an existing file.
84  *
85  * 'startWith' is the initial directory or file.
86  *
87  * 'filter' is one or more blank-separated file patterns, e.g.
88  * "*.png *.jpg"
89  *
90  * 'headline' is an explanatory text for the file selection box.
91  * Graphical UIs may omit that if no window manager is running.
92  *
93  * Returns the selected file name
94  * or an empty std::string if the user canceled the operation.
95  *
96  * Implemented from YApplication.
97  **/
98  virtual std::string askForExistingFile( const std::string & startWith,
99  const std::string & filter,
100  const std::string & headline );
101 
102  /**
103  * Open a file selection box and prompt the user for a file to save data
104  * to. Automatically asks for confirmation if the user selects an existing
105  * file.
106  *
107  * 'startWith' is the initial directory or file.
108  *
109  * 'filter' is one or more blank-separated file patterns, e.g.
110  * "*.png *.jpg"
111  *
112  * 'headline' is an explanatory text for the file selection box.
113  * Graphical UIs may omit that if no window manager is running.
114  *
115  * Returns the selected file name
116  * or an empty std::string if the user canceled the operation.
117  *
118  * Implemented from YApplication.
119  **/
120  virtual std::string askForSaveFileName( const std::string & startWith,
121  const std::string & filter,
122  const std::string & headline );
123 
124  /**
125  * Beep.
126  *
127  * Reimplemented from YApplication.
128  **/
129  virtual void beep();
130 
131  /**
132  * Redraw the screen.
133  *
134  * Reimplemented from YApplication.
135  **/
136  virtual void redrawScreen();
137 
138  /**
139  * Initialize the (text) console keyboard.
140  *
141  * Reimplemented from YApplication.
142  **/
143  virtual void initConsoleKeyboard();
144 
145  /**
146  * Set the (text) console font according to the current encoding etc.
147  * See the setfont(8) command and the console HowTo for details.
148  *
149  * Reimplemented from YApplication.
150  **/
151  virtual void setConsoleFont( const std::string & console_magic,
152  const std::string & font,
153  const std::string & screen_map,
154  const std::string & unicode_map,
155  const std::string & language );
156 
157  /**
158  * Run a shell command (typically an interactive program using NCurses)
159  * in a terminal (window).
160  *
161  * Here in the NCurses UI, this shuts down the NCurses lib, runs the
162  * command and then restores the status of the NCurses lib so that the next
163  * instance of the NCurses lib from the started command doesn't interfere
164  * with the NCurses UI's instance.
165  *
166  * Reimplemented from YApplication.
167  **/
168  virtual int runInTerminal( const std::string & command );
169 
170 
171  /// @{
172  /**
173  * To mix TUI (NCurses) with stdio, enclose the UI parts
174  * within openUI/closeUI
175  *
176  * Reimplemented from YApplication.
177  */
178  virtual void openUI() override;
179  virtual void closeUI() override;
180  /// @}
181 
182  // Display information and UI capabilities.
183  //
184  // All implemented from YApplication.
185 
186  virtual int displayWidth();
187  virtual int displayHeight();
188  virtual int displayDepth();
189  virtual long displayColors();
190 
191  virtual int defaultWidth();
192  virtual int defaultHeight();
193 
194  virtual bool isTextMode() { return true; }
195 
196  virtual bool hasImageSupport() { return false; }
197 
198  virtual bool hasIconSupport() { return false; }
199 
200  virtual bool hasAnimationSupport() { return false; }
201 
202  virtual bool hasFullUtf8Support();
203  virtual bool richTextSupportsTable() { return false; }
204 
205  virtual bool leftHandedMouse() { return false; }
206 
207  /**
208  * Set the application title
209  *
210  * Reimplemented from YApplication.
211  **/
212  virtual void setApplicationTitle(const std::string& title);
213 };
214 
215 
216 #endif // NCApplication_h
virtual std::string askForSaveFileName(const std::string &startWith, const std::string &filter, const std::string &headline)
Open a file selection box and prompt the user for a file to save data to.
virtual void setApplicationTitle(const std::string &title)
Set the application title.
virtual void redrawScreen()
Redraw the screen.
virtual ~NCApplication()
Destructor.
virtual int runInTerminal(const std::string &command)
Run a shell command (typically an interactive program using NCurses) in a terminal (window).
virtual void initConsoleKeyboard()
Initialize the (text) console keyboard.
virtual void setLanguage(const std::string &language, const std::string &encoding=std::string())
Set language and encoding for the locale environment ($LANG).
NCApplication()
Constructor.
virtual void beep()
Beep.
virtual std::string askForExistingDirectory(const std::string &startDir, const std::string &headline)
Open a directory selection box and prompt the user for an existing directory.
virtual void openUI() override
To mix TUI (NCurses) with stdio, enclose the UI parts within openUI/closeUI.
virtual std::string askForExistingFile(const std::string &startWith, const std::string &filter, const std::string &headline)
Open a file selection box and prompt the user for an existing file.
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 &language)
Set the (text) console font according to the current encoding etc.