?? glui.h
字號:
void (*glut_idle_CB)(void);
void add_cb_to_glut_window(int window,int cb_type,void *cb);
public:
GLUI_Node gluis;
GLUI_Control *active_control, *curr_left_button_glut_menu;
GLUI *active_control_glui;
int glui_id_counter;
GLUI_Glut_Window *find_glut_window( int window_id );
void set_glutIdleFunc(void (*f)(void));
/**************
void (*glut_keyboard_CB)(unsigned char, int, int);
void (*glut_reshape_CB)(int, int);
void (*glut_special_CB)(int, int, int);
void (*glut_mouse_CB)(int,int,int,int);
void (*glut_passive_motion_CB)(int,int);
void (*glut_visibility_CB)(int);
void (*glut_motion_CB)(int,int);
void (*glut_display_CB)(void);
void (*glut_entry_CB)(int);
**********/
void set_left_button_glut_menu_control( GLUI_Control *control );
/********** GLUT callthroughs **********/
/* These are the glut callbacks that we do not handle */
void set_glutReshapeFunc(void (*f)(int width, int height));
void set_glutKeyboardFunc(void (*f)(unsigned char key, int x, int y));
void set_glutSpecialFunc(void (*f)(int key, int x, int y));
void set_glutMouseFunc(void (*f)(int, int, int, int ));
void set_glutDisplayFunc(void (*f)(void)) {glutDisplayFunc(f);};
void set_glutTimerFunc(unsigned int millis, void (*f)(int value), int value)
{ ::glutTimerFunc(millis,f,value);};
void set_glutOverlayDisplayFunc(void(*f)(void)){glutOverlayDisplayFunc(f);};
void set_glutSpaceballMotionFunc(Int3_CB f) {glutSpaceballMotionFunc(f);};
void set_glutSpaceballRotateFunc(Int3_CB f) {glutSpaceballRotateFunc(f);};
void set_glutSpaceballButtonFunc(Int2_CB f) {glutSpaceballButtonFunc(f);};
void set_glutTabletMotionFunc(Int2_CB f) {glutTabletMotionFunc(f);};
void set_glutTabletButtonFunc(Int4_CB f) {glutTabletButtonFunc(f);};
/* void set_glutWindowStatusFunc(Int1_CB f) {glutWindowStatusFunc(f);}; */
void set_glutMenuStatusFunc(Int3_CB f) {glutMenuStatusFunc(f);};
void set_glutMenuStateFunc(Int1_CB f) {glutMenuStateFunc(f);};
void set_glutButtonBoxFunc(Int2_CB f) {glutButtonBoxFunc(f);};
void set_glutDialsFunc(Int2_CB f) {glutDialsFunc(f);};
GLUI *create_glui( char *name, long flags=0, int x=-1, int y=-1 );
GLUI *create_glui_subwindow( int parent_window, long flags=0 );
GLUI *find_glui_by_window_id( int window_id );
void get_viewport_area( int *x, int *y, int *w, int *h );
void auto_set_viewport( void );
void close_all( void );
void sync_live_all( void );
void reshape( void );
float get_version( void ) { return GLUI_VERSION; };
friend void glui_idle_func(void);
GLUI_Master_Object( void ) {
glut_idle_CB = NULL;
glui_id_counter = 1;
}
};
extern GLUI_Master_Object GLUI_Master;
/************************************************************/
/* */
/* Class for managing a GLUT window */
/* */
/************************************************************/
class GLUI_Glut_Window : public GLUI_Node {
public:
int glut_window_id;
/*********** Pointers to GLUT callthrough functions *****/
void (*glut_keyboard_CB)(unsigned char, int, int);
void (*glut_special_CB)(int, int, int);
void (*glut_reshape_CB)(int, int);
void (*glut_passive_motion_CB)(int,int);
void (*glut_mouse_CB)(int,int,int,int);
void (*glut_visibility_CB)(int);
void (*glut_motion_CB)(int,int);
void (*glut_display_CB)(void);
void (*glut_entry_CB)(int);
GLUI_Glut_Window( void ) {
glut_display_CB = NULL;
glut_reshape_CB = NULL;
glut_keyboard_CB = NULL;
glut_special_CB = NULL;
glut_mouse_CB = NULL;
glut_motion_CB = NULL;
glut_passive_motion_CB = NULL;
glut_entry_CB = NULL;
glut_visibility_CB = NULL;
glut_window_id = 0;
};
};
/************************************************************/
/* */
/* Main GLUI class (not user-level) */
/* */
/************************************************************/
class GLUI_Main : public GLUI_Node {
protected:
/*** Variables ***/
int main_gfx_window_id;
int mouse_button_down;
int glut_window_id;
int top_level_glut_window_id;
GLUI_Control *active_control;
GLUI_Control *mouse_over_control;
GLUI_Panel *main_panel;
int curr_cursor;
int w, h;
long flags;
int closing;
int parent_window;
int glui_id;
/********** Friend classes *************/
friend GLUI_Control;
friend GLUI_Rotation;
friend GLUI_Translation;
friend GLUI;
friend GLUI_Master_Object;
/********** Misc functions *************/
GLUI_Control *find_control( int x, int y );
GLUI_Control *find_next_control( GLUI_Control *control );
GLUI_Control *find_next_control_rec( GLUI_Control *control );
GLUI_Control *find_next_control_( GLUI_Control *control );
GLUI_Control *find_prev_control( GLUI_Control *control );
void create_standalone_window( char *name, int x=-1, int y=-1 );
void create_subwindow( int parent,int window_alignment );
void setup_default_glut_callbacks( void );
void mouse(int button, int state, int x, int y);
void keyboard(unsigned char key, int x, int y);
void special(int key, int x, int y);
void passive_motion(int x, int y);
void reshape( int w, int h );
void visibility(int state);
void motion(int x, int y);
void entry(int state);
void display( void );
void idle(void);
void (*glut_mouse_CB)(int, int, int, int);
void (*glut_keyboard_CB)(unsigned char, int, int);
void (*glut_special_CB)(int, int, int);
void (*glut_reshape_CB)(int, int);
/*********** Friend functions and classes **********/
friend void glui_mouse_func(int button, int state, int x, int y);
friend void glui_keyboard_func(unsigned char key, int x, int y);
friend void glui_special_func(int key, int x, int y);
friend void glui_passive_motion_func(int x, int y);
friend void glui_reshape_func( int w, int h );
friend void glui_visibility_func(int state);
friend void glui_motion_func(int x, int y);
friend void glui_entry_func(int state);
friend void glui_display_func( void );
friend void glui_idle_func(void);
friend void glui_parent_window_reshape_func( int w, int h );
friend void glui_parent_window_keyboard_func( unsigned char, int, int );
friend void glui_parent_window_special_func( int, int, int );
friend void glui_parent_window_mouse_func( int, int, int, int );
/*********** Controls ************/
GLUI_Control *controls;
int num_controls;
int add_control( GLUI_Node *parent, GLUI_Control *control );
/********** Constructors and Destructors ***********/
GLUI_Main( void );
public:
GLUI_StdBitmaps std_bitmaps;
GLUI_String window_name;
RGBc bkgd_color;
float bkgd_color_f[3];
void *font;
int curr_modifiers;
void adjust_glut_xy( int &x, int &y ) { y = h-y; };
void activate_control( GLUI_Control *control, int how );
void align_controls( GLUI_Control *control );
void restore_draw_buffer( int buffer_state );
void disactivate_current_control( void );
void draw_raised_box( int x, int y, int w, int h );
void draw_lowered_box( int x, int y, int w, int h );
int set_front_draw_buffer( void );
void post_update_main_gfx( void );
void pack_controls( void );
void close_internal( void );
void check_subwindow_position( void );
void set_ortho_projection( void );
void set_viewport( void );
void refresh( void );
};
/************************************************************/
/* */
/* GLUI_Control: base class for all controls */
/* */
/************************************************************/
class GLUI_Control : public GLUI_Node {
public:
int w, h; /* dimensions of control */
int x_abs, y_abs;
int x_off, y_off_top, y_off_bot; /* INNER margins, by which
child controls are indented */
int contain_x, contain_y;
int contain_w, contain_h;
/* if this is a container control (e.g.,
radiogroup or panel) this indicated dimensions
of inner area in which controls reside */
int active, active_type, can_activate;
int spacebar_mouse_click;
long user_id, type;
int is_container; /* Is this a container class (e.g., panel) */
int alignment;
GLUI_Update_CB callback;
void *ptr_val; /* A pointer value */
float float_val; /* A float value */
int enabled; /* Is this control grayed out? */
int int_val; /* An integer value */
float float_array_val[GLUI_DEF_MAX_ARRAY];
int state;
GLUI_String name; /* The name of this control */
GLUI_String text;
GLUI *glui;
void *font;
int live_type, live_inited;
int last_live_int; /* last value that live var known to have */
float last_live_float;
GLUI_String last_live_text;
float last_live_float_array[GLUI_DEF_MAX_ARRAY];
int float_array_size;
int collapsible, is_open;
GLUI_Node collapsed_node;
int hidden; /* Collapsed controls (and children) are hidden */
/*** Get/Set values ***/
virtual void set_name( char *string );
virtual void set_int_val( int new_int ) { int_val = new_int; output_live(true); };
virtual void set_float_val( float new_float ) { float_val = new_float; output_live(true); };
virtual void set_ptr_val( void *new_ptr ) { ptr_val = new_ptr; output_live(true); };
virtual void set_float_array_val( float *array_ptr );
virtual float get_float_val( void ) { return float_val; };
virtual int get_int_val( void ) { return int_val; };
virtual void get_float_array_val( float *array_ptr );
virtual int mouse_down_handler( int local_x, int local_y )
{ return false; };
virtual int mouse_up_handler( int local_x, int local_y, int inside )
{ return false; };
virtual int mouse_held_down_handler( int local_x, int local_y, int inside)
{ return false; };
virtual int key_handler( unsigned char key, int modifiers )
{ return false; };
virtual int special_handler( int key,int modifiers )
{ return false; };
virtual void update_size( void ) { };
virtual void idle( void ) { };
virtual int mouse_over( int state, int x, int y ) { return false; };
virtual void enable( void );
virtual void disable( void );
virtual void activate( int how ) { active = true; };
virtual void disactivate( void ) { active = false; };
void hide_internal( int recurse );
void unhide_internal( int recurse );
int can_draw( void ) { return (glui != NULL && hidden == false); };
virtual void align( void );
void pack( int x, int y ); /* Recalculate positions and offsets */
void pack_old( int x, int y );
void draw_recursive( int x, int y );
int set_to_glut_window( void );
void restore_window( int orig );
void translate_and_draw_front( void );
void translate_to_origin( void )
{glTranslatef((float)x_abs+.5,(float)y_abs+.5,0.0);};
virtual void draw( int x, int y )=0;
void set_font( void *new_font );
void *get_font( void );
int string_width( char *text );
int char_width( char c );
void draw_name( int x, int y );
void draw_box_inwards_outline( int x_min, int x_max,
int y_min, int y_max );
void draw_box( int x_min, int x_max, int y_min, int y_max,
float r, float g, float b );
void draw_bkgd_box( int x_min, int x_max, int y_min, int y_max );
void draw_emboss_box( int x_min, int x_max,int y_min,int y_max);
void draw_string( char *text );
void draw_char( char c );
void draw_active_box( int x_min, int x_max, int y_min, int y_max );
void set_to_bkgd_color( void );
void set_w( int new_w );
void set_h( int new_w );
void set_alignment( int new_align );
void sync_live( int recurse, int draw ); /* Reads live variable */
void init_live( void );
void output_live( int update_main_gfx ); /** Writes live variable **/
virtual void set_text( char *t ) {};
void execute_callback( void );
void get_this_column_dims( int *col_x, int *col_y,
int *col_w, int *col_h,
int *col_x_off, int *col_y_off );
virtual int needs_idle( void );
GLUI_Control(void) {
x_off = GLUI_XOFF;
y_off_top = GLUI_YOFF;
y_off_bot = GLUI_YOFF;
x_abs = GLUI_XOFF;
y_abs = GLUI_YOFF;
state = 0;
active = false;
enabled = true;
int_val = 0;
last_live_int = 0;
float_array_size = 0;
sprintf( (char*)name, "Control: %p", this );
float_val = 0.0;
last_live_float = 0.0;
ptr_val = NULL;
glui = NULL;
w = GLUI_DEFAULT_CONTROL_WIDTH;
h = GLUI_DEFAULT_CONTROL_HEIGHT;
font = NULL;
active_type = GLUI_CONTROL_ACTIVE_MOUSEDOWN;
alignment = GLUI_ALIGN_LEFT;
is_container = false;
can_activate = true; /* By default, you can activate a control */
spacebar_mouse_click = true; /* Does spacebar simulate a mouse click? */
live_type = GLUI_LIVE_NONE;
strcpy( (char*)text, "" );
strcpy( (char*)last_live_text, "" );
live_inited = false;
collapsible = false;
is_open = true;
hidden = false;
int i;
for( i=0; i<GLUI_DEF_MAX_ARRAY; i++ )
float_array_val[i] = last_live_float_array[i] = 0.0;
};
~GLUI_Control();
};
/************************************************************/
/* */
/* Button class (container) */
/* */
/************************************************************/
class GLUI_Button : public GLUI_Control
{
public:
int currently_inside;
int mouse_down_handler( int local_x, int local_y );
int mouse_up_handler( int local_x, int local_y, int same );
int mouse_held_down_handler( int local_x, int local_y, int inside );
int key_handler( unsigned char key,int modifiers );
void draw( int x, int y );
void draw_pressed( void );
void draw_unpressed( void );
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -