C-KIT-GUI-GTK 0.60
gtk_dlg_std.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_entry.h"
#include "../gui_gtk2/gtk_label.h"
#include "../gui_gtk2/gtk_button.h"
#include "../gui_gtk2/gtk_dlg_std.h"

Macros

#define IMIN(x, y)   (((x)<(y))?(x):(y))
 

Functions

int GUI_DialogYN_CB (void *parent, void *data)
 
int GUI_DialogEntryCB (void *parent, void **data)
 
int GUI_Dialog_2b (char *txt, char *tb1, char *tb2)
 
int GUI_Dialog_e2b (char *txt, char *entry, int eSiz, char *tb1, char *tb2)
 
int GUI_DialogEntry (char *label, char *entry, int eSiz, char *buttons[], int border)
 
void GUI_DialogYN (char *text, void *funcnam)
 
int GUI_MsgBox (char *text)
 
int GUI_Color_select (int *ir, int *ig, int *ib)
 
double GUI_Slider_get (MemObj *mo)
 
void GUI_Slider_set (MemObj *mo, double newVal)
 
int GUI_Slider_cb2 (void *parent, void *ev, void *data)
 
MemObj GUI_Slider__ (MemObj *o_par, int typ, void *funcnam, double valMin, double valMax, double valStart, char *opts)
 
int GUI_Slider_cb1 (void *parent, MemObj mo)
 

Variables

int UI_fontsizX
 
int UI_fontsizY
 
GtkWidget * UI_MainWin
 
GtkWidget * UI_act_wi
 
static GtkWidget * UI_DialogYNWin =NULL
 
static void(* UI_DialogYNFunc )()
 
static MemObj UI_DialogEntryWin
 

Detailed Description

=====================================================
List_functions_start:
GUI_MsgBox display text, OK-Button, also if GTK is not yet up
GUI_DialogYN dialogWindow w. OK-Button, Cancel-Button, callback-func
// GUI_Dialog_cb_e2b dialogWindow w. entry, 2 Buttons, callback-func
GUI_DialogEntry dialogWindow 1-n buttons, entry (opt.), waiting.
GUI_Dialog_2b dialogWindow w. 2 Buttons, waiting.
GUI_Dialog_e2b dialogWindow w. entry, 2 Buttons, waiting.
GUI_Color_select select-color-Dialog. Modal (wait).
GUI_Slider__ Slider = AdjustmentControl
GUI_Slider_set change slider-value
GUI_Slider_get query slider-value
GUI_DialogYN_CB INTERNAL callback of GUI_DialogYN
GUI_DialogEntryCB INTERNAL callback of GUI_DialogEntry
GUI_Slider_cb1 INTERNAL slider callback
GUI_Slider_cb2 INTERNAL slider callback
List_functions_end:
=====================================================
needs gtk_entry

Macro Definition Documentation

#define IMIN (   x,
 
)    (((x)<(y))?(x):(y))

Function Documentation

int GUI_DialogYN_CB ( void *  parent,
void *  data 
)

INTERNAL callback of GUI_DialogYN

int GUI_DialogEntryCB ( void *  parent,
void **  data 
)

INTERNAL callback of GUI_DialogEntry

int GUI_Dialog_2b ( char *  txt,
char *  tb1,
char *  tb2 
)
GUI_Dialog_2b dialogWindow w. 2 Buttons, waiting.
Input
txt text label
tb1 caption button 1
tb2 caption button 2
RetCod nr of button pressed or UI_FuncKill (delete window)
0 means first button pressed, 1=second ..
-1 = dialog cancelled
int GUI_Dialog_e2b ( char *  txt,
char *  entry,
int  eSiz,
char *  tb1,
char *  tb2 
)
GUI_Dialog_e2b dialogWindow w. entry, 2 Buttons, waiting.
Input
txt label
entry entrytext, in & out
eSiz size of inputfield entry (max. nr of chars)
tb1 caption button 1
tb2 caption button 2
Output:
entry entrytext
RetCod nr of button pressed or UI_FuncKill (delete window)
0 means first button pressed, 1=second ..
-1 = dialog cancelled
int GUI_DialogEntry ( char *  label,
char *  entry,
int  eSiz,
char *  buttons[],
int  border 
)
GUI_DialogEntry text, 1-n buttons; entry optional; waits for return.
Input
label text
entry userinput - defaultText; NULL = no userinput (only buttons)
eSiz size of inputfield entry (max. nr of chars)
buttons pointerarray of buttontext, NULL-terminated.
border size around button
Output:
entry content of inputfield on exit
eSiz nr of chars in inputfield entry
RetCod nr of button pressed or -1 = dialog cancelled
0 means first button pressed, 1=second ..
Example without entry:
char *buttons[]={"YES","NO","Cancel",NULL}, s1[256];
irc = GUI_DialogEntry ("Save model -", NULL, 0, buttons, 2);
// YES returns 0, NO returns 1, Cancel returns 2; X returns UI_FuncKill.
Example with entry:
strcpy (s1, "myName");
irc = GUI_DialogEntry ("GUI_DialogEntry", s1, 250, buttons, 2);
void GUI_DialogYN ( char *  text,
void *  funcnam 
)
GUI_DialogYN dialogWindow with text, OK-Button and Cancel-Button.
<funcnam> is called with int-value UI_FuncOK or UI_FuncCancel.
Input:
text multiple lines with \n
funcnam callbackfunktion for button-press
funcnam prototyp:
int funcnam (MemObj *parent, void **data);
GUI_DATA_EVENT =*(int*)data[0]=UI_FuncOK|UI_FuncCancel
Example:
GUI_DialogYN ("OK to save file xy", f_CB_save);
//=====================================================================
int f_CB_save (MemObj *mo, void **data) {
//=====================================================================
int idat;
idat = GUI_DATA_EVENT;
printf("f_CB_save %d\n",idat);
switch(idat) {
case UI_FuncOK:
// save ...
break;
case UI_FuncCancel:
// skip saving ...
break;
}
return 0;
}
int GUI_MsgBox ( char *  text)
display text, OK-Button.
Works also if GTK is not yet up.
int GUI_Color_select ( int *  ir,
int *  ig,
int *  ib 
)
GUI_Color_select select-color-Dialog. Modal (wait).
Returns 3 colors as 16-bit-integers.
Returncode 0=OK; -1=cancel.
double GUI_Slider_get ( MemObj *  mo)

query slider-value

void GUI_Slider_set ( MemObj *  mo,
double  newVal 
)

change slider-value

int GUI_Slider_cb2 ( void *  parent,
void *  ev,
void *  data 
)

GUI_Slider_cb2 INTERNAL slider callback

MemObj GUI_Slider__ ( MemObj *  o_par,
int  typ,
void *  funcnam,
double  valMin,
double  valMax,
double  valStart,
char *  opts 
)
GUI_Slider__ Slider = AdjustmentControl
Input:
parent parentBox
typ 0=horizontal, 1=vertical.
funcnam callBack-function for moving the slider; NULL = no callback.
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_EventMove
TYP_EventPress (left mousebutton)
TYP_EventRelease
GUI_DATA_D1 = *(double*)data[1] = slider-value (only TYP_EventMove)
GUI_OBJ_TYP(mo) = TYP_GUI_Slider
Example without callback:
wsl1 = GUI_Slider__ (&box1, 0, NULL, 0., 1., 0.5, "8");
// query slider-value
printf(" sliVal=%f\n",GUI_Slider_get(&wsl1));
// change slider-value
GUI_Slider_set (&wsl1, 0.75);
Example with callback:
wsl1 = GUI_Slider__ (&box1, 0, sl_CB, 0., 1., 0.5, "8");
int sl_CB (MemObj *mo, void **data) {
printf("sl_CB %lf\n",GUI_DATA_D1); // slider-value as double
}
int GUI_Slider_cb1 ( void *  parent,
MemObj  mo 
)

GUI_Slider_cb INTERNAL slider callback

Variable Documentation

int UI_fontsizX
int UI_fontsizY
GtkWidget* UI_MainWin
GtkWidget* UI_act_wi
GtkWidget* UI_DialogYNWin =NULL
static
void(* UI_DialogYNFunc)()
static
MemObj UI_DialogEntryWin
static