C-KIT-GUI-GTK 0.60
gtk_button.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>
#include "../ut/ut_cast.h"
#include "../ut/ut_umem.h"
#include "../gui/gui_types.h"
#include "../gui/gui_base.h"
#include "../gui_gtk2/gtk_base.h"
#include "../gui_gtk2/gtk_button.h"

Functions

MemObj GUI_button_img (MemObj *o_par, char *filnam, void *funcnam, void *data, char *opts)
 
int GUI_button_mod (MemObj *mo, char *ltext)
 
int GUI_button_styl (MemObj *mo, int iCol)
 
MemObj GUI_button__ (MemObj *o_par, char *ltext, void *funcnam, void *data, char *opts)
 
int GUI_button_press (void *parent, MemObj mo)
 
int GUI_ckbutt_get (MemObj *mo)
 
int GUI_ckbutt_set (MemObj *mo, int mode)
 
int GUI_ckbutt_set_noCB (MemObj *mo, int mode)
 
MemObj GUI_ckbutt__ (MemObj *o_par, char *ltxt, int state, void *funcnam, void *data, char *opts)
 

Variables

GtkWidget * UI_act_wi
 
int UI_fontsizY
 
Memspc UI_tmpSpc
 
static int UI_but_noCB = 0
 

Detailed Description

=====================================================
List_functions_start:
GUI_button__ create Button
GUI_button_mod modify buttontext (caption)
GUI_button_styl modify buttonbackgroundColor
GUI_button_img create Button with image
GUI_ckbutt__ create Checkbox
GUI_ckbutt_get returns state of checkbox; 0=not sel, 1=selected.
GUI_ckbutt_set activate/disactivate Checkbox, Radiobutton
GUI_ckbutt_set_noCB set Checkbox, but do NOT call userCB
List_functions_end:
=====================================================

Function Documentation

MemObj GUI_button_img ( MemObj *  o_par,
char *  filnam,
void *  funcnam,
void *  data,
char *  opts 
)
create button with pixmap
Input:
o_par parentBox
filnam image
funcnam callbackfunktion for the press-button-event
data get this data from the callbackfunktion; NULL for none
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.
RetCod: NULL = Error (filnam not exist)
funcnam prototyp:
see GUI_button__ ()
int GUI_button_mod ( MemObj *  mo,
char *  ltext 
)

GUI_Butt_Label modify buttontext (caption)

int GUI_button_styl ( MemObj *  mo,
int  iCol 
)
GUI_button_styl modify buttonbackgroundColor
0=default; 1=red; 2=blue
MemObj GUI_button__ ( MemObj *  o_par,
char *  ltext,
void *  funcnam,
void *  data,
char *  opts 
)
Button.
Input:
o_par parentBox
ltext caption (button-text)
funcnam callbackfunktion for the press-button-event
data get this (static) data from the callbackfunktion; NULL for none
opts options; (HorSiz,VertSiz)
HorSiz,VertSiz: size in characters; default is automatic size.
'e' = expand widget; default is fixed size.
Examples: "" or "10" or "10e,e"
"10e,e" horiz. size 10 chars, hor. and vert. expandable.
Output:
gBut must exist as long as button is alive.
funcnam prototyp:
int funcnam (MemObj *mo, void **data);
// data=table of 2 pointers;
GUI_DATA_EVENT =*(int*)data[0]=TYP_EventPress
GUI_DATA_I1=*(int*)data[1] or GUI_DATA_S1=(char*)data[1] user-data
GUI_OBJ_TYP(mo) = TYP_GUI_Button
Example with string-data:
GUI_button__ (box0, "TestButton", UI_func1, "b1-clicked", "");
int UI_func1 (MemObj *mo, void **data) {
printf(" typ=%d\n",GUI_OBJ_TYP(mo));
printf(" button |%s|\n", GUI_DATA_S1);
..
Example with integer-data:
static int icb = UI_FuncUCB1;
GUI_button__ (box0, "TestButton", UI_func1, (void*)&icb, "");
int UI_func1 (MemObj *mo, void **data) {
if(GUI_DATA_EVENT == TYP_EventPress) {
if(GUI_DATA_I1 == UI_FuncUCB1) {
..
Disactivate:
GUI_set_enable (&wButt, 0); //1=activ, 0=inaktiv
Change text/caption/label:
GUI_button_mod (&wButt, " newText "); // gtk_button_set_label
int GUI_button_press ( void *  parent,
MemObj  mo 
)
int GUI_ckbutt_get ( MemObj *  mo)

returns state of checkbox; 0=not sel, 1=selected.

int GUI_ckbutt_set ( MemObj *  mo,
int  mode 
)
activate/disactivate Checkbox, Radiobutton.
Input:
mode 1 = TRUE = ON
0 = FALSE = OFF
int GUI_ckbutt_set_noCB ( MemObj *  mo,
int  mode 
)
activate/disactivate Checkbox, Radiobutton but do not call userCB
Input:
mode 1 = TRUE = ON
0 = FALSE = OFF
MemObj GUI_ckbutt__ ( MemObj *  o_par,
char *  ltxt,
int  state,
void *  funcnam,
void *  data,
char *  opts 
)
Checkbox.
o_par parentBox
ltext caption (button-text)
state: 0=FALSE: not checked; 1=TRUE: checked.
funcnam callbackfunktion for the select/deselect-event
data get this (static) data from the callbackfunktion; NULL for none
opts options; (HorSiz,VertSiz)
HorSiz,VertSiz: size in characters; default is automatic size.
'e' = expand widget; default is fixed size.
Examples: "" or "10" or "10e,e"
"10e,e" horiz. size 10 chars, hor. and vert. expandable.
funcnam prototyp:
int funcnam (MemObj *mo, void **data);
// data=table of 2 pointers;
GUI_DATA_EVENT =*(int*)data[0]=TYP_EventPress|TYP_EventRelease
GUI_DATA_I1=*(int*)data[1] or GUI_DATA_S1=(char*)data[1] user-data
GUI_OBJ_TYP(mo) = TYP_GUI_CheckBox
---------------------------
Example without callback:
int istate;
MemObj cb1;
// create checkbox
cb1 = GUI_ckbutt__ (&box0, "ckb 1", TRUE, NULL, NULL, "");
// query state
istate = GUI_ckbutt_get (&cb1) // 0=not sel, 1=selected.
---------------------------
Example with callback:
GUI_ckbutt__ (&box0, "ckb 1", 0, f_ckButt_CB, NULL, "");
int f_ckButt_CB, (MemObj *parent, void **data) {
if(GUI_ckbutt_get(parent)) goto L_activate;
printf("f_ckbutt disactivate\n");
..
L_activate:
..
}
---------------------------
Optional:
activate with:
GUI_ckbutt_set (&cb1, TRUE);

Variable Documentation

GtkWidget* UI_act_wi
int UI_fontsizY
Memspc UI_tmpSpc
int UI_but_noCB = 0
static