From 098ad0a57f10bdd2d80d4a278ebf568be4a7f573 Mon Sep 17 00:00:00 2001 From: Phil Greenway Date: Mon, 17 Jan 2005 08:35:56 +0000 Subject: [PATCH] Updated git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10791 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/prefs/fonts/ButtonView.cpp | 69 ++++++++------- src/prefs/fonts/ButtonView.h | 10 +-- src/prefs/fonts/CacheView.cpp | 120 ++++++++++++-------------- src/prefs/fonts/CacheView.h | 6 -- src/prefs/fonts/FontSelectionView.cpp | 78 ++++++++++------- src/prefs/fonts/FontSelectionView.h | 1 - src/prefs/fonts/FontView.cpp | 37 +++++--- src/prefs/fonts/FontView.h | 3 +- src/prefs/fonts/FontsSettings.cpp | 58 +++++++++++++ src/prefs/fonts/FontsSettings.h | 16 ++++ src/prefs/fonts/MainWindow.cpp | 23 ++--- src/prefs/fonts/Pref_Utils.cpp | 30 +++++++ src/prefs/fonts/Pref_Utils.h | 10 +++ src/prefs/fonts/Resource.rsrc | Bin 4219 -> 4212 bytes src/prefs/fonts/main.cpp | 46 ++++++---- src/prefs/fonts/main.h | 9 +- 16 files changed, 333 insertions(+), 183 deletions(-) create mode 100644 src/prefs/fonts/FontsSettings.cpp create mode 100644 src/prefs/fonts/FontsSettings.h create mode 100644 src/prefs/fonts/Pref_Utils.cpp create mode 100644 src/prefs/fonts/Pref_Utils.h diff --git a/src/prefs/fonts/ButtonView.cpp b/src/prefs/fonts/ButtonView.cpp index ace049dacf..30dde41b37 100644 --- a/src/prefs/fonts/ButtonView.cpp +++ b/src/prefs/fonts/ButtonView.cpp @@ -13,41 +13,28 @@ * @param rect The size of the view. */ ButtonView::ButtonView(BRect rect) - : BView(rect, "ButtonView", B_FOLLOW_ALL, B_WILL_DRAW) + :BView(rect, "ButtonView", B_FOLLOW_ALL, B_WILL_DRAW) { - - float x; - float y; - BRect viewSize = Bounds(); - BButton *rescanButton; - BButton *defaultsButton; - - x = viewSize.Width() / 37; - y = viewSize.Height() / 6; - SetViewColor(216,216,216,0); - rescanButton = new BButton(*(new BRect(x, y, (9.0 * x), (4.0 * y))), - "rescanButton", - "Rescan", - new BMessage(RESCAN_FONTS_MSG), - B_FOLLOW_LEFT, - B_WILL_DRAW - ); - defaultsButton = new BButton(*(new BRect((11.0 * x), y, (19.0 * x), (4.0 * y))), - "defaultsButton", - "Defaults", - new BMessage(RESET_FONTS_MSG), - B_FOLLOW_LEFT, - B_WILL_DRAW - ); - revertButton = new BButton(*(new BRect((20.0 * x), y, (28.0 * x), (4.0 * y))), - "revertButton", - "Revert", - new BMessage(REVERT_MSG), - B_FOLLOW_LEFT, - B_WILL_DRAW - ); + BRect btnRect(0, 0, 75, 25); + btnRect.OffsetBy(10, 8); + BButton *rescanButton = new BButton(btnRect, + "rescanButton", "Rescan", + new BMessage(RESCAN_FONTS_MSG), + B_FOLLOW_LEFT, B_WILL_DRAW); + + btnRect.OffsetBy(96, 0); + BButton *defaultsButton = new BButton(btnRect, + "defaultsButton", "Defaults", + new BMessage(RESET_FONTS_MSG), + B_FOLLOW_LEFT, B_WILL_DRAW); + + btnRect.OffsetBy(85, 0); + revertButton = new BButton(btnRect, + "revertButton", "Revert", + new BMessage(REVERT_MSG), + B_FOLLOW_LEFT, B_WILL_DRAW); revertButton->SetEnabled(false); @@ -57,6 +44,24 @@ ButtonView::ButtonView(BRect rect) } + +void +ButtonView::Draw(BRect update) +{ + rgb_color dark = {100, 100, 100, 255}; + rgb_color light = {255, 255, 255, 255}; + BRect bounds(Bounds()); + BeginLineArray(6); + AddLine(bounds.LeftTop(), bounds.RightTop(), light); + AddLine(bounds.LeftTop(), bounds.LeftBottom(), light); + AddLine(bounds.RightTop(), bounds.RightBottom(), dark); + AddLine(bounds.RightBottom(), bounds.LeftBottom(), dark); + AddLine(BPoint(95, 9), BPoint(95, 34), dark); + AddLine(BPoint(96, 9), BPoint(96, 34), light); + EndLineArray(); +} + + /** * Returns the state of the revert button. */ diff --git a/src/prefs/fonts/ButtonView.h b/src/prefs/fonts/ButtonView.h index 0fdb39089e..eabcdd1a6b 100644 --- a/src/prefs/fonts/ButtonView.h +++ b/src/prefs/fonts/ButtonView.h @@ -21,11 +21,7 @@ */ #define REVERT_MSG 'rvrt' - #ifndef _VIEW_H - - #include - - #endif + #include #ifndef _BUTTON_H @@ -33,14 +29,14 @@ #endif - class ButtonView : public BView{ + class ButtonView : public BView { public: ButtonView(BRect frame); bool RevertState(); void SetRevertState(bool b); - + void Draw(BRect); private: /** diff --git a/src/prefs/fonts/CacheView.cpp b/src/prefs/fonts/CacheView.cpp index d4b45a9ead..9b9b397a8f 100644 --- a/src/prefs/fonts/CacheView.cpp +++ b/src/prefs/fonts/CacheView.cpp @@ -6,6 +6,10 @@ #include "CacheView.h" #endif +#include +#include "Pref_Utils.h" + +const char *kLabel = "font cache size: "; /** * Constructor @@ -16,75 +20,66 @@ * @param screenCurrVal The starting value of the screen slider. */ CacheView::CacheView(BRect rect, int minVal, int maxVal, int32 printCurrVal, int32 screenCurrVal) - : BView(rect, "CacheView", B_FOLLOW_ALL, B_WILL_DRAW) + :BView(rect, "CacheView", B_FOLLOW_ALL, B_WILL_DRAW) { - - BRect viewSize = Bounds(); - char sliderMinLabel[10]; - char sliderMaxLabel[10]; - char msg[100]; + SetViewColor(216, 216, 216, 0); origPrintVal = printCurrVal; origScreenVal = screenCurrVal; - SetViewColor(216, 216, 216, 0); rgb_color fillColor; - fillColor.red = 0; - fillColor.blue = 152; - fillColor.green = 102; + fillColor.red = 102; + fillColor.blue = 203; + fillColor.green = 152; - viewSize.InsetBy(15, 10); - - sprintf(msg, "Screen font cache size : %d kB", static_cast(screenCurrVal)); - - screenFCS = new BSlider(*(new BRect(viewSize.left, viewSize.top, viewSize.right, viewSize.top + 25.0)), - "screenFontCache", - msg, - new BMessage(SCREEN_FCS_UPDATE_MSG), - minVal, - maxVal, - B_TRIANGLE_THUMB - ); + float fontheight = FontHeight(true); + BRect rect(Bounds()); + rect.InsetBy(5.0, 3.0); + rect.top += fontheight; + rect.bottom = rect.top +(fontheight *2.0); + BString labels(B_EMPTY_STRING); + labels << "Screen" << kLabel << screenCurrVal << " kB"; + screenFCS = new BSlider(rect, + "screenFontCache", labels.String(), + new BMessage(SCREEN_FCS_UPDATE_MSG), + minVal, maxVal, B_TRIANGLE_THUMB); + screenFCS->SetModificationMessage(new BMessage(SCREEN_FCS_MODIFICATION_MSG)); - - sprintf(sliderMinLabel, "%d kB", minVal); - sprintf(sliderMaxLabel, "%d kB", maxVal); - screenFCS->SetLimitLabels(sliderMinLabel, sliderMaxLabel); + + BString minLabel(B_EMPTY_STRING); + BString maxLabel(B_EMPTY_STRING); + minLabel << minVal << " kB"; + maxLabel << maxVal << " kB"; + screenFCS->SetLimitLabels(minLabel.String(), maxLabel.String()); screenFCS->UseFillColor(TRUE, &fillColor); screenFCS->SetValue(screenCurrVal); - viewSize.top = viewSize.top + 65.0; + rect.OffsetTo(rect.left, rect.bottom +(fontheight *2.5)); - sprintf(msg, "Printing font cache size : %d kB", static_cast(printCurrVal)); + labels = ""; + labels << "Printing " << kLabel << printCurrVal << " kB"; - printFCS = new BSlider(*(new BRect(viewSize.left, viewSize.top, viewSize.right, viewSize.top + 25.0)), - "printFontCache", - msg, - new BMessage(PRINT_FCS_UPDATE_MSG), - minVal, - maxVal, - B_TRIANGLE_THUMB - ); + printFCS = new BSlider(rect, "printFontCache", labels.String(), + new BMessage(PRINT_FCS_UPDATE_MSG), + minVal, maxVal, B_TRIANGLE_THUMB); + printFCS->SetModificationMessage(new BMessage(PRINT_FCS_MODIFICATION_MSG)); - printFCS->SetLimitLabels(sliderMinLabel, sliderMaxLabel); + printFCS->SetLimitLabels(minLabel.String(), maxLabel.String()); printFCS->UseFillColor(TRUE, &fillColor); printFCS->SetValue(printCurrVal); - viewSize.top = viewSize.top + 70.0; + rect.OffsetTo(rect.left -1.0, rect.bottom +(fontheight *2.0)); + rect.right = rect.left +86.0; + rect.bottom = rect.top +24.0; - BButton *saveCache = new BButton(*(new BRect(viewSize.left, viewSize.top, 100.0, 20.0)), - "saveCache", - "Save Cache", - NULL, - B_FOLLOW_LEFT, - B_WILL_DRAW - ); + BButton *saveCache = new BButton(rect, + "saveCache", "Save Cache", + NULL, B_FOLLOW_LEFT, B_WILL_DRAW); AddChild(screenFCS); AddChild(printFCS); - AddChild(saveCache); - + AddChild(saveCache); } /** @@ -129,16 +124,14 @@ int CacheView::getScreenFCSValue(){ * Sets the sliders to their original values. */ void CacheView::revertToOriginal(){ + + BString label; + label << "Screen " << kLabel << getScreenFCSValue(); + updateScreenFCS(label.String()); - char msg[100]; - - screenFCS->SetValue(origScreenVal); - sprintf(msg, "Screen font cache size : %d kB", getScreenFCSValue()); - updateScreenFCS(msg); - - printFCS->SetValue(origPrintVal); - sprintf(msg, "Printing font cache size : %d kB", getPrintFCSValue()); - updatePrintFCS(msg); + label = "Printing "; + label << kLabel << getPrintFCSValue(); + updatePrintFCS(label.String()); }//revertToOriginal @@ -146,16 +139,13 @@ void CacheView::revertToOriginal(){ * Sets the sliders to their default values. */ void CacheView::resetToDefaults(){ - - char msg[100]; + BString label; + label << "Screen " << kLabel << getScreenFCSValue() << " kB"; + updateScreenFCS(label.String()); - screenFCS->SetValue((int32) 256); - sprintf(msg, "Screen font cache size : %d kB", getScreenFCSValue()); - updateScreenFCS(msg); - - printFCS->SetValue((int32) 256); - sprintf(msg, "Printing font cache size : %d kB", getPrintFCSValue()); - updatePrintFCS(msg); + label = "Printing "; + label << kLabel << getPrintFCSValue() << " kB"; + updatePrintFCS(label.String()); }//revertToOriginal diff --git a/src/prefs/fonts/CacheView.h b/src/prefs/fonts/CacheView.h index e067713ccd..971279ef52 100644 --- a/src/prefs/fonts/CacheView.h +++ b/src/prefs/fonts/CacheView.h @@ -41,11 +41,6 @@ #include - #endif - #ifndef _STDIO_H - - #include - #endif #ifndef _BUTTON_H @@ -64,7 +59,6 @@ int getScreenFCSValue(); void revertToOriginal(); void resetToDefaults(); - private: /** diff --git a/src/prefs/fonts/FontSelectionView.cpp b/src/prefs/fonts/FontSelectionView.cpp index 3da9ce55da..0199195f42 100644 --- a/src/prefs/fonts/FontSelectionView.cpp +++ b/src/prefs/fonts/FontSelectionView.cpp @@ -9,6 +9,18 @@ #endif +#include "Pref_Utils.h" + +// should be changed to allow larger and smaller +#define minSizeIndex 7 +#define maxSizeIndex 12 + +// constants for labels +const char *kPlainFont = "Plain font:"; +const char *kBoldFont = "Bold font:"; +const char *kFixedFont = "Fixed font:"; +const char *kSize = "Size: "; + /** * Constructor * @param rect The size of the view. @@ -19,24 +31,11 @@ FontSelectionView::FontSelectionView(BRect rect, const char *name, int type) : BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW) { - BBox *testTextBox; - float x; - float y; - BRect viewSize = Bounds(); - BMenuField *fontListField; - BMenuField *sizeListField; - - x = viewSize.Width() / 37; - y = viewSize.Height() / 8; - - minSizeIndex = 9; - maxSizeIndex = 12; - switch(type){ case PLAIN_FONT_SELECTION_VIEW: - sprintf(typeLabel, "Plain font"); + sprintf(typeLabel, kPlainFont); origFont = be_plain_font; workingFont = be_plain_font; setSizeChangedMessage = PLAIN_SIZE_CHANGED_MSG; @@ -51,7 +50,7 @@ FontSelectionView::FontSelectionView(BRect rect, const char *name, int type) case BOLD_FONT_SELECTION_VIEW: - sprintf(typeLabel, "Bold font"); + sprintf(typeLabel, kBoldFont); origFont = be_bold_font; workingFont = be_bold_font; setSizeChangedMessage = BOLD_SIZE_CHANGED_MSG; @@ -66,7 +65,7 @@ FontSelectionView::FontSelectionView(BRect rect, const char *name, int type) case FIXED_FONT_SELECTION_VIEW: - sprintf(typeLabel, "Fixed font"); + sprintf(typeLabel, kFixedFont); origFont = be_fixed_font; workingFont = be_fixed_font; setSizeChangedMessage = FIXED_SIZE_CHANGED_MSG; @@ -80,23 +79,42 @@ FontSelectionView::FontSelectionView(BRect rect, const char *name, int type) break; }//switch - + + float fontheight = FontHeight(false); + float divider = StringWidth(kFixedFont); + sizeList = new BPopUpMenu("sizeList", true, true, B_ITEMS_IN_COLUMN); fontList = new BPopUpMenu("fontList", true, true, B_ITEMS_IN_COLUMN); - fontListField = new BMenuField(*(new BRect(x, y, (25 * x), (3 * y))), "fontField", typeLabel, fontList); - fontListField->SetDivider(7 * x); - sizeListField = new BMenuField(*(new BRect((27 * x), y, (36 * x), (3 * y))), "fontField", "Size", sizeList); - sizeListField->SetDivider(31 * x); - - testTextBox = new BBox(*(new BRect((8 * x), (5 * y), (36 * x), (8 * y))), "TestTextBox", B_FOLLOW_ALL, B_WILL_DRAW, B_FANCY_BORDER); + + // create menus + // size box + rect = Bounds(); + float x = StringWidth("999") +16; + rect.left = rect.right -(x +StringWidth(kSize)+8.0); + rect.bottom = fontheight +5; + BMenuField *sizeListField = new BMenuField(rect, "fontField", kSize, sizeList, true); + sizeListField->SetDivider(StringWidth(kSize)+5.0); + sizeListField->SetAlignment(B_ALIGN_RIGHT); + // font menu + rect.right = rect.left; + rect.left = 1; + rect.bottom = fontheight *1.5; + BMenuField *fontListField = new BMenuField(rect, "fontField", typeLabel, fontList, false); + fontListField->SetDivider(divider +6.0); + fontListField->SetAlignment(B_ALIGN_RIGHT); + + rect = Bounds(); + rect.left = divider +8.0; + rect.top = fontheight *1.5 +4; + rect.InsetBy(1, 1); + BBox *testTextBox = new BBox(rect, "TestTextBox", B_FOLLOW_ALL, B_WILL_DRAW, B_FANCY_BORDER); // Place the text slightly inside the entire box area, so it doesn't overlap the box outline. - BRect testTextRect(testTextBox->Bounds()); - testTextRect.top = 2; - testTextRect.left = 4; - testTextRect.bottom = testTextRect.bottom - 2; - testTextRect.right = testTextRect.right - 4; - testText = new BStringView(testTextRect, "testText", "The quick brown fox jumped over the lazy dog.", B_FOLLOW_ALL, B_WILL_DRAW); + rect = testTextBox->Bounds().InsetByCopy(2, 2); + rect.right -= 2; + BRect testTextRect(rect); + testText = new BStringView(testTextRect, "testText", "The quick brown fox jumps over the lazy dog.", + B_FOLLOW_ALL, B_WILL_DRAW); testText->SetFont(&workingFont); fontList->SetLabelFromMarked(true); @@ -461,7 +479,7 @@ void FontSelectionView::UpdateFontSelection(BFont *fnt){ if(strcmp(sizeList->ItemAt(i)->Label(), size) == 0){ sizeList->ItemAt(i)->SetMarked(true); - + break; }//if }//for diff --git a/src/prefs/fonts/FontSelectionView.h b/src/prefs/fonts/FontSelectionView.h index f4f3028fd1..0c0fba462d 100644 --- a/src/prefs/fonts/FontSelectionView.h +++ b/src/prefs/fonts/FontSelectionView.h @@ -116,7 +116,6 @@ void emptyMenus(); void resetToDefaults(); void revertToOriginal(); - private: /** diff --git a/src/prefs/fonts/FontView.cpp b/src/prefs/fonts/FontView.cpp index 4db7a8707c..730129c4b5 100644 --- a/src/prefs/fonts/FontView.cpp +++ b/src/prefs/fonts/FontView.cpp @@ -9,26 +9,24 @@ #endif +#include "Pref_Utils.h" + /** * Constructor. * @param rect The size of the view. */ FontView::FontView(BRect rect) - : BView(rect, "FontView", B_FOLLOW_ALL, B_WILL_DRAW) + :BView(rect, "FontView", B_FOLLOW_ALL, B_WILL_DRAW) { - - float x; - float y; - BRect viewSize = Bounds(); - - SetViewColor(216, 216, 216, 0); - - x = viewSize.Width() / 39; - y = viewSize.Height() / 25; - - plainSelectionView = new FontSelectionView(*(new BRect(x, y, (38.0 * x), (8.0 * y))), "Plain", PLAIN_FONT_SELECTION_VIEW); - boldSelectionView = new FontSelectionView(*(new BRect(x, (9.0 * y), (38.0 * x), (16.0 * y))), "Bold", BOLD_FONT_SELECTION_VIEW); - fixedSelectionView = new FontSelectionView(*(new BRect(x, (17.0 * y), (38.0 * x), (24.0 * y))), "Fixed", FIXED_FONT_SELECTION_VIEW); + BRect bounds(Bounds().InsetByCopy(5, 5)); + + BRect rect(bounds); + rect.bottom = rect.top +FontHeight(true) *3.5; + plainSelectionView = new FontSelectionView(rect, "Plain", PLAIN_FONT_SELECTION_VIEW); + rect.OffsetBy(0, rect.Height()+4); + boldSelectionView = new FontSelectionView(rect, "Bold", BOLD_FONT_SELECTION_VIEW); + rect.OffsetBy(0, rect.Height()+4); + fixedSelectionView = new FontSelectionView(rect, "Fixed", FIXED_FONT_SELECTION_VIEW); AddChild(plainSelectionView); AddChild(boldSelectionView); @@ -36,6 +34,17 @@ FontView::FontView(BRect rect) } + +void +FontView::AttachedToWindow(void) +{ + if (Parent() != NULL) + SetViewColor(Parent()->ViewColor()); + else + SetViewColor(219, 219, 219, 255); +} + + /** * Calls each FontSelectionView's buildMenus() function to build the * font and size menus. diff --git a/src/prefs/fonts/FontView.h b/src/prefs/fonts/FontView.h index 3d34606fb1..5f10a08f41 100644 --- a/src/prefs/fonts/FontView.h +++ b/src/prefs/fonts/FontView.h @@ -28,8 +28,8 @@ class FontView : public BView{ public: - FontView(BRect frame); + void AttachedToWindow(void); FontSelectionView *plainSelectionView; FontSelectionView *boldSelectionView; FontSelectionView *fixedSelectionView; @@ -37,7 +37,6 @@ void emptyMenus(); void resetToDefaults(); void revertToOriginal(); - }; #endif diff --git a/src/prefs/fonts/FontsSettings.cpp b/src/prefs/fonts/FontsSettings.cpp new file mode 100644 index 0000000000..7f1d7be31b --- /dev/null +++ b/src/prefs/fonts/FontsSettings.cpp @@ -0,0 +1,58 @@ +/* + FontsSettings.cpp +*/ + +#include +#include +#include +#include +#include +#include + +#include "FontsSettings.h" + +const char FontsSettings::kSettingsFile[] = "Font_Settings"; +const BPoint kDEFAULT = BPoint(100, 100); + +FontsSettings::FontsSettings() +{ + BPath path; + 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) { + float x, y; + if (file.Read(&x, sizeof(float)) != sizeof(float)) { + x = kDEFAULT.x; + } + if (file.Read(&y, sizeof(float)) != sizeof(float)) { + y = kDEFAULT.y; + } + f_corner = BPoint(x, y); + } else { + f_corner = kDEFAULT; + } + } +} + +FontsSettings::~FontsSettings() +{ + BPath path; + if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) < B_OK) + return; + path.Append(kSettingsFile); + BFile file(path.Path(), B_WRITE_ONLY|B_CREATE_FILE); + if (file.InitCheck() == B_OK) { + float x = f_corner.x; + float y = f_corner.y; + file.Write(&x, sizeof(float)); + file.Write(&y, sizeof(float)); + } +} + + +void +FontsSettings::SetWindowCorner(BPoint where) +{ + f_corner = where; +} diff --git a/src/prefs/fonts/FontsSettings.h b/src/prefs/fonts/FontsSettings.h new file mode 100644 index 0000000000..7c5e1eca51 --- /dev/null +++ b/src/prefs/fonts/FontsSettings.h @@ -0,0 +1,16 @@ +#ifndef FONTS_SETTINGS_H +#define FONTS_SETTINGS_H + +class FontsSettings { + public: + FontsSettings(void); + ~FontsSettings(void); + + BPoint WindowCorner(void) const { return f_corner; } + void SetWindowCorner(BPoint); + private: + static const char kSettingsFile[]; + BPoint f_corner; +}; + +#endif //FONTS_SETTINGS_H diff --git a/src/prefs/fonts/MainWindow.cpp b/src/prefs/fonts/MainWindow.cpp index d9785b3457..9982517fd1 100644 --- a/src/prefs/fonts/MainWindow.cpp +++ b/src/prefs/fonts/MainWindow.cpp @@ -16,27 +16,28 @@ * @param frame The size to make the window. */ MainWindow::MainWindow(BRect frame) - : BWindow(frame, "Fonts", B_TITLED_WINDOW, B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE ){ + :BWindow(frame, "Fonts", B_TITLED_WINDOW, B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE ){ BRect r; BTabView *tabView; BTab *tab; BBox *topLevelView; - double buttonViewHeight = 38.0; + double buttonViewHeight = 43.0; r = Bounds(); - r.InsetBy(0, 10); - r.bottom -= buttonViewHeight; + r.top += 10; + r.bottom -= buttonViewHeight+1; - tabView = new BTabView(r, "tab_view", B_WIDTH_FROM_WIDEST); + tabView = new BTabView(r, "tab_view", B_WIDTH_FROM_LABEL); tabView->SetViewColor(216,216,216,0); r = tabView->Bounds(); - r.InsetBy(5,5); - r.bottom -= tabView->TabHeight(); + r.InsetBy(5, 5); + r.bottom -= tabView->TabHeight(); + r.right -=2; tab = new BTab(); tabView->AddTab(fontPanel = new FontView(r), tab); - tab->SetLabel("Fonts"); + tab->SetLabel(" Fonts "); tab = new BTab(); tabView->AddTab(cachePanel = new CacheView(r, 64, 4096, (int32) 256, (int32) 256), tab); tab->SetLabel("Cache"); @@ -59,8 +60,10 @@ MainWindow::MainWindow(BRect frame) */ bool MainWindow::QuitRequested() { - be_app->PostMessage(B_QUIT_REQUESTED); - return(true); + BMessage *message = new BMessage(B_QUIT_REQUESTED); + message->AddPoint("corner", Frame().LeftTop()); + be_app->PostMessage(message); + return true; } /** diff --git a/src/prefs/fonts/Pref_Utils.cpp b/src/prefs/fonts/Pref_Utils.cpp new file mode 100644 index 0000000000..ff1a08cbf9 --- /dev/null +++ b/src/prefs/fonts/Pref_Utils.cpp @@ -0,0 +1,30 @@ +#include "Pref_Utils.h" + +float +FontHeight(bool full, BView* target) +{ + font_height finfo; + if (target != NULL) + target->GetFontHeight(&finfo); + else + be_plain_font->GetHeight(&finfo); + + float height = ceil(finfo.ascent) + ceil(finfo.descent); + + if (full) + height += ceil(finfo.leading); + + return height; +} + +color_map* +ColorMap() +{ + color_map* cmap; + + BScreen screen(B_MAIN_SCREEN_ID); + cmap = (color_map*)screen.ColorMap(); + + return cmap; +} + diff --git a/src/prefs/fonts/Pref_Utils.h b/src/prefs/fonts/Pref_Utils.h new file mode 100644 index 0000000000..4379a1d3d4 --- /dev/null +++ b/src/prefs/fonts/Pref_Utils.h @@ -0,0 +1,10 @@ +#ifndef SHARED_PREF_UTILS +#define SHARED_PREF_UTILS + +#include +#include + +float FontHeight(bool full, BView* view = NULL); +color_map* ColorMap(); + +#endif diff --git a/src/prefs/fonts/Resource.rsrc b/src/prefs/fonts/Resource.rsrc index ef0d2a6b7e40dc2c1ea5159ae6f226a992774fb4..ec69bdc399c00832c2b5e826115afc4664029feb 100644 GIT binary patch delta 231 zcmeyZ@I_(50pE6h28NdmK+Md*u!fz1fd$A0fek?R3ML3Uf(uAPB_jBMY(}U!P_Hb6 z$xsSp3vK3QT+B9c0?X!SJS&(sA7U3`_4Y{2%r4b+^9%4{Fm&>F1L_nKf@)!8a0>`< z1epcG{0vU6{=rs`0Ri!DK926e4F91Z462A}vVnjcr=P#GXDU!R^W=m4s*Eg?p94wO d$-DwmobK+yz956xCeP-V0 n%jvp7d2B!teg-F3|6nV}fPi>6A4m6KhW}7tBKGhwP@Vw*isvy^ diff --git a/src/prefs/fonts/main.cpp b/src/prefs/fonts/main.cpp index 57cbc0d57f..c962423d8d 100644 --- a/src/prefs/fonts/main.cpp +++ b/src/prefs/fonts/main.cpp @@ -14,6 +14,8 @@ #endif +#include "FontsSettings.h" + /** * Main method. * @@ -38,22 +40,36 @@ int main(int, char**){ * Provides a contstructor for the application. */ Font_pref::Font_pref() - :BApplication("application/x-vnd.MSM-FontPrefPanel"){ + :BApplication("application/x-vnd.Haiku-FNPL") { - /* - * The main interface window. - */ - MainWindow *Main; - - /* - * Sets the size for the main window. - */ + f_settings = new FontsSettings(); BRect MainWindowRect; - - MainWindowRect.Set(100, 80, 450, 350); - Main = new MainWindow(MainWindowRect); - - Main->Show(); - + MainWindowRect.Set(100, 80, 445, 343); + window = new MainWindow(MainWindowRect); + window->MoveTo(f_settings->WindowCorner()); } +Font_pref::~Font_pref() +{ + delete f_settings; +} + + +bool +Font_pref::QuitRequested() +{ + BMessage *message = CurrentMessage(); + BPoint point; + if (message->FindPoint("corner", &point) == B_OK) { + f_settings->SetWindowCorner(point); + } + + return BApplication::QuitRequested(); +} + + +void +Font_pref::ReadyToRun() +{ + window->Show(); +} diff --git a/src/prefs/fonts/main.h b/src/prefs/fonts/main.h index 1a46f627be..e4c7bae112 100644 --- a/src/prefs/fonts/main.h +++ b/src/prefs/fonts/main.h @@ -13,6 +13,8 @@ #endif + class FontsSettings; + class MainWindow; /** * Main class. * @@ -26,7 +28,12 @@ * Constructor. */ Font_pref(); - + ~Font_pref(); + void ReadyToRun(); + bool QuitRequested(); + private: + FontsSettings *f_settings; + MainWindow *window; }; #endif