ARB
aw_window_Xm.hxx
Go to the documentation of this file.
1 #ifndef AW_WINDOW_XM_HXX
2 #define AW_WINDOW_XM_HXX
3 
4 #ifndef AW_DEVICE_HXX
5 #include <aw_device.hxx>
6 #endif
7 #ifndef AW_KEYSYM_HXX
8 #include <aw_keysym.hxx>
9 #endif
10 #ifndef _Xm_h
11 #include <Xm/Xm.h>
12 #endif
13 #ifndef CB_H
14 #include <cb.h>
15 #endif
16 #ifndef AW_SCALAR_HXX
17 #include "aw_scalar.hxx"
18 #endif
19 #ifndef ARB_MSG_H
20 #include <arb_msg.h>
21 #endif
22 
23 // macro definitions
24 #define p_r prvt
25 #define p_global (root->prvt)
26 #define p_aww(aww) (aww->p_w)
27 
28 #define MAP_ARAM(ar) p_w->areas[ar]
29 
30 #define INFO_WIDGET p_w->areas[AW_INFO_AREA]->get_area()
31 #define INFO_FORM p_w->areas[AW_INFO_AREA]->get_form()
32 #define MIDDLE_WIDGET p_w->areas[AW_MIDDLE_AREA]->get_area()
33 #define BOTTOM_WIDGET p_w->areas[AW_BOTTOM_AREA]->get_area()
34 
35 #define AW_SCROLL_MAX 100
36 #define AW_MAX_MENU_DEEP 10
37 
38 #define RES_CONVERT(res_name, res_value) \
39  XtVaTypedArg, (res_name), XmRString, (res_value), strlen(res_value) + 1
40 
41 #define AW_MOTIF_LABEL
42 
43 class Label : virtual Noncopyable {
44  char *label;
45  int len;
46  bool imageref;
47 public:
48  Label(const char *labeltext, AW_window *aww);
49  ~Label() { free(label); }
50 
51  size_t length() const { return len; }
52  const char *String() const { return label; }
53  bool is_imageref() const { return imageref; }
54 };
55 
56 
57 #define RES_LABEL_CONVERT(label) \
58  XmNlabelType, label.is_imageref() ? XmPIXMAP : XmSTRING, \
59  XtVaTypedArg, label.is_imageref() ? XmNlabelPixmap : XmNlabelString, \
60  XmRString, \
61  label.String(), \
62  label.length()+1
63 
64 #define AW_JUSTIFY_LABEL(widget, corr) \
65  switch (corr) { \
66  case 1: XtVaSetValues(widget, XmNalignment, XmALIGNMENT_CENTER, NULp); break; \
67  case 2: XtVaSetValues(widget, XmNalignment, XmALIGNMENT_END, NULp); break; \
68  default: break; \
69  }
70 
71 
72 struct AW_buttons_struct : virtual Noncopyable {
75 
79 };
80 
82  template<typename T> explicit AW_widget_value_pair(T t, Widget w) : value(t), widget(w), next(NULp) {}
83  ~AW_widget_value_pair() { aw_assert(!next); } // has to be unlinked from list BEFORE calling dtor
84 
87 
89 };
90 
92  AW_option_menu_struct(int numberi, const char *variable_namei, AW_VARIABLE_TYPE variable_typei, Widget label_widgeti, Widget menu_widgeti, AW_pos xi, AW_pos yi, int correct);
93 
99 
103 
106  int correct_for_at_center_intern; // needed for centered and right justified menus (former member of AW_at)
107 
109 };
110 
111 
113  AW_toggle_field_struct(int toggle_field_numberi, const char *variable_namei, AW_VARIABLE_TYPE variable_typei, Widget label_widgeti, int correct);
114 
119 
123 
124  int correct_for_at_center_intern; // needed for centered and right justified toggle fields (former member of AW_at)
125 
127 };
128 
129 
130 // -------------------------------------------
131 // area management: devices callbacks
132 
133 class AW_common_Xm;
134 class AW_device_Xm;
135 class AW_cb;
136 
138  Widget form; // for resizing
139  Widget area; // for displaying additional information
140 
141  AW_common_Xm *common;
142 
143  AW_device_Xm *device;
144  AW_device_size *size_device;
145  AW_device_print *print_device;
146  AW_device_click *click_device;
147 
148  AW_cb *expose_cb;
149  AW_cb *resize_cb;
150  AW_cb *double_click_cb;
151 
152  long click_time;
153 
154 public:
155  AW_area_management(Widget form, Widget widget);
156 
157  Widget get_form() const { return form; }
158  Widget get_area() const { return area; }
159 
160  AW_common_Xm *get_common() const { return common; }
161 
162  AW_device_Xm *get_screen_device();
164  AW_device_print *get_print_device();
165  AW_device_click *get_click_device();
166 
167  void create_devices(AW_window *aww, AW_area ar);
168 
169  void set_expose_callback(AW_window *aww, const WindowCallback& cb);
170  void set_resize_callback(AW_window *aww, const WindowCallback& cb);
171 
172  void set_input_callback(AW_window *aww, const WindowCallback& wcb);
173  void set_double_click_callback(AW_window *aww, const WindowCallback& wcb);
174  void set_motion_callback(AW_window *aww, const WindowCallback& wcb);
175 
178 
179  void run_expose_callback();
180  void run_resize_callback();
181 
182  AW_cb *get_double_click_cb() { return double_click_cb; }
183  long get_click_time() const { return click_time; }
184  void set_click_time(long click_time_) { click_time = click_time_; }
185 };
186 
187 class AW_selection_list;
188 
189 class AW_root_Motif : virtual Noncopyable {
190  Widget last_widget; // last created (sensitive) widget
191 public:
192  Display *display;
193  XtAppContext context;
198 
199  Pixel foreground;
200  Pixel background;
201 
202  XmFontList fontlist;
203 
207 
210 
213 
216  Colormap colormap;
217 
219  Cursor clock_cursor;
223  bool no_exit;
224 
226 
227  AW_root_Motif();
228  ~AW_root_Motif();
229 
230  Widget get_last_widget() const { return last_widget; }
231  void set_last_widget(Widget w) { last_widget = w; }
232 
233  void set_cursor(Display *d, Window w, Cursor c);
234  void normal_cursor();
235 };
236 
237 const int AW_NUMBER_OF_F_KEYS = 20;
238 #define AW_CALC_OFFSET_ON_EXPOSE -12345
239 
240 class AW_window_Motif : virtual Noncopyable {
241 public:
242 
243  Widget shell; // for show, hide
244  Widget scroll_bar_vertical; // for scrolling the
246  Widget menu_bar[AW_MAX_MENU_DEEP]; // for inserting topics to menu bar
248  Widget help_pull_down; // for inserting subtopics to the help pull_down
249  Widget mode_area; // for inserting buttons to the mode area
250  short number_of_modes; // holds number of mode buttons in window
251 
252  // ********** local modifiers **********
253 
259 
265 
267 
268  int WM_top_offset; // correction between position set and position reported ( = size of window frame - in most cases!)
270 
271  static int WM_max_top_offset;
272  static int WM_max_left_offset;
273 
274  bool knows_WM_offset() const { return WM_top_offset != AW_CALC_OFFSET_ON_EXPOSE; }
275 
276  AW_window_Motif();
278 };
279 
280 
281 void aw_root_init_font(Display *tool_d);
282 void AW_label_in_awar_list(AW_window *aww, Widget widget, const char *str);
283 void AW_server_callback(Widget wgt, XtPointer aw_cb_struct, XtPointer call_data);
284 
285 // ------------------------------------------------------------
286 // do not use the following
287 extern int aw_message_cb_result;
288 #define AW_MESSAGE_LISTEN_DELAY 500 // look in ms whether a father died
289 void message_cb(AW_window*, int result);
290 void input_cb(AW_window *aw, int buttonNr);
291 void input_history_cb(AW_window *aw, int mode);
292 void file_selection_cb(AW_window *aw, int ok_cancel_flag);
293 unsigned aw_message_timer_listen_event(AW_root *awr, AW_window *aww);
294 // ------------------------------------------------------------
295 
296 Widget aw_create_shell(AW_window *aww, bool allow_resize, bool allow_close, int width, int height, int posx, int posy);
297 void aw_realize_widget(AW_window *aww);
299 
300 __ATTR__NORETURN inline void type_mismatch(const char *triedType, const char *intoWhat) {
301  GBK_terminatef("Cannot insert %s into %s which uses a non-%s AWAR", triedType, intoWhat, triedType);
302 }
303 
304 #else
305 #error aw_window_Xm.hxx included twice
306 #endif
AW_widget_value_pair * first_toggle
AW_VARIABLE_TYPE toggle_field_var_type
GB_HASH * action_hash
void set_input_callback(AW_window *aww, const WindowCallback &wcb)
Definition: AW_window.cxx:1987
AW_toggle_field_struct * last_toggle_field
AW_option_menu_struct * last_option_menu
AW_bitset AW_active
Definition: aw_base.hxx:45
string result
#define AW_CALC_OFFSET_ON_EXPOSE
AW_cb * get_double_click_cb()
void set_last_widget(Widget w)
bool is_imageref() const
AW_option_menu_struct * next
bool is_resize_callback(AnyWinCB f)
Definition: AW_window.cxx:1529
Widget menu_bar[AW_MAX_MENU_DEEP]
AW_widget_value_pair * default_choice
void message_cb(AW_window *, int result)
Definition: AW_modal.cxx:33
void run_expose_callback()
Definition: AW_window.cxx:1485
static int WM_max_left_offset
void input_cb(AW_window *aw, int buttonNr)
Definition: AW_modal.cxx:151
AW_key_mod keymodifier
size_t length() const
void GBK_terminatef(const char *templat,...)
Definition: arb_msg.cxx:523
unsigned long AW_rgb
Definition: aw_base.hxx:51
AW_area_management(Widget form, Widget widget)
Definition: AW_window.cxx:3026
AW_selection_list * last_selection_list
Colormap colormap
AW_option_menu_struct * option_menu_list
AW_selection_list * selection_list
XmFontList fontlist
#define cb(action)
AW_widget_value_pair * first_choice
AW_area
Definition: aw_base.hxx:76
Cursor question_cursor
Widget get_last_widget() const
AW_widget_value_pair(T t, Widget w)
Widget toplevel_widget
double AW_pos
Definition: aw_base.hxx:29
AW_buttons_struct(AW_active maski, Widget w, AW_buttons_struct *next)
Definition: AW_window.cxx:3303
Widget get_area() const
static int WM_max_top_offset
AW_widget_value_pair * next
Widget scroll_bar_horizontal
void input_history_cb(AW_window *aw, int mode)
Definition: AW_modal.cxx:121
AW_VARIABLE_TYPE
Definition: aw_base.hxx:53
char * toggle_field_var_name
Display * display
void create_devices(AW_window *aww, AW_area ar)
Definition: AW_window.cxx:2066
void set_double_click_callback(AW_window *aww, const WindowCallback &wcb)
Definition: AW_window.cxx:1993
AW_cb ** modes_f_callbacks
#define aw_assert(bed)
Definition: aw_position.hxx:29
static double xi
Widget aw_create_shell(AW_window *aww, bool allow_resize, bool allow_close, int width, int height, int posx, int posy)
Definition: AW_window.cxx:2258
AW_buttons_struct * next
XtAppContext context
AW_toggle_field_struct * toggle_field_list
AW_device_click * get_click_device()
Definition: AW_window.cxx:3047
AW_toggle_field_struct * next
bool knows_WM_offset() const
AW_area_management * areas[AW_MAX_AREA]
AW_VARIABLE_TYPE variable_type
int aw_message_cb_result
Definition: AW_modal.cxx:31
Widget scroll_bar_vertical
AW_device_Xm * get_screen_device()
Definition: AW_window.cxx:3032
class AW_window * main_aww
Label(const char *labeltext, AW_window *aww)
Definition: AW_window.cxx:2150
void AW_label_in_awar_list(AW_window *aww, Widget widget, const char *str)
Definition: AW_window.cxx:2172
void aw_insert_default_help_entries(AW_window *aww)
Definition: AW_window.cxx:2139
void aw_root_init_font(Display *tool_d)
Definition: AW_xfont.cxx:300
const int AW_NUMBER_OF_F_KEYS
void AW_server_callback(Widget wgt, XtPointer aw_cb_struct, XtPointer call_data)
Definition: AW_window.cxx:1399
AW_rgb * color_table
WindowCallbackSimple AnyWinCB
Definition: aw_window.hxx:120
bool is_expose_callback(AnyWinCB f)
Definition: AW_window.cxx:1506
void set_click_time(long click_time_)
void normal_cursor()
Definition: AW_window.cxx:1395
Widget * modes_widgets
void file_selection_cb(AW_window *aw, int ok_cancel_flag)
Definition: AW_modal.cxx:162
AW_widget_value_pair * last_toggle
void aw_realize_widget(AW_window *aww)
Definition: AW_window.cxx:2388
AW_option_menu_struct(int numberi, const char *variable_namei, AW_VARIABLE_TYPE variable_typei, Widget label_widgeti, Widget menu_widgeti, AW_pos xi, AW_pos yi, int correct)
Definition: AW_window.cxx:3342
AW_device_size * get_size_device()
Definition: AW_window.cxx:3037
void set_resize_callback(AW_window *aww, const WindowCallback &cb)
Definition: AW_window.cxx:1864
unsigned aw_message_timer_listen_event(AW_root *awr, AW_window *aww)
Definition: AW_modal.cxx:40
void run_resize_callback()
Definition: AW_window.cxx:1854
__ATTR__NORETURN void type_mismatch(const char *triedType, const char *intoWhat)
AW_device_print * get_print_device()
Definition: AW_window.cxx:3042
AW_common_Xm * get_common() const
Display * old_cursor_display
long get_click_time() const
#define NULp
Definition: cxxforward.h:116
AW_key_mod
Definition: aw_keysym.hxx:46
AW_option_menu_struct * current_option_menu
Window old_cursor_window
Widget get_form() const
#define __ATTR__NORETURN
Definition: attributes.h:56
AW_VARIABLE_TYPE variable_type
AW_toggle_field_struct(int toggle_field_numberi, const char *variable_namei, AW_VARIABLE_TYPE variable_typei, Widget label_widgeti, int correct)
Definition: AW_window.cxx:3360
void set_cursor(Display *d, Window w, Cursor c)
Definition: AW_window.cxx:1377
Definition: trnsprob.h:20
#define AW_MAX_MENU_DEEP
Widget message_shell
void set_expose_callback(AW_window *aww, const WindowCallback &cb)
Definition: AW_window.cxx:1497
void set_motion_callback(AW_window *aww, const WindowCallback &wcb)
Definition: AW_window.cxx:2017
struct _WidgetRec * Widget
Definition: aw_base.hxx:48
AW_widget_value_pair * default_toggle
const char * String() const
AW_widget_value_pair * last_choice