ARB
AW_window_ogl.cxx
Go to the documentation of this file.
1 // ============================================================= //
2 // //
3 // File : AW_window_ogl.cxx //
4 // Purpose : open gl window //
5 // //
6 // Institute of Microbiology (Technical University Munich) //
7 // http://www.arb-home.de/ //
8 // //
9 // ============================================================= //
10 
11 #include "aw_window_ogl.hxx"
12 
13 // Extended by Daniel Koitzsch & Christian Becker 19-05-04
14 
15 #ifndef ARB_OPENGL
16 #error only compiles in ARB_OPENGL mode
17 #endif // ARB_OPENGL
18 
19 #define GLX_GLXEXT_PROTOTYPES
20 
21 #include <aw_window_Xm.hxx>
22 #include <aw_root.hxx>
23 #include <arbdb.h>
24 
25 #include <Xm/Frame.h>
26 #include <Xm/RowColumn.h>
27 #include <Xm/DrawingA.h>
28 #include <Xm/Form.h>
29 #include <Xm/Separator.h>
30 #include <Xm/MainW.h>
31 #include <Xm/CascadeB.h>
32 #include <Xm/MenuShell.h>
33 #include <Xm/ScrollBar.h>
34 
35 #include <X11/IntrinsicP.h>
36 #include <X11/StringDefs.h>
37 
38 #include "GLwMDrawA.h" //* Provides a special motif widget class
39 
40 // defined here by Yadhu in order to make it more General
42 
43 
45 }
46 
48 }
49 
50 void AW_window_menu_modes_opengl::init(AW_root *root_in, const char *wid,
51  const char *windowname, int width, int height) {
52 
53  Widget main_window;
54  Widget help_popup;
55  Widget help_label;
56  Widget separator;
57  Widget form1;
58  Widget form2;
59  const char *help_button = "HELP";
60  const char *help_mnemonic = "H";
61 
62 #if defined(DUMP_MENU_LIST)
63  initMenuListing(windowname);
64 #endif // DUMP_MENU_LIST
65  root = root_in; // for macro
66  window_name = strdup(windowname);
68 
69  int posx = 50;
70  int posy = 50;
71 
72  p_w->shell = aw_create_shell(this, true, true, width, height, posx, posy);
73 
74  main_window = XtVaCreateManagedWidget("mainWindow1",
75  xmMainWindowWidgetClass, p_w->shell,
76  NULp);
77 
78  p_w->menu_bar[0] = XtVaCreateManagedWidget("menu1", xmRowColumnWidgetClass,
79  main_window,
80  XmNrowColumnType, XmMENU_BAR,
81  NULp);
82 
83  // create shell for help-cascade
84  help_popup = XtVaCreatePopupShell("menu_shell", xmMenuShellWidgetClass,
85  p_w->menu_bar[0],
86  XmNwidth, 1,
87  XmNheight, 1,
88  XmNallowShellResize, true,
89  XmNoverrideRedirect, true,
90  NULp);
91 
92  // create row column in Pull-Down shell
93  p_w->help_pull_down = XtVaCreateWidget("menu_row_column",
94  xmRowColumnWidgetClass, help_popup,
95  XmNrowColumnType, XmMENU_PULLDOWN,
96  NULp);
97 
98  // create HELP-label in menu bar
99  help_label = XtVaCreateManagedWidget("menu1_top_b1",
100  xmCascadeButtonWidgetClass, p_w->menu_bar[0],
101  RES_CONVERT(XmNlabelString, help_button),
102  RES_CONVERT(XmNmnemonic, help_mnemonic),
103  XmNsubMenuId, p_w->help_pull_down, NULp);
104  XtVaSetValues(p_w->menu_bar[0], XmNmenuHelpWidget, help_label, NULp);
105  // insert help_label to button_list
106  root->make_sensitive(help_label, AWM_ALL);
107 
108  form1 = XtVaCreateManagedWidget("form1",
109  xmFormWidgetClass,
110  main_window,
111  XmNresizePolicy, XmRESIZE_NONE,
112  NULp);
113 
114  p_w->mode_area = XtVaCreateManagedWidget("mode area",
115  xmDrawingAreaWidgetClass,
116  form1,
117  XmNresizePolicy, XmRESIZE_NONE,
118  XmNwidth, 38,
119  XmNheight, height,
120  XmNx, 0,
121  XmNy, 0,
122  XmNleftOffset, 0,
123  XmNtopOffset, 0,
124  XmNbottomAttachment, XmATTACH_FORM,
125  XmNleftAttachment, XmATTACH_POSITION,
126  XmNtopAttachment, XmATTACH_POSITION,
127  XmNmarginHeight, 2,
128  XmNmarginWidth, 1,
129  NULp);
130 
131  separator = XtVaCreateManagedWidget("separator",
132  xmSeparatorWidgetClass,
133  form1,
134  XmNx, 37,
135  XmNshadowThickness, 4,
136  XmNorientation, XmVERTICAL,
137  XmNbottomAttachment, XmATTACH_FORM,
138  XmNtopAttachment, XmATTACH_FORM,
139  XmNleftAttachment, XmATTACH_NONE,
140  XmNleftWidget, NULp,
141  XmNrightAttachment, XmATTACH_NONE,
142  XmNleftOffset, 70,
143  XmNleftPosition, 0,
144  NULp);
145 
146  form2 = XtVaCreateManagedWidget("form2",
147  xmFormWidgetClass,
148  form1,
149  XmNwidth, width,
150  XmNheight, height,
151  XmNtopOffset, 0,
152  XmNbottomOffset, 0,
153  XmNleftOffset, 0,
154  XmNrightOffset, 0,
155  XmNrightAttachment, XmATTACH_FORM,
156  XmNbottomAttachment, XmATTACH_FORM,
157  XmNleftAttachment, XmATTACH_WIDGET,
158  XmNleftWidget, separator,
159  XmNtopAttachment, XmATTACH_POSITION,
160  XmNresizePolicy, XmRESIZE_NONE,
161  XmNx, 0,
162  XmNy, 0,
163  NULp);
165  new AW_area_management(form2, XtVaCreateManagedWidget("info_area",
166  xmDrawingAreaWidgetClass,
167  form2,
168  XmNheight, 0,
169  XmNbottomAttachment, XmATTACH_NONE,
170  XmNtopAttachment, XmATTACH_FORM,
171  XmNleftAttachment, XmATTACH_FORM,
172  XmNrightAttachment, XmATTACH_FORM,
173  XmNmarginHeight, 2,
174  XmNmarginWidth, 2,
175  NULp));
176 
178  new AW_area_management(form2, XtVaCreateManagedWidget("bottom_area",
179  xmDrawingAreaWidgetClass,
180  form2,
181  XmNheight, 0,
182  XmNbottomAttachment, XmATTACH_FORM,
183  XmNtopAttachment, XmATTACH_NONE,
184  XmNleftAttachment, XmATTACH_FORM,
185  XmNrightAttachment, XmATTACH_FORM,
186  NULp));
187 
188  p_w->scroll_bar_horizontal = XtVaCreateWidget("scroll_bar_horizontal",
189  xmScrollBarWidgetClass,
190  form2,
191  XmNheight, 15,
192  XmNminimum, 0,
193  XmNmaximum, AW_SCROLL_MAX,
194  XmNincrement, 10,
195  XmNsliderSize, AW_SCROLL_MAX,
196  XmNrightAttachment, XmATTACH_FORM,
197  XmNbottomAttachment, XmATTACH_FORM,
198  XmNbottomOffset, 0,
199  XmNleftAttachment, XmATTACH_FORM,
200  XmNtopAttachment, XmATTACH_NONE,
201  XmNorientation, XmHORIZONTAL,
202  XmNrightOffset, 18,
203  NULp);
204 
205  p_w->scroll_bar_vertical = XtVaCreateWidget("scroll_bar_vertical",
206  xmScrollBarWidgetClass,
207  form2,
208  XmNwidth, 15,
209  XmNminimum, 0,
210  XmNmaximum, AW_SCROLL_MAX,
211  XmNincrement, 10,
212  XmNsliderSize, AW_SCROLL_MAX,
213  XmNrightAttachment, XmATTACH_FORM,
214  XmNbottomAttachment, XmATTACH_WIDGET,
215  XmNbottomWidget, p_w->scroll_bar_horizontal,
216  XmNbottomOffset, 3,
217  XmNleftOffset, 3,
218  XmNrightOffset, 3,
219  XmNleftAttachment, XmATTACH_NONE,
220  XmNtopAttachment, XmATTACH_WIDGET,
221  XmNtopWidget, INFO_WIDGET,
222  NULp);
223 
224  p_w->frame = XtVaCreateManagedWidget("draw_area",
225  xmFrameWidgetClass,
226  form2,
227  XmNshadowType, XmSHADOW_IN,
228  XmNshadowThickness, 2,
229  XmNleftOffset, 3,
230  XmNtopOffset, 3,
231  XmNbottomOffset, 3,
232  XmNrightOffset, 3,
233  XmNtopOffset, 0,
234  NULp);
235 
236  Arg args[20];
237  int n;
238  Widget glw;
239  n = 0;
240 
241  XtSetArg(args[n], (char *) GLwNrgba, True); n++;
242  XtSetArg(args[n], (char *) GLwNallocateBackground, True); n++;
243  XtSetArg(args[n], (char *) GLwNallocateOtherColors, True); n++;
244  XtSetArg(args[n], (char *) GLwNdoublebuffer, True); n++;
245  XtSetArg(args[n], (char *) GLwNdepthSize, True); n++;
246  XtSetArg(args[n], (char *) GLwNredSize, 4); n++;
247  XtSetArg(args[n], (char *) GLwNgreenSize, 4); n++;
248  XtSetArg(args[n], (char *) GLwNblueSize, 4); n++;
249 
250  static int alpha_Attributes[] = { GLX_RGBA,
251  GLX_DEPTH_SIZE, 12,
252  GLX_RED_SIZE, 4,
253  GLX_GREEN_SIZE, 4,
254  GLX_BLUE_SIZE, 4,
255  GLX_ALPHA_SIZE, 4,
256  None };
257 
258  Widget tmp = XtCreateWidget("glw", glwMDrawingAreaWidgetClass,
259  form2, args, n);
260 
261  XVisualInfo *vi;
262  Display *dpy;
263  dpy = XtDisplay(tmp);
264  vi = glXChooseVisual(dpy, DefaultScreen(dpy), alpha_Attributes);
265  if (vi) {
266  XtSetArg(args[n], (char *) GLwNalphaSize, 4); n++;
268  printf("Alpha channel supported\n");
269  }
270  else {
271  AW_alpha_Size_Supported = false;
272  printf("Alpha channel NOT supported\n");
273  }
274 
275  XtSetArg(args[n], XmNmarginHeight, 0); n++;
276  XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
277  XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
278  XtSetArg(args[n], XmNtopWidget, p_w->areas[AW_INFO_AREA]->get_area()); n++;
279  XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
280  XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
281 
282  glw = XtCreateManagedWidget("glw", glwMDrawingAreaWidgetClass,
283  form2, args, n);
284 
286 
287  XmMainWindowSetAreas(main_window, p_w->menu_bar[0], (Widget) NULp, (Widget) NULp, (Widget) NULp, form1);
288 
289  aw_realize_widget(this);
290 
291  create_devices();
294 }
295 
296 
297 
void aw_realize_widget(AW_window *aww)
Definition: AW_window.cxx:2360
char * window_name
Definition: aw_window.hxx:335
Widget menu_bar[AW_MAX_MENU_DEEP]
#define GLwNalphaSize
Definition: GLwDrawA.h:119
bool AW_alpha_Size_Supported
char * GBS_string_2_key(const char *str)
Definition: adstring.cxx:52
char * window_defaults_name
window title
Definition: aw_window.hxx:336
void create_window_variables()
Definition: AW_window.cxx:974
Widget get_area() const
Widget scroll_bar_horizontal
void create_devices()
Definition: AW_window.cxx:2096
AW_root * root
Definition: aw_window.hxx:264
#define GLwNdoublebuffer
Definition: GLwDrawA.h:109
#define GLwNredSize
Definition: GLwDrawA.h:115
#define GLwNallocateOtherColors
Definition: GLwDrawA.h:92
AW_area_management * areas[AW_MAX_AREA]
virtual void init(AW_root *root, const char *wid, const char *windowname, int width, int height)
#define INFO_WIDGET
Widget scroll_bar_vertical
static Display * dpy
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:2230
#define GLwNallocateBackground
Definition: GLwDrawA.h:91
#define GLwNblueSize
Definition: GLwDrawA.h:117
#define RES_CONVERT(res_name, res_value)
AW_window_Motif * p_w
Definition: aw_window.hxx:280
#define AW_SCROLL_MAX
void make_sensitive(Widget w, AW_active mask)
Definition: AW_window.cxx:3244
#define NULp
Definition: cxxforward.h:97
void aw_insert_default_help_entries(AW_window *aww)
Definition: AW_window.cxx:2111
#define GLwNdepthSize
Definition: GLwDrawA.h:121
#define GLwNgreenSize
Definition: GLwDrawA.h:116
#define GLwNrgba
Definition: GLwDrawA.h:107
struct _WidgetRec * Widget
Definition: aw_base.hxx:48