From a69133d3177f025d9810bdf9305147f80bbb270e Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Fri, 25 Mar 2016 13:08:48 +0000 Subject: Separating platform-dependent from platform-independent code: make src/Fl.cxx cross-platform. File src/Fl_win32.cxx is now compiled instead of included in Fl.cxx. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11420 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/CMakeLists.txt | 3 +- src/Fl.cxx | 77 +++++--------------------- src/Fl_cocoa.mm | 3 - src/Fl_win32.cxx | 42 +++++++++++--- src/Fl_x.cxx | 24 ++------ src/Makefile | 10 ++-- src/drivers/Darwin/Fl_Darwin_System_Driver.cxx | 8 +++ src/drivers/Posix/Fl_Posix_System_Driver.cxx | 6 ++ src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx | 6 ++ src/fl_shortcut.cxx | 1 + 10 files changed, 80 insertions(+), 100 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2f95566aa..d59f848f0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -98,7 +98,6 @@ set(CPPFILES Fl_lock.cxx Fl_own_colormap.cxx Fl_visual.cxx - Fl_x.cxx filename_absolute.cxx filename_expand.cxx filename_ext.cxx @@ -182,6 +181,7 @@ if (USE_X11) drivers/Xlib/Fl_Translated_Xlib_Graphics_Driver.cxx drivers/Xlib/Fl_Xlib_Copy_Surface_Driver.cxx drivers/Xlib/Fl_Xlib_Image_Surface_Driver.cxx + Fl_x.cxx ) if (USE_XFT) set(DRIVER_FILES ${DRIVER_FILES} @@ -275,6 +275,7 @@ else () drivers/GDI/Fl_GDI_Graphics_Driver_vertex.cxx drivers/GDI/Fl_GDI_Copy_Surface_Driver.cxx drivers/GDI/Fl_GDI_Image_Surface_Driver.cxx + Fl_win32.cxx ) set(DRIVER_HEADER_FILES drivers/WinAPI/Fl_WinAPI_System_Driver.H diff --git a/src/Fl.cxx b/src/Fl.cxx index 34fe57453..27cc65b70 100644 --- a/src/Fl.cxx +++ b/src/Fl.cxx @@ -16,29 +16,17 @@ // http://www.fltk.org/str.php // +#include -#include "config_lib.h" - -/* We require Windows 2000 features (e.g. VK definitions) */ -#if defined(WIN32) -# if !defined(WINVER) || (WINVER < 0x0500) -# ifdef WINVER -# undef WINVER -# endif -# define WINVER 0x0500 -# endif -# if !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0500) -# ifdef _WIN32_WINNT -# undef _WIN32_WINNT -# endif -# define _WIN32_WINNT 0x0500 -# endif -#endif - -// recent versions of MinGW warn: "Please include winsock2.h before windows.h", -// hence we must include winsock2.h before FL/Fl.H (A.S. Dec. 2010, IMM May 2011) -#if defined(WIN32) && !defined(__CYGWIN__) -# include +#ifdef WIN32 +#elif defined(__APPLE__) +#elif defined(USE_SDL) +# pragma message "FL_SDL: implement the FLTK core in its own file" +#elif defined(ANDROID) +# pragma message "ANDROID: implement the FLTK core in its own file" +#elif defined(FL_PORTING) +# pragma message "FL_PORTING: implement the FLTK core in its own file" +# include "Fl_porting.cxx" #endif #include @@ -47,6 +35,7 @@ #include #include #include +#include #include #include @@ -56,27 +45,8 @@ # include #endif // DEBUG || DEBUG_WATCH -#ifdef WIN32 -#include // for fl_graphics_driver -#elif defined(__APPLE__) // PORTME: Fl_Screen_Driver - window driver and main loop -#elif defined(FL_PORTING) -# pragma message "FL_PORTING: implement global variables for your platform here" -#else // X11 -#endif - -#ifdef WIN32 -# include -void fl_free_fonts(void); -HBRUSH fl_brush_action(int action); -void fl_cleanup_pens(void); -void fl_release_dc(HWND,HDC); -void fl_cleanup_dc_list(void); -#elif defined(__APPLE__) // PORTME: Fl_Screen_Driver - platform functions -#endif // WIN32 - - // -// Runtime configuartion flags +// Runtime configuration flags // #ifdef FL_CFG_GFX_XLIB bool Fl::cfg_gfx_xlib = 1; @@ -152,24 +122,11 @@ bool Fl::cfg_sys_win32 = 1; bool Fl::cfg_sys_win32 = 0; #endif - // // Globals... // -// Pointers you can use to change FLTK to a foreign language. -// Note: Similar pointers are defined in FL/fl_ask.H and src/fl_ask.cxx -#if !defined(__APPLE__) || defined(FL_DOXYGEN) - const char* fl_local_alt = "Alt"; ///< string pointer used in shortcuts, you can change it to another language - const char* fl_local_ctrl = "Ctrl"; ///< string pointer used in shortcuts, you can change it to another language - const char* fl_local_meta = "Meta"; ///< string pointer used in shortcuts, you can change it to another language - const char* fl_local_shift = "Shift"; ///< string pointer used in shortcuts, you can change it to another language -#else - const char* fl_local_alt = "\xe2\x8c\xa5\\"; // U+2325 (option key) - const char* fl_local_ctrl = "\xe2\x8c\x83\\"; // U+2303 (up arrowhead) - const char* fl_local_meta = "\xe2\x8c\x98\\"; // U+2318 (place of interest sign) - const char* fl_local_shift = "\xe2\x87\xa7\\"; // U+21E7 (upwards white arrow) -#endif +Fl_Widget *fl_selection_requestor; #ifndef FL_DOXYGEN Fl_Widget *Fl::belowmouse_, @@ -1039,7 +996,6 @@ void fl_fix_focus() { } } -extern Fl_Widget *fl_selection_requestor; // from Fl_x.cxx // This function is called by ~Fl_Widget() and by Fl_Widget::deactivate() // and by Fl_Widget::hide(). It indicates that the widget does not want @@ -1459,8 +1415,6 @@ void Fl::paste(Fl_Widget &receiver) { } //////////////////////////////////////////////////////////////// -#include - void Fl_Widget::redraw() { damage(FL_DAMAGE_ALL); } @@ -1577,11 +1531,6 @@ void Fl_Widget::damage(uchar fl, int X, int Y, int W, int H) { } -#ifdef WIN32 -# include "Fl_win32.cxx" -#endif - - // // The following methods allow callbacks to schedule the deletion of // widgets at "safe" times. diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index 1762c17f5..ba61563c3 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -84,9 +84,6 @@ static void clipboard_check(void); static unsigned make_current_counts = 0; // if > 0, then Fl_Window::make_current() can be called only once static NSBitmapImageRep* rect_to_NSBitmapImageRep(Fl_Window *win, int x, int y, int w, int h); -// make this available on all platforms to make code maintainability easier -/*extern*/ class Fl_Widget *fl_selection_requestor; - int fl_mac_os_version = Fl_X::calc_mac_os_version(); // the version number of the running Mac OS X (e.g., 100604 for 10.6.4) // public variables diff --git a/src/Fl_win32.cxx b/src/Fl_win32.cxx index ef6cefff9..505c2b9ae 100644 --- a/src/Fl_win32.cxx +++ b/src/Fl_win32.cxx @@ -20,12 +20,37 @@ // in. Search other files for "WIN32" or filenames ending in _win32.cxx // for other system-specific code. -// This file must be #include'd in Fl.cxx and not compiled separately. +#if defined(WIN32) and !defined(FL_DOXYGEN) + +/* We require Windows 2000 features (e.g. VK definitions) */ +# if !defined(WINVER) || (WINVER < 0x0500) +# ifdef WINVER +# undef WINVER +# endif +# define WINVER 0x0500 +# endif +# if !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0500) +# ifdef _WIN32_WINNT +# undef _WIN32_WINNT +# endif +# define _WIN32_WINNT 0x0500 +# endif + +// recent versions of MinGW warn: "Please include winsock2.h before windows.h", +#if !defined(__CYGWIN__) +# include +#endif +#include +#include + +void fl_free_fonts(void); +void fl_release_dc(HWND,HDC); +void fl_cleanup_dc_list(void); -#ifndef FL_DOXYGEN #include #include -#include +#include // for fl_graphics_driver +#include "drivers/WinAPI/Fl_WinAPI_Window_Driver.H" #include #include #include @@ -63,6 +88,12 @@ #include #include +extern bool fl_clipboard_notify_empty(void); +extern void fl_trigger_clipboard_notify(int source); +extern HBRUSH fl_brush_action(int action); +extern void fl_cleanup_pens(void); + + // // USE_ASYNC_SELECT - define it if you have WSAAsyncSelect()... // USE_ASYNC_SELECT is OBSOLETED in 1.3 for the following reasons: @@ -85,9 +116,6 @@ for async mode proper operation, not mentioning the side effects... */ -// make this available on all platforms to make code maintainability easier -class Fl_Widget *fl_selection_requestor; - // Internal functions static void fl_clipboard_notify_target(HWND wnd); static void fl_clipboard_notify_untarget(HWND wnd); @@ -2467,7 +2495,7 @@ void preparePrintFront(void) } #endif // USE_PRINT_BUTTON -#endif // FL_DOXYGEN +#endif // defined(WIN32) and !defined(FL_DOXYGEN) // // End of "$Id$". diff --git a/src/Fl_x.cxx b/src/Fl_x.cxx index 068588471..aa8dc4b33 100644 --- a/src/Fl_x.cxx +++ b/src/Fl_x.cxx @@ -16,25 +16,7 @@ // http://www.fltk.org/str.php // -#include - -// make this available on all platforms to make code maintainability easier -class Fl_Widget *fl_selection_requestor; - -#ifdef WIN32 -//# include "Fl_win32.cxx" -#elif defined(__APPLE__) // PORTME: Fl_System_Driver - platform window driver - // PORTME: Fl_Screen_Driver - // PORTME: Fl_Window_Driver -//# include "Fl_mac.cxx" // now Fl_cocoa.mm -#elif defined(USE_SDL) -# pragma message "FL_SDL: implement the FLTK core in its own file" -#elif defined(ANDROID) -# pragma message "ANDROID: implement the FLTK core in its own file" -#elif defined(FL_PORTING) -# pragma message "FL_PORTING: implement the FLTK core in its own file" -# include "Fl_porting.cxx" -#elif !defined(FL_DOXYGEN) +#if !defined(FL_DOXYGEN) # define CONSOLIDATE_MOTION 1 /**** Define this if your keyboard lacks a backspace key... ****/ @@ -89,6 +71,8 @@ static bool have_xfixes = false; # include # endif +extern Fl_Widget *fl_selection_requestor; + //////////////////////////////////////////////////////////////// // interface to poll/select call: @@ -2986,7 +2970,7 @@ static int unused = prepare_print_button(); #endif // USE_PRINT_BUTTON -#endif +#endif // !defined(FL_DOXYGEN) // // End of "$Id$". diff --git a/src/Makefile b/src/Makefile index ab9e43866..e77d0f8ec 100644 --- a/src/Makefile +++ b/src/Makefile @@ -117,7 +117,6 @@ CPPFILES = \ Fl_lock.cxx \ Fl_own_colormap.cxx \ Fl_visual.cxx \ - Fl_x.cxx \ filename_absolute.cxx \ filename_expand.cxx \ filename_ext.cxx \ @@ -252,7 +251,8 @@ XLIBCPPFILES = \ drivers/X11/Fl_X11_Window_Driver.cxx \ drivers/X11/Fl_X11_Screen_Driver.cxx \ drivers/Posix/Fl_Posix_System_Driver.cxx \ - drivers/Posix/Fl_Posix_Printer_Driver.cxx + drivers/Posix/Fl_Posix_Printer_Driver.cxx \ + Fl_x.cxx XLIBFONTFILES = \ drivers/Xlib/Fl_Xlib_Graphics_Driver_font_x.cxx @@ -274,7 +274,8 @@ GDICPPFILES = \ drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx \ drivers/WinAPI/Fl_WinAPI_Screen_Driver.cxx \ drivers/WinAPI/Fl_WinAPI_System_Driver.cxx \ - drivers/WinAPI/Fl_WinAPI_Printer_Driver.cxx + drivers/WinAPI/Fl_WinAPI_Printer_Driver.cxx \ + Fl_win32.cxx PSCPPFILES = \ drivers/PostScript/Fl_PostScript.cxx \ @@ -576,7 +577,7 @@ include makedepend Fl_get_key.o: Fl_get_key_mac.cxx Fl_get_key_win32.cxx Fl_Native_File_Chooser.o : Fl_Native_File_Chooser_WIN32.cxx Fl_Native_File_Chooser_MAC.o: Fl_Native_File_Chooser_MAC.mm -Fl.o: Fl_win32.cxx +Fl_win32.o: Fl_win32.cxx Fl_cocoa.o: Fl_cocoa.mm fl_color.o: fl_dnd.o: fl_dnd_win32.cxx fl_dnd_x.cxx @@ -625,7 +626,6 @@ fl_vertex.o: ../FL/mac.H ../FL/win32.H Fl_visual.o: ../FL/mac.H ../FL/win32.H Fl_Window_fullscreen.o: ../FL/mac.H ../FL/win32.H Fl_Window_iconize.o: ../FL/mac.H ../FL/win32.H -Fl_x.o: ../FL/mac.H ../FL/win32.H gl_draw.o: ../FL/mac.H ../FL/win32.H gl_start.o: ../FL/mac.H ../FL/win32.H diff --git a/src/drivers/Darwin/Fl_Darwin_System_Driver.cxx b/src/drivers/Darwin/Fl_Darwin_System_Driver.cxx index 1b08b30e4..fa6893784 100644 --- a/src/drivers/Darwin/Fl_Darwin_System_Driver.cxx +++ b/src/drivers/Darwin/Fl_Darwin_System_Driver.cxx @@ -20,6 +20,14 @@ #include "../../config_lib.h" #include "Fl_Darwin_System_Driver.H" +//const char* fl_local_alt = "\xe2\x8c\xa5\\"; // U+2325 (option key) +const char* fl_local_alt = "⌥\\"; // U+2325 (option key) +//const char* fl_local_ctrl = "\xe2\x8c\x83\\"; // U+2303 (up arrowhead) +const char* fl_local_ctrl = "⌃\\"; // U+2303 (up arrowhead) +//const char* fl_local_meta = "\xe2\x8c\x98\\"; // U+2318 (place of interest sign) +const char* fl_local_meta = "⌘\\"; // U+2318 (place of interest sign) +//const char* fl_local_shift = "\xe2\x87\xa7\\"; // U+21E7 (upwards white arrow) +const char* fl_local_shift = "⇧\\"; // U+21E7 (upwards white arrow) // // End of "$Id$". diff --git a/src/drivers/Posix/Fl_Posix_System_Driver.cxx b/src/drivers/Posix/Fl_Posix_System_Driver.cxx index 866be9b3d..763dca752 100644 --- a/src/drivers/Posix/Fl_Posix_System_Driver.cxx +++ b/src/drivers/Posix/Fl_Posix_System_Driver.cxx @@ -20,6 +20,12 @@ #include "../../config_lib.h" #include "Fl_Posix_System_Driver.H" +// Pointers you can use to change FLTK to a foreign language. +// Note: Similar pointers are defined in FL/fl_ask.H and src/fl_ask.cxx +const char* fl_local_alt = "Alt"; ///< string pointer used in shortcuts, you can change it to another language +const char* fl_local_ctrl = "Ctrl"; ///< string pointer used in shortcuts, you can change it to another language +const char* fl_local_meta = "Meta"; ///< string pointer used in shortcuts, you can change it to another language +const char* fl_local_shift = "Shift"; ///< string pointer used in shortcuts, you can change it to another language // // End of "$Id$". diff --git a/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx b/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx index 031b0aac2..1a59a2c05 100644 --- a/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx +++ b/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx @@ -20,6 +20,12 @@ #include "../../config_lib.h" #include "Fl_WinAPI_System_Driver.H" +#if !defined(FL_DOXYGEN) +const char* fl_local_alt = "Alt"; +const char* fl_local_ctrl = "Ctrl"; +const char* fl_local_meta = "Meta"; +const char* fl_local_shift = "Shift"; +#endif // // End of "$Id$". diff --git a/src/fl_shortcut.cxx b/src/fl_shortcut.cxx index fc1a14c19..3602f913e 100644 --- a/src/fl_shortcut.cxx +++ b/src/fl_shortcut.cxx @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include "flstring.h" -- cgit v1.2.3