diff options
| author | Manolo Gouy <Manolo> | 2016-03-28 09:25:11 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2016-03-28 09:25:11 +0000 |
| commit | 6284720098cb3682f950db427c95ac87c2a10b3c (patch) | |
| tree | dbcfaa3ff88b889c91856f79136a6e25cf7ca914 /src/Fl_arg.cxx | |
| parent | 3dfec155adf812941e4478b210d1bee4dbd56c01 (diff) | |
Rewrite file src/Fl_arg.cxx under the driver model. Begin giving flesh to the Fl_System_Driver class.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11448 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_arg.cxx')
| -rw-r--r-- | src/Fl_arg.cxx | 193 |
1 files changed, 12 insertions, 181 deletions
diff --git a/src/Fl_arg.cxx b/src/Fl_arg.cxx index 8d56ac22e..5be54dc5e 100644 --- a/src/Fl_arg.cxx +++ b/src/Fl_arg.cxx @@ -20,34 +20,15 @@ // You do not need to call this! Feel free to make up your own switches. #include <FL/Fl.H> -#include <FL/x.H> #include <FL/Fl_Window.H> #include <FL/Fl_Window_Driver.H> -#include <FL/Fl_Graphics_Driver.H> +#include <FL/Fl_System_Driver.H> #include <FL/Fl_Tooltip.H> #include <FL/filename.H> #include <FL/fl_draw.H> #include <ctype.h> #include "flstring.h" -#if defined(WIN32) || defined(__APPLE__) // PORTME: Fl_System_Driver - command line arguments -#elif defined(FL_PORTING) -# pragma message "FL_PORTING: implement special command line handling" -#else -#endif - -#if defined(WIN32) || defined(__APPLE__) || defined(FL_PORTING) // PORTME: Fl_System_Driver - parse geometry -int XParseGeometry(const char*, int*, int*, unsigned int*, unsigned int*); -# define NoValue 0x0000 -# define XValue 0x0001 -# define YValue 0x0002 -# define WidthValue 0x0004 -# define HeightValue 0x0008 -# define AllValues 0x000F -# define XNegative 0x0010 -# define YNegative 0x0020 -#endif - static int fl_match(const char *a, const char *s, int atleast = 1) { const char *b = s; while (*a && (*a == *b || tolower(*a) == *b)) {a++; b++;} @@ -176,13 +157,8 @@ int Fl::arg(int argc, char **argv, int &i) { Fl_Tooltip::disable(); i++; return 1; -#ifdef __APPLE__ // PORTME: Fl_System_Driver - platform command line - // The Finder application in MacOS X passes the "-psn_N_NNNNN" option - // to all apps... - } else if (strncmp(s, "psn_", 4) == 0) { + } else if (Fl_System_Driver::driver()->single_arg(s)) { i++; - return 1; -#endif // __APPLE__ // PORTME: Fl_System_Driver - platform command line } const char *v = argv[i+1]; @@ -192,20 +168,15 @@ int Fl::arg(int argc, char **argv, int &i) { if (fl_match(s, "geometry")) { int flags, gx, gy; unsigned int gw, gh; - flags = XParseGeometry(v, &gx, &gy, &gw, &gh); + flags = Fl_System_Driver::driver()->XParseGeometry(v, &gx, &gy, &gw, &gh); if (!flags) return 0; geometry = v; -#if !defined(WIN32) && !defined(__APPLE__) // PORTME: Fl_System_Driver - platform command line } else if (fl_match(s, "display", 2)) { - Fl::display(v); -#endif + Fl_System_Driver::driver()->display_arg(v); -#ifdef __APPLE__ // PORTME: Fl_System_Driver - platform command line - // Xcode in MacOS X may pass "-NSDocumentRevisionsDebugMode YES" - } else if (strcmp(s, "NSDocumentRevisionsDebugMode") == 0) { + } else if (Fl_System_Driver::driver()->arg_and_value(s, v)) { // nothing to do -#endif // __APPLE__ // PORTME: Fl_System_Driver - platform command line } else if (fl_match(s, "title", 2)) { title = v; @@ -225,7 +196,9 @@ int Fl::arg(int argc, char **argv, int &i) { } else if (fl_match(s, "scheme", 1)) { Fl::scheme(v); - } else return 0; // unrecognized + } else { + return 0; // unrecognized + } i += 2; return 2; @@ -310,16 +283,16 @@ void Fl_Window::show(int argc, char **argv) { if (!beenhere) { if (geometry) { int fl = 0, gx = x(), gy = y(); unsigned int gw = w(), gh = h(); - fl = XParseGeometry(geometry, &gx, &gy, &gw, &gh); - if (fl & XNegative) gx = Fl::w()-w()+gx; - if (fl & YNegative) gy = Fl::h()-h()+gy; + fl = Fl_System_Driver::driver()->XParseGeometry(geometry, &gx, &gy, &gw, &gh); + if (fl & Fl_System_Driver::flXNegative) gx = Fl::w()-w()+gx; + if (fl & Fl_System_Driver::flYNegative) gy = Fl::h()-h()+gy; // int mw,mh; minsize(mw,mh); // if (mw > gw) gw = mw; // if (mh > gh) gh = mh; Fl_Widget *r = resizable(); if (!r) resizable(this); // for WIN32 we assume window is not mapped yet: - if (fl & (XValue | YValue)) + if (fl & (Fl_System_Driver::flXValue | Fl_System_Driver::flYValue)) x(-1), resize(gx,gy,gw,gh); else size(gw,gh); @@ -379,148 +352,6 @@ void Fl::args(int argc, char **argv) { int i; if (Fl::args(argc,argv,i) < argc) Fl::error(helpmsg); } -#if defined(WIN32) || defined(__APPLE__) // PORTME: Fl_System_Driver - platform command line arguments - -/* the following function was stolen from the X sources as indicated. */ - -/* Copyright Massachusetts Institute of Technology 1985, 1986, 1987 */ -/* $XConsortium: XParseGeom.c,v 11.18 91/02/21 17:23:05 rws Exp $ */ - -/* -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation, and that the name of M.I.T. not be used in advertising or -publicity pertaining to distribution of the software without specific, -written prior permission. M.I.T. makes no representations about the -suitability of this software for any purpose. It is provided "as is" -without express or implied warranty. -*/ - -/* - * XParseGeometry parses strings of the form - * "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where - * width, height, xoffset, and yoffset are unsigned integers. - * Example: "=80x24+300-49" - * The equal sign is optional. - * It returns a bitmask that indicates which of the four values - * were actually found in the string. For each value found, - * the corresponding argument is updated; for each value - * not found, the corresponding argument is left unchanged. - */ - -static int ReadInteger(char* string, char** NextString) -{ - int Result = 0; - int Sign = 1; - - if (*string == '+') - string++; - else if (*string == '-') { - string++; - Sign = -1; - } - for (; (*string >= '0') && (*string <= '9'); string++) { - Result = (Result * 10) + (*string - '0'); - } - *NextString = string; - if (Sign >= 0) - return (Result); - else - return (-Result); -} - -int XParseGeometry(const char* string, int* x, int* y, - unsigned int* width, unsigned int* height) -{ - int mask = NoValue; - char *strind; - unsigned int tempWidth = 0, tempHeight = 0; - int tempX = 0, tempY = 0; - char *nextCharacter; - - if ( (string == NULL) || (*string == '\0')) return(mask); - if (*string == '=') - string++; /* ignore possible '=' at beg of geometry spec */ - - strind = (char *)string; - if (*strind != '+' && *strind != '-' && *strind != 'x') { - tempWidth = ReadInteger(strind, &nextCharacter); - if (strind == nextCharacter) - return (0); - strind = nextCharacter; - mask |= WidthValue; - } - - if (*strind == 'x' || *strind == 'X') { - strind++; - tempHeight = ReadInteger(strind, &nextCharacter); - if (strind == nextCharacter) - return (0); - strind = nextCharacter; - mask |= HeightValue; - } - - if ((*strind == '+') || (*strind == '-')) { - if (*strind == '-') { - strind++; - tempX = -ReadInteger(strind, &nextCharacter); - if (strind == nextCharacter) - return (0); - strind = nextCharacter; - mask |= XNegative; - - } else { - strind++; - tempX = ReadInteger(strind, &nextCharacter); - if (strind == nextCharacter) - return(0); - strind = nextCharacter; - } - mask |= XValue; - if ((*strind == '+') || (*strind == '-')) { - if (*strind == '-') { - strind++; - tempY = -ReadInteger(strind, &nextCharacter); - if (strind == nextCharacter) - return(0); - strind = nextCharacter; - mask |= YNegative; - - } else { - strind++; - tempY = ReadInteger(strind, &nextCharacter); - if (strind == nextCharacter) - return(0); - strind = nextCharacter; - } - mask |= YValue; - } - } - - /* If strind isn't at the end of the string the it's an invalid - geometry specification. */ - - if (*strind != '\0') return (0); - - if (mask & XValue) - *x = tempX; - if (mask & YValue) - *y = tempY; - if (mask & WidthValue) - *width = tempWidth; - if (mask & HeightValue) - *height = tempHeight; - return (mask); -} - -#elif defined(FL_PORTING) - -int XParseGeometry(const char* string, int* x, int* y, unsigned int* width, unsigned int* height) { return 0; } - -#endif // ifdef WIN32 - // // End of "$Id$". // |
