From 7a0b14b7abd42f4de7323da28e5ffe170ff1eae7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Mon, 7 Nov 2005 13:26:34 +0000 Subject: [PATCH] Removed support for setting the app_server's cache configuration. We doesn't support that API anyway, and I really don't think this belongs there - the app_server should handle this by itself alone. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14745 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/preferences/fonts/CacheView.cpp | 166 ------------------------ src/preferences/fonts/CacheView.h | 38 ------ src/preferences/fonts/FontsSettings.cpp | 38 ++---- src/preferences/fonts/Jamfile | 1 - src/preferences/fonts/MainWindow.cpp | 45 ++----- src/preferences/fonts/MainWindow.h | 31 ++--- 6 files changed, 39 insertions(+), 280 deletions(-) delete mode 100644 src/preferences/fonts/CacheView.cpp delete mode 100644 src/preferences/fonts/CacheView.h diff --git a/src/preferences/fonts/CacheView.cpp b/src/preferences/fonts/CacheView.cpp deleted file mode 100644 index a9b8f91950..0000000000 --- a/src/preferences/fonts/CacheView.cpp +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright 2001-2005, Haiku. - * Distributed under the terms of the MIT License. - * - */ -#include "CacheView.h" - -#include -#include -#include "MainWindow.h" -#include "Pref_Utils.h" - -#define PRINT_FCS_UPDATE_MSG 'pfum' -#define SCREEN_FCS_UPDATE_MSG 'sfum' -#define PRINT_FCS_MODIFICATION_MSG 'pfmm' -#define SCREEN_FCS_MODIFICATION_MSG 'sfmm' - - -CacheView::CacheView(const BRect &frame, const int32 &sliderMin, - const int32 &sliderMax, const int32 &printVal, - const int32 &screenVal) - - : BView(frame, "Cache", B_FOLLOW_ALL, B_WILL_DRAW), - fSavedPrintValue(printVal), - fSavedScreenValue(screenVal) -{ - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); - - rgb_color fillColor = { 102, 152, 203, 255 }; - - BString minLabel(B_EMPTY_STRING); - BString maxLabel(B_EMPTY_STRING); - - float fontheight = FontHeight(true); - - BRect rect( Bounds().InsetByCopy(5.0,3.0) ); - rect.top += fontheight; - rect.bottom = rect.top +(fontheight *2.0); - - BString labels(B_EMPTY_STRING); - labels << "Screen font cache size: " << screenVal << " kB"; - - fScreenSlider = new BSlider(rect, "screenslider", labels.String(), - new BMessage(SCREEN_FCS_UPDATE_MSG), - sliderMin, sliderMax, B_TRIANGLE_THUMB); - - fScreenSlider->SetModificationMessage(new BMessage(SCREEN_FCS_MODIFICATION_MSG)); - AddChild(fScreenSlider); - - minLabel << sliderMin << " kB"; - maxLabel << sliderMax << " kB"; - - fScreenSlider->SetLimitLabels(minLabel.String(), maxLabel.String()); - fScreenSlider->UseFillColor(TRUE, &fillColor); - fScreenSlider->SetValue(screenVal); - - rect.OffsetTo(rect.left, rect.bottom +(fontheight *2.5)); - - labels = ""; - labels << "Printing font cache size: " << printVal << " kB"; - - fPrintSlider = new BSlider(rect, "printFontCache", labels.String(), - new BMessage(PRINT_FCS_UPDATE_MSG), - sliderMin, sliderMax, B_TRIANGLE_THUMB); - AddChild(fPrintSlider); - - fPrintSlider->SetModificationMessage(new BMessage(PRINT_FCS_MODIFICATION_MSG)); - - fPrintSlider->SetLimitLabels(minLabel.String(), maxLabel.String()); - fPrintSlider->UseFillColor(TRUE, &fillColor); - fPrintSlider->SetValue(printVal); - - rect.OffsetTo(rect.left -1.0, rect.bottom +(fontheight *2.0)); - rect.right = rect.left +86.0; - rect.bottom = rect.top +24.0; - - // TODO: figure out what to do with 'Save Cache' on R5. According to the - // BeOS Bible, it allocates a block of memory to disk, which is loaded on - // next boot. FreeType does better than this. - fSaveCache = new BButton(rect, "saveCache", "Save Cache", - NULL, B_FOLLOW_LEFT, B_WILL_DRAW); - AddChild(fSaveCache); - fSaveCache->SetEnabled(false); -} - -void -CacheView::AttachedToWindow(void) -{ - fScreenSlider->SetTarget(this); - fPrintSlider->SetTarget(this); - fSaveCache->SetTarget(this); -} - -void -CacheView::MessageReceived(BMessage *msg) -{ - switch(msg->what) - { - case PRINT_FCS_MODIFICATION_MSG: - { - UpdatePrintSettings(fPrintSlider->Value()); - - Window()->PostMessage(M_ENABLE_REVERT); - break; - } - case SCREEN_FCS_MODIFICATION_MSG: - { - UpdateScreenSettings(fScreenSlider->Value()); - Window()->PostMessage(M_ENABLE_REVERT); - break; - } - default: - { - BView::MessageReceived(msg); - break; - } - } -} - -void CacheView::Revert(void) -{ - fPrintSlider->SetValue(fSavedPrintValue); - fScreenSlider->SetValue(fSavedScreenValue); - UpdatePrintSettings(fSavedPrintValue); - UpdateScreenSettings(fSavedScreenValue); -} - -void CacheView::SetDefaults(void) -{ - fPrintSlider->SetValue(256); - fScreenSlider->SetValue(256); - UpdatePrintSettings(256); - UpdateScreenSettings(256); -} - -void -CacheView::UpdatePrintSettings(int32 value) -{ - struct font_cache_info fontCacheInfo; - - get_font_cache_info(B_PRINTING_FONT_CACHE|B_DEFAULT_CACHE_SETTING, - &fontCacheInfo); - fontCacheInfo.cache_size = value << 10; - set_font_cache_info(B_PRINTING_FONT_CACHE|B_DEFAULT_CACHE_SETTING, - &fontCacheInfo); - - BString str("Printing font cache size : "); - str << value << " kB"; - fPrintSlider->SetLabel(str.String()); -} - -void -CacheView::UpdateScreenSettings(int32 value) -{ - struct font_cache_info fontCacheInfo; - - get_font_cache_info(B_SCREEN_FONT_CACHE|B_DEFAULT_CACHE_SETTING, - &fontCacheInfo); - fontCacheInfo.cache_size = value << 10; - set_font_cache_info(B_SCREEN_FONT_CACHE|B_DEFAULT_CACHE_SETTING, - &fontCacheInfo); - - BString str("Screen font cache size : "); - str << value << " kB"; - fScreenSlider->SetLabel(str.String()); -} diff --git a/src/preferences/fonts/CacheView.h b/src/preferences/fonts/CacheView.h deleted file mode 100644 index f1eaba6129..0000000000 --- a/src/preferences/fonts/CacheView.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2001-2005, Haiku. - * Distributed under the terms of the MIT License. - * - */ -#ifndef CACHE_VIEW_H -#define CACHE_VIEW_H - -#include -#include -#include -#include - -class CacheView : public BView -{ -public: - CacheView(const BRect &frame, const int32 &sliderMin, - const int32 &sliderMax, const int32 &printVal, - const int32 &screenVal); - void AttachedToWindow(void); - void MessageReceived(BMessage *msg); - - void Revert(void); - void SetDefaults(void); - -private: - void UpdatePrintSettings(int32 value); - void UpdateScreenSettings(int32 value); - - BSlider *fScreenSlider; - BSlider *fPrintSlider; - BButton *fSaveCache; - - int32 fSavedPrintValue; - int32 fSavedScreenValue; -}; - -#endif diff --git a/src/preferences/fonts/FontsSettings.cpp b/src/preferences/fonts/FontsSettings.cpp index 3dc4786470..84853b9f87 100644 --- a/src/preferences/fonts/FontsSettings.cpp +++ b/src/preferences/fonts/FontsSettings.cpp @@ -1,8 +1,9 @@ /* * Copyright 2001-2005, Haiku. * Distributed under the terms of the MIT License. - * */ + + #include #include #include @@ -16,27 +17,26 @@ static const char kSettingsFile[] = "Font_Settings"; + FontsSettings::FontsSettings() { BPath path; BMessage msg; - + if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) { path.Append(kSettingsFile); BFile file(path.Path(), B_READ_ONLY); - + if (file.InitCheck() != B_OK) SetDefaults(); - else - if (msg.Unflatten(&file) != B_OK) + else if (msg.Unflatten(&file) != B_OK) SetDefaults(); else - { - msg.FindPoint("windowlocation",&fCorner); - } + msg.FindPoint("windowlocation", &fCorner); } } + FontsSettings::~FontsSettings() { BPath path; @@ -49,22 +49,7 @@ FontsSettings::~FontsSettings() BFile file(path.Path(), B_WRITE_ONLY|B_CREATE_FILE); if (file.InitCheck() == B_OK) { - msg.AddPoint("windowlocation",fCorner); - - // We need to add this to the settings file so that the app_server - // can get the font cache info on startup. This is the only - // place in the Fonts app that we actually need to do this because - // any other changes made are made through the API - struct font_cache_info cacheInfo; - - get_font_cache_info(B_SCREEN_FONT_CACHE|B_DEFAULT_CACHE_SETTING, - &cacheInfo); - msg.AddInt32("screencachesize",cacheInfo.cache_size); - - get_font_cache_info(B_PRINTING_FONT_CACHE|B_DEFAULT_CACHE_SETTING, - &cacheInfo); - msg.AddInt32("printcachesize",cacheInfo.cache_size); - + msg.AddPoint("windowlocation", fCorner); msg.Flatten(&file); } } @@ -76,9 +61,10 @@ FontsSettings::SetWindowCorner(BPoint where) fCorner = where; } + void -FontsSettings::SetDefaults(void) +FontsSettings::SetDefaults() { - fCorner.Set(100,100); + fCorner.Set(100, 100); } diff --git a/src/preferences/fonts/Jamfile b/src/preferences/fonts/Jamfile index e22585a992..fab04a5ad3 100644 --- a/src/preferences/fonts/Jamfile +++ b/src/preferences/fonts/Jamfile @@ -2,7 +2,6 @@ SubDir HAIKU_TOP src preferences fonts ; Preference Fonts : ButtonView.cpp - CacheView.cpp FontSelectionView.cpp FontsSettings.cpp FontView.cpp diff --git a/src/preferences/fonts/MainWindow.cpp b/src/preferences/fonts/MainWindow.cpp index fa3f76c94c..420ae39796 100644 --- a/src/preferences/fonts/MainWindow.cpp +++ b/src/preferences/fonts/MainWindow.cpp @@ -1,28 +1,21 @@ /* * Copyright 2001-2005, Haiku. * Distributed under the terms of the MIT License. - * */ + + #include "MainWindow.h" -MainWindow::MainWindow(void) - : BWindow( BRect(100,80,445,343) , "Fonts", B_TITLED_WINDOW, B_NOT_RESIZABLE | - B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE ) + +MainWindow::MainWindow() + : BWindow( BRect(100,80,445,343) , "Fonts", B_TITLED_WINDOW, + B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE) { BRect r; BTabView *tabView; BBox *topLevelView; double buttonViewHeight = 43.0; - struct font_cache_info cacheInfo; - int32 screenCacheSize, printCacheSize; - - get_font_cache_info(B_SCREEN_FONT_CACHE|B_DEFAULT_CACHE_SETTING, &cacheInfo); - screenCacheSize = cacheInfo.cache_size >> 10; - - get_font_cache_info(B_PRINTING_FONT_CACHE|B_DEFAULT_CACHE_SETTING, &cacheInfo); - printCacheSize = cacheInfo.cache_size >> 10; - r = Bounds(); r.top += 10; r.bottom -= buttonViewHeight+1; @@ -38,9 +31,6 @@ MainWindow::MainWindow(void) fSelectorView = new FontView(r); tabView->AddTab(fSelectorView); - fCacheView = new CacheView(r, 64, 4096, printCacheSize, screenCacheSize); - tabView->AddTab(fCacheView); - r = Bounds(); r.top = r.bottom - buttonViewHeight; @@ -55,8 +45,9 @@ MainWindow::MainWindow(void) MoveTo(fSettings.WindowCorner()); } + bool -MainWindow::QuitRequested(void) +MainWindow::QuitRequested() { fSettings.SetWindowCorner(Frame().LeftTop()); @@ -64,39 +55,31 @@ MainWindow::QuitRequested(void) return true; } + void MainWindow::MessageReceived(BMessage *message) { - switch(message->what) - { + switch (message->what) { case M_ENABLE_REVERT: - { fButtonView->SetRevertState(true); break; - } + case M_RESCAN_FONTS: - { fSelectorView->RescanFonts(); break; - } + case M_SET_DEFAULTS: - { fSelectorView->SetDefaults(); - fCacheView->SetDefaults(); fButtonView->SetRevertState(true); break; - } + case M_REVERT: - { fSelectorView->Revert(); - fCacheView->Revert(); fButtonView->SetRevertState(false); break; - } + default: - { BWindow::MessageReceived(message); break; - } } } diff --git a/src/preferences/fonts/MainWindow.h b/src/preferences/fonts/MainWindow.h index 60f8568955..0349543ad5 100644 --- a/src/preferences/fonts/MainWindow.h +++ b/src/preferences/fonts/MainWindow.h @@ -1,7 +1,6 @@ /* * Copyright 2001-2005, Haiku. * Distributed under the terms of the MIT License. - * */ #ifndef MAIN_WINDOW_H #define MAIN_WINDOW_H @@ -12,7 +11,6 @@ #include #include "FontView.h" -#include "CacheView.h" #include "ButtonView.h" #include "FontsSettings.h" @@ -24,21 +22,18 @@ #define M_SET_BOLD 'stbl' #define M_SET_FIXED 'stfx' -class MainWindow : public BWindow -{ -public: - MainWindow(void); - virtual bool QuitRequested(void); - virtual void MessageReceived(BMessage *message); - -private: - - FontView *fSelectorView; - ButtonView *fButtonView; - CacheView *fCacheView; - - FontsSettings fSettings; +class MainWindow : public BWindow { + public: + MainWindow(); + + virtual bool QuitRequested(); + virtual void MessageReceived(BMessage *message); + + private: + FontView *fSelectorView; + ButtonView *fButtonView; + + FontsSettings fSettings; }; -#endif - +#endif /* MAIN_WINDOW_H */