zfuncs.h (fotoxx-23.0) | : | zfuncs.h (fotoxx-23.1) | ||
---|---|---|---|---|
skipping to change at line 51 | skipping to change at line 51 | |||
#include <locale.h> | #include <locale.h> | |||
#include <glob.h> | #include <glob.h> | |||
#include <gtk/gtk.h> | #include <gtk/gtk.h> | |||
#include <clutter-gtk/clutter-gtk.h> | #include <clutter-gtk/clutter-gtk.h> | |||
#define VERTICAL GTK_ORIENTATION_VERTICAL // GTK shortcuts | #define VERTICAL GTK_ORIENTATION_VERTICAL // GTK shortcuts | |||
#define HORIZONTAL GTK_ORIENTATION_HORIZONTAL | #define HORIZONTAL GTK_ORIENTATION_HORIZONTAL | |||
#define PIXBUF GdkPixbuf | #define PIXBUF GdkPixbuf | |||
#define GDKCOLOR GdkColorspace | #define GDKCOLOR GdkColorspace | |||
#define int8 char | #define int8 ch | |||
// number types | // number types | |||
#define int16 short | #define int16 short | |||
#define int32 int | #define int32 int | |||
#define int64 long long | #define int64 long long | |||
// long long is always 64 bits | // long long is always 64 bits | |||
#define uint8 unsigned char | #define uint8 unsigned char | |||
#define uint16 unsigned short | #define uint16 unsigned short | |||
#define uint32 unsigned int | #define uint32 unsigned int | |||
#define uint64 unsigned long long | #define uint64 unsigned long long | |||
#define uchar unsigned char | ||||
#define cchar const char | #define ch char | |||
#define uch unsigned char | ||||
#define cch const char | ||||
#define VOL volatile | #define VOL volatile | |||
#define STATB struct stat // stat() file status buffer | #define STATB struct stat // stat() file status buffer | |||
#define mutex_t pthread_mutex_t // abbreviations | #define mutex_t pthread_mutex_t // abbreviations | |||
#define mutex_init pthread_mutex_init | #define mutex_init pthread_mutex_init | |||
#define mutex_lock pthread_mutex_lock | #define mutex_lock pthread_mutex_lock | |||
#define mutex_trylock pthread_mutex_trylock | #define mutex_trylock pthread_mutex_trylock | |||
#define mutex_unlock pthread_mutex_unlock | #define mutex_unlock pthread_mutex_unlock | |||
#define mutex_destroy pthread_mutex_destroy | #define mutex_destroy pthread_mutex_destroy | |||
skipping to change at line 84 | skipping to change at line 87 | |||
#define true 1 | #define true 1 | |||
#define false 0 | #define false 0 | |||
#define NOP | #define NOP | |||
// trace execution: source file, function, line no, caller address | // trace execution: source file, function, line no, caller address | |||
#define TRACE trace(__FILE__,__FUNCTION__,__LINE__,__builtin_return_address(0)); | #define TRACE trace(__FILE__,__FUNCTION__,__LINE__,__builtin_return_address(0)); | |||
// system functions =========================================================== = | // system functions =========================================================== = | |||
void *zmalloc(int64 cc, cchar *tag); // malloc() wrapper | void *zmalloc(int64 cc, ch *tag); // malloc() wrapper | |||
void zfree(void *pp); // free() wrapper | void zfree(void *pp); // free() wrapper | |||
void zmalloc_report(void *zd); // memory usage by tag > popup report | void zmalloc_report(void *zd); // memory usage by tag > popup report | |||
void zmalloc_growth(void *zd); // memory growth by tag > popup report | void zmalloc_growth(void *zd); // memory growth by tag > popup report | |||
int zmalloc_test(int64 cc); // test if cc free memory available | int zmalloc_test(int64 cc); // test if cc free memory available | |||
double realmemory(); // get available real memory in MB units | double realmemory(); // get available real memory in MB units | |||
double availmemory(); // get available memory (+swap) in MB units | double availmemory(); // get available memory (+swap) in MB units | |||
char * zstrdup(cchar *zstring, cchar *tag, int addcc = 0); | ch * zstrdup(ch *zstring, ch *tag, int addcc = 0); | |||
// strdup() wrapper with added space | // strdup() wrapper with added space | |||
int zstrcopy(char *&zstring, cchar *string, cchar *tag, int addcc = 0); | int zstrcopy(ch *&zstring, ch *string, ch *tag, int addcc = 0); | |||
// replace zstring with string + added cc | // replace zstring with string + added cc | |||
void Plog(int lev, cchar *format, ...); | void Plog(int lev, ch *format, ...); | |||
// add message to stdout log file, fflush() | // add message to stdout log file, fflush() | |||
void xmessage(cchar *message); | void xmessage(ch *message); | |||
// popup message not needing GTK | // popup message not needing GTK | |||
void zexit(int popup, cchar *message, ...); | void zexit(int popup, ch *message, ...); | |||
// exit a process and kill child processes | // exit a process and kill child processes | |||
void zbacktrace(); // produce a backtrace to stdout | void zbacktrace(); // produce a backtrace to stdout | |||
void zappcrash(cchar *format, ...); // crash with popup message in text window | void zappcrash(ch *format, ...); // crash with popup message in text window | |||
void catch_signals(); // catch signals and do backtrace dump | void catch_signals(); // catch signals and do backtrace dump | |||
void trace(cchar *file, cchar *func, int line, void *addr); // implements TRACE macro | void trace(ch *file, ch *func, int line, void *addr); // implements TRACE macro | |||
void tracedump(); // dump program trace data | void tracedump(); // dump program trace data | |||
void beroot(int argc, char *argv[]); | void beroot(int argc, ch *argv[]); | |||
// restart program as root if password OK | // restart program as root if password OK | |||
int runroot(cchar *command); | int runroot(ch *command); | |||
// run command as root via su or sudo | // run command as root via su or sudo | |||
double get_seconds(); // seconds since 2000.01.01 | double get_seconds(); // seconds since 2000.01.01 | |||
void logtime_init(cchar *text); | void logtime_init(ch *text); | |||
// set initial time | // set initial time | |||
void logtime(cchar *text); | void logtime(ch *text); | |||
// log elapsed time since prior call | // log elapsed time since prior call | |||
void start_timer(double &time0); // start a timer | void start_timer(double &time0); // start a timer | |||
double get_timer(double &time0); // get elapsed time in seconds | double get_timer(double &time0); // get elapsed time in seconds | |||
void start_CPUtimer(double &time0); // start a process CPU timer | void start_CPUtimer(double &time0); // start a process CPU timer | |||
double get_CPUtimer(double &time0); // get elapsed CPU time, seconds | double get_CPUtimer(double &time0); // get elapsed CPU time, seconds | |||
double CPUtime(); // get elapsed process CPU time for main() | double CPUtime(); // get elapsed process CPU time for main() | |||
double CPUtime2(); | double CPUtime2(); | |||
// " include all threads | // same, include all threads | |||
double jobtime(); | double jobtime(); | |||
// " include all threads + subprocesses | // same, include all threads + subprocesses | |||
void compact_time(const time_t DT, char *compactDT); | void compact_time(time_t DT, ch *compactDT); | |||
// time_t DT to yyyymmddhhmmss | // time_t DT to yyyymmddhhmmss | |||
void pretty_datetime(const time_t DT, char *prettyDT); | void pretty_datetime(time_t DT, ch *prettyDT); | |||
// time_t DT to yyyy-mm-dd hh:mm:ss | // time_t DT to yyyy-mm-dd hh:mm:ss | |||
void secs_datetime(double secs, int datetime[6]); // seconds to year/mon/day/hour/min/secs | void secs_datetime(double secs, int datetime[6]); // seconds to year/mon/day/hour/min/secs | |||
void datetime_secs(int datetime[6], double *secs); // year/mon/day/hour/min/secs to seconds | void datetime_secs(int datetime[6], double *secs); // year/mon/day/hour/min/secs to seconds | |||
int parseprocfile(cchar *pfile, cchar *pname, double *value, ...); | int parseprocfile(ch *pfile, ch *pname, double *value, ...); | |||
// get data from /proc file | // get data from /proc file | |||
int parseprocrec(char *prec, int field, double *value, ...); | int parseprocrec(ch *prec, int field, double *value, ...); | |||
// get data from /proc file record | // get data from /proc file record | |||
int get_smp_counts(int &Nperf, int &Neff); // return processor core counts | int get_smp_counts(int &Nperf, int &Neff); // return processor core counts | |||
int coretemp(); // get CPU temperature (package temp) | int coretemp(); // get CPU temperature (package temp) | |||
int disktemp(char *disk); // get disk temp, e.g. "/dev/sda" | int disktemp(ch *disk); // get disk temp, e.g. "/dev/sda" | |||
void zsleep(double dsecs); // sleep specified seconds | void zsleep(double dsecs); // sleep specified seconds | |||
void zloop(double dsecs); // loop specified seconds | void zloop(double dsecs); // loop specified seconds | |||
void spinlock(int lock); // lock/unlock enclosed code block | void spinlock(int lock); // lock/unlock enclosed code block | |||
int global_lock(cchar *lockfile); | int global_lock(ch *lockfile); | |||
// obtain exclusive lock, multi-process | // obtain exclusive lock, multi-process | |||
void global_unlock(int fd, cchar *lockfile); | void global_unlock(int fd, ch *lockfile); | |||
// release the lock | // release the lock | |||
int resource_lock(int &resource); // simple lock/unlock usable with GTK | int resource_lock(int &resource); // simple lock/unlock usable with GTK | |||
void resource_unlock(int &resource); // (never waits, returns lock status) | void resource_unlock(int &resource); // (never waits, returns lock status) | |||
int zget_locked(int ¶m); // lock and get multi-thread parameter | int zget_locked(int ¶m); // lock and get multi-thread parameter | |||
void zput_locked(int ¶m, int value); // put and unlock multi-thread parameter | void zput_locked(int ¶m, int value); // put and unlock multi-thread parameter | |||
int zadd_locked(int ¶m, int incr); // increment multi-thread parameter | int zadd_locked(int ¶m, int incr); // increment multi-thread parameter | |||
void start_detached_thread(void * tfunc(void *), void * arg); // start detached thread function | pthread_t start_detached_thread(void * tfunc(void *), void * arg); // start detached thread function | |||
pthread_t start_Jthread(void * threadfunc(void *), void * arg); // start joinable thread function | pthread_t start_Jthread(void * threadfunc(void *), void * arg); // start joinable thread function | |||
int wait_Jthread(pthread_t tid); // wait for completion (join thread) | int wait_Jthread(pthread_t tid); // wait for completion (join thread) | |||
void synch_threads(int NT = 0); // synchronize NT threads | void synch_threads(int NT = 0); // synchronize NT threads | |||
int main_thread(); // return 1 if main() thread, else 0 | int main_thread(); // return 1 if main() thread, else 0 | |||
void set_cpu_affinity(int cpu); // set cpu affinity for calling thread | void set_cpu_affinity(int cpu); // set cpu affinity for calling thread | |||
int zshell(cchar *options, cchar *command, ...); | int zshell(ch *options, ch *command, ...); | |||
// do shell command and get status | // do shell command and get status | |||
int zshell_gtk(cchar *options, cchar *command, ...); | int zshell_gtk(ch *options, ch *command, ...); | |||
// same, with parallel gtk mainloop | // same, with parallel gtk mainloop | |||
char * command_output(int &contx, cchar *command, ...); | ch * command_output(int &contx, ch *command, ...); | |||
// get shell command output | // get shell command output | |||
int command_status(int contx); // get exit status of command | int command_status(int contx); // get exit status of command | |||
int signalProc(cchar * pname, cchar * signal); | int signalProc(ch * pname, ch * signal); | |||
// pause/resume/kill subprocess | // pause/resume/kill subprocess | |||
char * fgets_trim(char * buff, int maxcc, FILE *, int bf = 0); | ch * fgets_trim(ch * buff, int maxcc, FILE *, int bf = 0); | |||
// fgets + trim trailing \n \r (blanks) | // fgets + trim trailing \n \r (blanks) | |||
int samefolder(cchar *file1, cchar *file2); | int samefolder(ch *file1, ch *file2); | |||
// returns 1 if files in same folder | // returns 1 if files in same folder | |||
int parsefile(cchar *path, char **dir, char **file, char **ext); | int parsefile(ch *path, ch **dir, ch **file, ch **ext); | |||
// parse a filespec | // parse a filespec | |||
int renamez(cchar *file1, cchar *file2); | int renamez(ch *file1, ch *file2); | |||
// rename, also across file systems | // rename, also across file systems | |||
int check_create_dir(char *path); | int check_create_dir(ch *path); | |||
// check if folder exists, ask to create | // check if folder exists, ask to create | |||
int copyFile(cchar *sfile, cchar *dfile); | int copyFile(ch *sfile, ch *dfile); | |||
// copy file to file or file to folder | // copy file to file or file to folder | |||
int cp_copy(cchar *sfile, cchar *dfile); | int cp_copy(ch *sfile, ch *dfile); | |||
// same, using shell "cp -f -p" | // same, using shell "cp -f -p" | |||
int diskspace(cchar *file); | int diskspace(ch *file); | |||
// get disk space for given file, MB | // get disk space for given file, MB | |||
char * get_file_extension(cchar *file); | ch * get_file_extension(ch *file); | |||
// get correct .ext if file.ext is wrong | // get correct .ext if file.ext is wrong | |||
int zreaddir(cchar *folder, char **&files); | int zreaddir(ch *folder, ch **&files); | |||
// return all files in a folder, sorted | // return all files in a folder, sorted | |||
int zreadfile(cchar *filename, char **&rrecs); | int zreadfile(ch *filename, ch **&rrecs); | |||
// read file, return array of records | // read file, return array of records | |||
int zwritefile(cchar *filename, char **&rrecs); | int zwritefile(ch *filename, ch **&rrecs); | |||
// write array of records to file | // write array of records to file | |||
void zreadfile_free(char **&rrecs); | void zreadfile_free(ch **&rrecs); | |||
// free zreadfile() memory | // free zreadfile() memory | |||
char * combine_argvs(int argc, char *argv[], int Nth); | ch * combine_argvs(int argc, ch *argv[], int Nth); | |||
// combine argv[ii] elements Nth to last | // combine argv[ii] elements Nth to last | |||
char * zescape_quotes(cchar *file); | ch * zescape_quotes(ch *file); | |||
// escape quote marks (") in file name | // escape quote marks (") in file name | |||
// measure CPU time spent in a function or code block within a function | // measure CPU time spent in a function or code block within a function | |||
extern VOL double cpu_profile_timer; // internal data tables | extern VOL double cpu_profile_timer; // internal data tables | |||
extern VOL double cpu_profile_table[100]; | extern VOL double cpu_profile_table[100]; | |||
extern VOL double cpu_profile_elapsed; | extern VOL double cpu_profile_elapsed; | |||
void cpu_profile_init(); // initialize at start of test | void cpu_profile_init(); // initialize at start of test | |||
void cpu_profile_report(); // report CPU time per function | void cpu_profile_report(); // report CPU time per function | |||
inline void cpu_profile_enter(int fnum) // at entry to measured code block | inline void cpu_profile_enter(int fnum) // at entry to measured code block | |||
{ cpu_profile_timer = cpu_profile_elapsed; } | { cpu_profile_timer = cpu_profile_elapsed; } | |||
skipping to change at line 180 | skipping to change at line 183 | |||
int pagefaultrate(); // monitor own process hard fault rate | int pagefaultrate(); // monitor own process hard fault rate | |||
// string macros and functions ================================================ = | // string macros and functions ================================================ = | |||
#define strmatch(str1,str2) (! strcmp((str1),(str2))) // TRUE if strings equal | #define strmatch(str1,str2) (! strcmp((str1),(str2))) // TRUE if strings equal | |||
#define strmatchN(str1,str2,cc) (! strncmp((str1),(str2),(cc))) // TRUE if strings[cc] equal | #define strmatchN(str1,str2,cc) (! strncmp((str1),(str2),(cc))) // TRUE if strings[cc] equal | |||
#define strmatchcase(str1,str2) (! strcasecmp((str1),(str2))) // TRUE if strings equal, ignoring case | #define strmatchcase(str1,str2) (! strcasecmp((str1),(str2))) // TRUE if strings equal, ignoring case | |||
#define strmatchcaseN(str1,str2,cc) (! strncasecmp((str1),(str2),(cc))) // TRUE if strings[cc] equal, ignoring case | #define strmatchcaseN(str1,str2,cc) (! strncasecmp((str1),(str2),(cc))) // TRUE if strings[cc] equal, ignoring case | |||
char * substringR(cchar *string, cchar *delims, int Nth); | ch * substringR(ch *string, ch *delims, int Nth); | |||
// get Nth delimited substring, thread-safe | // get Nth delimited substring, thread-safe | |||
char * substringR(cchar *string, cchar delim, int Nth); | ch * substringR(ch *string, ch delim, int Nth); | |||
// same, single delimiter | // same, single delimiter | |||
char * substring(cchar *string, cchar *delims, int Nth); | ch * substring(ch *string, ch *delims, int Nth); | |||
// same, no zfree() needed, not thread-safe | // same, no zfree() needed, not thread-safe | |||
char * substring(cchar *string, cchar delim, int Nth); | ch * substring(ch *string, ch delim, int Nth); | |||
// same, single delimiter | // same, single delimiter | |||
int strParms(int &bf, cchar *inp, char *pname, int maxcc, double &pval); | int strParms(int &bf, ch *inp, ch *pname, int maxcc, double &pval); | |||
// parse string: name1=val1 | name2 ... | // parse string: name1=val1 | name2 ... | |||
int strHash(cchar *string, uint max); | int strHash(ch *string, uint max); | |||
// string --> random int 0 to max-1 | // string --> random int 0 to max-1 | |||
int strncpy0(char *dest, cchar *source, uint cc); | int strncpy0(ch *dest, ch *source, uint cc); | |||
// strncpy, insure null, return 0 if fit | // strncpy, insure null, return 0 if fit | |||
void strnPad(char *dest, cchar *source, int cc); | void strnPad(ch *dest, ch *source, int cc); | |||
// strncpy with blank padding to cc | // strncpy with blank padding to cc | |||
int strTrim(char *dest, cchar *source); | int strTrim(ch *dest, ch *source); | |||
// remove trailing blanks | // remove trailing blanks | |||
int strTrim(char *string); | int strTrim(ch *string); | |||
// remove trailing blanks | // remove trailing blanks | |||
int strTrim2(char *dest, cchar *source); | int strTrim2(ch *dest, ch *source); | |||
// remove leading and trailing blanks | // remove leading and trailing blanks | |||
int strTrim2(char *string); | int strTrim2(ch *string); | |||
// remove leading and trailing blanks | // remove leading and trailing blanks | |||
int strCompress(char *dest, cchar *source); | int strCompress(ch *dest, ch *source); | |||
// remove all blanks incl. embedded | // remove all blanks incl. embedded | |||
int strCompress(char *string); | int strCompress(ch *string); | |||
// remove all blanks | // remove all blanks | |||
int strncatv(char *dest, int maxcc, cchar *source, ...); | int strncatv(ch *dest, int maxcc, ch *source, ...); | |||
// catenate strings (last = null) | // catenate strings (last = null) | |||
int strmatchV(cchar *string, ...); | int strmatchV(ch *string, ...); | |||
// compare to N strings, return 1-N or 0 | // compare to N strings, return 1-N or 0 | |||
void strToUpper(char *dest, cchar *source); | void strToUpper(ch *dest, ch *source); | |||
// move and conv. string to upper case | // move and conv. string to upper case | |||
void strToUpper(char *string); | void strToUpper(ch *string); | |||
// conv. string to upper case | // conv. string to upper case | |||
void strToLower(char *dest, cchar *source); | void strToLower(ch *dest, ch *source); | |||
// move and conv. string to lower case | // move and conv. string to lower case | |||
void strToLower(char *string); | void strToLower(ch *string); | |||
// conv. string to lower case | // conv. string to lower case | |||
int repl_1str(cchar *strin, char *strout, cchar *ssin, cchar *ssout); | int repl_1str(ch *strin, ch *strout, ch *ssin, ch *ssout); | |||
// copy string and replace 1 substring | // copy string and replace 1 substring | |||
int repl_Nstrs(cchar *strin, char *strout, ...); | int repl_Nstrs(ch *strin, ch *strout, ...); | |||
// copy string and replace N substrings | // copy string and replace N substrings | |||
int breakup_text(cchar *in, char **&out, cchar *delims, int cc1, int cc2); | int breakup_text(ch *in, ch **&out, ch *delims, int cc1, int cc2); | |||
// break long string into substrings | // break long string into substrings | |||
void strncpyx(char *out, cchar *in, int ccin); | void strncpyx(ch *out, ch *in, int ccin); | |||
// conv. string to hex format | // conv. string to hex format | |||
void StripZeros(char *pNum); | void StripZeros(ch *pNum); | |||
// 1.230000E+12 --> 1.23E+12 | // 1.230000E+12 --> 1.23E+12 | |||
int blank_null(cchar *string); | int blank_null(ch *string); | |||
// test for blank/null string | // test for blank/null string | |||
int clean_escapes(char *string); | int clean_escapes(ch *string); | |||
// replace \x escapes with real characters | // replace \x escapes with real characters | |||
int utf8len(cchar *utf8string); | int utf8len(ch *utf8string); | |||
// get graphic cc for UTF8 string | // get graphic cc for UTF8 string | |||
int utf8substring(char *utf8out, cchar *utf8in, int pos, int cc); | int utf8substring(ch *utf8out, ch *utf8in, int pos, int cc); | |||
// get graphic substring from UTF8 string | // get graphic substring from UTF8 string | |||
int utf8_check(cchar *string); | int utf8_check(ch *string); | |||
// check utf8 string for encoding errors | // check utf8 string for encoding errors | |||
int utf8_position(cchar *utf8in, int Nth); | int utf8_position(ch *utf8in, int Nth); | |||
// get byte position of Nth graphic char. | // get byte position of Nth graphic char. | |||
int zsed(cchar *file, ...); | int zsed(ch *file, ...); | |||
// replace string1/3... with string2/4... | // replace string1/3... with string2/4... | |||
cchar * zstrstr(cchar *haystack, cchar *needle); | ch * zstrstr(ch *haystack, ch *needle); | |||
// work like strstr() and strcasestr() | // work like strstr() and strcasestr() | |||
cchar * zstrcasestr(cchar *haystack, cchar *needle); | ch * zstrcasestr(ch *haystack, ch *needle); | |||
// (but "" does NOT match any string) | // (but "" does NOT match any string) | |||
char * zstrcpy(char *dest, const char *source); | ch * zstrcpy(ch *dest, ch *source); | |||
// strcpy with overlap allowed | // strcpy with overlap allowed | |||
char * zstrncpy(char *dest, const char *source, int cc); | ch * zstrncpy(ch *dest, ch *source, int cc); | |||
// strncpy with overlap allowed | // strncpy with overlap allowed | |||
int zstrcmp(const char *s1, const char *s2); | int zstrcmp(ch *s1, ch *s2); | |||
// like strcmp, but \n terminates like null | // like strcmp, but \n terminates like null | |||
int zstrcmp2(ch *s1, ch *s2); | ||||
// strcmp using ch *args, not cch* | ||||
int zstrcasecmp(ch *s1, ch *s2); | ||||
// strcasecmp using ch *args, not cch* | ||||
// number conversion ========================================================== = | // number conversion ========================================================== = | |||
int convSI (cchar *s, int &i, cchar **delm = 0); | int convSI (ch *s, int &i, ch **delm = 0); | |||
// string to int | // string to int | |||
int convSI (cchar *s, int &i, int low, int hi, cchar **delm = 0); | int convSI (ch *s, int &i, int low, int hi, ch **delm = 0); | |||
// (with low/high limit checking) | // (with low/high limit checking) | |||
int convSD (cchar *s, double &d, cchar **delm = 0); | int convSD (ch *s, double &d, ch **delm = 0); | |||
// string to double | // string to double | |||
int convSD (cchar *s, double &d, double low, double hi, cchar **delm = 0); | int convSD (ch *s, double &d, double low, double hi, ch **delm = 0); | |||
// (with low/high limit checking) | // (with low/high limit checking) | |||
int convSF (cchar *s, float &f, cchar **delm = 0); | int convSF (ch *s, float &f, ch **delm = 0); | |||
// string to double | // string to double | |||
int convSF (cchar *s, float &f, float low, float hi, cchar **delm = 0); | int convSF (ch *s, float &f, float low, float hi, ch **delm = 0); | |||
// (with low/high limit checking) | // (with low/high limit checking) | |||
int convIS (int iin, char *outp, int *cc = 0); | int convIS (int iin, ch *outp, int *cc = 0); | |||
// int to string, returned cc | // int to string, returned cc | |||
int convDS (double din, int prec, char *outp, int *cc = 0); | int convDS (double din, int prec, ch *outp, int *cc = 0); | |||
// double to string, precision, output cc | // double to string, precision, output cc | |||
double atofz(cchar *string); | double atofz(ch *string); | |||
// atof() for comma/period decimal points | // atof() for comma/period decimal points | |||
char * formatKBMB(double fnum, int prec); | ch * formatKBMB(double fnum, int prec); | |||
// format nnn B, nn.n KB, n.nn MB, etc. | // format nnn B, nn.n KB, n.nn MB, etc. | |||
// wildcard functions ========================================================= = | // wildcard functions ========================================================= = | |||
int MatchWild(cchar * wildstr, cchar * str); | int MatchWild(ch * wildstr, ch * str); | |||
// wildcard string match (match = 0) | // wildcard string match (match = 0) | |||
int MatchWildCase(cchar * wildstr, cchar * str); | int MatchWildCase(ch * wildstr, ch * str); | |||
// wildcard string match, ignoring case | // wildcard string match, ignoring case | |||
cchar * SearchWild(cchar *wpath, int &flag); | ch * SearchWild(ch *wpath, int &flag); | |||
// wildcard file search | // wildcard file search | |||
cchar * SearchWildCase(cchar *wpath, int &flag); | ch * SearchWildCase(ch *wpath, int &flag); | |||
// wildcard file search, ignoring case | // wildcard file search, ignoring case | |||
int zfind(cchar *pattern, char **&flist, int &NF); | int zfind(ch *pattern, ch **&flist, int &NF); | |||
// wildcard file search using glob() | // wildcard file search using glob() | |||
// search and sort functions ================================================== = | // search and sort functions ================================================== = | |||
int bsearch(int seekint, int nn, int list[]); // binary search sorted list[nn] | int bsearch(int seekint, int nn, int list[]); // binary search sorted list[nn] | |||
int bsearch(cchar *seekrec, cchar *allrecs, int recl, int nrecs); | int bsearch(ch *seekrec, ch *allrecs, int recl, int nrecs); | |||
// binary search sorted records | // binary search sorted records | |||
int bsearch(cchar *seekrec, cchar **allrecs, int N, int nrecs); | int bsearch(ch *seekrec, ch **allrecs, int N, int nrecs); | |||
// binary search sorted pointers to recs | // binary search sorted pointers to recs | |||
typedef int HeapSortUcomp(cchar *rec1, cchar *rec2); // return -1/0/+1 if rec1 </=/> rec2 | typedef int HeapSortUcomp(ch *rec1, ch *rec2); // return -1/0/+1 if rec1 </=/> rec2 | |||
void HeapSort(int vv[], int nn); // Heap Sort - integer | void HeapSort(int vv[], int nn); // Heap Sort - integer | |||
void HeapSort(float vv[], int nn); // Heap Sort - float | void HeapSort(float vv[], int nn); // Heap Sort - float | |||
void HeapSort(double vv[], int nn); // Heap Sort - double | void HeapSort(double vv[], int nn); // Heap Sort - double | |||
void HeapSort(char *vv[], int nn); | void HeapSort(ch *vv[], int nn); | |||
// Heap Sort - char, ascending order | // Heap Sort - char, ascending order | |||
void HeapSort(char *vv1[], char *vv2[], int nn); | void HeapSort(ch *vv1[], ch *vv2[], int nn); | |||
// Heap Sort - parallel char *, ascending | // Heap Sort - parallel char *, ascending | |||
void HeapSort(char *vv[], int nn, HeapSortUcomp); | void HeapSort(ch *vv[], int nn, HeapSortUcomp); | |||
// Heap Sort - char, user-defined order | // Heap Sort - char, user-defined order | |||
void HeapSort4(char *vv[], int nn, HeapSortUcomp); | void HeapSort4(ch *vv[], int nn, HeapSortUcomp); | |||
// Heap Sort - same, use 4 parallel threads | // Heap Sort - same, use 4 parallel threads | |||
void HeapSort(char *recs, int RL, int NR, HeapSortUcomp); | void HeapSort(ch *recs, int RL, int NR, HeapSortUcomp); | |||
// Heap Sort - records, user-defined order | // Heap Sort - records, user-defined order | |||
int MemSort(char * RECS, int RL, int NR, int KEYS[][3], int NK); // memory sort, records with multiple keys | int MemSort(ch * RECS, int RL, int NR, int KEYS[][3], int NK); // memory sort, records with multiple keys | |||
int zmember(int testval, int matchval1, ...); // test if value matches any in a list | int zmember(int testval, int matchval1, ...); // test if value matches any in a list | |||
// hash table class =========================================================== = | // hash table class =========================================================== = | |||
class HashTab | class HashTab | |||
{ | { | |||
static int tries1; // insert tries | static int tries1; // insert tries | |||
static int tries2; // find/delete tries | static int tries2; // find/delete tries | |||
int cap; // table capacity | int cap; // table capacity | |||
int count; // strings contained | int count; // strings contained | |||
int cc; // string length | int cc; // string length | |||
char * table; // table[cc][cap] | ch *table; // table[cc][cap] | |||
public: | public: | |||
HashTab(int cc, int cap); // constructor | HashTab(int cc, int cap); // constructor | |||
~HashTab(); // destructor | ~HashTab(); // destructor | |||
int Add(cchar * string); | int Add(ch * string); | |||
// add a new string | // add a new string | |||
int Del(cchar * string); | int Del(ch * string); | |||
// delete a string | // delete a string | |||
int Find(cchar * string); | int Find(ch * string); | |||
// find a string | // find a string | |||
int GetCount() { return count; }; // get string count | int GetCount() { return count; }; // get string count | |||
int GetNext(int & first, char * string); // get first/next string | int GetNext(int & first, ch * string); // get first/next string | |||
int Dump(); // dump hash table | int Dump(); // dump hash table | |||
}; | }; | |||
// list processing functions ================================================== = | // list processing functions ================================================== = | |||
typedef struct { // list data type | typedef struct { // list data type | |||
int count; // count of member strings | int count; // count of member strings | |||
char **mber; // member strings, null == missing | ch **mber; // member strings, null == missing | |||
} zlist_t; | } zlist_t; | |||
zlist_t * zlist_new(int count); // create zlist with 'count' empty members | zlist_t * zlist_new(int count); // create zlist with 'count' empty members | |||
void zlist_delete(zlist_t *zlist); // delete a zlist | void zlist_delete(zlist_t *zlist); // delete a zlist | |||
void zlist_dump(zlist_t *zlist); // dump zlist to stdout | void zlist_dump(zlist_t *zlist); // dump zlist to stdout | |||
int zlist_count(zlist_t *zlist); // get zlist member count | int zlist_count(zlist_t *zlist); // get zlist member count | |||
char * zlist_get(zlist_t *zlist, int Nth); | ch * zlist_get(zlist_t *zlist, int Nth); | |||
// get a zlist member | // get a zlist member | |||
void zlist_put(zlist_t *zlist, cchar *string, int Nth); | void zlist_put(zlist_t *zlist, ch *string, int Nth); | |||
// put a zlist member (replace existing) | // put a zlist member (replace existing) | |||
void zlist_insert(zlist_t *zlist, cchar *string, int Nth); | void zlist_insert(zlist_t *zlist, ch *string, int Nth); | |||
// insert Nth member, old Nth >> Nth+1 | // insert Nth member, old Nth >> Nth+1 | |||
void zlist_remove(zlist_t *zlist, int Nth); // remove a zlist member (count -= 1) | void zlist_remove(zlist_t *zlist, int Nth); // remove a zlist member (count -= 1) | |||
void zlist_clear(zlist_t *zlist, int Nth); // clear zlist from Nth member to end | void zlist_clear(zlist_t *zlist, int Nth); // clear zlist from Nth member to end | |||
void zlist_purge(zlist_t *zlist); // purge zlist of all null members | void zlist_purge(zlist_t *zlist); // purge zlist of all null members | |||
int zlist_add(zlist_t *zlist, cchar *string, int Funiq); | int zlist_add(zlist_t *zlist, ch *string, int Funiq); | |||
// add new member at first null or append | // add new member at first null or append | |||
int zlist_append(zlist_t *zlist, cchar *string, int Funiq); | int zlist_append(zlist_t *zlist, ch *string, int Funiq); | |||
// append new member at end (if unique) | // append new member at end (if unique) | |||
int zlist_prepend(zlist_t *zlist, cchar *string, int Funiq); | int zlist_prepend(zlist_t *zlist, ch *string, int Funiq); | |||
// prepend new member at posn 0 (if unique) | // prepend new member at posn 0 (if unique) | |||
int zlist_find(zlist_t *zlist, cchar *string, int posn); | int zlist_find(zlist_t *zlist, ch *string, int posn); | |||
// find next match from posn | // find next match from posn | |||
int zlist_findwild(zlist_t *zlist, cchar *wstring, int posn); | int zlist_findwild(zlist_t *zlist, ch *wstring, int posn); | |||
// find next wildcard match from posn | // find next wildcard match from posn | |||
zlist_t * zlist_copy(zlist_t *zlist1); // copy a zlist | zlist_t * zlist_copy(zlist_t *zlist1); // copy a zlist | |||
zlist_t * zlist_insert_zlist(zlist_t *zlist1, zlist_t *zlist2, int Nth); // insert zlist2 into zlist1 at posn Nth | zlist_t * zlist_insert_zlist(zlist_t *zlist1, zlist_t *zlist2, int Nth); // insert zlist2 into zlist1 at posn Nth | |||
zlist_t * zlist_remove(zlist_t *zlist1, zlist_t *zlist2); // remove all members of zlist2 from zlist1 | zlist_t * zlist_remove(zlist_t *zlist1, zlist_t *zlist2); // remove all members of zlist2 from zlist1 | |||
void zlist_sort(zlist_t *zlist); // sort zlist ascending | void zlist_sort(zlist_t *zlist); // sort zlist ascending | |||
void zlist_sort(zlist_t *zlist, int ccfunc(cchar *, cchar *)); | void zlist_sort(zlist_t *zlist, int ccfunc(ch *, ch *)); | |||
// sort zlist via caller compare function | // sort zlist via caller compare function | |||
int zlist_to_file(zlist_t *zlist, cchar *filename); | int zlist_to_file(zlist_t *zlist, ch *filename); | |||
// make file from zlist | // make file from zlist | |||
zlist_t * zlist_from_file(cchar *filename); | zlist_t * zlist_from_file(ch *filename); | |||
// make zlist from file | // make zlist from file | |||
// random number functions ==================================================== = | // random number functions ==================================================== = | |||
int lrandz(int64 * seed); // returns 0 to 0x7fffffff | int lrandz(int64 * seed); // returns 0 to 0x7fffffff | |||
int lrandz(); // built-in seed | int lrandz(); // built-in seed | |||
double drandz(int64 * seed); // returns 0.0 to 0.99999... | double drandz(int64 * seed); // returns 0.0 to 0.99999... | |||
double drandz(); // built-in seed | double drandz(); // built-in seed | |||
// spline curve-fitting functions ============================================= = | // spline curve-fitting functions ============================================= = | |||
void spline1(int nn, float *dx, float *dy); // define a curve using nn data points | void spline1(int nn, float *dx, float *dy); // define a curve using nn data points | |||
float spline2(float x); // return y-value for given x-value | float spline2(float x); // return y-value for given x-value | |||
// FIFO queue for text strings, single or dual-thread access ================== = | // FIFO queue for text strings, single or dual-thread access ================== = | |||
typedef struct { | typedef struct { | |||
int qcap; // queue capacity | int qcap; // queue capacity | |||
int qnewest; // newest entry position, circular | int qnewest; // newest entry position, circular | |||
int qoldest; // oldest entry position, circular | int qoldest; // oldest entry position, circular | |||
int qdone; // flag, last entry added to queue | int qdone; // flag, last entry added to queue | |||
char **qtext; // up to qcap text strings | ch **qtext; // up to qcap text strings | |||
} Qtext; | } Qtext; | |||
void Qtext_open(Qtext *qtext, int cap); // initialize Qtext queue, empty | void Qtext_open(Qtext *qtext, int cap); // initialize Qtext queue, empty | |||
void Qtext_put(Qtext *qtext, cchar *format, ...); | void Qtext_put(Qtext *qtext, ch *format, ...); | |||
// add text string to Qtext queue | // add text string to Qtext queue | |||
char * Qtext_get(Qtext *qtext); | ch * Qtext_get(Qtext *qtext); | |||
// remove text string from Qtext queue | // remove text string from Qtext queue | |||
void Qtext_close(Qtext *qtext); // close Qtext, zfree() leftover strings | void Qtext_close(Qtext *qtext); // close Qtext, zfree() leftover strings | |||
// application initialization and administration ============================== = | // application initialization and administration ============================== = | |||
int appimage_install(cchar *appname); // make appimage desktop and icon files | int appimage_install(ch *appname); // make appimage desktop and icon files | |||
void appimage_unstall(); // uninstall appimage | void appimage_unstall(); // uninstall appimage | |||
int zinitapp(cchar *appvers, int argc, char *argv[]); // initialize app (appname-N.N, custom homedir) | int zinitapp(ch *appvers, int argc, ch *argv[]); // initialize app (appname-N.N, custom homedir) | |||
cchar * get_zprefix(); | ch * get_zprefix(); | |||
// get /usr or /usr/local ... | // get /usr or /usr/local ... | |||
cchar * get_zhomedir(); | ch * get_zhomedir(); | |||
// get /home/user/.appname/ | // get /home/user/.appname/ | |||
cchar * get_zdatadir(); | ch * get_zdatadir(); | |||
// get data folder | // get data folder | |||
cchar * get_zimagedir(); | ch * get_zimagedir(); | |||
// get image folder | // get image folder | |||
cchar * get_zdocdir(); | ch * get_zdocdir(); | |||
// get document folder | // get document folder | |||
void zabout(); // popup app 'about' information | void zabout(); // popup app 'about' information | |||
void zsetfont(cchar *newfont); // set new app font and size | void zsetfont(ch *newfont); // set new app font and size | |||
int widget_font_metrics(GtkWidget *widget, int &fww, int &fhh); // get widget font char width/height | int widget_font_metrics(GtkWidget *widget, int &fww, int &fhh); // get widget font char width/height | |||
int get_zfilespec(cchar *ftype, cchar *fname, char *filespec); // get installation data file | int get_zfilespec(ch *ftype, ch *fname, ch *filespec); // get installation data file | |||
void showz_logfile(GtkWidget *parent); // show log file in popup window | void showz_logfile(GtkWidget *parent); // show log file in popup window | |||
void showz_textfile(cchar *type, cchar *file, GtkWidget *parent); | void showz_textfile(ch *type, ch *file, GtkWidget *parent); | |||
// show text file [.gz] in popup window | // show text file [.gz] in popup window | |||
void showz_html(cchar *url); | void showz_html(ch *url); | |||
// show html via preferred browser | // show html via preferred browser | |||
void showz_docfile(GtkWidget *, cchar *docfile, cchar *topic); | void showz_docfile(GtkWidget *, ch *docfile, ch *topic); | |||
// show docfile topic and assoc. image | // show docfile topic and assoc. image | |||
/******************************************************************************* * | /******************************************************************************* * | |||
GTK utility functions | GTK utility functions | |||
******************************************************************************** */ | ******************************************************************************** */ | |||
void zmainloop(int skip = 0); // do main loop, process menu events | void zmainloop(int skip = 0); // do main loop, process menu events | |||
void zmainsleep(float secs); // do main loop and sleep designated time | void zmainsleep(float secs); // do main loop and sleep designated time | |||
/******************************************************************************* */ | /******************************************************************************* */ | |||
skipping to change at line 397 | skipping to change at line 402 | |||
g_signal_connect(G_OBJECT(widget),event,G_CALLBACK(func),(void *) arg) | g_signal_connect(G_OBJECT(widget),event,G_CALLBACK(func),(void *) arg) | |||
/******************************************************************************* */ | /******************************************************************************* */ | |||
// textwidget functions - scrollable text widget for text reports and line edit ing | // textwidget functions - scrollable text widget for text reports and line edit ing | |||
// widget = zdialog_gtkwidget(zd,textwidget) where textwidget is a zdialog "tex t" widget type | // widget = zdialog_gtkwidget(zd,textwidget) where textwidget is a zdialog "tex t" widget type | |||
void textwidget_clear(GtkWidget *widget); // clear all text | void textwidget_clear(GtkWidget *widget); // clear all text | |||
void textwidget_clear(GtkWidget *widget, int line); // clear text from line to end | void textwidget_clear(GtkWidget *widget, int line); // clear text from line to end | |||
int textwidget_linecount(GtkWidget *widget); // get current line count | int textwidget_linecount(GtkWidget *widget); // get current line count | |||
void textwidget_append(GtkWidget *widget, int bold, cchar *format, ...); | void textwidget_append(GtkWidget *widget, int bold, ch *format, ...); | |||
// append line | // append line | |||
void textwidget_append2(GtkWidget *widget, int bold, cchar *format, ...); | void textwidget_append2(GtkWidget *widget, int bold, ch *format, ...); | |||
// append line and scroll to end | // append line and scroll to end | |||
void textwidget_insert(GtkWidget *widget, int bold, int line, cchar *format, ... | void textwidget_insert(GtkWidget *widget, int bold, int line, ch *format, ...); | |||
); // insert line | // insert line | |||
void textwidget_replace(GtkWidget *widget, int bold, int line, cchar *format, .. | void textwidget_replace(GtkWidget *widget, int bold, int line, ch *format, ...); | |||
.); // replace line | // replace line | |||
void textwidget_delete(GtkWidget *widget, int line); // delete line | void textwidget_delete(GtkWidget *widget, int line); // delete line | |||
int textwidget_find(GtkWidget *widget, char *matchtext, int line1); // find matching line | int textwidget_find(GtkWidget *widget, ch *matchtext, int line1); // find matching line | |||
void textwidget_insert_pixbuf(GtkWidget *textwidget, int line, GdkPixbuf *pixbuf ); // insert pixbuf image | void textwidget_insert_pixbuf(GtkWidget *textwidget, int line, GdkPixbuf *pixbuf ); // insert pixbuf image | |||
void textwidget_scroll(GtkWidget *widget, int line); // scroll line on screen | void textwidget_scroll(GtkWidget *widget, int line); // scroll line on screen | |||
void textwidget_scroll_top(GtkWidget *widget, int line); // scroll line to top of window | void textwidget_scroll_top(GtkWidget *widget, int line); // scroll line to top of window | |||
void textwidget_get_visible_lines(GtkWidget *textwidget, int &top, int &bott); // get range of visible lines | void textwidget_get_visible_lines(GtkWidget *textwidget, int &top, int &bott); // get range of visible lines | |||
void textwidget_dump(GtkWidget *widget, cchar *filename); // dump all text into a file | void textwidget_dump(GtkWidget *widget, ch *filename); // dump all text into a file | |||
void textwidget_save(GtkWidget *widget, GtkWindow *parent); // same, with save-as dialog | void textwidget_save(GtkWidget *widget, GtkWindow *parent); // same, with save-as dialog | |||
char * textwidget_line(GtkWidget *widget, int line, int strip); // retrieve line (strip \n) | ch * textwidget_line(GtkWidget *widget, int line, int strip); // retrieve line (strip \n) | |||
void textwidget_highlight_line(GtkWidget *widget, int line); // highlight line | void textwidget_highlight_line(GtkWidget *widget, int line); // highlight line | |||
char * textwidget_word(GtkWidget *, int line, int posn, cchar *dlims, char &end) ; // retrieve word | ch * textwidget_word(GtkWidget *, int line, int posn, ch *dlims, ch &end); // retrieve word | |||
void textwidget_highlight_word(GtkWidget *widget, int line, int posn, int cc); // highlight word | void textwidget_highlight_word(GtkWidget *widget, int line, int posn, int cc); // highlight word | |||
void textwidget_bold_word(GtkWidget *widget, int line, int posn, int cc); // make word bold | void textwidget_bold_word(GtkWidget *widget, int line, int posn, int cc); // make word bold | |||
void textwidget_underline_word(GtkWidget *widget, int line, int posn, int cc); // make word underlined | void textwidget_underline_word(GtkWidget *widget, int line, int posn, int cc); // make word underlined | |||
void textwidget_font_attributes(GtkWidget *widget); // set font attributes for all text | void textwidget_font_attributes(GtkWidget *widget); // set font attributes for all text | |||
typedef void textwidget_callbackfunc_t(GtkWidget *, int line, int posn, int KBke y); // widget event function to receive | typedef void textwidget_callbackfunc_t(GtkWidget *, int line, int posn, int KBke y); // widget event function to receive | |||
void textwidget_set_eventfunc(GtkWidget *, textwidget_callbackfunc_t func); // mouse click and KB events | void textwidget_set_eventfunc(GtkWidget *, textwidget_callbackfunc_t func); // mouse click and KB events | |||
/******************************************************************************* */ | /******************************************************************************* */ | |||
// functions to simplify building menus, tool bars, status bars | // functions to simplify building menus, tool bars, status bars | |||
typedef void cbFunc(GtkWidget *, cchar *mname); // menu or button response function | typedef void cbFunc(GtkWidget *, ch *mname); // menu or button response function | |||
GtkWidget * create_menubar(GtkWidget *vbox); // create menubar in packing box | GtkWidget * create_menubar(GtkWidget *vbox); // create menubar in packing box | |||
GtkWidget * add_menubar_item(GtkWidget *mbar, cchar *mname, cbFunc func = 0); | GtkWidget * add_menubar_item(GtkWidget *mbar, ch *mname, cbFunc func = 0); | |||
// add menu item to menubar | // add menu item to menubar | |||
GtkWidget * add_submenu_item(GtkWidget *mitem, cchar *subname, | GtkWidget * add_submenu_item(GtkWidget *mitem, ch *subname, | |||
// add submenu item to menu item | // add submenu item to menu item | |||
cbFunc func = 0, cchar *mtip = 0); | cbFunc func = 0, ch *mtip = 0); | |||
// with opt. function and popup tip | // with opt. function and popup tip | |||
GtkWidget * create_toolbar(GtkWidget *vbox, int iconsize = 24); // toolbar in packing box (no vert gtk3) | GtkWidget * create_toolbar(GtkWidget *vbox, int iconsize = 24); // toolbar in packing box (no vert gtk3) | |||
GtkWidget * add_toolbar_button(GtkWidget *tbar, cchar *lab, cchar *tip, | GtkWidget * add_toolbar_button(GtkWidget *tbar, ch *lab, ch *tip, | |||
// add button with label, tool-tip, icon | // add button with label, tool-tip, icon | |||
cchar *icon, cbFunc func); | ch *icon, cbFunc func); | |||
GtkWidget * create_stbar(GtkWidget *vbox); // create status bar in packing box | GtkWidget * create_stbar(GtkWidget *vbox); // create status bar in packing box | |||
int stbar_message(GtkWidget *stbar, cchar *message); // display message in status bar | int stbar_message(GtkWidget *stbar, ch *message); // display message in status bar | |||
/******************************************************************************* */ | /******************************************************************************* */ | |||
GtkWidget * create_popmenu(); // create an empty popup menu | GtkWidget * create_popmenu(); // create an empty popup menu | |||
GtkWidget * add_popmenu_item(GtkWidget *popmenu, cchar *mname, | GtkWidget * add_popmenu_item(GtkWidget *popmenu, ch *mname, | |||
// add menu item to popup menu | // add menu item to popup menu | |||
cbFunc func, cchar *arg, cchar *mtip = 0); | cbFunc func, ch *arg, ch *mtip = 0); | |||
void popup_menu(GtkWidget *, GtkWidget *popmenu); // pop-up menu at current mouse posn. | void popup_menu(GtkWidget *, GtkWidget *popmenu); // pop-up menu at current mouse posn. | |||
/******************************************************************************* */ | /******************************************************************************* */ | |||
// create vertical menu/toolbar in vertical packing box | // create vertical menu/toolbar in vertical packing box | |||
struct vmenuent { // menu data from caller | struct vmenuent { // menu data from caller | |||
cchar *name; | ch *name; | |||
// menu name, text | // menu name, text | |||
cchar *icon; | ch *icon; | |||
// opt. icon file name | // opt. icon file name | |||
cchar *desc; | ch *desc; | |||
// description (mouse hover popup) | // description (mouse hover popup) | |||
cbFunc *LMfunc; // menu func for left mouse click | cbFunc *LMfunc; // menu func for left mouse click | |||
cbFunc *RMfunc; // menu func for right mouse click | cbFunc *RMfunc; // menu func for right mouse click | |||
cbFunc *setupfunc; // opt. setup func for menu func | cbFunc *setupfunc; // opt. setup func for menu func | |||
cchar *arg; | ch *arg; | |||
// callback arg for menu func | // callback arg for menu func | |||
cchar *setuparg; | ch *setuparg; | |||
// callback arg for setup func | // callback arg for setup func | |||
cchar *RMarg; | ch *RMarg; | |||
// callback arg for RMfunc | // callback arg for RMfunc | |||
PIXBUF *pixbuf; // icon pixbuf or null | PIXBUF *pixbuf; // icon pixbuf or null | |||
PangoLayout *playout1, *playout2; // normal and bold menu text | PangoLayout *playout1, *playout2; // normal and bold menu text | |||
int namex, namey; // menu name position in layout | int namex, namey; // menu name position in layout | |||
int iconx, icony; // menu icon position | int iconx, icony; // menu icon position | |||
int ylo, yhi; // menu height limits | int ylo, yhi; // menu height limits | |||
int iconww, iconhh; // icon width and height | int iconww, iconhh; // icon width and height | |||
}; | }; | |||
struct Vmenu { | struct Vmenu { | |||
GtkWidget *vbox; // parent window (container) | GtkWidget *vbox; // parent window (container) | |||
GtkWidget *topwin; // top-level window of parent | GtkWidget *topwin; // top-level window of parent | |||
GtkWidget *layout; // drawing window | GtkWidget *layout; // drawing window | |||
float fgRGB[3]; // font color, RGB scaled 0-1 | float fgRGB[3]; // font color, RGB scaled 0-1 | |||
float bgRGB[3]; // background color, RGB scaled 0-1 | float bgRGB[3]; // background color, RGB scaled 0-1 | |||
int xmax, ymax; // layout size | int xmax, ymax; // layout size | |||
int mcount; // menu entry count | int mcount; // menu entry count | |||
vmenuent menu[100]; | vmenuent menu[100]; | |||
}; | }; | |||
Vmenu *Vmenu_new(GtkWidget *vbox, float fgRGB[3], float bgRGB[3]); // create new menu in parent vbox | Vmenu *Vmenu_new(GtkWidget *vbox, float fgRGB[3], float bgRGB[3]); // create new menu in parent vbox | |||
void Vmenu_add(Vmenu *vbm, cchar *name, cchar *icon, | void Vmenu_add(Vmenu *vbm, ch *name, ch *icon, | |||
// add menu item with response function | // add menu item with response function | |||
int iconww, int iconhh, cchar *desc, | int iconww, int iconhh, ch *desc, | |||
// function may be popup_menu() | // function may be popup_menu() | |||
cbFunc func, cchar *arg); | cbFunc func, ch *arg); | |||
void Vmenu_add_setup(Vmenu *vbm, int me, cbFunc RMfunc, cchar *arg); | void Vmenu_add_setup(Vmenu *vbm, int me, cbFunc RMfunc, ch *arg); | |||
// add opt. setup function | // add opt. setup function | |||
void Vmenu_add_RMfunc(Vmenu *vbm, int me, cbFunc RMfunc, cchar *arg); | void Vmenu_add_RMfunc(Vmenu *vbm, int me, cbFunc RMfunc, ch *arg); | |||
// add function for right mouse click | // add function for right mouse click | |||
void Vmenu_block(int flag); // block or unblock menu | void Vmenu_block(int flag); // block or unblock menu | |||
/******************************************************************************* */ | /******************************************************************************* */ | |||
// spline curve edit functions | // spline curve edit functions | |||
typedef void spcfunc_t(int spc); // callback function, spline curve edit | typedef void spcfunc_t(int spc); // callback function, spline curve edit | |||
struct spldat { // spline curve data | struct spldat { // spline curve data | |||
GtkWidget *drawarea; // drawing area for spline curves | GtkWidget *drawarea; // drawing area for spline curves | |||
skipping to change at line 531 | skipping to change at line 536 | |||
// entry, edit, text, radio, check, button, togbutt, spin, | // entry, edit, text, radio, check, button, togbutt, spin, | |||
// combo, hscale, vscale, imagebutt, colorbutt, icon, image | // combo, hscale, vscale, imagebutt, colorbutt, icon, image | |||
#define zdmaxwidgets 300 | #define zdmaxwidgets 300 | |||
#define zdmaxbutts 10 | #define zdmaxbutts 10 | |||
#define zdsentinel 0x97530000 | #define zdsentinel 0x97530000 | |||
#define zdialog_max 20 | #define zdialog_max 20 | |||
#define zdialog_button_shortcuts "Done OK Cancel Apply Reset" // buttons that may have KB shortcuts | #define zdialog_button_shortcuts "Done OK Cancel Apply Reset" // buttons that may have KB shortcuts | |||
struct zwidget { | struct zwidget { | |||
cchar *type; // dialog, hbox, vbox, label | ch *type; // dialog, hbox, vbox, label | |||
, entry ... | , entry ... | |||
cchar *wname; // widget name | ch *wname; // widget name | |||
cchar *pname; // parent (container) name | ch *pname; // parent (container) name | |||
char *data; // widget data, initial / re | ch *data; // widget data, initial / re | |||
turned | turned | |||
int size; // text entry cc or image pi xel size | int size; // text entry cc or image pi xel size | |||
int homog; // hbox/vbox: equal spacing flag | int homog; // hbox/vbox: equal spacing flag | |||
int expand; // widget is expandable flag | int expand; // widget is expandable flag | |||
int space; // extra padding space (pixe ls) | int space; // extra padding space (pixe ls) | |||
int wrap; // wrap mode for edit widget | int wrap; // wrap mode for edit widget | |||
int rescale; // widget is rescaled for mo re resolution | int rescale; // widget is rescaled for mo re resolution | |||
double lval, nval, hval; // scale range and neutral v alue | double lval, nval, hval; // scale range and neutral v alue | |||
double lolim, hilim, step; // range and step value for number widget | double lolim, hilim, step; // range and step value for number widget | |||
zlist_t *zlist; // combo box list of text en tries | zlist_t *zlist; // combo box list of text en tries | |||
GtkWidget *widget; // GTK widget pointer | GtkWidget *widget; // GTK widget pointer | |||
}; | }; | |||
struct zdialog { | struct zdialog { | |||
int sentinel1; // validity sentinel1 | int sentinel1; // validity sentinel1 | |||
int uniqueID; // unique ID, monotone incre asing | int uniqueID; // unique ID, monotone incre asing | |||
char *title; // dialog title | ch *title; // dialog title | |||
void *eventCB; // dialog event user callbac k function | void *eventCB; // dialog event user callbac k function | |||
void *popup_report_CB; // callback function for pop up_report | void *popup_report_CB; // callback function for pop up_report | |||
int zrunning; // dialog is running (0,1) | int zrunning; // dialog is running (0,1) | |||
int zstat; // dialog status (from compl etion button) | int zstat; // dialog status (from compl etion button) | |||
char zstat_button[40]; // completion button label | ch zstat_button[40]; // completion button label | |||
int disabled; // widget signals/events are disabled | int disabled; // widget signals/events are disabled | |||
int saveposn; // save and recall window po sition each use | int saveposn; // save and recall window po sition each use | |||
int saveinputs; // save and recall user inpu ts each use | int saveinputs; // save and recall user inpu ts each use | |||
GtkWidget *dialog; // dialog window or null (bo x parent) | GtkWidget *dialog; // dialog window or null (bo x parent) | |||
GtkWidget *parent; // parent window or null | GtkWidget *parent; // parent window or null | |||
cchar *ptype; // null or "window" or "box" | ch *ptype; // null or "window" or "box" | |||
parent | parent | |||
cchar *compbutton[zdmaxbutts]; // dialog completion button | ch *compbutton[zdmaxbutts]; // dialog completion button | |||
labels | labels | |||
GtkWidget *compwidget[zdmaxbutts]; // dialog completion button widgets | GtkWidget *compwidget[zdmaxbutts]; // dialog completion button widgets | |||
zwidget widget[zdmaxwidgets]; // dialog widgets (EOF = typ e = 0) | zwidget widget[zdmaxwidgets]; // dialog widgets (EOF = typ e = 0) | |||
char event[40]; // active event or widget | ch event[40]; // active event or widget | |||
GtkWidget *lastwidget; // last widget active | GtkWidget *lastwidget; // last widget active | |||
int sentinel2; // validity sentinel2 | int sentinel2; // validity sentinel2 | |||
}; | }; | |||
zdialog *zdialog_new(cchar *title, GtkWidget *parent, ...); | zdialog *zdialog_new(ch *title, GtkWidget *parent, ...); | |||
// create a zdialog with opt. buttons | // create a zdialog with opt. buttons | |||
void zdialog_set_title(zdialog *zd, cchar *title); | void zdialog_set_title(zdialog *zd, ch *title); | |||
// change zdialog title | // change zdialog title | |||
void zdialog_set_modal(zdialog *zd); // set zdialog modal | void zdialog_set_modal(zdialog *zd); // set zdialog modal | |||
void zdialog_set_decorated(zdialog *zd, int decorated); // set zdialog decorated or not | void zdialog_set_decorated(zdialog *zd, int decorated); // set zdialog decorated or not | |||
void zdialog_present(zdialog *zd); // zdialog visible and on top | void zdialog_present(zdialog *zd); // zdialog visible and on top | |||
void zdialog_can_focus(zdialog *zd, int Fcan); // zdialog can/not have focus (e.g. report) | void zdialog_can_focus(zdialog *zd, int Fcan); // zdialog can/not have focus (e.g. report) | |||
void zdialog_set_focus(zdialog *zd, cchar *widget = null); // set focus on window [ widget ] | void zdialog_set_focus(zdialog *zd, ch *widget = null); // set focus on window [ widget ] | |||
int zdialog_add_widget(zdialog *zd, // add widget to zdialog | int zdialog_add_widget(zdialog *zd, // add widget to zdialog | |||
cchar *type, cchar *wname, cchar *pname, | ch *type, ch *wname, ch *pname, | |||
// required args | // required args | |||
cchar *data = 0, int size = 0, int homog = 0, | ch *data = 0, int size = 0, int homog = 0, | |||
// optional args | // optional args | |||
int expand = 0, int space = 0, int wrap = 0); | int expand = 0, int space = 0, int wrap = 0); | |||
int zdialog_add_widget(zdialog *zd, // add widget to zdialog | int zdialog_add_widget(zdialog *zd, // add widget to zdialog | |||
cchar *type, cchar *wname, cchar *pname, | ch *type, ch *wname, ch *pname, | |||
// (alternative form) | // (alternative form) | |||
cchar *data, cchar *options); | ch *data, ch *options); | |||
// "size=nn|homog|expand|space=nn|wrap" | // "size=nn|homog|expand|space=nn|wrap" | |||
int zdialog_valid(zdialog *zd, cchar *title = 0); | int zdialog_valid(zdialog *zd, ch *title = 0); | |||
// return 1/0 if zdialog valid/invalid | // return 1/0 if zdialog valid/invalid | |||
int zdialog_valid2(zdialog *zd, cchar *title = 0); | int zdialog_valid2(zdialog *zd, ch *title = 0); | |||
// silent version of above | // silent version of above | |||
int zdialog_find_widget(zdialog *zd, cchar *wname); | int zdialog_find_widget(zdialog *zd, ch *wname); | |||
// find zdialog widget from widget name | // find zdialog widget from widget name | |||
GtkWidget * zdialog_gtkwidget(zdialog *zd, cchar *wname); | GtkWidget * zdialog_gtkwidget(zdialog *zd, ch *wname); | |||
// GTK widget from zdialog widget name | // GTK widget from zdialog widget name | |||
int zdialog_set_image(zdialog *zd, cchar *wname, GdkPixbuf *); | int zdialog_set_image(zdialog *zd, ch *wname, GdkPixbuf *); | |||
// set "image" widget from a GDK pixbuf | // set "image" widget from a GDK pixbuf | |||
int zdialog_add_ttip(zdialog *zd, cchar *wname, cchar *ttip); | int zdialog_add_ttip(zdialog *zd, ch *wname, ch *ttip); | |||
// add popup tool tip to a widget | // add popup tool tip to a widget | |||
int zdialog_resize(zdialog *zd, int width, int height); // set size > widget sizes | int zdialog_resize(zdialog *zd, int width, int height); // set size > widget sizes | |||
int zdialog_put_data(zdialog *zd, cchar *wname, cchar *data); | int zdialog_put_data(zdialog *zd, ch *wname, ch *data); | |||
// put data in widget (entry, spin ...) | // put data in widget (entry, spin ...) | |||
cchar * zdialog_get_data(zdialog *zd, cchar *wname); | ch * zdialog_get_data(zdialog *zd, ch *wname); | |||
// get widget data | // get widget data | |||
int zdialog_set_limits(zdialog *, cchar *wname, double min, double max); | int zdialog_set_limits(zdialog *, ch *wname, double min, double max); | |||
// set new widget limits (spin, scale) | // set new widget limits (spin, scale) | |||
int zdialog_get_limits(zdialog *, cchar *wname, double &min, double &max); | int zdialog_get_limits(zdialog *, ch *wname, double &min, double &max); | |||
// get widget limits (spin, scale) | // get widget limits (spin, scale) | |||
int zdialog_rescale(zdialog *zd, cchar *wname, float, float, float); | int zdialog_rescale(zdialog *zd, ch *wname, float, float, float); | |||
// rescale widget, lo/neut/hi vals | // rescale widget, lo/neut/hi vals | |||
typedef int zdialog_event(zdialog *zd, cchar *wname); | typedef int zdialog_event(zdialog *zd, ch *wname); | |||
// widget event callback function | // widget event callback function | |||
int zdialog_run(zdialog *zd, zdialog_event = 0, cchar *posn = 0); | int zdialog_run(zdialog *zd, zdialog_event = 0, ch *posn = 0); | |||
// run dialog, handle events | // run dialog, handle events | |||
void zdialog_KB_addshortcut(cchar *key, cchar *menu); | void zdialog_KB_addshortcut(ch *key, ch *menu); | |||
// KB shortcut for zdialog compl. button | // KB shortcut for zdialog compl. button | |||
void KBevent(GdkEventKey *event); // extern: pass KB events to main app | void KBevent(GdkEventKey *event); // extern: pass KB events to main app | |||
int zdialog_send_event(zdialog *zd, cchar *event); // send an event to an active dialog | int zdialog_send_event(zdialog *zd, ch *event); // send an event to an active dialog | |||
int zdialog_send_response(zdialog *zd, int zstat); // complete a dialog, set status | int zdialog_send_response(zdialog *zd, int zstat); // complete a dialog, set status | |||
int zdialog_show(zdialog *zd, int flag); // show or hide a dialog | int zdialog_show(zdialog *zd, int flag); // show or hide a dialog | |||
int zdialog_destroy(zdialog *zd); // destroy dialog (caller resp.) | int zdialog_destroy(zdialog *zd); // destroy dialog (caller resp.) | |||
int zdialog_free(zdialog *&zd); // free zdialog memory | int zdialog_free(zdialog *&zd); // free zdialog memory | |||
int zdialog_wait(zdialog *zd); // wait for dialog completion | int zdialog_wait(zdialog *zd); // wait for dialog completion | |||
int zdialog_goto(zdialog *zd, cchar *wname); // put cursor at named widget | int zdialog_goto(zdialog *zd, ch *wname); // put cursor at named widget | |||
void zdialog_set_cursor(zdialog *zd, GdkCursor *cursor); // set cursor for dialog window | void zdialog_set_cursor(zdialog *zd, GdkCursor *cursor); // set cursor for dialog window | |||
int zdialog_stuff(zdialog *zd, cchar *wname, cchar *data); | int zdialog_stuff(zdialog *zd, ch *wname, ch *data); | |||
// stuff string data into widget | // stuff string data into widget | |||
int zdialog_stuff(zdialog *zd, cchar *wname, int data); | int zdialog_stuff(zdialog *zd, ch *wname, int data); | |||
// stuff int data | // stuff int data | |||
int zdialog_stuff(zdialog *zd, cchar *wname, double data); | int zdialog_stuff(zdialog *zd, ch *wname, double data); | |||
// stuff double data | // stuff double data | |||
int zdialog_stuff(zdialog *zd, cchar *wname, double data, cchar *format); | int zdialog_stuff(zdialog *zd, ch *wname, double data, ch *format); | |||
// stuff double data, formatted | // stuff double data, formatted | |||
int zdialog_labelfont(zdialog *zd, cchar *lab, cchar *font, cchar *txt); | int zdialog_labelfont(zdialog *zd, ch *lab, ch *font, ch *txt); | |||
// stuff label text with font | // stuff label text with font | |||
int zdialog_fetch(zdialog *zd, cchar *wname, char *data, int maxcc); | int zdialog_fetch(zdialog *zd, ch *wname, ch *data, int maxcc); | |||
// get string data from widget | // get string data from widget | |||
int zdialog_fetch(zdialog *zd, cchar *wname, int &data); | int zdialog_fetch(zdialog *zd, ch *wname, int &data); | |||
// get int data | // get int data | |||
int zdialog_fetch(zdialog *zd, cchar *wname, double &data); | int zdialog_fetch(zdialog *zd, ch *wname, double &data); | |||
// get double data | // get double data | |||
int zdialog_fetch(zdialog *zd, cchar *wname, float &data); | int zdialog_fetch(zdialog *zd, ch *wname, float &data); | |||
// get float data | // get float data | |||
int zdialog_combo_clear(zdialog *zd, cchar *wname); | int zdialog_combo_clear(zdialog *zd, ch *wname); | |||
// clear combo box entries | // clear combo box entries | |||
int zdialog_combo_popup(zdialog *zd, cchar *wname); | int zdialog_combo_popup(zdialog *zd, ch *wname); | |||
// open combo box pick list | // open combo box pick list | |||
int zdialog_load_widgets(zdialog *zd, spldat *sd, cchar *fname, FILE *fid); | int zdialog_load_widgets(zdialog *zd, spldat *sd, ch *fname, FILE *fid); | |||
// load zdialog widgets from a file | // load zdialog widgets from a file | |||
int zdialog_save_widgets(zdialog *zd, spldat *sd, cchar *fname, FILE *fid); | int zdialog_save_widgets(zdialog *zd, spldat *sd, ch *fname, FILE *fid); | |||
// save zdialog widgets to a file | // save zdialog widgets to a file | |||
int zdialog_load_prev_widgets(zdialog *zd, spldat *sd, cchar *fname); | int zdialog_load_prev_widgets(zdialog *zd, spldat *sd, ch *fname); | |||
// save last-used zdialog widgets | // save last-used zdialog widgets | |||
int zdialog_save_last_widgets(zdialog *zd, spldat *sd, cchar *fname); | int zdialog_save_last_widgets(zdialog *zd, spldat *sd, ch *fname); | |||
// load last-used zdialog widgets | // load last-used zdialog widgets | |||
int zdialog_geometry(cchar *action); | int zdialog_geometry(ch *action); | |||
// load/save zdialog window positiion/size | // load/save zdialog window positiion/size | |||
void zdialog_set_position(zdialog *zd, cchar *posn); | void zdialog_set_position(zdialog *zd, ch *posn); | |||
// set initial/new zdialog window position | // set initial/new zdialog window position | |||
void zdialog_save_position(zdialog *zd); // save zdialog window position | void zdialog_save_position(zdialog *zd); // save zdialog window position | |||
int zdialog_inputs(cchar *action); // load or save zdialog input fields | int zdialog_inputs(ch *action); // load or save zdialog input fields | |||
int zdialog_save_inputs(zdialog *zd); // save zdialog input fields when finished | int zdialog_save_inputs(zdialog *zd); // save zdialog input fields when finished | |||
int zdialog_restore_inputs(zdialog *zd); // restore zdialog inputs from prior use | int zdialog_restore_inputs(zdialog *zd); // restore zdialog inputs from prior use | |||
char * zdialog_text(GtkWidget *parent, cchar *title, cchar *inittext); | ch * zdialog_text(GtkWidget *parent, ch *title, ch *inittext); | |||
// get N text input lines from user | // get N text input lines from user | |||
char * zdialog_text1(GtkWidget *parent, cchar *title, cchar *inittext); | ch * zdialog_text1(GtkWidget *parent, ch *title, ch *inittext); | |||
// get one text input line from user | // get one text input line from user | |||
int zdialog_choose(GtkWidget *parent, cchar *where, cchar *message, ...); | int zdialog_choose(GtkWidget *parent, ch *where, ch *message, ...); | |||
// show message, return button choice | // show message, return button choice | |||
int zdialog_choose2(GtkWidget *parent, cchar *where, cchar *message, ...); | int zdialog_choose2(GtkWidget *parent, ch *where, ch *message, ...); | |||
// " " " including KB inputs | // same, including KB inputs | |||
void zdialog_popup_text(cchar *textfile, GtkWidget *parent); | void zdialog_popup_text(ch *textfile, GtkWidget *parent); | |||
// get chars/text for GtkTextView insert | // get chars/text for GtkTextView insert | |||
// write text report in popup window | // write text report in popup window | |||
zdialog * popup_report_open(cchar *title, GtkWidget *parent, int ww, int hh, | zdialog * popup_report_open(ch *title, GtkWidget *parent, int ww, int hh, | |||
// open popup report - pixel size, | // open popup report - pixel size, | |||
int Fheader, textwidget_callbackfunc_t CBfunc, ...); | int Fheader, textwidget_callbackfunc_t CBfunc, ...); | |||
// header line, callback function | // header line, callback function | |||
void popup_report_header(zdialog *zd, int bold, cchar *format, ...); | void popup_report_header(zdialog *zd, int bold, ch *format, ...); | |||
// write non-scrolling header line | // write non-scrolling header line | |||
void popup_report_write(zdialog *zd, int bold, cchar *format, ...); | void popup_report_write(zdialog *zd, int bold, ch *format, ...); | |||
// write text line | // write text line | |||
void popup_report_write2(zdialog *zd, int bold, cchar *format, ...); | void popup_report_write2(zdialog *zd, int bold, ch *format, ...); | |||
// write text line and scroll to end | // write text line and scroll to end | |||
void popup_report_top(zdialog *zd); | void popup_report_top(zdialog *zd); | |||
// go to top of report window | // go to top of report window | |||
void popup_report_bottom(zdialog *zd); | void popup_report_bottom(zdialog *zd); | |||
// go to bottom of report window | // go to bottom of report window | |||
void popup_report_clear(zdialog *zd); | void popup_report_clear(zdialog *zd); | |||
// clear report window | // clear report window | |||
void popup_report_clear(zdialog *zd, int line); | void popup_report_clear(zdialog *zd, int line); | |||
// clear from line to end | // clear from line to end | |||
void popup_report_insert(zdialog *zd, int bold, int line, cchar *format, ...); | void popup_report_insert(zdialog *zd, int bold, int line, ch *format, ...); | |||
// insert new line | // insert new line | |||
void popup_report_replace(zdialog *zd, int bold, int line, cchar *format, ...); | void popup_report_replace(zdialog *zd, int bold, int line, ch *format, ...); | |||
// replace existing line | // replace existing line | |||
void popup_report_delete(zdialog *zd, int line); | void popup_report_delete(zdialog *zd, int line); | |||
// delete line | // delete line | |||
int popup_report_find(zdialog *zd, char *matchtext, int line1); | int popup_report_find(zdialog *zd, ch *matchtext, int line1); | |||
// find matching line | // find matching line | |||
void popup_report_insert_pixbuf(zdialog *zd, int line, GdkPixbuf *pixbuf); | void popup_report_insert_pixbuf(zdialog *zd, int line, GdkPixbuf *pixbuf); | |||
// insert pixbuf image after line | // insert pixbuf image after line | |||
void popup_report_scroll(zdialog *zd, int line); | void popup_report_scroll(zdialog *zd, int line); | |||
// scroll to make line visible | // scroll to make line visible | |||
void popup_report_scroll_top(zdialog *zd, int line); | void popup_report_scroll_top(zdialog *zd, int line); | |||
// scroll to put line at top | // scroll to put line at top | |||
void popup_report_get_visible_lines(zdialog *zd, int &top, int &bott); | void popup_report_get_visible_lines(zdialog *zd, int &top, int &bott); | |||
// get visible lines range | // get visible lines range | |||
char * popup_report_line(zdialog *zd, int line, int strip); | ch * popup_report_line(zdialog *zd, int line, int strip); | |||
// retrieve line (strip \n) | // retrieve line (strip \n) | |||
char * popup_report_word(zdialog *zd, int line, int posn, cchar *dlims, char &en | ch * popup_report_word(zdialog *zd, int line, int posn, ch *dlims, ch &end); | |||
d); // retrieve word | // retrieve word | |||
void popup_report_highlight_line(zdialog *zd, int line); | void popup_report_highlight_line(zdialog *zd, int line); | |||
// highlight line | // highlight line | |||
void popup_report_highlight_word(zdialog *zd, int line, int posn, int cc); | void popup_report_highlight_word(zdialog *zd, int line, int posn, int cc); | |||
// highlight word | // highlight word | |||
void popup_report_underline_word(zdialog *zd, int line, int posn, int cc); | void popup_report_underline_word(zdialog *zd, int line, int posn, int cc); | |||
// underline word | // underline word | |||
void popup_report_bold_word(zdialog *zd, int line, int posn, int cc); | void popup_report_bold_word(zdialog *zd, int line, int posn, int cc); | |||
// bold word | // bold word | |||
void popup_report_font_attributes(zdialog *zd); | void popup_report_font_attributes(zdialog *zd); | |||
// font attributes for entire report | // font attributes for entire report | |||
void popup_report_close(zdialog *zd, int secs); | void popup_report_close(zdialog *zd, int secs); | |||
// close window after seconds | // close window after seconds | |||
// shell command to popup window | // shell command to popup window | |||
int popup_command(cchar *command, int ww = 400, int hh = 300, GtkWidget *parent = 0, int top = 0); | int popup_command(ch *command, int ww = 400, int hh = 300, GtkWidget *parent = 0 , int top = 0); | |||
// popups: message, dialog, image, picklist | // popups: message, dialog, image, picklist | |||
void zmessageACK(GtkWidget *parent, cchar *format, ... ); | void zmessageACK(GtkWidget *parent, ch *format, ... ); | |||
// display message, wait for OK | // display message, wait for OK | |||
int zmessageYN(GtkWidget *parent, cchar *format, ... ); | int zmessageYN(GtkWidget *parent, ch *format, ... ); | |||
// display message, wait for YES/NO | // display message, wait for YES/NO | |||
zdialog * zmessage_post(GtkWidget *, cchar *loc, int s, cchar *f, ...); | zdialog * zmessage_post(GtkWidget *, ch *loc, int s, ch *f, ...); | |||
// show message, timeout or cancel | // show message, timeout or cancel | |||
zdialog * zmessage_post_bold(GtkWidget *, cchar *loc, int s, cchar *f, ...); | zdialog * zmessage_post_bold(GtkWidget *, ch *loc, int s, ch *f, ...); | |||
// " " with big red bold font | // same, with big red bold font | |||
void poptext_screen(cchar *text, int px, int py, float s1, float s2); | void poptext_screen(ch *text, int px, int py, float s1, float s2); | |||
// show popup text at screen posn | // show popup text at screen posn | |||
void poptext_mouse(cchar *text, int dx, int dy, float s1, float s2); | void poptext_mouse(ch *text, int dx, int dy, float s1, float s2); | |||
// " " " at mouse posn + offset | // same, at mouse posn + offset | |||
void poptext_window(GtkWindow *, cchar *tx, int x, int y, float s1, float s2); | void poptext_window(GtkWindow *, ch *tx, int x, int y, float s1, float s2); | |||
// " " " at window posn + offset | // same, at window posn + offset | |||
void poptext_widget(GtkWidget *, cchar *tx, int x, int y, float s1, float s2); | void poptext_widget(GtkWidget *, ch *tx, int x, int y, float s1, float s2); | |||
// " " " at widget posn + offset | // same, at widget posn + offset | |||
int poptext_killnow(); // kill current popup window | int poptext_killnow(); // kill current popup window | |||
int popup_image(cchar *imagefile, GtkWindow *parent, int Fnewin, int size); | int popup_image(ch *imagefile, GtkWindow *parent, int Fnewin, int size); | |||
// popup window with image | // popup window with image | |||
cchar * popup_picklist(GtkWidget *paren, cchar **list, cchar **desc, int Np); | ch * popup_picklist(GtkWidget *paren, ch **list, ch **desc, int Np); | |||
// popup picklist, return choice | // popup picklist, return choice | |||
// file chooser dialogs for one file, multiple files, or folder | // file chooser dialogs for one file, multiple files, or folder | |||
char * zgetfile(cchar *title, GtkWindow *parent, cchar *action, cchar *file, in | ch * zgetfile(ch *title, GtkWindow *parent, ch *action, ch *file, int hidden = | |||
t hidden = 0); | 0); | |||
char ** zgetfiles(cchar *title, GtkWindow *parent, cchar *action, cchar *file, i | ch ** zgetfiles(ch *title, GtkWindow *parent, ch *action, ch *file, int hidden = | |||
nt hidden = 0); | 0); | |||
char * zgetfolder(cchar *title, GtkWindow *parent, cchar *initfolder); | ch * zgetfolder(ch *title, GtkWindow *parent, ch *initfolder); | |||
// print an image file, choosing printer, paper, orientation, margins, and scal e | // print an image file, choosing printer, paper, orientation, margins, and scal e | |||
void print_image_file(GtkWidget *parent, cchar *imagefile); | void print_image_file(GtkWidget *parent, ch *imagefile); | |||
// drag and drop functions | // drag and drop functions | |||
typedef char * drag_drop_source_func(); | typedef ch * drag_drop_source_func(); | |||
// user function, set drag-drop text | // user function, set drag-drop text | |||
typedef void drag_drop_dest_func(int x, int y, char *text); | typedef void drag_drop_dest_func(int x, int y, ch *text); | |||
// user function, get drag-drop text | // user function, get drag-drop text | |||
void drag_drop_source(GtkWidget *window, drag_drop_source_func); // connect source window to user function | void drag_drop_source(GtkWidget *window, drag_drop_source_func); // connect source window to user function | |||
void drag_drop_dest(GtkWidget *window, drag_drop_dest_func); // connect dest. window to user function | void drag_drop_dest(GtkWidget *window, drag_drop_dest_func); // connect dest. window to user function | |||
// miscellaneous GDK/GTK functions | // miscellaneous GDK/GTK functions | |||
PIXBUF * get_thumbnail(cchar *fpath, int size); | PIXBUF * get_thumbnail(ch *fpath, int size); | |||
// get sized thumbnail for image file | // get sized thumbnail for image file | |||
GdkCursor * zmakecursor(cchar *iconfile); | GdkCursor * zmakecursor(ch *iconfile); | |||
// make a cursor from an image file | // make a cursor from an image file | |||
PIXBUF * gdk_pixbuf_rotate(PIXBUF *, float deg, int alfa = 0); // rotate pixbuf through any angle | PIXBUF * gdk_pixbuf_rotate(PIXBUF *, float deg, int alfa = 0); // rotate pixbuf through any angle | |||
PIXBUF * gdk_pixbuf_stripalpha(PIXBUF *pixbuf); // strip alpha channel from pixbuf | PIXBUF * gdk_pixbuf_stripalpha(PIXBUF *pixbuf); // strip alpha channel from pixbuf | |||
PIXBUF * text_pixbuf(cchar *text, cchar *font, int fsize, GtkWidget *); // create pixbuf with text using font | PIXBUF * text_pixbuf(ch *text, ch *font, int fsize, GtkWidget *); // create pixbuf with text using font | |||
int move_pointer(GtkWidget *, int px, int py); // move the mouse pointer to px, py | int move_pointer(GtkWidget *, int px, int py); // move the mouse pointer to px, py | |||
void window_to_mouse(GtkWidget *window); // move GtkWidget/window to mouse position | void window_to_mouse(GtkWidget *window); // move GtkWidget/window to mouse position | |||
End of changes. 76 change blocks. | ||||
500 lines changed or deleted | 507 lines changed or added |