gCAD3D 2.40
gui_gtk3/gtk_base.c File Reference

window, boxes, Basefunctions More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <gtk/gtk.h>
#include "../ut/ut_umem.h"
#include "../ut/ut_umb.h"
#include "../gui/gui_types.h"
#include "../gui/gui_base.h"
#include "../gui_gtk3/gtk_base.h"

Functions

int GUI_key_set1 (int ikey)
 
int GUI_obj_focus (MemObj *mo)
 
int GUI_Win_exist (char *winTit)
 
char * GUI_Win_tit (void *gtkWin)
 
void GUI_Init_style (void *win1)
 
void GUI_Init__ (char *fRC)
 
void GUI_Win_kill (MemObj *mo)
 
MemObj GUI_Win__ (char *wtit, void *funcnam, char *opts)
 
int GUI_Win_Id ()
 
int GUI_Win_raise (MemObj *mo)
 
int GUI_Win_exit (void *parent, MemObj mo)
 
int GUI_main_quit ()
 
int GUI_WinTit (MemObj *mo, char *wtit)
 
int GUI_Win_ev_key (MemObj *o_par, void *fKey)
 
int GUI_Win_key (void *parent, void *event, void *data)
 
int GUI_Win_ev_button (MemObj *o_par, void *fButton)
 
int GUI_Win_button (void *parent, void *ev, void *data)
 
int GUI_Win_go (MemObj *o_par)
 
void GUI_Tip (char *txt)
 
int GUI_is_win_alive (void *win)
 
int GUI_is_alive (int winId)
 
int GUI_Win_up (MemObj *parentWin, MemObj *o_win, int typ)
 
int GUI_update__ ()
 
int GUI_idle__ (void *funcnam, void *data)
 
int GUI_timer__ (void *funcnam, int interval, void *data)
 
int GUI_packwn (void *parent, void *wi, int hsiz, int vsiz)
 
int GUI_siz_eval (int *ihs, int *ivs, int hsiz, int vsiz)
 
int GUI_siz_set (void *parent, int hSiz, int vSiz)
 
MemObj GUI_box_h (MemObj *o_par, char *opts)
 
MemObj GUI_box_v (MemObj *o_par, char *opts)
 
MemObj GUI_box__ (MemObj *o_par, int typ, char *opts)
 
int GUI_w_pack_d (int *isx, int *isy, int *iex, int *iey, char *siz)
 
int GUI_w_pack2 (int pTyp, void *pObj, void *cObj, char *opts)
 
int GUI_w_pack1 (int pTyp, void *pObj, void *cObj, char *opts)
 
int GUI_w_pack_w (int pTyp, void *pObj, void *cObj, int *isx, int *isy, int *iex, int *iey)
 
int GUI_w_pack_b (int pTyp, void *pObj, void *cObj, int *isx, int *isy, int *iex, int *iey)
 
void GUI_spc__ (MemObj *o_par, int typ, int spc)
 
void GUI_sep__ (MemObj *o_par, int typ, int border)
 
int GUI_set_enable (MemObj *mo, int mode)
 
int GUI_set_show (MemObj *mo, int mode)
 
int GUI_get_keys_mod ()
 
int GUI_get_version (char *SW, int *vMaj, int *vMin)
 
int GUI_ck_version (int vMaj, int vMin)
 
int GUI_cursor__ (MemObj *mo, int iCur)
 
int GUI_OBJ_TYP (MemObj *mo)
 
int GUI_OBJ_SRC (MemObj *mo)
 
void ** GUI_SETDAT_E (int ie)
 
void ** GUI_SETDAT_ES (int ie, char *is)
 
void ** GUI_SETDAT_EI (int ie, int ii)
 

Variables

int UI_fontsizX
 
int UI_fontsizY
 
GtkWidget * UI_MainWin
 
GtkWidget * UI_act_wi
 
static int UI_act_Id
 
static GdkRGBA colR ={1.0, 0.1, 0.1, 1.0}
 
static GdkRGBA colB ={0.1, 0.1, 1.0, 1.0}
 
GdkRGBA * UI_stylTab [3]
 

Detailed Description

window, boxes, Basefunctions

=====================================================
List_functions_start:
GUI_Init__ must be 1. call ..
GUI_Win__ create new window
GUI_Win_ev_key add callback for the key-events
GUI_Win_ev_button add callback for the mouse-button event
GUI_Win_go windowSetup finished; display it ..
GUI_Win_up window always on top
GUI_WinTit set titletext
GUI_Win_kill destroy window
GUI_Win_exist returns nr of windows with windowTitle <winTit>;
GUI_main_quit close application
GUI_box_h horizontal container for widgets
GUI_box_v vertical container for widgets
GUI_box__ container for widgets
GUI_sep_h horiz. separationline (Ruler)
GUI_sep_v vertical separationline (Ruler)
GUI_sep__ horiz.|vertical separationline (Ruler)
GUI_spc_h horiz. (free) space
GUI_spc_v vertical (free) space
GUI_spc__ horiz.|vertical (free) space
GUI_Tip Tooltip (infotext for widget)
GUI_cursor_set set/change cursor
GUI_key_set1 change uncommon keys
GUI_hide__ hide object
GUI_show__ show object
GUI_obj_focus set focus to widget
GUI_set_show show/hide object
GUI_set_enable make (groups of) widgets unselectable disable enable
GUI_get_keys_mod get state of modifier-keys;
GUI_is_alive test if window win (GtkWidget) is active
GUI_update__ update all windows
GUI_idle__ register a idle-function
GUI_timer__ register a timer-function
GUI_SETDAT_E create a GUI_DATA-block (event)
GUI_SETDAT_EI create a GUI_DATA-block (event + integer-data)
GUI_SETDAT_ES create a GUI_DATA-block (event + string-data)
GUI_OBJ_TYP get gui-typ from MemObj
GUI_OBJ_SRC get gui-src from MemObj (the gui-widget-nr)
GUI_get_version returns guiSW, SW-mayor-version, SW-minor-version
GUI_Win_exit INTERNAL callback from destroy window
GUI_Win_key INTERNAL callback key_event
GUI_Win_button INTERNAL callback button_press_event
GUI_packwn INTERNAL pack widget normal
GUI_siz_set INTERNAL set widget-size
GUI_siz_eval INTERNAL eval widget-size
GUI_ck_version INTERNAL check GTK_MAJOR_VERSION,GTK_MINOR_VERSION
List_functions_end:
=====================================================

Function Documentation

int GUI_key_set1 ( int  ikey)

GUI_key_set1 change uncommon keys

int GUI_obj_focus ( MemObj mo)
int GUI_Win_exist ( char *  winTit)
char* GUI_Win_tit ( void *  gtkWin)
void GUI_Init_style ( void *  win1)

INTERNAL

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>
*
void GUI_Win_kill ( MemObj mo)

GUI_Win_kill destroy window from its MemObj

MemObj GUI_Win__ ( char *  wtit,
void *  funcnam,
char *  opts 
)
*
* 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_Id ( )
* get id for active window;
* must be called after GUI_Win__() and before GUI_Win_go().
* Use id with GUI_is_alive()
*
int GUI_Win_raise ( MemObj mo)
* raise window
*
int GUI_Win_exit ( void *  parent,
MemObj  mo 
)
* INTERNAL
* callback from destroy window.
*
int GUI_main_quit ( )

GUI_main_quit close application

int GUI_WinTit ( MemObj mo,
char *  wtit 
)

GUI_WinTit set titletext

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__
*
int GUI_Win_key ( void *  parent,
void *  event,
void *  data 
)
* INTERNAL
* key_press_event: GdkEventKey GDK_KEY_PRESS or GDK_KEY_RELEASE
*
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]);
*
*
int GUI_Win_button ( void *  parent,
void *  ev,
void *  data 
)
* INTERNAL
* button_press_event: GdkEventButton
* GDK_BUTTON_PRESS GDK_BUTTON_RELEASE GDK_SCROLL
*
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.
*
void GUI_Tip ( char *  txt)
* add infotext (tooltip) to last created widget.
* \n starts new line.
* how to add new message: see INF_MSG_new
*
int GUI_is_win_alive ( void *  win)
int GUI_is_alive ( int  winId)
* test if window mo is active
* get winId with GUI_Win_Id() on init
* 0=no, 1=yes
*
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
*
int GUI_update__ ( )

update all windows

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.
* }
*
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.
*
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)
*
int GUI_siz_eval ( int *  ihs,
int *  ivs,
int  hsiz,
int  vsiz 
)
* INTERNAL
* RetCod: 0 = 0,0 minimum size (size of caption)
* 1 = 0,1 maximum size (expand inside container)
* 2 = ... absolute size
*
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
*
MemObj GUI_box_h ( MemObj o_par,
char *  opts 
)
* 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 *  opts 
)
* 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 *  opts 
)
* 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

int GUI_w_pack2 ( int  pTyp,
void *  pObj,
void *  cObj,
char *  opts 
)
int GUI_w_pack1 ( int  pTyp,
void *  pObj,
void *  cObj,
char *  opts 
)
int GUI_w_pack_w ( int  pTyp,
void *  pObj,
void *  cObj,
int *  isx,
int *  isy,
int *  iex,
int *  iey 
)

pack widget=box into window|frame|toolbar gtk_box_pack_start does not work with parent = window|frame|toolbar pTyp parentTyp pObj parentObj ONLY Gtk2

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

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
*
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.
*
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
*
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
*
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");
*
int GUI_get_version ( char *  SW,
int *  vMaj,
int *  vMin 
)
* GUI_get_version returns guiSW, SW-mayor-version, SW-minor-version
* Output:
* SW "gtk"
* vMaj 2 or 3
*
int GUI_ck_version ( int  vMaj,
int  vMin 
)

INTERNAL check GTK_MAJOR_VERSION,GTK_MINOR_VERSION

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
*
int GUI_OBJ_TYP ( MemObj mo)

returns type of gui-obj

int GUI_OBJ_SRC ( MemObj mo)

returns gui-widget-nr

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
*
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"
*
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
*

Variable Documentation

int UI_fontsizX
int UI_fontsizY
GtkWidget* UI_MainWin
GtkWidget* UI_act_wi
int UI_act_Id
static
GdkRGBA colR ={1.0, 0.1, 0.1, 1.0}
static
GdkRGBA colB ={0.1, 0.1, 1.0, 1.0}
static
GdkRGBA* UI_stylTab[3]