File: gui.h

package info (click to toggle)
openscenegraph 1.2.0-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 26,924 kB
  • ctags: 25,229
  • sloc: cpp: 239,326; ansic: 2,178; sh: 1,990; yacc: 548; perl: 237; makefile: 227; lex: 151
file content (102 lines) | stat: -rw-r--r-- 2,054 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#ifndef GUI_H
#define GUI_H
#include <X11/Intrinsic.h>
#include <Producer/VisualChooser>

class Gui {
    public :

	class IdleCallback {
	    public:
		IdleCallback() {}
		virtual void operator()() = 0;
	};

	class GinitCallback {
	    public:
		GinitCallback() {}
		virtual void operator()(Window) = 0;
	};

	enum Mode {
	    Embedded,
	    Detached
 	};

	Gui()
	{
	    icb = NULL;
	    _vc = NULL;
	    _mx = _my = 0.0;
	    _button_state = 0;
	    _mode = Embedded;
	}
	void setMode( Mode mode ) { _mode = mode; }
	void init(int *argc, char **argv, GinitCallback *ginitCB =0 );
	void mainLoop(IdleCallback *cb=NULL);

	void setVisualChooser( Producer::VisualChooser *vc )
	{
	    _vc = vc;
	}

	Window getRenderWindow() 
	{ 
	    if( !XtIsWidget(glw) ) return 0L;
	    return XtWindow(glw);
	}

	static void s_quitCB( Widget, XtPointer, XtPointer );
	static void s_exposeCB(Widget, XtPointer, XtPointer );
	static void s_resizeCB(Widget, XtPointer, XtPointer );
	static void s_ginitCB(Widget, XtPointer, XtPointer );
	static void s_inputCB(Widget, XtPointer, XtPointer );
	static bool s_idle( XtPointer );

	void quitCB( Widget, XtPointer );
	void exposeCB( Widget, XtPointer );
	void resizeCB( Widget, XtPointer );
	void ginitCB( Widget, XtPointer );
	void inputCB( Widget, XtPointer );
	void idle();


	float mx() { return _mx; }
	float my() { return _my; }
	unsigned int buttonState() { return _button_state; }


    private : 

        XtAppContext  app_context;
	Widget root,
		mainWindow,
		  menuBar,
		    fileMenu,
        	      newButton,
        	      openButton,
        	      closeButton,
        	      quitButton,
        	    fileCascade,
        	    editMenu,
        	    editCascade,
        	    utilsMenu,
                    utilsCascade,
                    helpMenu,
        	    helpCascade,
        	    mainForm,
		    frame,
		    glw;

	unsigned int glwWidth, glwHeight;
	IdleCallback *icb;
	GinitCallback *gicb;
	Producer::VisualChooser *_vc;

	float _mx, _my;
	unsigned int _button_state;
	Mode _mode;

};

#endif