libt3widget
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups
main.h
1 /* Copyright (C) 2011-2012 G.P. Halkes
2  This program is free software: you can redistribute it and/or modify
3  it under the terms of the GNU General Public License version 3, as
4  published by the Free Software Foundation.
5 
6  This program is distributed in the hope that it will be useful,
7  but WITHOUT ANY WARRANTY; without even the implied warranty of
8  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9  GNU General Public License for more details.
10 
11  You should have received a copy of the GNU General Public License
12  along with this program. If not, see <http://www.gnu.org/licenses/>.
13 */
14 #ifndef T3_WIDGET_MAIN_H
15 #define T3_WIDGET_MAIN_H
16 
17 #include <t3widget/util.h>
18 #include <t3widget/dialogs/dialog.h>
19 #include <t3widget/dialogs/insertchardialog.h>
20 #include <t3widget/dialogs/messagedialog.h>
21 
22 namespace t3_widget {
23 
37 #define T3_WIDGET_VERSION 0
38 
40 class T3_WIDGET_API complex_error_t {
41  public:
42  enum source_t{
43  SRC_NONE,
44  SRC_ERRNO,
45  SRC_TRANSCRIPT,
46  SRC_T3_KEY,
47  SRC_T3_WINDOW
48  };
49  private:
50  bool success;
51  source_t source;
52  int error;
53  const char *file_name;
54  int line_number;
55 
56  public:
57  complex_error_t(void);
58  complex_error_t(source_t _source, int _error, const char *_file_name = NULL, int _line_number = 0);
59  void set_error(source_t _source, int _error, const char *_file_name = NULL, int _line_number = 0);
60  bool get_success(void);
61  source_t get_source(void);
62  int get_error(void);
63  const char *get_string(void);
64 };
65 
68 class T3_WIDGET_API init_parameters_t {
69  public:
70  const char *program_name;
71  const char *term;
84 
86  static init_parameters_t *create(void);
87  private:
88  init_parameters_t(void);
89 };
90 
91 //FIXME: shouldn't these be internal?
93 T3_WIDGET_API extern insert_char_dialog_t *insert_char_dialog;
95 T3_WIDGET_API extern message_dialog_t *message_dialog;
96 
98 T3_WIDGET_API sigc::connection connect_resize(const sigc::slot<void, int, int> &slot);
102 T3_WIDGET_API sigc::connection connect_update_notification(const sigc::slot<void> &slot);
108 T3_WIDGET_API sigc::connection connect_on_init(const sigc::slot<void, bool> &slot);
113 T3_WIDGET_API sigc::connection connect_terminal_settings_changed(const sigc::slot<void> &slot);
114 
120 T3_WIDGET_API complex_error_t init(const init_parameters_t *params);
125 T3_WIDGET_API void restore(void);
131 T3_WIDGET_API void iterate(void);
136 T3_WIDGET_API int main_loop(void);
142 T3_WIDGET_API void suspend(void);
148 T3_WIDGET_API void redraw(void);
149 
155 T3_WIDGET_API void exit_main_loop(int exit_code)
156 #ifdef __GNUC__
157 __attribute__((noreturn))
158 #endif
159 ;
168 T3_WIDGET_API void cleanup(void);
169 
176 T3_WIDGET_API bool set_color_mode(bool on);
180 T3_WIDGET_API void set_attribute(attribute_t attribute, t3_attr_t value);
184 T3_WIDGET_API t3_attr_t get_attribute(attribute_t attribute);
188 T3_WIDGET_API t3_attr_t get_default_attribute(attribute_t attribute, bool color_mode);
190 T3_WIDGET_API long get_version(void);
191 
193 T3_WIDGET_API long get_libt3key_version(void);
194 
196 T3_WIDGET_API long get_libt3window_version(void);
197 
199 T3_WIDGET_API void get_screen_size(int *height, int *width);
200 }; // namespace
201 
202 #endif