gCAD3D 2.35
gui_gtk3/gtk_dlg_std.c File Reference

standard-dialogs, msgbox, slider, color-selection, license-info More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>
#include "../ut/ut_cast.h"
#include "../ut/ut_umem.h"
#include "../ut/ut_mem.h"
#include "../ut/ut_os.h"
#include "../gui/gui_types.h"
#include "../gui/gui_base.h"
#include "../gui_gtk3/gtk_base.h"
#include "../gui_gtk3/gtk_entry.h"
#include "../gui_gtk3/gtk_label.h"
#include "../gui_gtk3/gtk_button.h"
#include "../gui_gtk3/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_MsgBox1 (char *text, void *win)
 
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)
 
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)
 
int GUI_Slider_cb2 (void *parent, void *ev, void *data)
 
int GUI_AboutInfo (char *progInfo, char *auxInfo, char *url, char *img)
 
int GUI_Dialog_run (char *dnam, int dnSiz, char *fnam, int fnSiz, GtkWidget *gtkDlg)
 

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

standard-dialogs, msgbox, slider, color-selection, license-info

=====================================================
List_functions_start:
GUI_MsgBox display text, OK-Button, also if GTK is not yet up
GUI_MsgBox1 display text, OK-Button, modal over window
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_AboutInfo license-info
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
GUI_Dialog_run INTERNAL for gtk_dialog_run
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);
Example:
GUI_DialogYN ("OK to save file xy", f_CB_save);
//=====================================================================
int f_CB_save (MemObj *mo, void **data) {
//=====================================================================
int idat;
printf("f_CB_save %d\n",idat);
switch(idat) {
case UI_FuncOK:
// save ...
break;
// skip saving ...
break;
}
return 0;
}
int GUI_MsgBox1 ( char *  text,
void *  win 
)
GUI_MsgBox1 display text, OK-Button, modal over window
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

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 or
TYP_EventPress (left mousebutton)
GUI_DATA_D1 = *(double*)data[1] = slider-value (only TYP_EventMove)
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) {
if(GUI_DATA_EVENT == TYP_EventMove) {
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

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

GUI_Slider_cb2 INTERNAL slider callback

int GUI_AboutInfo ( char *  progInfo,
char *  auxInfo,
char *  url,
char *  img 
)
GUI_AboutInfo display license-info, hompage-url, ..
Input:
progInfo program name & version
auxInfo comments
url homepage-url
img filename of log in icon-drectory
int GUI_Dialog_run ( char *  dnam,
int  dnSiz,
char *  fnam,
int  fnSiz,
GtkWidget *  gtkDlg 
)

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