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

Last change on this file was 5948, checked in by westram, 16 years ago
  • now it is possible to set the sens mask for any widget (buttons, selections in radio-buttons, etc..).
  • added AWT_create_debug_menu (encapsulates db browser)
  • reverted order of sens-list (aka AW_buttons_struct)
  • replaced AW_INSERT_BUTTON_IN_SENS_LIST by AW_root::make_sensitive(). Now only adds to sens-list, if mask != AWM_ALL
  • removed unused IDs from
    • insert_sub_menu
    • create_menu
    • create_mode
    • insert_help_topic
    • AW_option_menu_struct
    • AW_buttons_struct
    • AW_at
  • removed
    • (AW_window) id() - only used once in old editor (seems useless; removed there)
    • (AW_root) set_sensitive and set_insensitive (those using id as param; were not used)
    • (AW_root) enable_execute_macro (outdated)
  • renamed
    • (AW_root) set_sensitive → apply_sensitivity
    • (AW_window) mask() → sens_mask()
    • (AW_root_Motif) get_last_button_widget → get_last_widget (because it always returns the last widget regardless whether it was a button or not). Now every call to make_sensitive sets the widget as "last-one".
  • new functions
    • (AW_root) define_remote_command (fails if remote-command is redefined with different callback)
    • (AW_cb_struct) is_equal (used by define_remote_command)
  • fixed duplicated remote commands
    • all GDE duplicated resolved by [5940]
    • create_trees_window (all move buttons used same id)
    • Each user mask menu created "new_mask" (now they generate "new_Species_mask", "new_Gene_mask" etc.)
    • species- and gene-color-submenu used same id
File size: 17.1 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 nono
17#endif // ARB_OPENGL
18
19/** OpenGL header files */
20// #include <GL/glew.h>
21// #include <GL/GLwMDrawA.h>       /** Provides a special motif widget class */
22#define GLX_GLXEXT_PROTOTYPES
23// #include <GL/glx.h>
24// #include <GL/glut.h>
25
26#include <arbdb.h>
27
28#include <Xm/Xm.h>
29#include <Xm/Frame.h>
30#include <Xm/RowColumn.h>
31#include <Xm/DrawingA.h>
32#include <Xm/Form.h>
33#include <Xm/Separator.h>
34#include <Xm/MainW.h>
35#include <Xm/CascadeB.h>
36#include <Xm/MenuShell.h>
37#include <Xm/ScrollBar.h>
38
39#include <aw_window_Xm.hxx>
40
41#include <X11/IntrinsicP.h>
42#include <X11/StringDefs.h>
43
44// #include "GLwDrawA.h"
45#include "GLwMDrawA.h" /** Provides a special motif widget class */
46
47/* defined here by Yadhu inorder to make it more General */
48bool AW_alpha_Size_Supported = false;
49
50
51AW_window_menu_modes_opengl::AW_window_menu_modes_opengl(void) {
52}
53
54AW_window_menu_modes_opengl::~AW_window_menu_modes_opengl(void) {
55}
56
57void AW_window_menu_modes_opengl::init(AW_root *root_in, const char *wid,
58                                       const char *windowname, int width, int height) {
59
60    Widget main_window;
61    Widget help_popup;
62    Widget help_label;
63    Widget separator;
64    Widget form1;
65    Widget form2;
66    //Widget frame;
67    const char *help_button = "HELP";
68    const char *help_mnemonic = "H";
69
70#if defined(DUMP_MENU_LIST)
71    initMenuListing(windowname);
72#endif // DUMP_MENU_LIST
73    root = root_in; // for makro
74    window_name = strdup(windowname);
75    window_defaults_name = GBS_string_2_key(wid);
76
77    int posx = 50;
78    int posy = 50;
79
80    p_w->shell= aw_create_shell(this, true, true, width, height, posx, posy);
81
82    main_window = XtVaCreateManagedWidget("mainWindow1",
83                                          xmMainWindowWidgetClass, p_w->shell, 
84                                          NULL);
85
86    p_w->menu_bar[0] = XtVaCreateManagedWidget("menu1", xmRowColumnWidgetClass,
87                                               main_window, 
88                                               XmNrowColumnType, XmMENU_BAR, 
89                                               NULL);
90
91    // create shell for help-cascade
92    help_popup = XtVaCreatePopupShell("menu_shell", xmMenuShellWidgetClass,
93                                      p_w->menu_bar[0], 
94                                      XmNwidth, 1, 
95                                      XmNheight, 1, 
96                                      XmNallowShellResize, true, 
97                                      XmNoverrideRedirect, true, 
98                                      NULL);
99
100    //create row column in Pull-Down shell
101    p_w->help_pull_down = XtVaCreateWidget("menu_row_column",
102                                           xmRowColumnWidgetClass, help_popup, 
103                                           XmNrowColumnType, XmMENU_PULLDOWN,
104                                           NULL);
105
106                                                    // create HELP-label in menu bar
107    help_label = XtVaCreateManagedWidget("menu1_top_b1",
108                                         xmCascadeButtonWidgetClass, p_w->menu_bar[0],
109                                         RES_CONVERT( XmNlabelString, help_button ),
110                                         RES_CONVERT( XmNmnemonic, help_mnemonic ),
111                                         XmNsubMenuId, p_w->help_pull_down, NULL );
112    XtVaSetValues(p_w->menu_bar[0], XmNmenuHelpWidget, help_label, NULL);
113    //insert help_label to button_list
114    root->make_sensitive(help_label, AWM_ALL);
115
116    form1 = XtVaCreateManagedWidget( "form1",
117                                     xmFormWidgetClass,
118                                     main_window,
119                                     // XmNwidth, width,
120                                     // XmNheight, height,
121                                     XmNresizePolicy, XmRESIZE_NONE,
122                                     // XmNx, 0,
123                                     // XmNy, 0,
124                                     NULL);
125
126    p_w->mode_area = XtVaCreateManagedWidget( "mode area",
127                                              xmDrawingAreaWidgetClass,
128                                              form1,
129                                              XmNresizePolicy, XmRESIZE_NONE,
130                                              XmNwidth, 38,
131                                              XmNheight, height,
132                                              XmNx, 0,
133                                              XmNy, 0,
134                                              XmNleftOffset, 0,
135                                              XmNtopOffset, 0,
136                                              XmNbottomAttachment, XmATTACH_FORM,
137                                              XmNleftAttachment, XmATTACH_POSITION,
138                                              XmNtopAttachment, XmATTACH_POSITION,
139                                              XmNmarginHeight, 2,
140                                              XmNmarginWidth, 1,
141                                              NULL);
142
143    separator = XtVaCreateManagedWidget( "separator",
144                                         xmSeparatorWidgetClass,
145                                         form1,
146                                         XmNx, 37,
147                                         XmNshadowThickness, 4,
148                                         XmNorientation, XmVERTICAL,
149                                         XmNbottomAttachment, XmATTACH_FORM,
150                                         XmNtopAttachment, XmATTACH_FORM,
151                                         XmNleftAttachment, XmATTACH_NONE,
152                                         XmNleftWidget, NULL,
153                                         XmNrightAttachment, XmATTACH_NONE,
154                                         XmNleftOffset, 70,
155                                         XmNleftPosition, 0,
156                                         NULL);
157
158    form2 = XtVaCreateManagedWidget( "form2",
159                                     xmFormWidgetClass,
160                                     form1,
161                                     XmNwidth, width,
162                                     XmNheight, height,
163                                     XmNtopOffset, 0,
164                                     XmNbottomOffset, 0,
165                                     XmNleftOffset, 0,
166                                     XmNrightOffset, 0,
167                                     XmNrightAttachment, XmATTACH_FORM,
168                                     XmNbottomAttachment, XmATTACH_FORM,
169                                     XmNleftAttachment, XmATTACH_WIDGET,
170                                     XmNleftWidget, separator,
171                                     XmNtopAttachment, XmATTACH_POSITION,
172                                     XmNresizePolicy, XmRESIZE_NONE,
173                                     XmNx, 0,
174                                     XmNy, 0,
175                                     NULL);
176    p_w->areas[AW_INFO_AREA] =
177        new AW_area_management(root, form2, XtVaCreateManagedWidget( "info_area",
178                                                                     xmDrawingAreaWidgetClass,
179                                                                     form2,
180                                                                     XmNheight, 0,
181                                                                     XmNbottomAttachment, XmATTACH_NONE,
182                                                                     XmNtopAttachment, XmATTACH_FORM,
183                                                                     XmNleftAttachment, XmATTACH_FORM,
184                                                                     XmNrightAttachment, XmATTACH_FORM,
185                                                                     XmNmarginHeight, 2,
186                                                                     XmNmarginWidth, 2,
187                                                                     NULL));
188
189    p_w->areas[AW_BOTTOM_AREA] =
190        new AW_area_management(root, form2, XtVaCreateManagedWidget( "bottom_area",
191                                                                     xmDrawingAreaWidgetClass,
192                                                                     form2,
193                                                                     XmNheight, 0,
194                                                                     XmNbottomAttachment, XmATTACH_FORM,
195                                                                     XmNtopAttachment, XmATTACH_NONE,
196                                                                     XmNleftAttachment, XmATTACH_FORM,
197                                                                     XmNrightAttachment, XmATTACH_FORM,
198                                                                     NULL));
199
200    /*p_w->scroll_bar_horizontal = XtVaCreateWidget( "scroll_bar_horizontal",
201      xmScrollBarWidgetClass, form2,
202      //XmNincrement, 10,
203      NULL );
204
205      p_w->scroll_bar_vertical = XtVaCreateWidget( "scroll_bar_vertical",
206      xmScrollBarWidgetClass, form2,
207      //XmNincrement, 10,
208      NULL );*/
209
210    /// If I define the scroll bars as unmanaged widgets, they won't appear.
211
212    //p_w->scroll_bar_horizontal = XtVaCreateManagedWidget( "scroll_bar_horizontal",
213    p_w->scroll_bar_horizontal = XtVaCreateWidget( "scroll_bar_horizontal",
214                                                   xmScrollBarWidgetClass,
215                                                   form2,
216                                                   XmNheight, 15,
217                                                   XmNminimum, 0,
218                                                   XmNmaximum, AW_SCROLL_MAX,
219                                                   XmNincrement, 10,
220
221                                                   //XmNpageIncrement, 1,
222                                                   //XmNinitialDelay, 1,
223
224                                                   XmNsliderSize, AW_SCROLL_MAX,
225                                                   XmNrightAttachment, XmATTACH_FORM,
226                                                   XmNbottomAttachment, XmATTACH_FORM,
227                                                   XmNbottomOffset, 0,
228                                                   XmNleftAttachment, XmATTACH_FORM,
229                                                   XmNtopAttachment, XmATTACH_NONE,
230                                                   XmNorientation, XmHORIZONTAL,
231                                                   XmNrightOffset, 18,
232                                                   NULL );
233
234    //p_w->scroll_bar_vertical = XtVaCreateManagedWidget( "scroll_bar_vertical",
235    p_w->scroll_bar_vertical = XtVaCreateWidget( "scroll_bar_vertical",
236                                                 xmScrollBarWidgetClass,
237                                                 form2,
238                                                 XmNwidth, 15,
239                                                 XmNminimum, 0,
240                                                 XmNmaximum, AW_SCROLL_MAX,
241                                                 XmNincrement, 10,
242
243                                                 //XmNpageIncrement, 1,
244                                                 //XmNinitialDelay, 1,
245
246                                                 XmNsliderSize, AW_SCROLL_MAX,
247                                                 XmNrightAttachment, XmATTACH_FORM,
248                                                 XmNbottomAttachment, XmATTACH_WIDGET,
249                                                 XmNbottomWidget, p_w->scroll_bar_horizontal,
250                                                 XmNbottomOffset, 3,
251                                                 XmNleftOffset, 3,
252                                                 XmNrightOffset, 3,
253                                                 XmNleftAttachment, XmATTACH_NONE,
254                                                 XmNtopAttachment, XmATTACH_WIDGET,
255                                                 XmNtopWidget, INFO_WIDGET,
256                                                 NULL );
257    //XmScrollBarSetValues();
258
259    p_w->frame = XtVaCreateManagedWidget( "draw_area",
260                                          xmFrameWidgetClass,
261                                          //                    xmDrawingAreaWidgetClass,
262                                          form2,
263                                          XmNshadowType, XmSHADOW_IN,
264                                          XmNshadowThickness, 2,
265                                          XmNleftOffset, 3,
266                                          XmNtopOffset, 3,
267                                          XmNbottomOffset, 3,
268                                          XmNrightOffset, 3,
269                                          //XmNbottomAttachment, XmATTACH_WIDGET,
270                                          //    XmNbottomAttachment, XmATTACH_FORM,
271                                          //XmNbottomWidget, p_w->scroll_bar_horizontal,
272
273                                          //XmNtopAttachment, XmATTACH_FORM,
274                                          //    XmNtopAttachment, XmATTACH_WIDGET,
275                                          //    XmNtopWidget, p_w->areas[AW_INFO_AREA]->area,
276
277                                          XmNtopOffset, 0,
278                                          //      XmNleftAttachment, XmATTACH_FORM,
279                                          //    XmNrightAttachment, XmATTACH_FORM,
280                                          //XmNrightAttachment, XmATTACH_WIDGET,
281                                          //XmNrightWidget, p_w->scroll_bar_vertical,
282                                          NULL);
283
284    Arg args[20];
285    int n;
286    Widget glw;
287    n = 0;
288
289    XtSetArg(args[n], (char *) GLwNrgba, True); n++;
290    XtSetArg(args[n], (char *) GLwNallocateBackground, True); n++;
291    XtSetArg(args[n], (char *) GLwNallocateOtherColors,True); n++;
292    XtSetArg(args[n], (char *) GLwNdoublebuffer, True); n++;
293    XtSetArg(args[n], (char *) GLwNdepthSize, True); n++;
294    XtSetArg(args[n], (char *) GLwNredSize, 4); n++;
295    XtSetArg(args[n], (char *) GLwNgreenSize, 4); n++;
296    XtSetArg(args[n], (char *) GLwNblueSize, 4); n++;
297
298    static int alpha_Attributes[] = {GLX_RGBA,
299                                     GLX_DEPTH_SIZE, 12,
300                                     GLX_RED_SIZE, 4,
301                                     GLX_GREEN_SIZE, 4,
302                                     GLX_BLUE_SIZE, 4,
303                                     GLX_ALPHA_SIZE, 4,
304                                     None};
305
306    Widget tmp = XtCreateWidget("glw", glwMDrawingAreaWidgetClass,
307                                form2, args, n);
308
309    XVisualInfo *vi;
310    Display *dpy;
311    dpy = XtDisplay(tmp);
312    vi = glXChooseVisual(dpy, DefaultScreen( dpy ), alpha_Attributes);
313    if (vi) {
314        XtSetArg(args[n], (char *) GLwNalphaSize, 4); n++;
315        AW_alpha_Size_Supported = true;
316        printf("Alpha channel supported\n");
317    } else {
318        AW_alpha_Size_Supported = false;
319        printf("Alpha channel NOT supported\n");
320    }
321
322    XtSetArg(args[n], XmNmarginHeight, 0); n++;
323    XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
324    XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
325    XtSetArg(args[n], XmNtopWidget, p_w->areas[AW_INFO_AREA]->area); n++;
326    XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
327    XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
328
329    glw = XtCreateManagedWidget("glw", glwMDrawingAreaWidgetClass,
330                                form2, args, n);
331
332    p_w->areas[AW_MIDDLE_AREA] =
333        new AW_area_management(root,p_w->frame,glw);
334
335    /*p_w->areas[AW_MIDDLE_AREA] =
336      new AW_area_management(root,p_w->frame, XtVaCreateManagedWidget( "draw area",
337      //xmDrawingAreaWidgetClass,
338      glwMDrawingAreaWidgetClass,
339      form2,
340      //p_w->frame,
341      XmNmarginHeight, 0,
342      //XtNresize, TRUE,
343      XmNmarginWidth, 0,
344      XmNbottomAttachment, XmATTACH_FORM,
345      XmNtopAttachment, XmATTACH_WIDGET,
346      XmNtopWidget, p_w->areas[AW_INFO_AREA]->area,
347      XmNleftAttachment, XmATTACH_FORM,
348      XmNrightAttachment, XmATTACH_FORM,
349      NULL));*/
350
351    /*XtVaSetValues( p_w->areas[AW_MIDDLE_AREA]->area,
352      XmNx, 0,
353      XmNy, 0,
354      XmNwidth, 600,
355      XmNheight, 700,
356      NULL );*/
357
358    XmMainWindowSetAreas( main_window, p_w->menu_bar[0], (Widget) NULL, (Widget) NULL, (Widget) NULL, form1 );
359
360    aw_realize_widget(this);
361
362    create_devices();
363    aw_create_help_entry(this);
364    create_window_variables();
365}
366
367
368
Note: See TracBrowser for help on using the repository browser.