zfuncs and zfuncstest

This is a package of various utility programs that were used in building the other applications on this web site. Technical documentation (APIs) is included. A menu-driven test program (zfuncstest) for most of the functions is included. The makefile builds zfuncstest. 

Highlights

MatchWild       compare strings with multiple wildcards (* and ?)
SearchWild      search for files matching pathname with wildcards anywhere
convDS          convert double to string with most compact format
bsearch         binary search function
HeapSort        heapsort with callback to compare recs, allowing weird sorts
spline1/2 cubic spline curve-fitting functions
GTK menus       build GTK menus and toolbars with simple functions
wprintf         printf() interface to scrolling windows, variable font
zdialog         build basic GTK dialogs with simple functions
pixbuf_rotate   rotate a GDK pixbuf through any angle
HashTab         hash table C++ class (fast string store and search)
Queue           queue C++ class (push, pop newest, pop oldest) (thread safe)
Tree            sparse array C++ class, put/get data by string or number index


Tarball with source code, make file, user guide: downloads

Example dialog box created with zdialog

C-code to create this dialog and receive user inputs:

// create dialog box with buttons
zdialog *zd = zdialog_new("zdialog test","OK","cancel","error","done",NULL);

// add widgets to dialog
zdialog_add_widget(zd,"hbox","hb1","dialog",0,"space=5");      //  container box
zdialog_add_widget(zd,"label","label1","hb1","label 1");       //  label
zdialog_add_widget(zd,"entry","entry1","hb1","init data 1");   //  text entry
zdialog_add_widget(zd,"hbox","hb2","dialog",0,"space=5");
zdialog_add_widget(zd,"label","label21","hb2","label 21");
zdialog_add_widget(zd,"entry","entry21","hb2","init data 21","expand");
zdialog_add_widget(zd,"label","label22","hb2","label 22");
zdialog_add_widget(zd,"entry","entry22","hb2","init data 22");
zdialog_add_widget(zd,"hbox","hb3","dialog",0,"space=5");
zdialog_add_widget(zd,"label","label3","hb3","label 3");
zdialog_add_widget(zd,"radio","rb1","hb3","RB 1");
zdialog_add_widget(zd,"radio","rb2","hb3","RB 2");
zdialog_add_widget(zd,"radio","rb3","hb3","RB3");
zdialog_add_widget(zd,"hbox","hb4","dialog",0,"space=5");
zdialog_add_widget(zd,"label","label4","hb4","label 4","space=10");
zdialog_add_widget(zd,"check","ck1","hb4","check 1","space=5");
zdialog_add_widget(zd,"check","ck2","hb4","check 2","space=5");
zdialog_add_widget(zd,"hbox","hb5","dialog",0,"space=5");
zdialog_add_widget(zd,"button","butt1","hb5","button 1");
zdialog_add_widget(zd,"togbutt","tog1","hb5","toggle button");
zdialog_add_widget(zd,"spin","spin1","hb5","10,20,1,15");
zdialog_add_widget(zd,"hbox","hb6","dialog");
zdialog_add_widget(zd,"combo","combo1","hb6","1st entry");
zdialog_add_widget(zd,"hscale","hs1","hb6","0,100,1,50","expand");
zdialog_add_widget(zd,"frame","fr1","dialog",0,"expand");
zdialog_add_widget(zd,"edit","text1","fr1","initial data");

// add entries to combo box dropdown list
zdialog_cb_app(zd,"combo1","2nd entry");
zdialog_cb_app(zd,"combo1","3rd entry");
zdialog_cb_app(zd,"combo1","4th entry");
zdialog_cb_app(zd,"combo1","5th entry");
//  run the dialog with event and completion functions
zdialog_run(zd, zcallback_event, zcallback_compl);
...

// respond to dialog events - get user data from widgets
int zcallback_event(zdialog *zd, const char * wname)
{
    char wdata[200];
    zdialog_fetch(zd,wname,wdata,200);
    printf("widget: %s data: %s \n",wname,wdata);
    return 0;
}

// respond to dialog completion buttons - print which button was used
int zcallback_compl(zdialog *zd, int zstat)
{
    printf("dialog status: %d \n",zstat);
    zdialog_free(zd);
    return 0;
}