]> git.mxchange.org Git - flightgear.git/blob - src/GUI/gui.cxx
Melchior: Make line wrapping in textboxes configurable, and enable it by default
[flightgear.git] / src / GUI / gui.cxx
1 /**************************************************************************
2  * gui.cxx
3  *
4  * Written 1998 by Durk Talsma, started Juni, 1998.  For the flight gear
5  * project.
6  *
7  * Additional mouse supported added by David Megginson, 1999.
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License as
11  * published by the Free Software Foundation; either version 2 of the
12  * License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22  *
23  * $Id$
24  **************************************************************************/
25
26
27 #ifdef HAVE_CONFIG_H
28 #  include <config.h>
29 #endif
30
31 #include <simgear/compiler.h>
32
33 #ifdef HAVE_WINDOWS_H
34 #  include <windows.h>
35 #endif
36
37 #include <simgear/structure/exception.hxx>
38 #include <simgear/misc/sg_path.hxx>
39 #include <simgear/props/props.hxx>
40 #include <simgear/props/props_io.hxx>
41
42 #include <plib/pu.h>
43
44 #include <Include/general.hxx>
45 #include <Main/main.hxx>
46 #include <Main/globals.hxx>
47 #include <Main/fg_props.hxx>
48
49 #include "gui.h"
50 #include "gui_local.hxx"
51 #include "preset_dlg.hxx"
52 #include "layout.hxx"
53
54 extern void initDialog (void);
55 extern void mkDialogInit (void);
56 extern void ConfirmExitDialogInit(void);
57
58
59 puFont guiFnt = 0;
60 fntTexFont *guiFntHandle = 0;
61
62
63 /* -------------------------------------------------------------------------
64 init the gui
65 _____________________________________________________________________*/
66
67
68 void guiInit()
69 {
70     char *mesa_win_state;
71
72     // Initialize PUI
73     puInit();
74     puSetDefaultStyle         ( PUSTYLE_SMALL_SHADED ); //PUSTYLE_DEFAULT
75     puSetDefaultColourScheme  (0.8, 0.8, 0.9, 1);
76
77     initDialog();
78
79     // Next check home directory
80     SGPath fntpath;
81     char* envp = ::getenv( "FG_FONTS" );
82     if ( envp != NULL ) {
83         fntpath.set( envp );
84     } else {
85         fntpath.set( globals->get_fg_root() );
86         fntpath.append( "Fonts" );
87     }
88
89     // Install our fast fonts
90     SGPropertyNode *locale = globals->get_locale();
91     fntpath.append(locale->getStringValue("font", "typewriter.txf"));
92     guiFntHandle = new fntTexFont ;
93     guiFntHandle -> load ( (char *)fntpath.c_str() ) ;
94     puFont GuiFont ( guiFntHandle, 15 ) ;
95     puSetDefaultFonts( GuiFont, GuiFont ) ;
96     guiFnt = puGetDefaultLabelFont();
97
98     LayoutWidget::setDefaultFont(&GuiFont, 15);
99   
100     if (!fgHasNode("/sim/startup/mouse-pointer")) {
101         // no preference specified for mouse pointer, attempt to autodetect...
102         // Determine if we need to render the cursor, or if the windowing
103         // system will do it.  First test if we are rendering with glide.
104         if ( strstr ( general.get_glRenderer(), "Glide" ) ) {
105             // Test for the MESA_GLX_FX env variable
106             if ( (mesa_win_state = getenv( "MESA_GLX_FX" )) != NULL) {
107                 // test if we are fullscreen mesa/glide
108                 if ( (mesa_win_state[0] == 'f') ||
109                      (mesa_win_state[0] == 'F') ) {
110                     puShowCursor ();
111                 }
112             }
113         }
114 //        mouse_active = ~mouse_active;
115     } else if ( !fgGetBool("/sim/startup/mouse-pointer") ) {
116         // don't show pointer
117     } else {
118         // force showing pointer
119         puShowCursor();
120 //        mouse_active = ~mouse_active;
121     }
122         
123     // MOUSE_VIEW mode stuff
124         initMouseQuat();
125
126     // Set up our Dialog Boxes
127     ConfirmExitDialogInit();
128     fgPresetInit();
129         
130     mkDialogInit();
131 }