]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/gtk/settings.cpp
Fixed handling of keypress WXK_NUMPAD_NEXT
[wxWidgets.git] / src / gtk / settings.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: settings.cpp
3// Purpose:
4// Author: Robert Roebling
5// Id: $Id$
6// Copyright: (c) 1998 Robert Roebling
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
9
10
11#ifdef __GNUG__
12#pragma implementation "settings.h"
13#endif
14
15#include "wx/settings.h"
16#include "wx/debug.h"
17
18#include "gdk/gdk.h"
19#include "gtk/gtk.h"
20
21/*
22#define wxSYS_COLOUR_SCROLLBAR 0
23#define wxSYS_COLOUR_BACKGROUND 1
24#define wxSYS_COLOUR_ACTIVECAPTION 2
25#define wxSYS_COLOUR_INACTIVECAPTION 3
26#define wxSYS_COLOUR_MENU 4
27#define wxSYS_COLOUR_WINDOW 5
28#define wxSYS_COLOUR_WINDOWFRAME 6
29#define wxSYS_COLOUR_MENUTEXT 7
30#define wxSYS_COLOUR_WINDOWTEXT 8
31#define wxSYS_COLOUR_CAPTIONTEXT 9
32#define wxSYS_COLOUR_ACTIVEBORDER 10
33#define wxSYS_COLOUR_INACTIVEBORDER 11
34#define wxSYS_COLOUR_APPWORKSPACE 12
35#define wxSYS_COLOUR_HIGHLIGHT 13
36#define wxSYS_COLOUR_HIGHLIGHTTEXT 14
37#define wxSYS_COLOUR_BTNFACE 15
38#define wxSYS_COLOUR_BTNSHADOW 16
39#define wxSYS_COLOUR_GRAYTEXT 17
40#define wxSYS_COLOUR_BTNTEXT 18
41#define wxSYS_COLOUR_INACTIVECAPTIONTEXT 19
42#define wxSYS_COLOUR_BTNHIGHLIGHT 20
43
44#define wxSYS_COLOUR_3DDKSHADOW 21
45#define wxSYS_COLOUR_3DLIGHT 22
46#define wxSYS_COLOUR_INFOTEXT 23
47#define wxSYS_COLOUR_INFOBK 24
48
49#define wxSYS_COLOUR_DESKTOP wxSYS_COLOUR_BACKGROUND
50#define wxSYS_COLOUR_3DFACE wxSYS_COLOUR_BTNFACE
51#define wxSYS_COLOUR_3DSHADOW wxSYS_COLOUR_BTNSHADOW
52#define wxSYS_COLOUR_3DHIGHLIGHT wxSYS_COLOUR_BTNHIGHLIGHT
53#define wxSYS_COLOUR_3DHILIGHT wxSYS_COLOUR_BTNHIGHLIGHT
54#define wxSYS_COLOUR_BTNHILIGHT wxSYS_COLOUR_BTNHIGHLIGHT
55*/
56
57#define SHIFT (8*(sizeof(short int)-sizeof(char)))
58
59wxColour *g_systemWinColour = (wxColour *) NULL;
60wxColour *g_systemBtnFaceColour = (wxColour *) NULL;
61wxColour *g_systemBtnShadowColour = (wxColour *) NULL;
62wxColour *g_systemBtnHighlightColour = (wxColour *) NULL;
63wxColour *g_systemHighlightColour = (wxColour *) NULL;
64
65wxFont *g_systemFont = (wxFont *) NULL;
66
67void wxSystemSettings::Done()
68{
69 delete g_systemWinColour;
70 delete g_systemBtnFaceColour;
71 delete g_systemBtnShadowColour;
72 delete g_systemBtnHighlightColour;
73 delete g_systemHighlightColour;
74 delete g_systemFont;
75}
76
77wxColour wxSystemSettings::GetSystemColour( int index )
78{
79 switch (index)
80 {
81 case wxSYS_COLOUR_SCROLLBAR:
82 case wxSYS_COLOUR_BACKGROUND:
83 case wxSYS_COLOUR_ACTIVECAPTION:
84 case wxSYS_COLOUR_INACTIVECAPTION:
85 case wxSYS_COLOUR_MENU:
86 case wxSYS_COLOUR_WINDOWFRAME:
87 case wxSYS_COLOUR_ACTIVEBORDER:
88 case wxSYS_COLOUR_INACTIVEBORDER:
89 case wxSYS_COLOUR_BTNFACE:
90 {
91 GtkStyle *style = gtk_widget_get_default_style();
92 if (!g_systemBtnFaceColour)
93 {
94 g_systemBtnFaceColour =
95 new wxColour( style->bg[0].red >> SHIFT,
96 style->bg[0].green >> SHIFT,
97 style->bg[0].blue >> SHIFT );
98 }
99 return *g_systemBtnFaceColour;
100 }
101 case wxSYS_COLOUR_WINDOW:
102 {
103 GtkStyle *style = gtk_widget_get_default_style();
104 if (!g_systemWinColour)
105 {
106 g_systemWinColour =
107 new wxColour( style->base[0].red >> SHIFT,
108 style->base[0].green >> SHIFT,
109 style->base[0].blue >> SHIFT );
110 }
111 return *g_systemWinColour;
112 }
113 case wxSYS_COLOUR_GRAYTEXT:
114 case wxSYS_COLOUR_BTNSHADOW:
115 {
116 GtkStyle *style = gtk_widget_get_default_style();
117 if (!g_systemBtnShadowColour)
118 {
119 g_systemBtnShadowColour =
120 new wxColour( style->dark[0].red >> SHIFT,
121 style->dark[0].green >> SHIFT,
122 style->dark[0].blue >> SHIFT );
123 }
124 return *g_systemBtnShadowColour;
125 }
126 case wxSYS_COLOUR_BTNHIGHLIGHT:
127 {
128 GtkStyle *style = gtk_widget_get_default_style();
129 if (!g_systemBtnHighlightColour)
130 {
131 g_systemBtnHighlightColour =
132 new wxColour( style->light[0].red >> SHIFT,
133 style->light[0].green >> SHIFT,
134 style->light[0].blue >> SHIFT );
135 }
136 return *g_systemBtnHighlightColour;
137 }
138 case wxSYS_COLOUR_HIGHLIGHT:
139 {
140 GtkStyle *style = gtk_widget_get_default_style();
141 if (!g_systemHighlightColour)
142 {
143 g_systemHighlightColour =
144 new wxColour( style->bg[GTK_STATE_SELECTED].red >> SHIFT,
145 style->bg[GTK_STATE_SELECTED].green >> SHIFT,
146 style->bg[GTK_STATE_SELECTED].blue >> SHIFT );
147 }
148 return *g_systemHighlightColour;
149 }
150 case wxSYS_COLOUR_MENUTEXT:
151 case wxSYS_COLOUR_WINDOWTEXT:
152 case wxSYS_COLOUR_CAPTIONTEXT:
153 case wxSYS_COLOUR_INACTIVECAPTIONTEXT:
154 case wxSYS_COLOUR_BTNTEXT:
155 case wxSYS_COLOUR_INFOTEXT:
156 {
157 return *wxBLACK;
158 }
159 case wxSYS_COLOUR_HIGHLIGHTTEXT:
160 {
161 return *wxWHITE;
162 }
163 case wxSYS_COLOUR_INFOBK:
164 case wxSYS_COLOUR_APPWORKSPACE:
165 {
166 return *wxWHITE; // ?
167 }
168 }
169 return *wxWHITE;
170}
171
172wxFont wxSystemSettings::GetSystemFont( int index )
173{
174 switch (index)
175 {
176 case wxSYS_OEM_FIXED_FONT:
177 case wxSYS_ANSI_FIXED_FONT:
178 case wxSYS_SYSTEM_FIXED_FONT:
179 {
180 return *wxNORMAL_FONT;
181 }
182 case wxSYS_ANSI_VAR_FONT:
183 case wxSYS_SYSTEM_FONT:
184 case wxSYS_DEVICE_DEFAULT_FONT:
185 case wxSYS_DEFAULT_GUI_FONT:
186 {
187 if (!g_systemFont)
188 g_systemFont = new wxFont( 12, wxSWISS, wxNORMAL, wxNORMAL );
189 return *g_systemFont;
190 }
191 }
192
193 return wxNullFont;
194}
195
196int wxSystemSettings::GetSystemMetric( int index )
197{
198 switch (index)
199 {
200 case wxSYS_SCREEN_X: return gdk_screen_width();
201 case wxSYS_SCREEN_Y: return gdk_screen_height();
202 case wxSYS_HSCROLL_Y: return 15;
203 case wxSYS_VSCROLL_X: return 15;
204 }
205
206 wxCHECK_MSG( index, 0, _T("wxSystemSettings::GetSystemMetric not fully implemented") );
207
208 return 0;
209}