1 | Index: src/servers/app/ServerApp.h
|
---|
2 | ===================================================================
|
---|
3 | --- src/servers/app/ServerApp.h (révision 30247)
|
---|
4 | +++ src/servers/app/ServerApp.h (copie de travail)
|
---|
5 | @@ -8,11 +8,13 @@
|
---|
6 | * Stephan Aßmus <superstippi@gmx.de>
|
---|
7 | * Stefano Ceccherini (burton666@libero.it)
|
---|
8 | * Axel Dörfler, axeld@pinc-software.de
|
---|
9 | + * Philippe Saint-Pierre, stpere@gmail.com
|
---|
10 | */
|
---|
11 | #ifndef SERVER_APP_H
|
---|
12 | #define SERVER_APP_H
|
---|
13 |
|
---|
14 |
|
---|
15 | +#include "ServerFont.h"
|
---|
16 | #include "ClientMemoryAllocator.h"
|
---|
17 | #include "MessageLooper.h"
|
---|
18 |
|
---|
19 | @@ -84,6 +86,8 @@
|
---|
20 |
|
---|
21 | Desktop* GetDesktop() const { return fDesktop; }
|
---|
22 |
|
---|
23 | + status_t GetFont(char *which, ServerFont& font);
|
---|
24 | +
|
---|
25 | BPrivate::BTokenSpace& ViewTokens() { return fViewTokens; }
|
---|
26 |
|
---|
27 | private:
|
---|
28 | @@ -111,6 +115,10 @@
|
---|
29 | BString fSignature;
|
---|
30 | team_id fClientTeam;
|
---|
31 |
|
---|
32 | + ServerFont fPlainFont;
|
---|
33 | + ServerFont fBoldFont;
|
---|
34 | + ServerFont fFixedFont;
|
---|
35 | +
|
---|
36 | mutable BLocker fWindowListLock;
|
---|
37 | BObjectList<ServerWindow> fWindowList;
|
---|
38 | BPrivate::BTokenSpace fViewTokens;
|
---|
39 | Index: src/servers/app/DecorManager.cpp
|
---|
40 | ===================================================================
|
---|
41 | --- src/servers/app/DecorManager.cpp (révision 30247)
|
---|
42 | +++ src/servers/app/DecorManager.cpp (copie de travail)
|
---|
43 | @@ -2,7 +2,8 @@
|
---|
44 | * Copyright (c) 2001-2005, Haiku, Inc.
|
---|
45 | * Distributed under the terms of the MIT license.
|
---|
46 | *
|
---|
47 | - * Author: DarkWyrm <bpmagic@columbus.rr.com>
|
---|
48 | + * Author: DarkWyrm <bpmagic@columbus.rr.com>
|
---|
49 | + * Philippe Saint-Pierre, stpere@gmail.com
|
---|
50 | */
|
---|
51 |
|
---|
52 |
|
---|
53 | @@ -16,13 +17,13 @@
|
---|
54 | #include "AppServer.h"
|
---|
55 | #include "DefaultDecorator.h"
|
---|
56 | #include "Desktop.h"
|
---|
57 | -#include "DesktopSettings.h"
|
---|
58 | +#include "ServerApp.h"
|
---|
59 | #include "ServerConfig.h"
|
---|
60 | #include "DecorManager.h"
|
---|
61 |
|
---|
62 | typedef float get_version(void);
|
---|
63 | -typedef Decorator* create_decorator(DesktopSettings& desktopSettings, BRect rect,
|
---|
64 | - window_look look, uint32 flags);
|
---|
65 | +typedef Decorator* create_decorator(BRect rect,
|
---|
66 | + window_look look, uint32 flags, ServerApp *app);
|
---|
67 |
|
---|
68 | // Globals
|
---|
69 | DecorManager gDecorManager;
|
---|
70 | @@ -42,7 +43,7 @@
|
---|
71 |
|
---|
72 | Decorator* Instantiate(Desktop* desktop, DrawingEngine* engine,
|
---|
73 | BRect rect, const char* title,
|
---|
74 | - window_look look, uint32 flags);
|
---|
75 | + window_look look, uint32 flags, ServerApp *app);
|
---|
76 |
|
---|
77 | private:
|
---|
78 | image_id fID;
|
---|
79 | @@ -76,19 +77,18 @@
|
---|
80 |
|
---|
81 | Decorator *
|
---|
82 | DecorInfo::Instantiate(Desktop* desktop, DrawingEngine* engine, BRect rect,
|
---|
83 | - const char *title, window_look look, uint32 flags)
|
---|
84 | + const char *title, window_look look, uint32 flags, ServerApp* app)
|
---|
85 | {
|
---|
86 | if (!desktop->LockSingleWindow())
|
---|
87 | return NULL;
|
---|
88 |
|
---|
89 | - DesktopSettings settings(desktop);
|
---|
90 | Decorator *decorator;
|
---|
91 |
|
---|
92 | try {
|
---|
93 | if (fAllocator != NULL)
|
---|
94 | - decorator = fAllocator(settings, rect, look, flags);
|
---|
95 | + decorator = fAllocator(rect, look, flags, app);
|
---|
96 | else
|
---|
97 | - decorator = new DefaultDecorator(settings, rect, look, flags);
|
---|
98 | + decorator = new DefaultDecorator(rect, look, flags, app);
|
---|
99 | } catch (...) {
|
---|
100 | desktop->UnlockSingleWindow();
|
---|
101 | return NULL;
|
---|
102 | @@ -197,7 +197,7 @@
|
---|
103 |
|
---|
104 | Decorator *
|
---|
105 | DecorManager::AllocateDecorator(Desktop* desktop, DrawingEngine* engine,
|
---|
106 | - BRect rect, const char* title, window_look look, uint32 flags)
|
---|
107 | + BRect rect, const char* title, window_look look, uint32 flags, ServerApp *app)
|
---|
108 | {
|
---|
109 | // Create a new instance of the current decorator.
|
---|
110 | // Ownership is that of the caller
|
---|
111 | @@ -209,7 +209,7 @@
|
---|
112 | }
|
---|
113 |
|
---|
114 | return fCurrentDecor->Instantiate(desktop, engine, rect, title,
|
---|
115 | - look, flags);
|
---|
116 | + look, flags, app);
|
---|
117 | }
|
---|
118 |
|
---|
119 |
|
---|
120 | Index: src/servers/app/ServerApp.cpp
|
---|
121 | ===================================================================
|
---|
122 | --- src/servers/app/ServerApp.cpp (révision 30247)
|
---|
123 | +++ src/servers/app/ServerApp.cpp (copie de travail)
|
---|
124 | @@ -10,6 +10,7 @@
|
---|
125 | * Axel Dörfler, axeld@pinc-software.de
|
---|
126 | * Jérôme Duval, jerome.duval@free.fr
|
---|
127 | * Andrej Spielmann, <andrej.spielmann@seh.ox.ac.uk>
|
---|
128 | + * Philippe Saint-Pierre, stpere@gmail.com
|
---|
129 | */
|
---|
130 |
|
---|
131 | /*!
|
---|
132 | @@ -123,6 +124,14 @@
|
---|
133 | fInitialWorkspace = desktop->CurrentWorkspace();
|
---|
134 | // TODO: this should probably be retrieved when the app is loaded!
|
---|
135 |
|
---|
136 | + // record the current system wide fonts..
|
---|
137 | + desktop->LockSingleWindow();
|
---|
138 | + DesktopSettings settings(desktop);
|
---|
139 | + settings.GetDefaultPlainFont(fPlainFont);
|
---|
140 | + settings.GetDefaultBoldFont(fBoldFont);
|
---|
141 | + settings.GetDefaultFixedFont(fFixedFont);
|
---|
142 | + desktop->UnlockSingleWindow();
|
---|
143 | +
|
---|
144 | STRACE(("ServerApp %s:\n", Signature()));
|
---|
145 | STRACE(("\tBApp port: %ld\n", fClientReplyPort));
|
---|
146 | STRACE(("\tReceiver port: %ld\n", fMessagePort));
|
---|
147 | @@ -390,6 +399,36 @@
|
---|
148 | }
|
---|
149 |
|
---|
150 |
|
---|
151 | +// Helper function to attach the fonts attribute to a link
|
---|
152 | +// Could be made a method of the link itself, I suppose
|
---|
153 | +
|
---|
154 | +void
|
---|
155 | +_AttachFont(BPrivate::PortLink& fLink, ServerFont& font)
|
---|
156 | +{
|
---|
157 | + fLink.Attach<uint16>(font.FamilyID());
|
---|
158 | + fLink.Attach<uint16>(font.StyleID());
|
---|
159 | + fLink.Attach<float>(font.Size());
|
---|
160 | + fLink.Attach<uint16>(font.Face());
|
---|
161 | + fLink.Attach<uint32>(font.Flags());
|
---|
162 | +}
|
---|
163 | +
|
---|
164 | +
|
---|
165 | +status_t
|
---|
166 | +ServerApp::GetFont(char *which, ServerFont& font)
|
---|
167 | +{
|
---|
168 | + if (!strcmp(which, "plain")) {
|
---|
169 | + font = fPlainFont;
|
---|
170 | + } else if (!strcmp(which, "bold")) {
|
---|
171 | + font = fBoldFont;
|
---|
172 | + } else if (!strcmp(which, "fixed")) {
|
---|
173 | + font = fFixedFont;
|
---|
174 | + } else
|
---|
175 | + return B_BAD_VALUE;
|
---|
176 | +
|
---|
177 | + return B_OK;
|
---|
178 | +}
|
---|
179 | +
|
---|
180 | +
|
---|
181 | /*!
|
---|
182 | \brief Handler function for BApplication API messages
|
---|
183 | \param code Identifier code for the message. Equivalent to BMessage::what
|
---|
184 | @@ -1123,8 +1162,44 @@
|
---|
185 |
|
---|
186 | /* font messages */
|
---|
187 |
|
---|
188 | + case AS_GET_SYSTEM_FONT:
|
---|
189 | + {
|
---|
190 | + FTRACE(("ServerApp %s: AS_GET_SYSTEM_FONT\n", Signature()));
|
---|
191 | + // gets :
|
---|
192 | + // 1) string - font type ("plain", ...)
|
---|
193 | +
|
---|
194 | + char type[B_OS_NAME_LENGTH];
|
---|
195 | + ServerFont font;
|
---|
196 | +
|
---|
197 | + status_t status = link.ReadString(type, sizeof(type));
|
---|
198 | +
|
---|
199 | + if (status == B_OK) {
|
---|
200 | + if (!strcmp(type, "plain")) {
|
---|
201 | + fLink.StartMessage(B_OK);
|
---|
202 | + _AttachFont(fLink, fPlainFont);
|
---|
203 | + } else if (!strcmp(type, "bold")) {
|
---|
204 | + fLink.StartMessage(B_OK);
|
---|
205 | + _AttachFont(fLink, fBoldFont);
|
---|
206 | + } else if (!strcmp(type, "fixed")) {
|
---|
207 | + fLink.StartMessage(B_OK);
|
---|
208 | + _AttachFont(fLink, fFixedFont);
|
---|
209 | + } else {
|
---|
210 | + FTRACE(("Font name not found : %s\n", type));
|
---|
211 | + status = B_BAD_VALUE;
|
---|
212 | + }
|
---|
213 | + }
|
---|
214 | +
|
---|
215 | + if (status != B_OK) {
|
---|
216 | + fLink.StartMessage(status);
|
---|
217 | + }
|
---|
218 | +
|
---|
219 | + fLink.Flush();
|
---|
220 | + break;
|
---|
221 | + }
|
---|
222 | +
|
---|
223 | case AS_SET_SYSTEM_FONT:
|
---|
224 | {
|
---|
225 | + FTRACE(("ServerApp %s: AS_SET_SYSTEM_FONT\n", Signature()));
|
---|
226 | // gets:
|
---|
227 | // 1) string - font type ("plain", ...)
|
---|
228 | // 2) string - family
|
---|
229 | @@ -1209,40 +1284,17 @@
|
---|
230 | // 4) uint16 - face flags
|
---|
231 | // 5) uint32 - font flags
|
---|
232 |
|
---|
233 | - if (!fDesktop->LockSingleWindow()) {
|
---|
234 | - fLink.StartMessage(B_OK);
|
---|
235 | - fLink.Flush();
|
---|
236 | - break;
|
---|
237 | - }
|
---|
238 | -
|
---|
239 | - DesktopSettings settings(fDesktop);
|
---|
240 | fLink.StartMessage(B_OK);
|
---|
241 |
|
---|
242 | - for (int32 i = 0; i < 3; i++) {
|
---|
243 | - ServerFont font;
|
---|
244 | - switch (i) {
|
---|
245 | - case 0:
|
---|
246 | - settings.GetDefaultPlainFont(font);
|
---|
247 | - fLink.AttachString("plain");
|
---|
248 | - break;
|
---|
249 | - case 1:
|
---|
250 | - settings.GetDefaultBoldFont(font);
|
---|
251 | - fLink.AttachString("bold");
|
---|
252 | - break;
|
---|
253 | - case 2:
|
---|
254 | - settings.GetDefaultFixedFont(font);
|
---|
255 | - fLink.AttachString("fixed");
|
---|
256 | - break;
|
---|
257 | - }
|
---|
258 | + fLink.AttachString("plain");
|
---|
259 | + _AttachFont(fLink, fPlainFont);
|
---|
260 |
|
---|
261 | - fLink.Attach<uint16>(font.FamilyID());
|
---|
262 | - fLink.Attach<uint16>(font.StyleID());
|
---|
263 | - fLink.Attach<float>(font.Size());
|
---|
264 | - fLink.Attach<uint16>(font.Face());
|
---|
265 | - fLink.Attach<uint32>(font.Flags());
|
---|
266 | - }
|
---|
267 | + fLink.AttachString("bold");
|
---|
268 | + _AttachFont(fLink, fBoldFont);
|
---|
269 |
|
---|
270 | - fDesktop->UnlockSingleWindow();
|
---|
271 | + fLink.AttachString("fixed");
|
---|
272 | + _AttachFont(fLink, fFixedFont);
|
---|
273 | +
|
---|
274 | fLink.Flush();
|
---|
275 | break;
|
---|
276 | }
|
---|
277 | Index: src/servers/app/Decorator.cpp
|
---|
278 | ===================================================================
|
---|
279 | --- src/servers/app/Decorator.cpp (révision 30247)
|
---|
280 | +++ src/servers/app/Decorator.cpp (copie de travail)
|
---|
281 | @@ -28,9 +28,10 @@
|
---|
282 | \param wfeel style of window feel. See Window.h
|
---|
283 | \param wflags various window flags. See Window.h
|
---|
284 | */
|
---|
285 | -Decorator::Decorator(DesktopSettings& settings, BRect rect, window_look look,
|
---|
286 | - uint32 flags)
|
---|
287 | +Decorator::Decorator(BRect rect, window_look look,
|
---|
288 | + uint32 flags, ServerApp *app)
|
---|
289 | :
|
---|
290 | + fServerApp(app),
|
---|
291 | fDrawingEngine(NULL),
|
---|
292 | fDrawState(),
|
---|
293 |
|
---|
294 | @@ -103,7 +104,7 @@
|
---|
295 | /*! \brief Called whenever the system fonts are changed.
|
---|
296 | */
|
---|
297 | void
|
---|
298 | -Decorator::FontsChanged(DesktopSettings& settings, BRegion* updateRegion)
|
---|
299 | +Decorator::FontsChanged(BRegion* updateRegion)
|
---|
300 | {
|
---|
301 | }
|
---|
302 |
|
---|
303 | @@ -112,7 +113,7 @@
|
---|
304 | \param look New value for the look
|
---|
305 | */
|
---|
306 | void
|
---|
307 | -Decorator::SetLook(DesktopSettings& settings, window_look look,
|
---|
308 | +Decorator::SetLook(window_look look,
|
---|
309 | BRegion* updateRect)
|
---|
310 | {
|
---|
311 | fLook = look;
|
---|
312 | Index: src/servers/app/DefaultDecorator.h
|
---|
313 | ===================================================================
|
---|
314 | --- src/servers/app/DefaultDecorator.h (révision 30247)
|
---|
315 | +++ src/servers/app/DefaultDecorator.h (copie de travail)
|
---|
316 | @@ -18,18 +18,15 @@
|
---|
317 |
|
---|
318 | class DefaultDecorator: public Decorator {
|
---|
319 | public:
|
---|
320 | - DefaultDecorator(DesktopSettings& settings,
|
---|
321 | - BRect frame, window_look look,
|
---|
322 | - uint32 flags);
|
---|
323 | + DefaultDecorator(BRect frame, window_look look,
|
---|
324 | + uint32 flags, ServerApp *app);
|
---|
325 | virtual ~DefaultDecorator();
|
---|
326 |
|
---|
327 | virtual void SetTitle(const char* string,
|
---|
328 | BRegion* updateRegion = NULL);
|
---|
329 | - virtual void FontsChanged(DesktopSettings& settings,
|
---|
330 | - BRegion* updateRegion);
|
---|
331 | - virtual void SetLook(DesktopSettings& settings,
|
---|
332 | - window_look look,
|
---|
333 | - BRegion* updateRegion = NULL);
|
---|
334 | + virtual void FontsChanged(BRegion* updateRegion);
|
---|
335 | + virtual void SetLook(window_look look,
|
---|
336 | + BRegion* updateRegion = NULL);
|
---|
337 | virtual void SetFlags(uint32 flags,
|
---|
338 | BRegion* updateRegion = NULL);
|
---|
339 |
|
---|
340 | @@ -70,7 +67,7 @@
|
---|
341 | virtual void _SetColors();
|
---|
342 |
|
---|
343 | private:
|
---|
344 | - void _UpdateFont(DesktopSettings& settings);
|
---|
345 | + void _UpdateFont();
|
---|
346 | void _DrawButtonBitmap(ServerBitmap* bitmap,
|
---|
347 | BRect rect);
|
---|
348 | void _DrawBlendedRect(DrawingEngine *engine,
|
---|
349 | Index: src/servers/app/ServerWindow.cpp
|
---|
350 | ===================================================================
|
---|
351 | --- src/servers/app/ServerWindow.cpp (révision 30247)
|
---|
352 | +++ src/servers/app/ServerWindow.cpp (copie de travail)
|
---|
353 | @@ -9,6 +9,7 @@
|
---|
354 | * Stefano Ceccherini (burton666@libero.it)
|
---|
355 | * Axel Dörfler, axeld@pinc-software.de
|
---|
356 | * Artur Wyszynski <harakash@gmail.com>
|
---|
357 | + * Philippe Saint-Pierre, stpere@gmail.com
|
---|
358 | */
|
---|
359 |
|
---|
360 | /*!
|
---|
361 | @@ -618,11 +619,12 @@
|
---|
362 | // fDesktop->LockSingleWindow();
|
---|
363 | }
|
---|
364 |
|
---|
365 | - // TODO: default fonts should be created and stored in the Application
|
---|
366 | - DesktopSettings settings(fDesktop);
|
---|
367 | ServerFont font;
|
---|
368 | - settings.GetDefaultPlainFont(font);
|
---|
369 | - newView->CurrentState()->SetFont(font);
|
---|
370 | + if (App()->GetFont("plain", font) == B_OK) {
|
---|
371 | + newView->CurrentState()->SetFont(font);
|
---|
372 | + } else {
|
---|
373 | + debug_printf("Plain font not found!\n");
|
---|
374 | + }
|
---|
375 |
|
---|
376 | if (_parent) {
|
---|
377 | View *parent;
|
---|
378 | Index: src/servers/app/Window.cpp
|
---|
379 | ===================================================================
|
---|
380 | --- src/servers/app/Window.cpp (révision 30247)
|
---|
381 | +++ src/servers/app/Window.cpp (copie de travail)
|
---|
382 | @@ -7,6 +7,7 @@
|
---|
383 | * Adi Oanca <adioanca@gmail.com>
|
---|
384 | * Stephan Aßmus <superstippi@gmx.de>
|
---|
385 | * Axel Dörfler, axeld@pinc-software.de
|
---|
386 | + * Philippe Saint-Pierre, stpere@gmail.com
|
---|
387 | */
|
---|
388 |
|
---|
389 |
|
---|
390 | @@ -144,7 +145,7 @@
|
---|
391 |
|
---|
392 | if (fLook != B_NO_BORDER_WINDOW_LOOK) {
|
---|
393 | fDecorator = gDecorManager.AllocateDecorator(fDesktop, fDrawingEngine,
|
---|
394 | - frame, name, fLook, fFlags);
|
---|
395 | + frame, name, fLook, fFlags, ServerWindow()->App());
|
---|
396 | if (fDecorator) {
|
---|
397 | fDecorator->GetSizeLimits(&fMinWidth, &fMinHeight,
|
---|
398 | &fMaxWidth, &fMaxHeight);
|
---|
399 | @@ -887,7 +888,6 @@
|
---|
400 | // clicking a simple View
|
---|
401 | if (!IsFocus()) {
|
---|
402 | DesktopSettings desktopSettings(fDesktop);
|
---|
403 | -
|
---|
404 | // Activate window in case it doesn't accept first click, and
|
---|
405 | // we're not in FFM mode
|
---|
406 | if ((Flags() & B_WILL_ACCEPT_FIRST_CLICK) == 0
|
---|
407 | @@ -1329,8 +1329,7 @@
|
---|
408 | Window::FontsChanged(BRegion* updateRegion)
|
---|
409 | {
|
---|
410 | if (fDecorator != NULL) {
|
---|
411 | - DesktopSettings settings(fDesktop);
|
---|
412 | - fDecorator->FontsChanged(settings, updateRegion);
|
---|
413 | + fDecorator->FontsChanged(updateRegion);
|
---|
414 | fBorderRegionValid = false;
|
---|
415 | }
|
---|
416 | }
|
---|
417 | @@ -1342,7 +1341,7 @@
|
---|
418 | if (fDecorator == NULL && look != B_NO_BORDER_WINDOW_LOOK) {
|
---|
419 | // we need a new decorator
|
---|
420 | fDecorator = gDecorManager.AllocateDecorator(fDesktop, fDrawingEngine,
|
---|
421 | - Frame(), Title(), fLook, fFlags);
|
---|
422 | + Frame(), Title(), fLook, fFlags, ServerWindow()->App());
|
---|
423 | if (IsFocus())
|
---|
424 | fDecorator->SetFocus(true);
|
---|
425 | }
|
---|
426 | @@ -1358,8 +1357,7 @@
|
---|
427 | // likely not valid anymore either
|
---|
428 |
|
---|
429 | if (fDecorator != NULL) {
|
---|
430 | - DesktopSettings settings(fDesktop);
|
---|
431 | - fDecorator->SetLook(settings, look, updateRegion);
|
---|
432 | + fDecorator->SetLook(look, updateRegion);
|
---|
433 |
|
---|
434 | // we might need to resize the window!
|
---|
435 | fDecorator->GetSizeLimits(&fMinWidth, &fMinHeight, &fMaxWidth, &fMaxHeight);
|
---|
436 | Index: src/servers/app/Decorator.h
|
---|
437 | ===================================================================
|
---|
438 | --- src/servers/app/Decorator.h (révision 30247)
|
---|
439 | +++ src/servers/app/Decorator.h (copie de travail)
|
---|
440 | @@ -16,8 +16,8 @@
|
---|
441 | #include <Window.h>
|
---|
442 |
|
---|
443 | #include "DrawState.h"
|
---|
444 | +#include "ServerApp.h"
|
---|
445 |
|
---|
446 | -class DesktopSettings;
|
---|
447 | class DrawingEngine;
|
---|
448 | class ServerFont;
|
---|
449 | class BRegion;
|
---|
450 | @@ -46,18 +46,17 @@
|
---|
451 |
|
---|
452 | class Decorator {
|
---|
453 | public:
|
---|
454 | - Decorator(DesktopSettings& settings, BRect rect,
|
---|
455 | - window_look look, uint32 flags);
|
---|
456 | + Decorator(BRect rect, window_look look, uint32 flags,
|
---|
457 | + ServerApp *app);
|
---|
458 | virtual ~Decorator();
|
---|
459 |
|
---|
460 | void SetDrawingEngine(DrawingEngine *driver);
|
---|
461 | inline DrawingEngine* GetDrawingEngine() const
|
---|
462 | { return fDrawingEngine; }
|
---|
463 |
|
---|
464 | - virtual void FontsChanged(DesktopSettings& settings,
|
---|
465 | - BRegion* updateRegion = NULL);
|
---|
466 | - virtual void SetLook(DesktopSettings& settings, window_look look,
|
---|
467 | - BRegion* updateRegion = NULL);
|
---|
468 | + virtual void FontsChanged(BRegion* updateRegion = NULL);
|
---|
469 | + virtual void SetLook(window_look look,
|
---|
470 | + BRegion* updateRegion = NULL);
|
---|
471 | virtual void SetFlags(uint32 flags,
|
---|
472 | BRegion* updateRegion = NULL);
|
---|
473 |
|
---|
474 | @@ -137,6 +136,8 @@
|
---|
475 |
|
---|
476 | virtual void _SetFocus();
|
---|
477 |
|
---|
478 | + ServerApp* fServerApp;
|
---|
479 | +
|
---|
480 | DrawingEngine* fDrawingEngine;
|
---|
481 | DrawState fDrawState;
|
---|
482 |
|
---|
483 | @@ -144,6 +145,7 @@
|
---|
484 | uint32 fFlags;
|
---|
485 |
|
---|
486 | BRect fZoomRect;
|
---|
487 | +
|
---|
488 | BRect fCloseRect;
|
---|
489 | BRect fMinimizeRect;
|
---|
490 | BRect fTabRect;
|
---|
491 | Index: src/servers/app/DefaultDecorator.cpp
|
---|
492 | ===================================================================
|
---|
493 | --- src/servers/app/DefaultDecorator.cpp (révision 30247)
|
---|
494 | +++ src/servers/app/DefaultDecorator.cpp (copie de travail)
|
---|
495 | @@ -13,7 +13,6 @@
|
---|
496 | #include "DefaultDecorator.h"
|
---|
497 |
|
---|
498 | #include "BitmapDrawingEngine.h"
|
---|
499 | -#include "DesktopSettings.h"
|
---|
500 | #include "DrawingEngine.h"
|
---|
501 | #include "DrawState.h"
|
---|
502 | #include "FontManager.h"
|
---|
503 | @@ -55,17 +54,14 @@
|
---|
504 | // #pragma mark -
|
---|
505 |
|
---|
506 |
|
---|
507 | -// TODO: get rid of DesktopSettings here, and introduce private accessor
|
---|
508 | -// methods to the Decorator base class
|
---|
509 | -
|
---|
510 | -DefaultDecorator::DefaultDecorator(DesktopSettings& settings, BRect rect,
|
---|
511 | - window_look look, uint32 flags)
|
---|
512 | - : Decorator(settings, rect, look, flags),
|
---|
513 | +DefaultDecorator::DefaultDecorator(BRect rect,
|
---|
514 | + window_look look, uint32 flags, ServerApp *app)
|
---|
515 | + : Decorator(rect, look, flags, app),
|
---|
516 | fTabOffset(0),
|
---|
517 | fTabLocation(0.0),
|
---|
518 | fLastClicked(0)
|
---|
519 | {
|
---|
520 | - _UpdateFont(settings);
|
---|
521 | + _UpdateFont();
|
---|
522 |
|
---|
523 | // common colors to both focus and non focus state
|
---|
524 | fFrameColors[0] = (rgb_color){ 152, 152, 152, 255 };
|
---|
525 | @@ -137,7 +133,7 @@
|
---|
526 |
|
---|
527 |
|
---|
528 | void
|
---|
529 | -DefaultDecorator::FontsChanged(DesktopSettings& settings, BRegion* updateRegion)
|
---|
530 | +DefaultDecorator::FontsChanged(BRegion* updateRegion)
|
---|
531 | {
|
---|
532 | // get previous extent
|
---|
533 | if (updateRegion != NULL) {
|
---|
534 | @@ -146,7 +142,7 @@
|
---|
535 | updateRegion->Include(&extent);
|
---|
536 | }
|
---|
537 |
|
---|
538 | - _UpdateFont(settings);
|
---|
539 | + _UpdateFont();
|
---|
540 | _DoLayout();
|
---|
541 |
|
---|
542 | if (updateRegion != NULL) {
|
---|
543 | @@ -158,8 +154,7 @@
|
---|
544 |
|
---|
545 |
|
---|
546 | void
|
---|
547 | -DefaultDecorator::SetLook(DesktopSettings& settings, window_look look,
|
---|
548 | - BRegion* updateRegion)
|
---|
549 | +DefaultDecorator::SetLook(window_look look, BRegion* updateRegion)
|
---|
550 | {
|
---|
551 | // TODO: we could be much smarter about the update region
|
---|
552 |
|
---|
553 | @@ -172,7 +167,7 @@
|
---|
554 |
|
---|
555 | fLook = look;
|
---|
556 |
|
---|
557 | - _UpdateFont(settings);
|
---|
558 | + _UpdateFont();
|
---|
559 | _DoLayout();
|
---|
560 |
|
---|
561 | if (updateRegion != NULL) {
|
---|
562 | @@ -1120,15 +1115,17 @@
|
---|
563 |
|
---|
564 |
|
---|
565 | void
|
---|
566 | -DefaultDecorator::_UpdateFont(DesktopSettings& settings)
|
---|
567 | +DefaultDecorator::_UpdateFont()
|
---|
568 | {
|
---|
569 | ServerFont font;
|
---|
570 | +
|
---|
571 | if (fLook == B_FLOATING_WINDOW_LOOK || fLook == kLeftTitledWindowLook) {
|
---|
572 | - settings.GetDefaultPlainFont(font);
|
---|
573 | + fServerApp->GetFont("plain", font);
|
---|
574 | if (fLook == kLeftTitledWindowLook)
|
---|
575 | font.SetRotation(90.0f);
|
---|
576 | + fDrawState.SetFont(font);
|
---|
577 | } else
|
---|
578 | - settings.GetDefaultBoldFont(font);
|
---|
579 | + fServerApp->GetFont("bold", font);
|
---|
580 |
|
---|
581 | font.SetFlags(B_FORCE_ANTIALIASING);
|
---|
582 | font.SetSpacing(B_STRING_SPACING);
|
---|
583 | Index: src/servers/app/DecorManager.h
|
---|
584 | ===================================================================
|
---|
585 | --- src/servers/app/DecorManager.h (révision 30247)
|
---|
586 | +++ src/servers/app/DecorManager.h (copie de travail)
|
---|
587 | @@ -30,7 +30,7 @@
|
---|
588 | DrawingEngine* engine,
|
---|
589 | BRect rect,
|
---|
590 | const char* title, window_look look,
|
---|
591 | - uint32 flags);
|
---|
592 | + uint32 flags, ServerApp *app);
|
---|
593 |
|
---|
594 | int32 CountDecorators() const;
|
---|
595 |
|
---|
596 | Index: src/kits/app/Application.cpp
|
---|
597 | ===================================================================
|
---|
598 | --- src/kits/app/Application.cpp (révision 30247)
|
---|
599 | +++ src/kits/app/Application.cpp (copie de travail)
|
---|
600 | @@ -31,6 +31,7 @@
|
---|
601 | #include <Resources.h>
|
---|
602 | #include <Roster.h>
|
---|
603 | #include <Window.h>
|
---|
604 | +#include <Font.h>
|
---|
605 |
|
---|
606 | #include <AppMisc.h>
|
---|
607 | #include <AppServerLink.h>
|
---|
608 | @@ -250,6 +251,11 @@
|
---|
609 |
|
---|
610 | // uninitialize be_app, the be_app_messenger is invalidated automatically
|
---|
611 | be_app = NULL;
|
---|
612 | +
|
---|
613 | + // free the fonts symbols (they are application specific)
|
---|
614 | + delete be_plain_font;
|
---|
615 | + delete be_bold_font;
|
---|
616 | + delete be_fixed_font;
|
---|
617 | }
|
---|
618 |
|
---|
619 |
|
---|
620 | @@ -433,8 +439,12 @@
|
---|
621 |
|
---|
622 | #ifndef RUN_WITHOUT_APP_SERVER
|
---|
623 | // app server connection and IK initialization
|
---|
624 | - if (initGUI)
|
---|
625 | + if (initGUI) {
|
---|
626 | fInitError = _InitGUIContext();
|
---|
627 | + be_plain_font = new BFont("plain");
|
---|
628 | + be_bold_font = new BFont("bold");
|
---|
629 | + be_fixed_font = new BFont("fixed");
|
---|
630 | + }
|
---|
631 | #endif // RUN_WITHOUT_APP_SERVER
|
---|
632 | }
|
---|
633 |
|
---|
634 | Index: src/kits/interface/InterfaceDefs.cpp
|
---|
635 | ===================================================================
|
---|
636 | --- src/kits/interface/InterfaceDefs.cpp (révision 30247)
|
---|
637 | +++ src/kits/interface/InterfaceDefs.cpp (copie de travail)
|
---|
638 | @@ -938,7 +938,6 @@
|
---|
639 |
|
---|
640 | BPrivate::gWidthBuffer = new BPrivate::WidthBuffer;
|
---|
641 |
|
---|
642 | - _init_global_fonts_();
|
---|
643 |
|
---|
644 | _menu_info_ptr_ = &BMenu::sMenuInfo;
|
---|
645 |
|
---|
646 | Index: src/kits/interface/Font.cpp
|
---|
647 | ===================================================================
|
---|
648 | --- src/kits/interface/Font.cpp (révision 30247)
|
---|
649 | +++ src/kits/interface/Font.cpp (copie de travail)
|
---|
650 | @@ -12,6 +12,7 @@
|
---|
651 |
|
---|
652 |
|
---|
653 | #include <AppServerLink.h>
|
---|
654 | +#include <Application.h>
|
---|
655 | #include <FontPrivate.h>
|
---|
656 | #include <ObjectList.h>
|
---|
657 | #include <ServerProtocol.h>
|
---|
658 | @@ -36,16 +37,12 @@
|
---|
659 | const float kUninitializedAscent = INFINITY;
|
---|
660 | const uint32 kUninitializedExtraFlags = 0xffffffff;
|
---|
661 |
|
---|
662 | -// The actual objects which the globals point to
|
---|
663 | -static BFont sPlainFont;
|
---|
664 | -static BFont sBoldFont;
|
---|
665 | -static BFont sFixedFont;
|
---|
666 | +// Font symbols - these are specific to every application
|
---|
667 | +// they will be initialized at application launch...
|
---|
668 | +const BFont *be_plain_font = NULL;
|
---|
669 | +const BFont *be_bold_font = NULL;
|
---|
670 | +const BFont *be_fixed_font = NULL;
|
---|
671 |
|
---|
672 | -const BFont *be_plain_font = &sPlainFont;
|
---|
673 | -const BFont *be_bold_font = &sBoldFont;
|
---|
674 | -const BFont *be_fixed_font = &sFixedFont;
|
---|
675 | -
|
---|
676 | -
|
---|
677 | struct style {
|
---|
678 | BString name;
|
---|
679 | uint16 face;
|
---|
680 | @@ -307,53 +304,17 @@
|
---|
681 | // #pragma mark -
|
---|
682 |
|
---|
683 |
|
---|
684 | -void
|
---|
685 | -_init_global_fonts_()
|
---|
686 | +void _font_control_(BFont *font, int32 cmd, void *data)
|
---|
687 | {
|
---|
688 | - BPrivate::AppServerLink link;
|
---|
689 | - link.StartMessage(AS_GET_SYSTEM_FONTS);
|
---|
690 | -
|
---|
691 | - int32 code;
|
---|
692 | - if (link.FlushWithReply(code) != B_OK
|
---|
693 | - || code != B_OK) {
|
---|
694 | - printf("DEBUG: Couldn't initialize global fonts!\n");
|
---|
695 | - return;
|
---|
696 | - }
|
---|
697 | -
|
---|
698 | - char type[B_OS_NAME_LENGTH];
|
---|
699 | -
|
---|
700 | - while (link.ReadString(type, sizeof(type)) >= B_OK && type[0]) {
|
---|
701 | - BFont dummy;
|
---|
702 | - BFont *font = &dummy;
|
---|
703 | -
|
---|
704 | - if (!strcmp(type, "plain"))
|
---|
705 | - font = &sPlainFont;
|
---|
706 | - else if (!strcmp(type, "bold"))
|
---|
707 | - font = &sBoldFont;
|
---|
708 | - else if (!strcmp(type, "fixed"))
|
---|
709 | - font = &sFixedFont;
|
---|
710 | -
|
---|
711 | - link.Read<uint16>(&font->fFamilyID);
|
---|
712 | - link.Read<uint16>(&font->fStyleID);
|
---|
713 | - link.Read<float>(&font->fSize);
|
---|
714 | - link.Read<uint16>(&font->fFace);
|
---|
715 | - link.Read<uint32>(&font->fFlags);
|
---|
716 | -
|
---|
717 | - font->fHeight.ascent = kUninitializedAscent;
|
---|
718 | - font->fExtraFlags = kUninitializedExtraFlags;
|
---|
719 | - }
|
---|
720 | }
|
---|
721 |
|
---|
722 |
|
---|
723 | -void _font_control_(BFont *font, int32 cmd, void *data)
|
---|
724 | -{
|
---|
725 | -}
|
---|
726 | -
|
---|
727 | status_t get_font_cache_info(uint32 id, void *set)
|
---|
728 | {
|
---|
729 | return B_ERROR;
|
---|
730 | }
|
---|
731 |
|
---|
732 | +
|
---|
733 | status_t set_font_cache_info(uint32 id, void *set)
|
---|
734 | {
|
---|
735 | return B_ERROR;
|
---|
736 | @@ -503,7 +464,6 @@
|
---|
737 |
|
---|
738 | BFont::BFont()
|
---|
739 | :
|
---|
740 | - // initialise for be_plain_font (avoid circular definition)
|
---|
741 | fFamilyID(0),
|
---|
742 | fStyleID(0),
|
---|
743 | fSize(10.0),
|
---|
744 | @@ -516,7 +476,7 @@
|
---|
745 | fFlags(0),
|
---|
746 | fExtraFlags(kUninitializedExtraFlags)
|
---|
747 | {
|
---|
748 | - if (be_plain_font != NULL && this != &sPlainFont)
|
---|
749 | + if (be_plain_font != NULL)
|
---|
750 | *this = *be_plain_font;
|
---|
751 | else {
|
---|
752 | fHeight.ascent = 7.0;
|
---|
753 | @@ -526,6 +486,52 @@
|
---|
754 | }
|
---|
755 |
|
---|
756 |
|
---|
757 | +BFont::BFont(const char *which)
|
---|
758 | + :
|
---|
759 | + fFamilyID(0),
|
---|
760 | + fStyleID(0),
|
---|
761 | + fSize(10.0),
|
---|
762 | + fShear(90.0),
|
---|
763 | + fRotation(0.0),
|
---|
764 | + fFalseBoldWidth(0.0),
|
---|
765 | + fSpacing(0),
|
---|
766 | + fEncoding(0),
|
---|
767 | + fFace(0),
|
---|
768 | + fFlags(0),
|
---|
769 | + fExtraFlags(kUninitializedExtraFlags)
|
---|
770 | +{
|
---|
771 | + if (be_app
|
---|
772 | + && (!strcmp(which, "plain")
|
---|
773 | + || !strcmp(which, "bold")
|
---|
774 | + || !strcmp(which, "fixed"))) {
|
---|
775 | +
|
---|
776 | + BPrivate::AppServerLink link;
|
---|
777 | +
|
---|
778 | + link.StartMessage(AS_GET_SYSTEM_FONT);
|
---|
779 | + link.AttachString(which, B_OS_NAME_LENGTH);
|
---|
780 | +
|
---|
781 | + int32 code;
|
---|
782 | + link.FlushWithReply(code);
|
---|
783 | +
|
---|
784 | + if (code == B_OK) {
|
---|
785 | + link.Read<uint16>(&fFamilyID);
|
---|
786 | + link.Read<uint16>(&fStyleID);
|
---|
787 | + link.Read<float>(&fSize);
|
---|
788 | + link.Read<uint16>(&fFace);
|
---|
789 | + link.Read<uint32>(&fFlags);
|
---|
790 | +
|
---|
791 | + fHeight.ascent = kUninitializedAscent;
|
---|
792 | + fExtraFlags = kUninitializedExtraFlags;
|
---|
793 | + return;
|
---|
794 | + }
|
---|
795 | + }
|
---|
796 | + // else...
|
---|
797 | + fHeight.ascent = 7.0;
|
---|
798 | + fHeight.descent = 2.0;
|
---|
799 | + fHeight.leading = 13.0;
|
---|
800 | +}
|
---|
801 | +
|
---|
802 | +
|
---|
803 | BFont::BFont(const BFont &font)
|
---|
804 | {
|
---|
805 | *this = font;
|
---|
806 | @@ -536,8 +542,10 @@
|
---|
807 | {
|
---|
808 | if (font)
|
---|
809 | *this = *font;
|
---|
810 | + else if (be_plain_font)
|
---|
811 | + *this = *be_plain_font;
|
---|
812 | else
|
---|
813 | - *this = *be_plain_font;
|
---|
814 | + *this = BFont("plain");
|
---|
815 | }
|
---|
816 |
|
---|
817 |
|
---|
818 | Index: headers/os/interface/Font.h
|
---|
819 | ===================================================================
|
---|
820 | --- headers/os/interface/Font.h (révision 30247)
|
---|
821 | +++ headers/os/interface/Font.h (copie de travail)
|
---|
822 | @@ -148,6 +148,7 @@
|
---|
823 | class BFont {
|
---|
824 | public:
|
---|
825 | BFont();
|
---|
826 | + BFont(const char *which);
|
---|
827 | BFont(const BFont &font);
|
---|
828 | BFont(const BFont *font);
|
---|
829 |
|
---|
830 | @@ -240,8 +241,6 @@
|
---|
831 | void PrintToStream() const;
|
---|
832 |
|
---|
833 | private:
|
---|
834 | - friend void _init_global_fonts_();
|
---|
835 | -
|
---|
836 | uint16 fFamilyID;
|
---|
837 | uint16 fStyleID;
|
---|
838 | float fSize;
|
---|
839 | Index: headers/private/app/ServerProtocol.h
|
---|
840 | ===================================================================
|
---|
841 | --- headers/private/app/ServerProtocol.h (révision 30247)
|
---|
842 | +++ headers/private/app/ServerProtocol.h (copie de travail)
|
---|
843 | @@ -108,6 +108,7 @@
|
---|
844 |
|
---|
845 | // Font-related server communications
|
---|
846 | AS_SET_SYSTEM_FONT,
|
---|
847 | + AS_GET_SYSTEM_FONT,
|
---|
848 | AS_GET_SYSTEM_FONTS,
|
---|
849 | AS_GET_SYSTEM_DEFAULT_FONT,
|
---|
850 | AS_SYSTEM_FONT_CHANGED,
|
---|