diff options
Diffstat (limited to 'app/wlib/include')
-rw-r--r-- | app/wlib/include/CMakeLists.txt | 12 | ||||
-rw-r--r-- | app/wlib/include/getline.h | 132 | ||||
-rw-r--r-- | app/wlib/include/getopt.h | 2 | ||||
-rw-r--r-- | app/wlib/include/wlib.h | 407 |
4 files changed, 395 insertions, 158 deletions
diff --git a/app/wlib/include/CMakeLists.txt b/app/wlib/include/CMakeLists.txt new file mode 100644 index 0000000..5891b02 --- /dev/null +++ b/app/wlib/include/CMakeLists.txt @@ -0,0 +1,12 @@ +
+target_include_directories(xtrkcad-wlib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
+
+target_sources(xtrkcad-wlib
+ PUBLIC
+ wlib.h)
+
+if(WIN32)
+ target_sources(xtrkcad-wlib
+ PRIVATE
+ getopt.h)
+endif()
\ No newline at end of file diff --git a/app/wlib/include/getline.h b/app/wlib/include/getline.h new file mode 100644 index 0000000..ffbb699 --- /dev/null +++ b/app/wlib/include/getline.h @@ -0,0 +1,132 @@ +#ifndef GETLINE_H +#define GETLINE_H + +#include <stdio.h> + +#define restrict __restrict +typedef long long ssize_t; + +ssize_t getline(char **restrict lineptr, size_t *restrict n, FILE *restrict stream); +ssize_t getdelim(char **restrict lineptr, size_t *restrict n, int delim, FILE *restrict stream); + +/* +~$ export MANWIDTH=80 +~$ man getline | col -b +GETLINE(3) Linux Programmer's Manual GETLINE(3) + +NAME + getline, getdelim - delimited string input + +SYNOPSIS + #include <stdio.h> + + ssize_t getline(char **lineptr, size_t *n, FILE *stream); + + ssize_t getdelim(char **lineptr, size_t *n, int delim, FILE *stream); + + Feature Test Macro Requirements for glibc (see feature_test_macros(7)): + + getline(), getdelim(): + Since glibc 2.10: + _POSIX_C_SOURCE >= 200809L + Before glibc 2.10: + _GNU_SOURCE + +DESCRIPTION + getline() reads an entire line from stream, storing the address of the + buffer containing the text into *lineptr. The buffer is null-termi- + nated and includes the newline character, if one was found. + + If *lineptr is set to NULL and *n is set 0 before the call, then get- + line() will allocate a buffer for storing the line. This buffer should + be freed by the user program even if getline() failed. + + Alternatively, before calling getline(), *lineptr can contain a pointer + to a malloc(3)-allocated buffer *n bytes in size. If the buffer is not + large enough to hold the line, getline() resizes it with realloc(3), + updating *lineptr and *n as necessary. + + In either case, on a successful call, *lineptr and *n will be updated + to reflect the buffer address and allocated size respectively. + + getdelim() works like getline(), except that a line delimiter other + than newline can be specified as the delimiter argument. As with get- + line(), a delimiter character is not added if one was not present in + the input before end of file was reached. + +RETURN VALUE + On success, getline() and getdelim() return the number of characters + read, including the delimiter character, but not including the termi- + nating null byte ('\0'). This value can be used to handle embedded + null bytes in the line read. + + Both functions return -1 on failure to read a line (including end-of- + file condition). In the event of an error, errno is set to indicate + the cause. + +ERRORS + EINVAL Bad arguments (n or lineptr is NULL, or stream is not valid). + + ENOMEM Allocation or reallocation of the line buffer failed. + +ATTRIBUTES + For an explanation of the terms used in this section, see at- + tributes(7). + + +------------------------------------------------+ + ¦Interface ¦ Attribute ¦ Value ¦ + +----------------------+---------------+---------¦ + ¦getline(), getdelim() ¦ Thread safety ¦ MT-Safe ¦ + +------------------------------------------------+ + +CONFORMING TO + Both getline() and getdelim() were originally GNU extensions. They + were standardized in POSIX.1-2008. + +EXAMPLE + #define _GNU_SOURCE + #include <stdio.h> + #include <stdlib.h> + + int + main(int argc, char *argv[]) + { + FILE *stream; + char *line = NULL; + size_t len = 0; + ssize_t nread; + + if (argc != 2) { + fprintf(stderr, "Usage: %s <file>\n", argv[0]); + exit(EXIT_FAILURE); + } + + stream = fopen(argv[1], "r"); + if (stream == NULL) { + perror("fopen"); + exit(EXIT_FAILURE); + } + + while ((nread = getline(&line, &len, stream)) != -1) { + printf("Retrieved line of length %zu:\n", nread); + fwrite(line, nread, 1, stdout); + } + + free(line); + fclose(stream); + exit(EXIT_SUCCESS); + } + +SEE ALSO + read(2), fgets(3), fopen(3), fread(3), scanf(3) + +COLOPHON + This page is part of release 5.05 of the Linux man-pages project. A + description of the project, information about reporting bugs, and the + latest version of this page, can be found at + https://www.kernel.org/doc/man-pages/. + +GNU 2019-03-06 GETLINE(3) +*/ + +#endif /* GETLINE_H */ diff --git a/app/wlib/include/getopt.h b/app/wlib/include/getopt.h index e9a8354..4a3ced4 100644 --- a/app/wlib/include/getopt.h +++ b/app/wlib/include/getopt.h @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with ASPEX; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ extern char *optarg; diff --git a/app/wlib/include/wlib.h b/app/wlib/include/wlib.h index d3bfc18..88b2806 100644 --- a/app/wlib/include/wlib.h +++ b/app/wlib/include/wlib.h @@ -7,6 +7,7 @@ #ifdef WINDOWS #include <stdio.h> #define FILE_SEP_CHAR "\\" +#include "getline.h" #else #define FILE_SEP_CHAR "/" #endif @@ -23,17 +24,25 @@ char *g_win32_getlocale (void); #endif // conversion routines to and from UTF-8 -bool wSystemToUTF8(const char *inString, char *outString, unsigned outStringLength); -bool wUTF8ToSystem(const char *inString, char *outString, unsigned outStringLength); +bool wSystemToUTF8(const char *inString, char *outString, + unsigned outStringLength); +bool wUTF8ToSystem(const char *inString, char *outString, + unsigned outStringLength); bool wIsUTF8(const char * string); /* * Interface types */ +// a big integer typedef long wInteger_t; -typedef int wPos_t; +// Position/Size of objects drawn on a WDraw canvas (fractional pixels) +typedef double wDrawPix_t; +// Position/Size of controls/windows (integral pixels) +typedef long wWinPix_t; +// Boolean typedef int wBool_t; +// index for lists etc typedef int wIndex_t; /* @@ -68,7 +77,7 @@ typedef int wDrawColor; typedef struct { const char * name; const char * value; - } wBalloonHelp_t; +} wBalloonHelp_t; extern long debugWindow; extern long wDebugFont; @@ -78,8 +87,10 @@ extern long wDebugFont; * Bitmap Controls bitmap.c */ -wControl_p wBitmapCreate(wWin_p parent, wPos_t x, wPos_t y, long options, wIcon_p iconP); -wIcon_p wIconCreateBitMap(wPos_t w, wPos_t h, const char *bits, wDrawColor color); +wControl_p wBitmapCreate(wWin_p parent, wWinPix_t x, wWinPix_t y, long options, + const struct wIcon_t * iconP); +wIcon_p wIconCreateBitMap(wWinPix_t w, wWinPix_t h, const char *bits, + wDrawColor color); wIcon_p wIconCreatePixMap(char *pm[]); void wIconSetColor(wIcon_p ip, wDrawColor color); @@ -97,12 +108,15 @@ typedef enum { wBoxThickB, wBoxThickW, wBoxRidge, - wBoxTrough } - wBoxType_e; + wBoxTrough +} +wBoxType_e; -void wBoxSetSize(wBox_p b, wPos_t w, wPos_t h); -void wlibDrawBox(wWin_p win, wBoxType_e style, wPos_t x, wPos_t y, wPos_t w, wPos_t h); -wBox_p wBoxCreate(wWin_p parent, wPos_t bx, wPos_t by, const char *labelStr, wBoxType_e boxTyp, wPos_t bw, wPos_t bh); +void wBoxSetSize(wBox_p b, wWinPix_t w, wWinPix_t h); +void wlibDrawBox(wWin_p win, wBoxType_e style, wWinPix_t x, wWinPix_t y, + wWinPix_t w, wWinPix_t h); +wBox_p wBoxCreate(wWin_p parent, wWinPix_t bx, wWinPix_t by, + const char *labelStr, wBoxType_e boxTyp, wWinPix_t bw, wWinPix_t bh); /*------------------------------------------------------------------------------ * @@ -129,13 +143,19 @@ typedef void (*wChoiceCallBack_p)( long, void * ); void wButtonSetLabel(wButton_p bb, const char *labelStr); void wButtonSetBusy(wButton_p bb, int value); -wButton_p wButtonCreate(wWin_p parent, wPos_t x, wPos_t y, const char *helpStr, const char *labelStr, long option, wPos_t width, wButtonCallBack_p action, void *data); +wButton_p wButtonCreate(wWin_p parent, wWinPix_t x, wWinPix_t y, + const char *helpStr, const char *labelStr, long option, wWinPix_t width, + wButtonCallBack_p action, void *data); void wRadioSetValue(wChoice_p bc, long value); long wRadioGetValue(wChoice_p bc); void wToggleSetValue(wChoice_p bc, long value); long wToggleGetValue(wChoice_p b); -wChoice_p wRadioCreate(wWin_p parent, wPos_t x, wPos_t y, const char *helpStr, const char *labelStr, long option, const char **labels, long *valueP, wChoiceCallBack_p action, void *data); -wChoice_p wToggleCreate(wWin_p parent, wPos_t x, wPos_t y, const char *helpStr, const char *labelStr, long option, const char **labels, long *valueP, wChoiceCallBack_p action, void *data); +wChoice_p wRadioCreate(wWin_p parent, wWinPix_t x, wWinPix_t y, + const char *helpStr, const char *labelStr, long option, + const char * const *labels, long *valueP, wChoiceCallBack_p action, void *data); +wChoice_p wToggleCreate(wWin_p parent, wWinPix_t x, wWinPix_t y, + const char *helpStr, const char *labelStr, long option, + const char * const *labels, long *valueP, wChoiceCallBack_p action, void *data); /*------------------------------------------------------------------------------ @@ -160,7 +180,8 @@ void wHelp( const char * ); #define NT_WARNING 2 #define NT_ERROR 4 -wBool_t wNoticeEx( int type, const char * msg, const char * yes, const char * no ); +wBool_t wNoticeEx( int type, const char * msg, const char * yes, + const char * no ); unsigned wOpenFileExternal(char *filename); @@ -179,19 +200,20 @@ unsigned long wGetTimer( void ); void wExit( int ); typedef enum { wCursorNormal, - wCursorNone, - wCursorAppStart, - wCursorHand, - wCursorNo, - wCursorSizeAll, - wCursorSizeNESW, - wCursorSizeNS, - wCursorSizeNWSE, - wCursorSizeWE, - wCursorWait, - wCursorIBeam, - wCursorCross, - wCursorQuestion } wCursor_t; + wCursorNone, + wCursorAppStart, + wCursorHand, + wCursorNo, + wCursorSizeAll, + wCursorSizeNESW, + wCursorSizeNS, + wCursorSizeNWSE, + wCursorSizeWE, + wCursorWait, + wCursorIBeam, + wCursorCross, + wCursorQuestion + } wCursor_t; void wSetCursor( wDraw_p, wCursor_t ); #define defaultCursor wCursorCross @@ -202,12 +224,13 @@ const char * wMemStats( void ); #define WKEY_ALT (1<<3) int wGetKeyState( void ); -void wGetDisplaySize( wPos_t*, wPos_t* ); +void wGetDisplaySize( wWinPix_t*, wWinPix_t* ); -wIcon_p wIconCreateBitMap( wPos_t, wPos_t, const char * bits, wDrawColor ); +wIcon_p wIconCreateBitMap( wWinPix_t, wWinPix_t, const char * bits, + wDrawColor ); wIcon_p wIconCreatePixMap( char *[] ); void wIconSetColor( wIcon_p, wDrawColor ); -void wIconDraw( wDraw_p d, wIcon_p bm, wPos_t x, wPos_t y ); +void wIconDraw( wDraw_p d, wIcon_p bm, wWinPix_t x, wWinPix_t y ); void wConvertToCharSet( char *, int ); void wConvertFromCharSet( char *, int ); @@ -226,8 +249,9 @@ typedef enum { wResize_e, wState_e, wQuit_e, - wRedraw_e } - winProcEvent; + wRedraw_e +} +winProcEvent; typedef void (*wWinCallBack_p)( wWin_p, winProcEvent, void *, void * ); /* Creation Options */ @@ -246,10 +270,12 @@ typedef void (*wWinCallBack_p)( wWin_p, winProcEvent, void *, void * ); #define F_RESTRICT (1L<<15) #define F_NOTTRANSIENT (1L<<16) -wWin_p wWinMainCreate( const char *, wPos_t, wPos_t, const char *, const char *, const char *, - long, wWinCallBack_p, void * ); -wWin_p wWinPopupCreate( wWin_p, wPos_t, wPos_t, const char *, const char *, const char *, - long, wWinCallBack_p, void * ); +wWin_p wWinMainCreate( const char *, wWinPix_t, wWinPix_t, const char *, + const char *, const char *, + long, wWinCallBack_p, void * ); +wWin_p wWinPopupCreate( wWin_p, wWinPix_t, wWinPix_t, const char *, + const char *, const char *, + long, wWinCallBack_p, void * ); wWin_p wMain( int, char *[] ); void wWinSetBigIcon( wWin_p, wIcon_p ); @@ -257,17 +283,19 @@ void wWinSetSmallIcon( wWin_p, wIcon_p ); void wWinShow( wWin_p, wBool_t ); wBool_t wWinIsVisible( wWin_p ); wBool_t wWinIsMaximized( wWin_p win); -void wWinGetSize ( wWin_p, wPos_t *, wPos_t * ); -void wWinSetSize( wWin_p, wPos_t, wPos_t ); +void wWinGetSize ( wWin_p, wWinPix_t *, wWinPix_t * ); +void wWinSetSize( wWin_p, wWinPix_t, wWinPix_t ); void wWinSetTitle( wWin_p, const char * ); void wWinSetBusy( wWin_p, wBool_t ); const char * wWinGetTitle( wWin_p ); -void wWinClear( wWin_p, wPos_t, wPos_t, wPos_t, wPos_t ); +void wWinClear( wWin_p, wWinPix_t, wWinPix_t, wWinPix_t, wWinPix_t ); void wMessage( wWin_p, const char *, wBool_t ); void wWinTop( wWin_p ); void wWinDoCancel( wWin_p ); void wWinBlockEnable( wBool_t ); -void wSetGeometry(wWin_p, int min_width, int max_width, int min_height, int max_height, int base_width, int base_height, double aspect_ratio); +void wSetGeometry(wWin_p, wWinPix_t min_width, wWinPix_t max_width, + wWinPix_t min_height, wWinPix_t max_height, wWinPix_t base_width, + wWinPix_t base_height, double aspect_ratio); int wCreateSplash( char *appName, char *appVer ); int wSetSplashInfo( char *msg ); @@ -284,20 +312,23 @@ void wDestroySplash( void ); #define BO_READONLY (1L<<2) #define BO_NOTAB (1L<<8) #define BO_BORDER (1L<<9) -#define BO_ENTER (1L<<10) +//#define BO_ENTER (1L<<10) +#define BO_ENTER 0 +#define BO_REPEAT (1L<<11) +#define BO_IGNFOCUS (1L<<12) -wPos_t wLabelWidth( const char * ); +wWinPix_t wLabelWidth( const char * ); const char * wControlGetHelp( wControl_p ); void wControlSetHelp( wControl_p, const char * ); void wControlShow( wControl_p, wBool_t ); -wPos_t wControlGetWidth( wControl_p ); -wPos_t wControlGetHeight( wControl_p ); -wPos_t wControlGetPosX( wControl_p ); -wPos_t wControlGetPosY( wControl_p ); -void wControlSetPos( wControl_p, wPos_t, wPos_t ); +wWinPix_t wControlGetWidth( wControl_p ); +wWinPix_t wControlGetHeight( wControl_p ); +wWinPix_t wControlGetPosX( wControl_p ); +wWinPix_t wControlGetPosY( wControl_p ); +void wControlSetPos( wControl_p, wWinPix_t, wWinPix_t ); void wControlSetFocus( wControl_p ); void wControlActive( wControl_p, wBool_t ); -void wControlSetBalloon( wControl_p, wPos_t, wPos_t, const char * ); +void wControlSetBalloon( wControl_p, wWinPix_t, wWinPix_t, const char * ); void wControlSetLabel( wControl_p, const char * ); void wControlSetBalloonText( wControl_p, const char * ); void wControlSetContext( wControl_p, void * ); @@ -314,11 +345,12 @@ void wControlLinkedActive( wControl_p b, int active ); #define BS_TRIM (1<<12) /* Creation CallBacks */ typedef void (*wStringCallBack_p)( const char *, void *); -wString_p wStringCreate( wWin_p, wPos_t, wPos_t, const char *, const char *, long, - wPos_t, char *, wIndex_t, wStringCallBack_p, - void * ); +wString_p wStringCreate( wWin_p, wWinPix_t, wWinPix_t, const char *, + const char *, long, + wWinPix_t, char *, wIndex_t, wStringCallBack_p, + void * ); void wStringSetValue( wString_p, const char * ); -void wStringSetWidth( wString_p, wPos_t ); +void wStringSetWidth( wString_p, wWinPix_t ); const char * wStringGetValue( wString_p ); @@ -328,14 +360,16 @@ const char * wStringGetValue( wString_p ); */ /* Creation CallBacks */ -typedef void (*wIntegerCallBack_p)( long, void * , int); -typedef void (*wFloatCallBack_p)( double, void * , int); -wInteger_p wIntegerCreate( wWin_p, wPos_t, wPos_t, const char *, const char *, long, - wPos_t, wInteger_t, wInteger_t, wInteger_t *, - wIntegerCallBack_p, void * ); -wFloat_p wFloatCreate( wWin_p, wPos_t, wPos_t, const char *, const char *, long, - wPos_t, double, double, double *, - wFloatCallBack_p, void * ); +typedef void (*wIntegerCallBack_p)( long, void *, int); +typedef void (*wFloatCallBack_p)( double, void *, int); +wInteger_p wIntegerCreate( wWin_p, wWinPix_t, wWinPix_t, const char *, + const char *, long, + wWinPix_t, wInteger_t, wInteger_t, wInteger_t *, + wIntegerCallBack_p, void * ); +wFloat_p wFloatCreate( wWin_p, wWinPix_t, wWinPix_t, const char *, + const char *, long, + wWinPix_t, double, double, double *, + wFloatCallBack_p, void * ); void wIntegerSetValue( wInteger_p, wInteger_t ); void wFloatSetValue( wFloat_p, double ); wInteger_t wIntegerGetValue( wInteger_p ); @@ -348,7 +382,8 @@ double wFloatGetValue( wFloat_p ); */ /* Creation CallBacks */ -typedef void (*wListCallBack_p)( wIndex_t, const char *, wIndex_t, void *, void * ); +typedef void (*wListCallBack_p)( wIndex_t, const char *, wIndex_t, void *, + void * ); /* Creation Options */ #define BL_DUP (1L<<16) @@ -364,12 +399,17 @@ typedef void (*wListCallBack_p)( wIndex_t, const char *, wIndex_t, void *, void /* lists, droplists and combo boxes */ -wList_p wListCreate( wWin_p, wPos_t, wPos_t, const char *, const char *, long, - long, wPos_t, int, wPos_t *, wBool_t *, const char **, long *, wListCallBack_p, void * ); -wList_p wDropListCreate( wWin_p, wPos_t, wPos_t, const char *, const char *, long, - long, wPos_t, long *, wListCallBack_p, void * ); - -wList_p wComboListCreate(wWin_p parent, wPos_t x, wPos_t y, const char *helpStr, const char *labelStr, long option, long number, wPos_t width, long *valueP, wListCallBack_p action, void *data); +wList_p wListCreate( wWin_p, wWinPix_t, wWinPix_t, const char *, const char *, + long, + long, wWinPix_t, int, wWinPix_t *, wBool_t *, const char **, long *, + wListCallBack_p, void * ); +wList_p wDropListCreate( wWin_p, wWinPix_t, wWinPix_t, const char *, + const char *, long, + long, wWinPix_t, long *, wListCallBack_p, void * ); + +wList_p wComboListCreate(wWin_p parent, wWinPix_t x, wWinPix_t y, + const char *helpStr, const char *labelStr, long option, long number, + wWinPix_t width, long *valueP, wListCallBack_p action, void *data); void wListClear(wList_p b); void wListSetIndex(wList_p b, int element); wIndex_t wListFindValue(wList_p b, const char *val); @@ -379,11 +419,13 @@ void *wListGetItemContext(wList_p b, wIndex_t inx); wBool_t wListGetItemSelected(wList_p b, wIndex_t inx); wIndex_t wListGetSelectedCount(wList_p b); void wListSelectAll(wList_p bl); -wBool_t wListSetValues(wList_p b, wIndex_t row, const char *labelStr, wIcon_p bm, void *itemData); +wBool_t wListSetValues(wList_p b, wIndex_t row, const char *labelStr, + wIcon_p bm, void *itemData); void wListDelete(wList_p b, wIndex_t inx); -int wListGetColumnWidths(wList_p bl, int colCnt, wPos_t *colWidths); -wIndex_t wListAddValue(wList_p b, const char *labelStr, wIcon_p bm, void *itemData); -void wListSetSize(wList_p bl, wPos_t w, wPos_t h); +int wListGetColumnWidths(wList_p bl, int colCnt, wWinPix_t *colWidths); +wIndex_t wListAddValue(wList_p b, const char *labelStr, wIcon_p bm, + void *itemData); +void wListSetSize(wList_p bl, wWinPix_t w, wWinPix_t h); wIndex_t wListGetValues( wList_p, char *, int, void * *, void * * ); /** \todo Check for the existance of following functions */ @@ -404,13 +446,13 @@ void wListSetEditable( wList_p, wBool_t ); #define wMessageSetFont( x ) ( x & (BM_LARGE | BM_SMALL )) #define wMessageCreate( w, p1, p2, l, p3, m ) wMessageCreateEx( w, p1, p2, l, p3, m, 0 ) -wMessage_p wMessageCreateEx( wWin_p, wPos_t, wPos_t, const char *, - wPos_t, const char *, long ); +wMessage_p wMessageCreateEx( wWin_p, wWinPix_t, wWinPix_t, const char *, + wWinPix_t, const char *, long ); void wMessageSetValue( wMessage_p, const char * ); -void wMessageSetWidth( wMessage_p, wPos_t ); -wPos_t wMessageGetWidth( const char *testString ); -wPos_t wMessageGetHeight( long ); +void wMessageSetWidth( wMessage_p, wWinPix_t ); +wWinPix_t wMessageGetWidth( const char *testString ); +wWinPix_t wMessageGetHeight( long ); /*------------------------------------------------------------------------------ @@ -422,7 +464,7 @@ typedef struct { int width; int x0, y0; int x1, y1; - } wLines_t, * wLines_p; +} wLines_t, * wLines_p; wLine_p wLineCreate( wWin_p, const char *, int, wLines_t *); @@ -439,8 +481,9 @@ wLine_p wLineCreate( wWin_p, const char *, int, wLines_t *); #define BT_DOBOLD (1L<<21) #define BT_TOP (1L<<20) /* Show the top of the text */ -wText_p wTextCreate( wWin_p, wPos_t, wPos_t, const char *, const char *, long, - wPos_t, wPos_t ); +wText_p wTextCreate( wWin_p, wWinPix_t, wWinPix_t, const char *, const char *, + long, + wWinPix_t, wWinPix_t ); void wTextClear( wText_p ); void wTextAppend( wText_p, const char * ); void wTextSetReadonly( wText_p, wBool_t ); @@ -450,8 +493,9 @@ wBool_t wTextGetModified( wText_p ); void wTextReadFile( wText_p, const char * ); wBool_t wTextSave( wText_p, const char * ); wBool_t wTextPrint( wText_p ); -void wTextSetSize( wText_p, wPos_t, wPos_t ); -void wTextComputeSize( wText_p, int, int, wPos_t *, wPos_t * ); +void wTextSetSize( wText_p, wWinPix_t, wWinPix_t ); +void wTextComputeSize( wText_p, wWinPix_t, wWinPix_t, wWinPix_t *, + wWinPix_t * ); void wTextSetPosition( wText_p bt, int pos ); @@ -483,14 +527,16 @@ typedef enum { wDrawLineDashDot, wDrawLineDashDotDot, wDrawLineCenter, - wDrawLinePhantom} - wDrawLineType_e; + wDrawLinePhantom +} +wDrawLineType_e; typedef enum { wPolyLineStraight, wPolyLineSmooth, - wPolyLineRound} - wPolyLine_e; + wPolyLineRound +} +wPolyLine_e; typedef int wAction_t; #define wActionMove (1) @@ -510,7 +556,10 @@ typedef int wAction_t; #define wActionScrollDown (15) #define wActionScrollLeft (16) #define wActionScrollRight (17) -#define wActionLast wActionScrollRight +#define wActionMDown (18) +#define wActionMDrag (19) +#define wActionMUp (20) +#define wActionLast wActionMUp #define wRGB(R,G,B)\ @@ -518,8 +567,9 @@ typedef int wAction_t; /* Creation CallBacks */ -typedef void (*wDrawRedrawCallBack_p)( wDraw_p, void *, wPos_t, wPos_t ); -typedef void (*wDrawActionCallBack_p)( wDraw_p, void*, wAction_t, wPos_t, wPos_t ); +typedef void (*wDrawRedrawCallBack_p)( wDraw_p, void *, wWinPix_t, wWinPix_t ); +typedef void (*wDrawActionCallBack_p)( wDraw_p, void*, wAction_t, wDrawPix_t, + wDrawPix_t ); /* Creation Options */ #define BD_TICKS (1L<<25) @@ -529,38 +579,44 @@ typedef void (*wDrawActionCallBack_p)( wDraw_p, void*, wAction_t, wPos_t, wPos_t #define BD_MODKEYS (1L<<29) /* Create: */ -wDraw_p wDrawCreate( wWin_p, wPos_t, wPos_t, const char *, long, - wPos_t, wPos_t, void *, - wDrawRedrawCallBack_p, wDrawActionCallBack_p ); +wDraw_p wDrawCreate( wWin_p, wWinPix_t, wWinPix_t, const char *, long, + wWinPix_t, wWinPix_t, void *, + wDrawRedrawCallBack_p, wDrawActionCallBack_p ); /* Draw: */ -void wDrawLine( wDraw_p, wPos_t, wPos_t, wPos_t, wPos_t, - wDrawWidth, wDrawLineType_e, wDrawColor, - wDrawOpts ); +void wDrawLine( wDraw_p, wDrawPix_t, wDrawPix_t, wDrawPix_t, wDrawPix_t, + wDrawWidth, wDrawLineType_e, wDrawColor, + wDrawOpts ); #define double2wAngle_t( A ) (A) typedef double wAngle_t; -void wDrawArc( wDraw_p, wPos_t, wPos_t, wPos_t, wAngle_t, wAngle_t, - int, wDrawWidth, wDrawLineType_e, wDrawColor, - wDrawOpts ); -void wDrawPoint( wDraw_p, wPos_t, wPos_t, wDrawColor, wDrawOpts ); +void wDrawArc( wDraw_p, wDrawPix_t, wDrawPix_t, wDrawPix_t, wAngle_t, + wAngle_t, + int, wDrawWidth, wDrawLineType_e, wDrawColor, + wDrawOpts ); +void wDrawPoint( wDraw_p, wDrawPix_t, wDrawPix_t, wDrawColor, wDrawOpts ); #define double2wFontSize_t( FS ) (FS) typedef double wFontSize_t; -void wDrawString( wDraw_p, wPos_t, wPos_t, wAngle_t, const char *, wFont_p, - wFontSize_t, wDrawColor, wDrawOpts ); -void wDrawFilledRectangle( wDraw_p, wPos_t, wPos_t, wPos_t, wPos_t, - wDrawColor, wDrawOpts ); -void wDrawPolygon( wDraw_p, wPos_t [][2], wPolyLine_e [], wIndex_t, wDrawColor, wDrawWidth, wDrawLineType_e, - wDrawOpts, int, int ); -void wDrawFilledCircle( wDraw_p, wPos_t, wPos_t, wPos_t, wDrawColor, wDrawOpts ); - -void wDrawGetTextSize( wPos_t *, wPos_t *, wPos_t *, wPos_t *, wDraw_p, const char *, wFont_p, - wFontSize_t ); +void wDrawString( wDraw_p, wDrawPix_t, wDrawPix_t, wAngle_t, const char *, + wFont_p, + wFontSize_t, wDrawColor, wDrawOpts ); +void wDrawFilledRectangle( wDraw_p, wDrawPix_t, wDrawPix_t, wDrawPix_t, + wDrawPix_t, + wDrawColor, wDrawOpts ); +void wDrawPolygon( wDraw_p, wDrawPix_t [][2], wPolyLine_e [], wIndex_t, + wDrawColor, wDrawWidth, wDrawLineType_e, + wDrawOpts, int, int ); +void wDrawFilledCircle( wDraw_p, wDrawPix_t, wDrawPix_t, wDrawPix_t, + wDrawColor, wDrawOpts ); + +void wDrawGetTextSize( wDrawPix_t *, wDrawPix_t *, wDrawPix_t *, wDrawPix_t *, + wDraw_p, const char *, wFont_p, + wFontSize_t ); void wDrawClear( wDraw_p ); void wDrawClearTemp( wDraw_p ); wBool_t wDrawSetTempMode( wDraw_p, wBool_t ); void wDrawDelayUpdate( wDraw_p, wBool_t ); -void wDrawClip( wDraw_p, wPos_t, wPos_t, wPos_t, wPos_t ); +void wDrawClip( wDraw_p, wDrawPix_t, wDrawPix_t, wDrawPix_t, wDrawPix_t ); wDrawColor wDrawColorGray( int ); wDrawColor wDrawFindColor( long ); long wDrawGetRGB( wDrawColor ); @@ -568,15 +624,16 @@ long wDrawGetRGB( wDrawColor ); /* Geometry */ double wDrawGetDPI( wDraw_p ); double wDrawGetMaxRadius( wDraw_p ); -void wDrawSetSize( wDraw_p, wPos_t, wPos_t, void * ); -void wDrawGetSize( wDraw_p, wPos_t *, wPos_t * ); +void wDrawSetSize( wDraw_p, wWinPix_t, wWinPix_t, void * ); +void wDrawGetSize( wDraw_p, wWinPix_t *, wWinPix_t * ); /* Bitmaps */ -wDrawBitMap_p wDrawBitMapCreate( wDraw_p, int, int, int, int, const unsigned char * ); -void wDrawBitMap( wDraw_p, wDrawBitMap_p, wPos_t, wPos_t, - wDrawColor, wDrawOpts ); +wDrawBitMap_p wDrawBitMapCreate( wDraw_p, int, int, int, int, + const unsigned char * ); +void wDrawBitMap( wDraw_p, wDrawBitMap_p, wDrawPix_t, wDrawPix_t, + wDrawColor, wDrawOpts ); -wDraw_p wBitMapCreate( wPos_t, wPos_t, int ); +wDraw_p wBitMapCreate( wWinPix_t, wWinPix_t, int ); wBool_t wBitMapDelete( wDraw_p ); wBool_t wBitMapWriteFile( wDraw_p, const char * ); @@ -585,7 +642,9 @@ void * wDrawGetContext( wDraw_p ); void wDrawSaveImage( wDraw_p ); void wDrawRestoreImage( wDraw_p ); int wDrawSetBackground( wDraw_p, char * path, char ** error); -void wDrawShowBackground( wDraw_p, wPos_t pos_x, wPos_t pos_y, wPos_t width, wAngle_t angle, int screen); +void wDrawCloneBackground(wDraw_p from, wDraw_p to); +void wDrawShowBackground( wDraw_p, wWinPix_t pos_x, wWinPix_t pos_y, + wWinPix_t width, wAngle_t angle, int screen); /*------------------------------------------------------------------------------ * @@ -594,7 +653,7 @@ void wDrawShowBackground( wDraw_p, wPos_t pos_x, wPos_t pos_y, wPos_t width, w void wInitializeFonts(); void wSelectFont( const char * ); wFontSize_t wSelectedFontSize( void ); -void wSetSelectionFontSize(wFontSize_t); +void wSetSelectedFontSize(wFontSize_t size); #define F_TIMES (1) #define F_HELV (2) wFont_p wStandardFont( int, wBool_t, wBool_t ); @@ -616,7 +675,7 @@ wDraw_p wPrintPageStart( void ); wBool_t wPrintPageEnd( wDraw_p ); void wPrintDocEnd( void ); wBool_t wPrintQuit( void ); -void wPrintClip( wPos_t, wPos_t, wPos_t, wPos_t ); +void wPrintClip( wDrawPix_t, wDrawPix_t, wDrawPix_t, wDrawPix_t ); const char * wPrintGetName( void ); @@ -656,37 +715,40 @@ typedef enum { wAccelKey_F10, wAccelKey_F11, wAccelKey_F12, - wAccelKey_Numpad_Add, - wAccelKey_Numpad_Subtract, - wAccelKey_LineFeed } - wAccelKey_e; + wAccelKey_Numpad_Add, + wAccelKey_Numpad_Subtract, + wAccelKey_LineFeed +} +wAccelKey_e; typedef enum { wModKey_None, wModKey_Alt, wModKey_Shift, - wModKey_Ctrl } - wModKey_e; + wModKey_Ctrl +} +wModKey_e; void wDoAccelHelp( wAccelKey_e key, void * ); /* Creation CallBacks */ typedef void (*wMenuCallBack_p)( void * ); typedef void (*wMenuListCallBack_p)( int, const char *, void * ); -typedef void (*wMenuToggleCallBack_p)( wBool_t , void * ); +typedef void (*wMenuCallBack_p)( void * ); typedef void (*wAccelKeyCallBack_p)( wAccelKey_e, void * ); typedef void (*wMenuTraceCallBack_p)( wMenu_p, const char *, void * ); /* Creation Options */ #define BM_ICON (1L<<0) -wMenu_p wMenuCreate( wWin_p, wPos_t, wPos_t, const char *, const char *, long ); +wMenu_p wMenuCreate( wWin_p, wWinPix_t, wWinPix_t, const char *, const char *, + long ); wMenu_p wMenuBarAdd( wWin_p, const char *, const char * ); wMenuPush_p wMenuPushCreate( wMenu_p, const char *, const char *, long, - wMenuCallBack_p, void * ); + wMenuCallBack_p, void * ); wMenuRadio_p wMenuRadioCreate( wMenu_p, const char *, const char *, long, - wMenuCallBack_p, void * ); + wMenuCallBack_p, void * ); wMenu_p wMenuMenuCreate( wMenu_p, const char *, const char * ); wMenu_p wMenuPopupCreate( wWin_p, const char * ); @@ -699,7 +761,8 @@ void wMenuListDelete( wMenuList_p, const char * ); const char * wMenuListGet( wMenuList_p, int, void ** ); void wMenuListClear( wMenuList_p ); -wMenuToggle_p wMenuToggleCreate( wMenu_p, const char *, const char *, long, wBool_t, wMenuToggleCallBack_p, void * ); +wMenuToggle_p wMenuToggleCreate( wMenu_p, const char *, const char *, long, + wBool_t, wMenuCallBack_p, void * ); wBool_t wMenuToggleSet( wMenuToggle_p, wBool_t ); wBool_t wMenuToggleGet( wMenuToggle_p ); void wMenuToggleEnable( wMenuToggle_p, wBool_t ); @@ -725,11 +788,13 @@ struct wFilSel_t; typedef enum { FS_SAVE, FS_LOAD, - FS_UPDATE } - wFilSelMode_e; + FS_UPDATE +} +wFilSelMode_e; typedef int (*wFilSelCallBack_p)( int files, char ** fileName, void * ); -struct wFilSel_t * wFilSelCreate(wWin_p, wFilSelMode_e, int, const char *, const char *, - wFilSelCallBack_p, void * ); +struct wFilSel_t * wFilSelCreate(wWin_p, wFilSelMode_e, int, const char *, + const char *, + wFilSelCallBack_p, void * ); int wFilSelect( struct wFilSel_t *, const char * ); @@ -741,8 +806,9 @@ int wFilSelect( struct wFilSel_t *, const char * ); typedef void (*wColorSelectButtonCallBack_p)( void *, wDrawColor ); wBool_t wColorSelect( const char *, wDrawColor * ); -wButton_p wColorSelectButtonCreate( wWin_p, wPos_t, wPos_t, const char *, const char *, - long, wPos_t, wDrawColor *, wColorSelectButtonCallBack_p, void * ); +wButton_p wColorSelectButtonCreate( wWin_p, wWinPix_t, wWinPix_t, const char *, + const char *, + long, wWinPix_t, wDrawColor *, wColorSelectButtonCallBack_p, void * ); void wColorSelectButtonSetColor( wButton_p, wDrawColor ); wDrawColor wColorSelectButtonGetColor( wButton_p ); @@ -756,21 +822,33 @@ char * wPrefGetString(const char *section, const char *name); char * wPrefGetStringBasic( const char *section, const char *name ); char * wPrefGetStringExt(const char *section, const char *name); +void wPrefsLoad(char * name); + void wPrefSetInteger(const char *, const char *, long ); -wBool_t wPrefGetInteger(const char *section, const char *name, long *result, long defaultValue); -wBool_t wPrefGetIntegerBasic(const char *section, const char *name, long *result, long defaultValue); -wBool_t wPrefGetIntegerExt(const char *section, const char *name, long *result, long defaultValue); +wBool_t wPrefGetInteger(const char *section, const char *name, long *result, + long defaultValue); +wBool_t wPrefGetIntegerBasic(const char *section, const char *name, + long *result, long defaultValue); +wBool_t wPrefGetIntegerExt(const char *section, const char *name, long *result, + long defaultValue); void wPrefSetFloat( const char *, const char *, double ); -wBool_t wPrefGetFloat(const char *section, const char *name, double *result, double defaultValue); -wBool_t wPrefGetFloatBasic(const char *section, const char *name, double *result, double defaultValue); -wBool_t wPrefGetFloatExt(const char *section, const char *name, double *result, double defaultValue); - -const char * wPrefGetSectionItem( const char * sectionName, wIndex_t * index, const char ** name ); -void wPrefFlush( void ); -void wPrefReset( void ); - -void CleanupCustom( void ); +wBool_t wPrefGetFloat(const char *section, const char *name, double *result, + double defaultValue); +wBool_t wPrefGetFloatBasic(const char *section, const char *name, + double *result, double defaultValue); +wBool_t wPrefGetFloatExt(const char *section, const char *name, double *result, + double defaultValue); + +//const char * wPrefGetSectionItem( const char * sectionName, wIndex_t * index, +// const char ** name ); +void wPrefFlush( char * name); +void wPrefReset( void ); +void wPrefTokenize(char* line, char** section, char** name, char** value); +void wPrefFormatLine(const char* section, const char* name, + const char* value, char* result); + +//void CleanupCustom( void ); /*------------------------------------------------------------------------------ * @@ -778,18 +856,30 @@ void CleanupCustom( void ); */ wStatus_p wStatusCreate( - wWin_p parent, - wPos_t x, - wPos_t y, - const char * labelStr, - wPos_t width, - const char *message ); + wWin_p parent, + wWinPix_t x, + wWinPix_t y, + const char * labelStr, + wWinPix_t width, + const char *message ); -wPos_t wStatusGetWidth(const char *testString); -wPos_t wStatusGetHeight(long flags); +wWinPix_t wStatusGetWidth(const char *testString); +wWinPix_t wStatusGetHeight(long flags); void wStatusSetValue(wStatus_p b, const char * arg); -void wStatusSetWidth(wStatus_p b, wPos_t width); +void wStatusSetWidth(wStatus_p b, wWinPix_t width); + +/*------------------------------------------------------------------------------ + * + * System-Information + */ + +char* wGetTempPath(void); +char* wGetOSVersion(void); +char* wGetProfileFilename(void); +char* wGetUserID(void); +const char* wGetUserHomeRootDir(void); +const char *wGetPlatformVersion(void); /*------------------------------------------------------------------------------- * User Preferences @@ -797,4 +887,7 @@ void wStatusSetWidth(wStatus_p b, wPos_t width); #define PREFSECTION "Preference" #define LARGEICON "LargeIcons" +#define DPISET "ScreenDPI" +#define PRINTSCALE "PrintScale" +#define PRINTTEXTSCALE "PrintTextScale" #endif |