gCAD3D 2.35
gui_gtk3/gtk_lists.c File Reference

lists with 1 or 2 columns More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include "../ut/ut_cast.h"
#include "../ut/ut_umem.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_lists.h"
#include "../gui_gtk3/gtk_dlg_files.h"

Data Structures

struct  CSV_struct
 

Functions

int GUI_list2_modCol (MemObj *mo, int iCol, char *txt)
 
int GUI_list1_dlg_w (char *sels, int sSiz, void *parWin, char *winTit, char *fNam, char *mode, char *titLst[], char *opts)
 
int GUI_list1_dlg_exit (void *parent, void *data)
 
void GUI_list1_dlg_del ()
 
int GUI_list1_dlg__ (MemObj *o_par, char *winTit, char *fNam, char *mode, char *titLst[], void *funcnam, char *opts)
 
MemObj GUI_list1__ (MemObj *o_par, char *fNam, char *mode, char *titLst[], void *funcnam, char *opts)
 
MemObj GUI_list2__ (MemObj *o_par, char *fNam, char *mode, char *titLst[], void *funcnam, char *opts)
 
int GUI_list1_add_f (MemObj *mo, char *fNam, char *mode)
 
int GUI_list2_add_f (MemObj *mo, char *fNam, char *mode)
 
int GUI_list1_add_l (MemObj *mo, char *c1, char *c2, char *c3)
 
int GUI_list1_clear (MemObj *mo)
 
int GUI_list1_f (void *list_store, char *fnam, char *mode)
 
int GUI_list2_f (void *list_store, char *fnam, char *mode)
 
int GUI_list1_cbKey (void *parent, void *event, MemObj mo)
 
int GUI_list1_cbMouse (void *parent, void *ev, MemObj mo)
 
int GUI_list1_cbSel (void *selection, MemObj mo)
 
int GUI_list1_dlg_cbw (Obj_gui2 *go, void **data)
 
int GUI_list1_h2_cb1 (void *selection, void *data)
 
int GUI_list1_h2_cb3 (void *parent, void *data)
 
int GUI_list1_h2__ (char *titP, char *titC, char *lButP, char *txtP, char *fnamP, void *funcP, void *funcC, char *opts)
 

Variables

static GtkWidget * UI_list1_win =NULL
 
static void * UI_List_p1
 
static void * UI_List_p2
 
static void * UI_List_p3
 
static void * UI_List_p4
 
static void * UI_List_p5
 
static GtkListStore * UI_ListStore
 
static int GUI_list1_msbt
 
static int GUI_list1_evt
 
static int GUI_list1_stat
 
static char GUI_list1_s1 [256]
 
static char GUI_list1_s2 [256]
 
static char GUI_list1_s3 [256]
 
static char GUI_list1_s4 [256]
 
int UI_fontsizX
 
int UI_fontsizY
 
GtkWidget * UI_act_wi
 
GtkWidget * UI_MainWin
 

Detailed Description

lists with 1 or 2 columns

=====================================================
List_functions_start:
GUI_list1__ List from file, callback. 1 or 2 columns.
GUI_list1_clear also for GUI_list2__
GUI_list1_add_f add lines from file to list
GUI_list1_add_l add line to list (1,2 or 3 columns). Also for GUI_list2.
GUI_list2__ list from file; 2 or 3 columns(val.s with blanks); callback.
GUI_list2_add_f add lines from file to list
GUI_list2_modCol modify column # <iCol> of active (selected) Line
GUI_list1_dlg__ List from file in new window, callback.
GUI_list1_dlg_del delete list-window GUI_list1_dlg
GUI_list1_dlg_w list from file in a new window, waiting.
GUI_list1_h2__ make hierarchical SelectList.
GUI_list1_f INTERNAL populate list
GUI_list2_f INTERNAL populate list
GUI_list1_cbSel INTERNAL callback list selection
GUI_list1_dlg_cbw INTERNAL callback from GUI_list1_dlg_w
GUI_list1_dlg_exit INTERNAL list-window exiting
List_functions_end:
=====================================================

Function Documentation

int GUI_list2_modCol ( MemObj mo,
int  iCol,
char *  txt 
)
modify column # <iCol> of active (selected) Line
Input:
iCol ColNr; 0=first !
txt ColText
int GUI_list1_dlg_w ( char *  sels,
int  sSiz,
void *  parWin,
char *  winTit,
char *  fNam,
char *  mode,
char *  titLst[],
char *  opts 
)
GUI_list1_dlg_w list from file in a new window, waiting.
Inputs:
sSiz size of sels in characters
parWin, parent-window; NULL for primary window
winTit window-title
fNam filename of list to display; mode=nr of words per line
mode "1" selection returns 1 word;
"2" selection returns 2 words;
titLst 1 or 2 headertitles; NULL = 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:
sels selected string, 1 or 2 words, separated by \n
RetCod: 0 OK, data valid
-1 cancelled by user
TODO:
add option filter to GUI_List
int GUI_list1_dlg_exit ( void *  parent,
void *  data 
)
INTERNAL
list-window exiting; report to user ..
void GUI_list1_dlg_del ( )

GUI_list1_dlg_del delete list-window GUI_list1_dlg

int GUI_list1_dlg__ ( MemObj o_par,
char *  winTit,
char *  fNam,
char *  mode,
char *  titLst[],
void *  funcnam,
char *  opts 
)
GUI_list1_dlg__ list from file in a new window, modal, callback.
Inputs:
o_par parent-window; NULL for primary window
winTit window-title
fNam filename of list to display; mode=nr of words per line
mode "1" selection returns 1 word;
"2" selection returns 2 words;
titLst 1 or 2 headertitles; NULL = none
funcnam callback-function of selection
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 prototype:
int funcnam (MemObj *mo, void **data);
// data=table of 5 pointers;
0=TYP_EventPress|TYP_EventExit GUI_DATA_EVENT
1=mousButtonNr(1|2|3) GUI_DATA_I1
2=colNr(1|2) GUI_DATA_I2
3=sel.Text col.1; GUI_DATA_S3
4=sel.Text col.2 (only if colNr=2) GUI_DATA_S4
TYP_EventExit is returned from cancel list; no further data.
Example see GUI_list1__
MemObj GUI_list1__ ( MemObj o_par,
char *  fNam,
char *  mode,
char *  titLst[],
void *  funcnam,
char *  opts 
)
list from file; 1 or 2 columns; callback.
Values may not have blanks.
File with 2 columns: value1 - a single blank - value2
Input:
o_par parentBox
fNam filename of list to display; mode=nr of words per line
mode "1" selection returns 1 word;
"2" selection returns 2 words;
titLst 1 or 2 headertitles; NULL = none
funcnam callback - returns the selected line (as list of words)
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.
funcnam prototype:
int funcnam (void *parent, void **data);
// data=table of 5 pointers;
0=TYP_EventPress|TYP_EventEnter GUI_DATA_EVENT
1=mouseButtonNr or keyCode GUI_DATA_I1
2=colNr(1|2) GUI_DATA_I2
3=sel.Text col.1 GUI_DATA_S3
4=sel.Text col.2 (only if colNr=2) GUI_DATA_S4
Cursorkeys (up,down), page-keys (up,down) provide a usercall of type
TYP_EventEnter; GUI_DATA_I1 gives the keyCode (eg GUI_KeyCurUp)
MousButtonClicks provide a usercall of type TYP_EventPress;
GUI_DATA_I1 gives the mouseButtonNr (GUI_MouseL|GUI_MouseM|GUI_MouseR)
DoubleClick provides 3 userCalls of type TYP_EventPress; first and second
with GUI_MouseL, the third call with GUI_Mouse2L.
The Enter-key provides a usercall of type TYP_EventPress;
GUI_DATA_I1 = GUI_Mouse2L
Example:
GUI_list1__ (Box, "list2.dat", "2", NULL, cb_list_sel, "60,10");
printf(" mouseButtNr=%d selColNr=%d\n",GUI_DATA_I1,GUI_DATA_I2);
printf(" txt sel |%s|%s|\n",GUI_DATA_S3,GUI_DATA_S4);
}
Example with titles:
char *tiTab[] = {"ID","Value"};
GUI_list1__ (Box, "list2.dat", "2", tiTab, cbl, "");
MemObj GUI_list2__ ( MemObj o_par,
char *  fNam,
char *  mode,
char *  titLst[],
void *  funcnam,
char *  opts 
)
list from file; 2 or 3 columns; callback.
Values may have blanks ..
Fileformat: csv ..
Input:
o_par parentBox
fNam filename of list to display; mode=nr of vals; NULL = none.
mode "2" selection returns 2 words;
"3" selection returns 3 words;
titLst 2 or 3 headertitles or NULL = no headers
funcnam callback - returns the selected line (as list of words)
opts options; (HorSiz,VertSiz)
HorSiz,VertSiz: size in characters; default is automatic size.
negative values: size in pixels.
'e' = expand widget; default is fixed size.
Examples: "" or "10" or "10e,e"
"10e,e" horiz. size 10 chars, hor. and vert. expandable.
funcnam prototype:
int funcnam (void *parent, void **data);
// data=table of 5 pointers;
0=TYP_EventPress|TYP_EventEnter GUI_DATA_EVENT
1=mouseButtonNr or keyCode GUI_DATA_I1
2=colNr(1|2) GUI_DATA_I2
3=sel.Text col.1 GUI_DATA_S3
4=sel.Text col.2 (only if colNr=2) GUI_DATA_S4
5=sel.Text col.2 (only if colNr=3) GUI_DATA_S5
Cursorkeys (up,down), page-keys (up,down) provide a usercall of type
TYP_EventEnter; GUI_DATA_I1 gives the keyCode (eg GUI_KeyCurUp)
MousButtonClicks or the Enter-key provide a usercall of type TYP_EventPress;
GUI_DATA_I1 gives the mouseButtonNr (1|2|3) or DoubleClick (4) or
ReturnKey (13).
DoubleClick provides 3 userCalls of type TYP_EventPress; first and second
with mouseButton 1, the third call with mouseButton=4.
Example:
GUI_list2__ (Box, "list3.csv", "3", NULL, cb_list_sel, "60,10");
..
int cb_list_sel (MemObj *mo, void **data) {
printf(" mouseButtNr=%d selColNr=%d\n",GUI_DATA_I1,GUI_DATA_I2);
printf(" txt sel |%s|%s|%s|\n",GUI_DATA_S3,GUI_DATA_S4,GUI_DATA_S5);
}
Example with titles:
char *tiTab[] = {"ID","Value","Info"};
GUI_list2__ (Box, "list2.dat", "3", tiTab, cbl, "60,10");
int GUI_list1_add_f ( MemObj mo,
char *  fNam,
char *  mode 
)
add lines from file to list
fNam filename of list to display; mode=nr of words per line
mode "1" selection returns 1 word;
"2" selection returns 2 words;
int GUI_list2_add_f ( MemObj mo,
char *  fNam,
char *  mode 
)
add lines from file to list
fNam filename of list to display; mode=nr of words per line
mode "1" selection returns 1 word;
"2" selection returns 2 words;
int GUI_list1_add_l ( MemObj mo,
char *  c1,
char *  c2,
char *  c3 
)
add line to list (1,2 or 3 columns)
Also for GUI_list2.
int GUI_list1_clear ( MemObj mo)
int GUI_list1_f ( void *  list_store,
char *  fnam,
char *  mode 
)
GUI_list1_f INTERNAL populate list
1 or 2 columns from file (sep = blank)
int GUI_list2_f ( void *  list_store,
char *  fnam,
char *  mode 
)

GUI_list2_f INTERNAL populate list 2 or 3 columns from csv-file

int GUI_list1_cbKey ( void *  parent,
void *  event,
MemObj  mo 
)
INTERNAL
int GUI_list1_cbMouse ( void *  parent,
void *  ev,
MemObj  mo 
)
INTERNAL
int GUI_list1_cbSel ( void *  selection,
MemObj  mo 
)
GUI_list1_cbSel INTERNAL callback list selection (list1 & list2)
sig changed: from mouse-select, key-blank, key-PageDwn !
isel always 0
calls user with 0=TYP_EventPress|TYP_EventEnter GUI_DATA_EVENT
1=mousButtonNr(1|2|3)Return(13) GUI_DATA_I1
2=columnNr(1|2|3) GUI_DATA_I2
3=sel.Text column.1; GUI_DATA_S3
4=sel.Text col.2 (only if colNr=2) GUI_DATA_S4
5=sel.Text col.3 (only if colNr=3) GUI_DATA_S5
int GUI_list1_dlg_cbw ( Obj_gui2 go,
void **  data 
)
INTERNAL
int GUI_list1_h2_cb1 ( void *  selection,
void *  data 
)
GUI_list1_cbSel INTERNAL callback list selection
sig changed: from mouse-select, key-blank, key-PageDwn !
isel always 0
calls user with 0=TYP_EventPress; GUI_DATA_EVENT
2=mousButtonNr(1|2|3) GUI_DATA_I1
3=colNr(1|2) GUI_DATA_I2
4=sel.Text col.1;a GUI_DATA_S3
5=sel.Text col.2 (only if colNr=2) GUI_DATA_S4
int GUI_list1_h2_cb3 ( void *  parent,
void *  data 
)

INTERNAL; parent-button pressed; display parentList fnamP

int GUI_list1_h2__ ( char *  titP,
char *  titC,
char *  lButP,
char *  txtP,
char *  fnamP,
void *  funcP,
void *  funcC,
char *  opts 
)
make hierarchical SelectList. Select childObject or
select "Parents" with "<<--" -Button.
selecting parents-button changes childList -> parentList
selecting parentObject gets new childList by calling funcP
selecting childObject exits (provides parentText and childText by funcC)
the name of file with childs is the 1. parameter of funcP
Input:
titP titletext for selection of parent
titC titletext for selection of child
lButP caption parents-button
txtP active parent
fnamP Name of file with parents
funcP user has selected a parent; create childlist from selected parent.
funcC user has selected a child; exit and report selection -> user.
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:
RetCod:
1 - destroy HList;
0 - keep HList.
-2 file fnamP does not exist
funcP (char *fnamC, char *parentTxt) {}
funcC (char *parentTxt, char *childtxt) {}

Variable Documentation

GtkWidget* UI_list1_win =NULL
static
void* UI_List_p1
static
void * UI_List_p2
static
void * UI_List_p3
static
void * UI_List_p4
static
void * UI_List_p5
static
GtkListStore* UI_ListStore
static
int GUI_list1_msbt
static
int GUI_list1_evt
static
int GUI_list1_stat
static
char GUI_list1_s1[256]
static
char GUI_list1_s2[256]
static
char GUI_list1_s3[256]
static
char GUI_list1_s4[256]
static
int UI_fontsizX
int UI_fontsizY
GtkWidget* UI_act_wi
GtkWidget* UI_MainWin