From b68b751fd46b633d6eb394b842690edc9be3c2f1 Mon Sep 17 00:00:00 2001 From: mfranz Date: Sun, 27 Jul 2008 09:39:10 +0000 Subject: [PATCH] get rid of mouse.cxx and pu{Show|Hide}Cursor() --- FlightGear.dsp | 15 --- projects/VC7.1/FlightGear.vcproj | 3 - projects/VC8/FlightGearLib.vcproj | 4 - src/GUI/Makefile.am | 2 +- src/GUI/README | 1 - src/GUI/gui.h | 6 -- src/GUI/gui_funcs.cxx | 59 +++-------- src/GUI/mouse.cxx | 169 ------------------------------ src/Main/renderer.cxx | 2 - 9 files changed, 14 insertions(+), 247 deletions(-) delete mode 100644 src/GUI/mouse.cxx diff --git a/FlightGear.dsp b/FlightGear.dsp index 86e3033fc..593c9766d 100644 --- a/FlightGear.dsp +++ b/FlightGear.dsp @@ -6956,21 +6956,6 @@ SOURCE=.\src\GUI\gui_local.hxx # End Source File # Begin Source File -SOURCE=.\src\GUI\mouse.cxx - -!IF "$(CFG)" == "FlightGear - Win32 Release" - -# PROP Intermediate_Dir "Release\Lib_GUI" - -!ELSEIF "$(CFG)" == "FlightGear - Win32 Debug" - -# PROP Intermediate_Dir "Debug\Lib_GUI" - -!ENDIF - -# End Source File -# Begin Source File - SOURCE=.\src\GUI\fonts.cxx !IF "$(CFG)" == "FlightGear - Win32 Release" diff --git a/projects/VC7.1/FlightGear.vcproj b/projects/VC7.1/FlightGear.vcproj index c5ea2cc57..76c4f40cd 100755 --- a/projects/VC7.1/FlightGear.vcproj +++ b/projects/VC7.1/FlightGear.vcproj @@ -1781,9 +1781,6 @@ - - diff --git a/projects/VC8/FlightGearLib.vcproj b/projects/VC8/FlightGearLib.vcproj index 8b5729bb0..58e0ba086 100755 --- a/projects/VC8/FlightGearLib.vcproj +++ b/projects/VC8/FlightGearLib.vcproj @@ -2922,10 +2922,6 @@ RelativePath="..\..\src\sound\morse.cxx" > - - diff --git a/src/GUI/Makefile.am b/src/GUI/Makefile.am index f858803ab..512e5d192 100644 --- a/src/GUI/Makefile.am +++ b/src/GUI/Makefile.am @@ -6,7 +6,7 @@ libGUI_a_SOURCES = \ dialog.cxx dialog.hxx \ menubar.cxx menubar.hxx \ gui.cxx gui.h gui_funcs.cxx \ - mouse.cxx fonts.cxx \ + fonts.cxx \ AirportList.cxx AirportList.hxx \ property_list.cxx property_list.hxx \ layout.cxx layout-props.cxx layout.hxx \ diff --git a/src/GUI/README b/src/GUI/README index 2c3b8a34a..9ad2d5f44 100644 --- a/src/GUI/README +++ b/src/GUI/README @@ -10,7 +10,6 @@ dialog.[ch]xx XML-configurable dialog box. gui.cxx, gui.h Top-level GUI functions (deprecated). gui_funcs.cxx Implementation of internal GUI functions (deprecated). menubar.[ch]xx XML-configurable menu bar. -mouse.cxx Old GUI mouse support (deprecated). new_gui.[ch]xx Top-level for the GUI subsystem. diff --git a/src/GUI/gui.h b/src/GUI/gui.h index 7548ed5a9..f778349dd 100644 --- a/src/GUI/gui.h +++ b/src/GUI/gui.h @@ -73,10 +73,4 @@ typedef struct { } __fg_gui_fn_t; extern const __fg_gui_fn_t __fg_gui_fn[]; -// mouse.cxx -extern void guiInitMouse(int width, int height); -extern void maybeToggleMouse( void ); -extern void TurnCursorOn( void ); -extern void TurnCursorOff( void ); - #endif // _GUI_H_ diff --git a/src/GUI/gui_funcs.cxx b/src/GUI/gui_funcs.cxx index 3d089161c..833649411 100644 --- a/src/GUI/gui_funcs.cxx +++ b/src/GUI/gui_funcs.cxx @@ -40,9 +40,10 @@ #include #include +#include +#include #include -#include // for help call back #ifdef WIN32 @@ -52,22 +53,11 @@ # endif #endif -#include - -#include #include #include #include -#include -#include -#include -#include #include -#include -#include
-#include
-#include
#include
#include
#include
@@ -81,8 +71,7 @@ #include "gui.h" -SG_USING_STD(string); -SG_USING_STD(cout); +using std::string; #if defined( TR_HIRES_SNAP) @@ -230,7 +219,6 @@ void fgHiResDump() { FILE *f; string message; - bool show_pu_cursor = false; bool menu_status = fgGetBool("/sim/menubar/visibility"); char *filename = new char [24]; static int count = 1; @@ -244,11 +232,8 @@ void fgHiResDump() } fgSetBool("/sim/menubar/visibility", false); - TurnCursorOff(); - if ( !puCursorIsHidden() ) { - show_pu_cursor = true; - puHideCursor(); - } + int mouse = fgGetMouseCursor(); + fgSetMouseCursor(MOUSE_CURSOR_NONE); FGRenderer *renderer = globals->get_renderer(); // renderer->init(); @@ -415,11 +400,7 @@ void fgHiResDump() delete [] filename; - if ( show_pu_cursor ) { - puShowCursor(); - } - - TurnCursorOn(); + fgSetMouseCursor(mouse); fgSetBool("/sim/menubar/visibility", menu_status); if ( !freeze ) { @@ -469,12 +450,8 @@ GLubyte *hiResScreenCapture( int multiplier ) #if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__) // win32 print screen function void printScreen () { - bool show_pu_cursor = false; - TurnCursorOff(); - if ( !puCursorIsHidden() ) { - show_pu_cursor = true; - puHideCursor(); - } + int mouse = fgGetMouseCursor(); + fgSetMouseCursor(MOUSE_CURSOR_NONE); CGlPrinter p( CGlPrinter::PRINT_BITMAP ); int cur_width = fgGetInt("/sim/startup/xsize"); @@ -482,10 +459,7 @@ void printScreen () { p.Begin( "FlightGear", cur_width*3, cur_height*3 ); p.End( hiResScreenCapture(3) ); - if ( show_pu_cursor ) { - puShowCursor(); - } - TurnCursorOn(); + fgSetMouseCursor(mouse); } #endif // #ifdef WIN32 @@ -502,7 +476,6 @@ void fgHiResDumpWrapper () { // do a screen snap shot bool fgDumpSnapShot () { - bool show_pu_cursor = false; static SGConstPropertyNode_ptr master_freeze = fgGetNode("/sim/freeze/master"); bool freeze = master_freeze->getBoolValue(); @@ -510,11 +483,9 @@ bool fgDumpSnapShot () { fgSetBool("/sim/freeze/master", true); } - TurnCursorOff(); - if ( !puCursorIsHidden() ) { - show_pu_cursor = true; - puHideCursor(); - } + int mouse = fgGetMouseCursor(); + fgSetMouseCursor(MOUSE_CURSOR_NONE); + fgSetBool("/sim/signals/screenshot", true); FGRenderer *renderer = globals->get_renderer(); @@ -555,11 +526,7 @@ bool fgDumpSnapShot () { fgSetString("/sim/paths/screenshot-last", path.c_str()); fgSetBool("/sim/signals/screenshot", false); - if ( show_pu_cursor ) { - puShowCursor(); - } - - TurnCursorOn(); + fgSetMouseCursor(mouse); if ( !freeze ) { fgSetBool("/sim/freeze/master", false); diff --git a/src/GUI/mouse.cxx b/src/GUI/mouse.cxx deleted file mode 100644 index d39599cec..000000000 --- a/src/GUI/mouse.cxx +++ /dev/null @@ -1,169 +0,0 @@ -/************************************************************************** - * gui.cxx - * - * Written 1998 by Durk Talsma, started Juni, 1998. For the flight gear - * project. - * - * Additional mouse supported added by David Megginson, 1999. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $Id$ - **************************************************************************/ - - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include - -#ifdef HAVE_WINDOWS_H -# include -#endif - -#include
- -#include - -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include
-#include
-#include
- -#include "gui.h" - -SG_USING_STD(string); -SG_USING_STD(cout); - -/* -------------------------------------------------------------------- -Mouse stuff ----------------------------------------------------------------------*/ - -#if defined(WIN32) || defined(__CYGWIN32__) -#define WIN32_CURSOR_TWEAKS -// uncomment this for cursor to turn off when menu is disabled -// #define WIN32_CURSOR_TWEAKS_OFF -#elif (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9) -#define X_CURSOR_TWEAKS -#endif - -static int mouse_active = 0; - -static int MOUSE_XSIZE = 0; -static int MOUSE_YSIZE = 0; - -typedef enum { - MOUSE_POINTER, - MOUSE_YOKE, - MOUSE_VIEW -} MouseMode; - -/* -------------------------------------------------------------------- -Support for mouse as control yoke (david@megginson.com) - -- right button toggles between pointer and yoke -- horizontal drag with no buttons moves ailerons -- vertical drag with no buttons moves elevators -- horizontal drag with left button moves brakes (left=on) -- vertical drag with left button moves throttle (up=more) -- horizontal drag with middle button moves rudder -- vertical drag with middle button moves trim - -For the *_sensitivity variables, a lower number means more sensitive. - -TODO: figure out how to keep pointer from leaving window in yoke mode. -TODO: add thresholds and null zones -TODO: sensitivity should be configurable at user option. -TODO: allow differential braking (this will be useful if FlightGear - ever supports tail-draggers like the DC-3) ----------------------------------------------------------------------*/ - -MouseMode mouse_mode = MOUSE_POINTER; - -void guiInitMouse(int width, int height) -{ - MOUSE_XSIZE = width; - MOUSE_YSIZE = height; -} - -void TurnCursorOn( void ) -{ - mouse_active = ~0; -#if defined(WIN32) - switch (mouse_mode) { - case MOUSE_POINTER: - fgSetMouseCursor(MOUSE_CURSOR_POINTER); - break; - case MOUSE_YOKE: - fgSetMouseCursor(MOUSE_CURSOR_CROSSHAIR); - break; - case MOUSE_VIEW: - fgSetMouseCursor(MOUSE_CURSOR_LEFTRIGHT); - break; - } -#endif -#if defined(X_CURSOR_TWEAKS) - fgWarpMouse( MOUSE_XSIZE/2, MOUSE_YSIZE/2 ); -#endif -} - -void TurnCursorOff( void ) -{ - mouse_active = 0; -#if defined(WIN32_CURSOR_TWEAKS) - fgSetMouseCursor(MOUSE_CURSOR_NONE); -#elif defined(X_CURSOR_TWEAKS) - fgWarpMouse( MOUSE_XSIZE, MOUSE_YSIZE ); -#endif -} - -void maybeToggleMouse( void ) -{ -#if defined(WIN32_CURSOR_TWEAKS_OFF) - static int first_time = ~0; - static int mouse_changed = 0; - - if ( first_time ) { - if(!mouse_active) { - mouse_changed = ~mouse_changed; - TurnCursorOn(); - } - } else { - if( mouse_mode != MOUSE_POINTER ) - return; - if( mouse_changed ) { - mouse_changed = ~mouse_changed; - if(mouse_active) { - TurnCursorOff(); - } - } - } - first_time = ~first_time; -#endif // #ifdef WIN32 -} - diff --git a/src/Main/renderer.cxx b/src/Main/renderer.cxx index 6eafe627f..f40a50452 100644 --- a/src/Main/renderer.cxx +++ b/src/Main/renderer.cxx @@ -833,8 +833,6 @@ FGRenderer::resize( int width, int height ) { if (height != lastheight) fgSetInt("/sim/startup/ysize", lastheight = height); - guiInitMouse(width, height); - // for all views FGViewMgr *viewmgr = globals->get_viewmgr(); if (viewmgr) {