source: branches/profile/GL/glAW/AW_window_ogl.cxx

Last change on this file was 9704, checked in by westram, 11 years ago
  • removed default entries (see [9703]) from ARB_NT and ARB_PARSIMONY
  • harmonized main help entries for each executable
File size: 14.2 KB
Line 
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
41bool AW_alpha_Size_Supported = false;
42
43
44AW_window_menu_modes_opengl::AW_window_menu_modes_opengl() {
45}
46
47AW_window_menu_modes_opengl::~AW_window_menu_modes_opengl() {
48}
49
50void 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);
67    window_defaults_name = GBS_string_2_key(wid);
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                                          NULL);
77
78    p_w->menu_bar[0] = XtVaCreateManagedWidget("menu1", xmRowColumnWidgetClass,
79                                               main_window,
80                                               XmNrowColumnType, XmMENU_BAR,
81                                               NULL);
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                                      NULL);
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                                           NULL);
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, NULL);
104    XtVaSetValues(p_w->menu_bar[0], XmNmenuHelpWidget, help_label, NULL);
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                                     NULL);
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                                              NULL);
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, NULL,
141                                         XmNrightAttachment, XmATTACH_NONE,
142                                         XmNleftOffset, 70,
143                                         XmNleftPosition, 0,
144                                         NULL);
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                                     NULL);
164    p_w->areas[AW_INFO_AREA] =
165        new AW_area_management(root, 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                                                                     NULL));
176
177    p_w->areas[AW_BOTTOM_AREA] =
178        new AW_area_management(root, 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                                                                     NULL));
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                                                   NULL);
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                                                 NULL);
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                                          NULL);
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++;
267        AW_alpha_Size_Supported = true;
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
285    p_w->areas[AW_MIDDLE_AREA] =
286        new AW_area_management(root, p_w->frame, glw);
287
288    XmMainWindowSetAreas(main_window, p_w->menu_bar[0], (Widget) NULL, (Widget) NULL, (Widget) NULL, form1);
289
290    aw_realize_widget(this);
291
292    create_devices();
293    aw_insert_default_help_entries(this);
294    create_window_variables();
295}
296
297
298
Note: See TracBrowser for help on using the repository browser.