gCAD3D 2.35
gui_gtk2/gtk_base.h File Reference

Go to the source code of this file.

Macros

#define GUI_spc_h(o_par, hsiz)   GUI_spc__(o_par,0,hsiz)
 
#define GUI_spc_v(o_par, vsiz)   GUI_spc__(o_par,1,vsiz)
 
#define GUI_sep_h(o_par, hsiz)   GUI_sep__(o_par,0,hsiz)
 
#define GUI_sep_v(o_par, vsiz)   GUI_sep__(o_par,1,vsiz)
 
#define GUI_hide__(o_par)   GUI_set_show(o_par,0)
 
#define GUI_show__(o_par)   GUI_set_show(o_par,1)
 

Functions

void GUI_Init__ (char *fRC)
 
MemObj GUI_Win__ (char *wtit, void *funcnam, char *opts)
 
int GUI_Win_go (MemObj *o_par)
 
int GUI_Win_ev_key (MemObj *o_par, void *fKey)
 
int GUI_Win_ev_button (MemObj *o_par, void *fButton)
 
int GUI_Win_up (MemObj *parentWin, MemObj *o_win, int typ)
 
char * GUI_Win_tit (void *gtkWin)
 
void GUI_Win_kill (MemObj *mo)
 
int GUI_main_quit ()
 
MemObj GUI_box_h (MemObj *o_par, char *siz)
 
MemObj GUI_box_v (MemObj *o_par, char *siz)
 
MemObj GUI_box__ (MemObj *o_par, int typ, char *siz)
 
int GUI_w_pack_d (int *isx, int *isy, int *iex, int *iey, char *siz)
 
int GUI_w_pack_b (int pTyp, void *pObj, void *cObj, int *isx, int *isy, int *iex, int *iey)
 
int GUI_w_pack2 (int pTyp, void *pObj, void *cObj, char *siz)
 
int GUI_w_pack1 (int pTyp, void *pObj, void *cObj, char *siz)
 
void GUI_spc__ (MemObj *o_par, int typ, int spc)
 
void GUI_sep__ (MemObj *o_par, int typ, int border)
 
int GUI_is_alive (int winId)
 
int GUI_get_keys_mod ()
 
int GUI_update__ ()
 
int GUI_set_show (MemObj *mo, int mode)
 
int GUI_set_enable (MemObj *mo, int mode)
 
int GUI_idle__ (void *funcnam, void *data)
 
int GUI_timer__ (void *funcnam, int interval, void *data)
 
int GUI_Win_exit (void *parent, MemObj um)
 
int GUI_Win_key (void *parent, void *event, void *data)
 
int GUI_Win_button (void *parent, void *ev, void *data)
 
int GUI_packwn (void *parent, void *wi, int hsiz, int vsiz)
 
int GUI_siz_set (void *parent, int hSiz, int vSiz)
 
int GUI_cursor__ (MemObj *mo, int iCur)
 
void ** GUI_SETDAT_E (int ie)
 
void ** GUI_SETDAT_EI (int ie, int ii)
 
void ** GUI_SETDAT_ES (int ie, char *is)
 
int GUI_OBJ_TYP (MemObj *mo)
 
int GUI_OBJ_SRC (MemObj *mo)
 

Macro Definition Documentation

#define GUI_spc_h (   o_par,
  hsiz 
)    GUI_spc__(o_par,0,hsiz)
#define GUI_spc_v (   o_par,
  vsiz 
)    GUI_spc__(o_par,1,vsiz)
#define GUI_sep_h (   o_par,
  hsiz 
)    GUI_sep__(o_par,0,hsiz)
#define GUI_sep_v (   o_par,
  vsiz 
)    GUI_sep__(o_par,1,vsiz)
#define GUI_hide__ (   o_par)    GUI_set_show(o_par,0)
#define GUI_show__ (   o_par)    GUI_set_show(o_par,1)

Function Documentation

void GUI_Init__ ( char *  fRC)
GUI_Init__ must be 1. call ..
fRC UNUSED (style-info-file)
get local memSpc UI_tmpSpc & a new memBlockId <UI_umbId>
GUI_Init__ must be 1. call ..
fRC UNUSED (style-info-file)
get local memSpc UI_tmpSpc & a new memBlockId <UI_umbId>
MemObj GUI_Win__ ( char *  wtit,
void *  funcnam,
char *  opts 
)
Input:
wtit WindowTitle. or NULL = none
funcnam callback from DestroyWindow
opts options; (HorSiz,VertSiz)
HorSiz,VertSiz: size in characters; default is automatic size.
negative values: size in pixels.
Examples:
"" size automatic
"100,20" horiz. size 10 chars, vertical 20 lines
"-1000,-500" horiz. size 1000 pixels, vertical 500 pixels
funcnam prototype:
int funcnam (MemObj *mo, void **data);
// data=table of 1 pointers;
GUI_DATA_EVENT =*(int*)data[0]=TYP_EventExit
GUI_DATA_I1 =*(int*)data[1]=UI_FuncExit
Examples without callback:
MemObj win0, box0;
win0 = GUI_Win__ ("testWindow", NULL, 300, 100);
box0 = GUI_box__ (&win0, 1, 1, 1);
lbl1 = GUI_label__ (&box0, "Label..", -1, 5);
GUI_button__ (&box0, " Exit ", f_cb_exit, "but3", 0, 0);
GUI_Win_go (win0);
Examples with callback:
win0 = GUI_Win__ ("testWindow", w_cb_exit, 0, 0);
int w_cb_exit (MemObj *mo, void **data) {
printf("w_cb_exit %d\n",GUI_DATA_EVENT); // is TYP_EventExit from exit
// or TYP_EventPress from button
.. do cleanup ..
int win0Id;
win0Id = GUI_Win_Id ();
if(GUI_is_alive(win0Id)) printf(" testWindow is alive\n");
Input:
wtit WindowTitle. or NULL = none
funcnam callback from DestroyWindow; see prototype below.
opts options; (HorSiz,VertSiz)
HorSiz,VertSiz: size in characters; default is automatic size.
negative values: size in pixels.
Examples:
"" size automatic
"100,20" horiz. size 10 chars, vertical 20 lines
"-1000,-500" horiz. size 1000 pixels, vertical 500 pixels
funcnam prototype:
int funcnam (MemObj *mo, void **data);
// data=table of 1 pointers;
GUI_DATA_EVENT =*(int*)data[0]=TYP_EventExit
GUI_DATA_I1 =*(int*)data[1]=UI_FuncExit
Examples without callback:
MemObj win0, box0;
win0 = GUI_Win__ ("testWindow", NULL, 300, 100);
box0 = GUI_box__ (&win0, 1, 1, 1);
lbl1 = GUI_label__ (&box0, "Label..", -1, 5);
GUI_button__ (&box0, " Exit ", f_cb_exit, "but3", 0, 0);
GUI_Win_go (win0);
Examples with callback:
win0 = GUI_Win__ ("testWindow", w_cb_exit, 0, 0);
int w_cb_exit (MemObj *mo, void **data) {
printf("w_cb_exit %d\n",GUI_DATA_EVENT); // is TYP_EventExit from exit
// or TYP_EventPress from button
.. do cleanup ..
int win0Id;
win0Id = GUI_Win_Id ();
if(GUI_is_alive(win0Id)) printf(" testWindow is alive\n");
int GUI_Win_go ( MemObj o_par)
GUI_Win_go windowSetup finished; display it ..
If this window is the first window, this function does not return.
GUI_Win_go windowSetup finished; display it ..
If this window is the first window, this function does not return.
int GUI_Win_ev_key ( MemObj o_par,
void *  fKey 
)
add callback for the key-events
Input:
o_par parentWindow
fKey callback-function key-events
prototyp fKey:
int fKey (void *parent, void **data);
// data=table of pointers to 4 ints;
// data[0]=(int*)=type of event; TYP_EventPress|TYP_EventRelease
// data[1]=(int*)=device; TYP_DeviceKeyb
// data[2]=(int*)=keyvalue; eg 'a'
// data[3]=(int*)=state of modifierkeys; &1=shift; &4=ctrl; &8=alt.
printf(" key=%d\n",*(int*)data[2]);
Example see GUI_entry__
add callback for the key-events
Input:
o_par parentWindow
fKey callback-function key-events
prototyp fKey:
int fKey (void *parent, void **data);
// data=table of pointers to 4 ints;
// data[0]=(int*)=type of event; TYP_EventPress|TYP_EventRelease
// data[1]=(int*)=device; TYP_DeviceKeyb
// data[2]=(int*)=keyvalue; eg 'a'
// data[3]=(int*)=state of modifierkeys; &1=shift; &4=ctrl; &8=alt.
printf(" key=%d\n",*(int*)data[2]);
Example see GUI_entry__
int GUI_Win_ev_button ( MemObj o_par,
void *  fButton 
)
add callback for the mouse-button event
Input:
o_par parentWindow
fButton callback-function mouse-button event
prototype:
int fButton (void *parent, void **data);
// data=table of pointers to 3 ints;
// data[0]=(int*)=type of event; TYP_EventPress|TYP_EventRelease
// data[1]=(int*)=device; TYP_DeviceMouse
// data[2]=(int*)=button; GUI_MouseL|GUI_MouseM|GUI_MouseR - left,mid,right
GUI_MouseScUp|GUI_MouseScDown - scroll up/down
printf(" button=%d\n",*(int*)data[2]);
add callback for the mouse-button event
Input:
o_par parentWindow
fButton callback-function mouse-button event
prototype:
int fButton (void *parent, void **data);
// data=table of pointers to 3 ints;
// data[0]=(int*)=type of event; TYP_EventPress|TYP_EventRelease
// data[1]=(int*)=device; TYP_DeviceMouse
// data[2]=(int*)=button; GUI_MouseL|GUI_MouseM|GUI_MouseR - left,mid,right
GUI_MouseScUp|GUI_MouseScDown - scroll up/down
printf(" button=%d\n",*(int*)data[2]);
int GUI_Win_up ( MemObj parentWin,
MemObj o_win,
int  typ 
)
window always on top ..
Input:
parentWin NULL for top-level-parentwindow
o_win window to be kept on top of parentWin
typ 0=normal, 1=modal (block all other windows)
DOES NOT WORK FOR THE PARENT-WINDOW: USE WM_raise_wTit
window always on top ..
Input:
parentWin NULL for top-level-parentwindow
o_win window to be kept on top of parentWin
typ 0=normal, 1=modal (block all other windows)
DOES NOT WORK FOR THE PARENT-WINDOW: USE WM_raise_wTit
char* GUI_Win_tit ( void *  gtkWin)
void GUI_Win_kill ( MemObj mo)

GUI_Win_kill destroy window from its MemObj

GUI_Win_kill destroy window from its MemObj

int GUI_main_quit ( )

GUI_main_quit close application

GUI_main_quit close application

MemObj GUI_box_h ( MemObj o_par,
char *  siz 
)
GUI_box_h horizontal container for widgets
opts options; (HorSiz VertSiz)
HorSiz,VertSiz: size in characters; default is automatic size.
'e' = expand widget; default is fixed size.
negative values: size in pixels.
Examples: "" or "10" or "10e,e"
"10e,e" horiz. size 10 chars, hor. and vert. expandable.
GUI_box_h horizontal container for widgets
opts options; (HorSiz VertSiz)
HorSiz,VertSiz: size in characters; default is automatic size.
'e' = expand widget; default is fixed size.
negative values: size in pixels.
Examples: "" or "10" or "10e,e"
"10e,e" horiz. size 10 chars, hor. and vert. expandable.
MemObj GUI_box_v ( MemObj o_par,
char *  siz 
)
GUI_box_v vertical container for widgets
opts options; (HorSiz VertSiz)
HorSiz,VertSiz: size in characters; default is automatic size.
'e' = expand widget; default is fixed size.
negative values: size in pixels.
Examples: "" or "10" or "10e,e"
"10e,e" horiz. size 10 chars, hor. and vert. expandable.
GUI_box_v vertical container for widgets
opts options; (HorSiz VertSiz)
HorSiz,VertSiz: size in characters; default is automatic size.
'e' = expand widget; default is fixed size.
negative values: size in pixels.
Examples: "" or "10" or "10e,e"
"10e,e" horiz. size 10 chars, hor. and vert. expandable.
MemObj GUI_box__ ( MemObj o_par,
int  typ,
char *  siz 
)
GUI_box__ container for widgets
Input:
o_par must be a window or a box
typ 0=horizontal, 1=vertical
opts options; (HorSiz VertSiz)
HorSiz,VertSiz: size in characters; default is automatic size.
'e' = expand widget; default is fixed size.
negative values: size in pixels.
Examples: "" or "10" or "10e,e"
"10e,e" horiz. size 10 chars, hor. and vert. expandable.
GUI_box__ container for widgets
Input:
o_par must be a window or a box
typ 0=horizontal, 1=vertical
opts options; (HorSiz VertSiz)
HorSiz,VertSiz: size in characters; default is automatic size.
'e' = expand widget; default is fixed size.
negative values: size in pixels.
Examples: "" or "10" or "10e,e"
"10e,e" horiz. size 10 chars, hor. and vert. expandable.
int GUI_w_pack_d ( int *  isx,
int *  isy,
int *  iex,
int *  iey,
char *  siz 
)

Input: siz automaticSize; expand; ae automaticSize; do not expand; a defined size, expandable 5e defined size, do not expand. 5 Output: isx hor.size; 0=automatic; else size in pixels iex hor.expand; 0=expand=yes, 1=do not expand isy vert.size; 0=automatic; else size in pixels iey vert.expand; 0=expand=yes, 1=do not expand

Input: siz automaticSize; expand; ae automaticSize; do not expand; a defined size, expandable 5e defined size, do not expand. 5 Output: isx hor.size; 0=automatic; else size in pixels iex hor.expand; 0=expand=yes, 1=do not expand isy vert.size; 0=automatic; else size in pixels iey vert.expand; 0=expand=yes, 1=do not expand

int GUI_w_pack_b ( int  pTyp,
void *  pObj,
void *  cObj,
int *  isx,
int *  isy,
int *  iex,
int *  iey 
)

pack widget into box (not if parent is a window|frame|toolbar) ONLY Gtk2

pack widget into box (not if parent is a window|frame|toolbar) ONLY Gtk2

int GUI_w_pack2 ( int  pTyp,
void *  pObj,
void *  cObj,
char *  siz 
)
int GUI_w_pack1 ( int  pTyp,
void *  pObj,
void *  cObj,
char *  siz 
)
void GUI_spc__ ( MemObj o_par,
int  typ,
int  spc 
)
GUI_spc_h (parent, spc); // make a horizontal (free) space (spc=nr chars)
GUI_spc_v (parent, spc); // make a vertical (free) space (spc=nr chars)
Input:
o_par parentBox
typ 0=horizontal, 1=vertical
spc size in pixels
GUI_spc_h (parent, spc); // make a horizontal (free) space (spc=nr chars)
GUI_spc_v (parent, spc); // make a vertical (free) space (spc=nr chars)
Input:
o_par parentBox
typ 0=horizontal, 1=vertical
spc size in pixels
void GUI_sep__ ( MemObj o_par,
int  typ,
int  border 
)
create Vertical. separationline
Input:
o_par parentBox
typ 0=horizontal, 1=vertical
border distance left / right of the separationline.
create Vertical. separationline
Input:
o_par parentBox
typ 0=horizontal, 1=vertical
border distance left / right of the separationline.
int GUI_is_alive ( int  winId)
test if window mo is active
get winId with GUI_Win_Id() on init
0=no, 1=yes
test if window mo is active
get winId with GUI_Win_Id() on init
0=no, 1=yes
int GUI_get_keys_mod ( )
GUI_get_keys_mod get state of modifier-keys
(Mousebuttons, Shift, Ctrl, Alt);
int i1 = GUI_get_keys_mod ();
if(i1 & 1) printf(" shift is on\n");
if(i1 & 4) printf(" ctrl is on\n");
if(i1 & 8) printf(" alt is on\n");
if(i1 & 256) printf(" mouseButt. 1 is on\n");
if(i1 & 512) printf(" mouseButt. 2 is on\n");
if(i1 & 1024) printf(" mouseButt. 3 is on\n");
GUI_get_keys_mod get state of modifier-keys
(Mousebuttons, Shift, Ctrl, Alt);
int i1 = GUI_get_keys_mod ();
if(i1 & 1) printf(" shift is on\n");
if(i1 & 4) printf(" ctrl is on\n");
if(i1 & 8) printf(" alt is on\n");
if(i1 & 256) printf(" mouseButt. 1 is on\n");
if(i1 & 512) printf(" mouseButt. 2 is on\n");
if(i1 & 1024) printf(" mouseButt. 3 is on\n");
int GUI_update__ ( )

update all windows

update all windows

int GUI_set_show ( MemObj mo,
int  mode 
)
GUI_set_show show/hide object
mode 0=hide obj, 1=show obj, 2=query state
RetCode for mode=2: state; 0=hidden, 1=visible
GUI_set_show show/hide object
mode 0=hide obj, 1=show obj, 2=query state
RetCode for mode=2: state; 0=hidden, 1=visible
int GUI_set_enable ( MemObj mo,
int  mode 
)
GUI_set_enable makes widgets / groups of widgets unselectable (disactivate)
mode 1=TRUE=active; 0=FALSE=unpickable, inactive; 2=query state
RetCode for mode=2: state; 0=inactive, 1=active
GUI_set_enable makes widgets / groups of widgets unselectable (disactivate)
mode 1=TRUE=active; 0=FALSE=unpickable, inactive; 2=query state
RetCode for mode=2: state; 0=inactive, 1=active
int GUI_idle__ ( void *  funcnam,
void *  data 
)
GUI_Idle register a idle-function
Example:
GUI_idle__ (AP_Idle_CB, NULL);
int AP_Idle_CB (void *data) {
.. work ..
return 0; // removes idle-Call!
return 1; // keep idle-Call; call AP_Idle_CB again.
}
GUI_Idle register a idle-function
Example:
GUI_idle__ (AP_Idle_CB, NULL);
int AP_Idle_CB (void *data) {
.. work ..
return 0; // removes idle-Call!
return 1; // keep idle-Call; call AP_Idle_CB again.
}
int GUI_timer__ ( void *  funcnam,
int  interval,
void *  data 
)
GUI_timer__ register a timer-function
interval time in ms
(int) irc = funcnam ((void*)data) {..
return 0; // removes timer
return 1; // keep timer; call funcnam again.
GUI_timer__ register a timer-function
interval time in ms
(int) irc = funcnam ((void*)data) {..
return 0; // removes timer
return 1; // keep timer; call funcnam again.
int GUI_Win_exit ( void *  parent,
MemObj  um 
)
INTERNAL
callback from destroy window.
INTERNAL
callback from destroy window.
int GUI_Win_key ( void *  parent,
void *  event,
void *  data 
)
INTERNAL
key_press_event: GdkEventKey GDK_KEY_PRESS or GDK_KEY_RELEASE
INTERNAL
key_press_event: GdkEventKey GDK_KEY_PRESS or GDK_KEY_RELEASE
int GUI_Win_button ( void *  parent,
void *  ev,
void *  data 
)
INTERNAL
button_press_event: GdkEventButton
GDK_BUTTON_PRESS GDK_BUTTON_RELEASE GDK_SCROLL
INTERNAL
button_press_event: GdkEventButton
GDK_BUTTON_PRESS GDK_BUTTON_RELEASE GDK_SCROLL
int GUI_packwn ( void *  parent,
void *  wi,
int  hsiz,
int  vsiz 
)
INTERNAL
GUI_packwn pack widget normal
Input:
parent parentBox
hsiz 0,0 minimum size (size of caption)
0,1 maximum size (expand inside container)
>1 prepare size for <siz> nr of characters
<0 absolute size (in pixels)
INTERNAL
GUI_packwn pack widget normal
Input:
parent parentBox
hsiz 0,0 minimum size (size of caption)
0,1 maximum size (expand inside container)
>1 prepare size for <siz> nr of characters
<0 absolute size (in pixels)
int GUI_siz_set ( void *  parent,
int  hSiz,
int  vSiz 
)
INTERNAL
set size of widget size in pixels x,y.
Input:
parent parentBox
.Siz 0 = do not modify
INTERNAL
set size of widget size in pixels x,y.
Input:
parent parentBox
.Siz 0 = do not modify
int GUI_cursor__ ( MemObj mo,
int  iCur 
)
GUI_cursor__ change cursor;
mo window-obj; NULL = mainWindow
iCur 0=normal, 1=wait, 2=rotate, 3=hand, 4=size 5=blocked
GUI_cursor__ change cursor;
mo window-obj; NULL = mainWindow
iCur 0=normal, 1=wait, 2=rotate, 3=hand, 4=size 5=blocked
void** GUI_SETDAT_E ( int  ie)
GUI_SETDAT_E create a GUI_DATA-block
Input:
ifunc int GUI_DATA_EVENT
Usage:
cbFunc (NULL, GUI_SETDAT_E(TYP_EventExit));
// call cbFunc (mo, **data)
// with data[0] = GUI_DATA_EVENT = (int)TYP_EventExit
GUI_SETDAT_E create a GUI_DATA-block
Input:
ifunc int GUI_DATA_EVENT
Usage:
cbFunc (NULL, GUI_SETDAT_E(TYP_EventExit));
// call cbFunc (mo, **data)
// with data[0] = GUI_DATA_EVENT = (int)TYP_EventExit
void** GUI_SETDAT_EI ( int  ie,
int  ii 
)
GUI_SETDAT_EI create a GUI_DATA-block
Input:
ie int event; eg TYP_EventPress
ii int data
Usage:
// call cbFunc (mo, **data)
// with data[0] = GUI_DATA_EVENT = (int)TYP_EventPress
// with data[1] = GUI_DATA_I1 = (int)UI_FuncInit
GUI_SETDAT_EI create a GUI_DATA-block
Input:
ie int event; eg TYP_EventPress
ii int data
Usage:
// call cbFunc (mo, **data)
// with data[0] = GUI_DATA_EVENT = (int)TYP_EventPress
// with data[1] = GUI_DATA_I1 = (int)UI_FuncInit
void** GUI_SETDAT_ES ( int  ie,
char *  is 
)
GUI_SETDAT_ES create a GUI_DATA-block
Input:
ie int event; eg TYP_EventPress
is stringpointer
Usage:
cbFunc (NULL, GUI_SETDAT_ES (TYP_EventPress,"Func1"));
// call cbFunc (mo, **data)
// with data[0] = GUI_DATA_EVENT = (int)TYP_EventPress
// with data[1] = GUI_DATA_S1 = (char*)data[1] = "Func1"
GUI_SETDAT_ES create a GUI_DATA-block
Input:
ie int event; eg TYP_EventPress
is stringpointer
Usage:
cbFunc (NULL, GUI_SETDAT_ES (TYP_EventPress,"Func1"));
// call cbFunc (mo, **data)
// with data[0] = GUI_DATA_EVENT = (int)TYP_EventPress
// with data[1] = GUI_DATA_S1 = (char*)data[1] = "Func1"
int GUI_OBJ_TYP ( MemObj mo)

returns type of gui-obj

returns type of gui-obj

int GUI_OBJ_SRC ( MemObj mo)

returns gui-widget-nr

returns gui-widget-nr