diff --git a/src/apps/terminal/AppearPrefView.cpp b/src/apps/terminal/AppearPrefView.cpp index a894fedef4..32efdfd08e 100644 --- a/src/apps/terminal/AppearPrefView.cpp +++ b/src/apps/terminal/AppearPrefView.cpp @@ -22,7 +22,6 @@ #include #include -#include "MenuUtil.h" #include "PrefHandler.h" #include "TermConst.h" @@ -73,7 +72,7 @@ AppearancePrefView::AppearancePrefView(const char *name, .Add(fFont = new BMenuField("font", "Font:", fontMenu)) .Add(fFontSize = new BMenuField("size", "Size:", sizeMenu)) .Add(fColorField = new BMenuField("color", "Color:", - MakeMenu(MSG_COLOR_FIELD_CHANGED, kColorTable, + _MakeMenu(MSG_COLOR_FIELD_CHANGED, kColorTable, kColorTable[0]))) .Add(BSpaceLayoutItem::CreateGlue()) .Add(fColorControl = new BColorControl(BPoint(10, 10), @@ -228,6 +227,7 @@ IsFontUsable(const BFont &font) } +/* static */ BMenu * AppearancePrefView::_MakeFontMenu(uint32 command, const char *defaultFamily, const char *defaultStyle) @@ -271,6 +271,7 @@ AppearancePrefView::_MakeFontMenu(uint32 command, } +/* static */ BMenu * AppearancePrefView::_MakeSizeMenu(uint32 command, uint8 defaultSize) { @@ -306,3 +307,26 @@ AppearancePrefView::_MakeSizeMenu(uint32 command, uint8 defaultSize) return menu; } + + +/* static */ +BPopUpMenu * +AppearancePrefView::_MakeMenu(uint32 msg, const char **items, + const char *defaultItemName) +{ + BPopUpMenu *menu = new BPopUpMenu(""); + + int32 i = 0; + while (*items) { + if (!strcmp(*items, "")) + menu->AddSeparatorItem(); + else + menu->AddItem(new BMenuItem(*items, new BMessage(msg))); + if (!strcmp(*items, defaultItemName)) + menu->ItemAt(i)->SetMarked(true); + + items++; + i++; + } + return menu; +} diff --git a/src/apps/terminal/AppearPrefView.h b/src/apps/terminal/AppearPrefView.h index fdc986a187..2bade841f0 100644 --- a/src/apps/terminal/AppearPrefView.h +++ b/src/apps/terminal/AppearPrefView.h @@ -13,9 +13,6 @@ #include -// -// Appearance Message -// const ulong MSG_HALF_FONT_CHANGED = 'mchf'; const ulong MSG_HALF_SIZE_CHANGED = 'mchs'; const ulong MSG_FULL_FONT_CHANGED = 'mcff'; @@ -30,33 +27,40 @@ const ulong MSG_HISTORY_CHANGED = 'mhst'; const ulong MSG_PREF_MODIFIED = 'mpmo'; - class BColorControl; class BMenu; class BMenuField; +class BPopUpMenu; class AppearancePrefView : public BView { - public: - AppearancePrefView(const char *name, const BMessenger &messenger); +public: + AppearancePrefView(const char *name, + const BMessenger &messenger); - virtual void Revert(); - virtual void MessageReceived(BMessage *message); - virtual void AttachedToWindow(); + virtual void Revert(); + virtual void MessageReceived(BMessage *message); + virtual void AttachedToWindow(); - virtual void GetPreferredSize(float *_width, float *_height); + virtual void GetPreferredSize(float *_width, + float *_height); - private: - BMenu* _MakeFontMenu(uint32 command, const char *defaultFamily, - const char *defaultStyle); - BMenu* _MakeSizeMenu(uint32 command, uint8 defaultSize); +private: + static BMenu* _MakeFontMenu(uint32 command, + const char *defaultFamily, + const char *defaultStyle); + static BMenu* _MakeSizeMenu(uint32 command, + uint8 defaultSize); + + static BPopUpMenu* _MakeMenu(uint32 msg, const char **items, + const char *defaultItemName); + + BMenuField *fFont; + BMenuField *fFontSize; - BMenuField *fFont; - BMenuField *fFontSize; + BMenuField *fColorField; + BColorControl *fColorControl; - BMenuField *fColorField; - BColorControl *fColorControl; - - BMessenger fTerminalMessenger; + BMessenger fTerminalMessenger; }; #endif // APPEARANCE_PREF_VIEW_H diff --git a/src/apps/terminal/FindWindow.cpp b/src/apps/terminal/FindWindow.cpp index 94029a59b3..5bf1508aa4 100644 --- a/src/apps/terminal/FindWindow.cpp +++ b/src/apps/terminal/FindWindow.cpp @@ -21,18 +21,19 @@ const uint32 MSG_FIND_HIDE = 'Fhid'; -FindWindow::FindWindow(BRect frame, BMessenger messenger , BString &str, - bool findSelection, bool matchWord, bool matchCase, bool forwardSearch) +FindWindow::FindWindow(BRect frame, BMessenger messenger, BString &str, + bool findSelection, bool matchWord, bool matchCase, + bool forwardSearch) : BWindow(frame, "Find", B_FLOATING_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_CLOSE_ON_ESCAPE | B_AUTO_UPDATE_SIZE_LIMITS), fFindDlgMessenger(messenger) { - AddShortcut((ulong)'W', (ulong)B_COMMAND_KEY, new BMessage(MSG_FIND_HIDE)); - SetLayout(new BGroupLayout(B_VERTICAL)); + BBox *separator = new BBox("separator"); + separator->SetExplicitMinSize(BSize(200, B_SIZE_UNSET)); separator->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1)); BView *layoutView = BGroupLayoutBuilder(B_VERTICAL, 10) @@ -79,6 +80,9 @@ FindWindow::FindWindow(BRect frame, BMessenger messenger , BString &str, fFindButton->MakeDefault(true); + AddShortcut((ulong)'W', (ulong)B_COMMAND_KEY, + new BMessage(MSG_FIND_HIDE)); + Show(); } @@ -131,8 +135,8 @@ FindWindow::_SendFindMessage() message.AddBool("findselection", true); //Add the other parameters - // TODO: "usetext" is never checked for elsewhere and seems redundant with - // "findselection", why is it here? + // TODO: "usetext" is never checked for elsewhere and seems + // redundant with "findselection", why is it here? message.AddBool("usetext", fTextRadio->Value() == B_CONTROL_ON); message.AddBool("forwardsearch", fForwardSearchBox->Value() == B_CONTROL_ON); message.AddBool("matchcase", fMatchCaseBox->Value() == B_CONTROL_ON); @@ -140,4 +144,3 @@ FindWindow::_SendFindMessage() fFindDlgMessenger.SendMessage(&message); } - diff --git a/src/apps/terminal/Jamfile b/src/apps/terminal/Jamfile index 0ca9a628e0..5e38e513c1 100644 --- a/src/apps/terminal/Jamfile +++ b/src/apps/terminal/Jamfile @@ -13,7 +13,6 @@ Application Terminal : FindWindow.cpp Globals.cpp HistoryBuffer.cpp - MenuUtil.cpp PrefHandler.cpp PrefWindow.cpp Shell.cpp diff --git a/src/apps/terminal/MenuUtil.cpp b/src/apps/terminal/MenuUtil.cpp deleted file mode 100644 index 54b7ebe9bc..0000000000 --- a/src/apps/terminal/MenuUtil.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2001-2009, Haiku, Inc. - * Copyright (c) 2003-4 Kian Duffy - * Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai. - * Distributed under the terms of the MIT license. - * - * Authors: - * Kian Duffy - */ - -#include "MenuUtil.h" - -#include -#include - -#include -#include -#include -#include - -#include "Coding.h" -#include "PrefHandler.h" -#include "TermConst.h" - - -BPopUpMenu * -MakeMenu(ulong msg, const char **items, const char *defaultItemName) -{ - BPopUpMenu *menu = new BPopUpMenu(""); - - int32 i = 0; - while (*items) { - if (!strcmp(*items, "")) - menu->AddSeparatorItem(); - else - menu->AddItem(new BMenuItem(*items, new BMessage(msg))); - if (!strcmp(*items, defaultItemName)) - menu->ItemAt(i)->SetMarked(true); - - items++; - i++; - } - return menu; -} - - -void -MakeEncodingMenu(BMenu *eMenu, bool withShortcuts) -{ - int encoding; - int i = 0; - while (get_nth_encoding(i, &encoding) == B_OK) { - BMessage *msg = new BMessage(MENU_ENCODING); - msg->AddInt32("op", (int32)encoding); - if (withShortcuts) { - eMenu->AddItem(new BMenuItem(EncodingAsString(encoding), msg, - id2shortcut(encoding))); - } else - eMenu->AddItem(new BMenuItem(EncodingAsString(encoding), msg)); - - i++; - } -} - - -void -LoadLocaleFile(PrefHandler *pref) -{ - char name[B_PATH_NAME_LENGTH]; - const char *locale; - - locale = PrefHandler::Default()->getString(PREF_GUI_LANGUAGE); - // TODO: this effectively disables any locale support - which is okay for now - sprintf(name, "%s%s", /*LOCALE_FILE_DIR*/"", locale); - - //if (pref->OpenText(name) < B_OK) - // pref->OpenText(LOCALE_FILE_DEFAULT); -} diff --git a/src/apps/terminal/MenuUtil.h b/src/apps/terminal/MenuUtil.h deleted file mode 100644 index 757f0b83a2..0000000000 --- a/src/apps/terminal/MenuUtil.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2001-2009, Haiku, Inc. - * Copyright (c) 2003-4 Kian Duffy - * Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai. - * Distributed under the terms of the MIT license. - * - * Authors: - * Kian Duffy - */ -#ifndef MENU_UTIL_H -#define MENU_UTIL_H - -#include - - -class BPopUpMenu; -class BMenu; -class PrefHandler; - -BPopUpMenu* MakeMenu(ulong msg, const char** items, - const char* defaultItemName); -void MakeEncodingMenu(BMenu *eMenu, bool withShortcuts); -void LoadLocaleFile(PrefHandler* handler); - -#endif // MENU_UTIL_H diff --git a/src/apps/terminal/TermWindow.cpp b/src/apps/terminal/TermWindow.cpp index f908a46ffe..f76760c866 100644 --- a/src/apps/terminal/TermWindow.cpp +++ b/src/apps/terminal/TermWindow.cpp @@ -31,7 +31,6 @@ #include "Arguments.h" #include "AppearPrefView.h" #include "Coding.h" -#include "MenuUtil.h" #include "FindWindow.h" #include "PrefWindow.h" #include "PrefHandler.h" @@ -255,13 +254,30 @@ TermWindow::MenusBeginning() } +/* static */ +void +TermWindow::_MakeEncodingMenu(BMenu *eMenu, bool withShortcuts) +{ + int encoding; + int i = 0; + while (get_nth_encoding(i, &encoding) == B_OK) { + BMessage *msg = new BMessage(MENU_ENCODING); + msg->AddInt32("op", (int32)encoding); + if (withShortcuts) { + eMenu->AddItem(new BMenuItem(EncodingAsString(encoding), + msg, id2shortcut(encoding))); + } else + eMenu->AddItem(new BMenuItem(EncodingAsString(encoding), + msg)); + + i++; + } +} + + void TermWindow::_SetupMenu() { - PrefHandler menuText; - - LoadLocaleFile(&menuText); - // Menu bar object. fMenubar = new BMenuBar(Bounds(), "mbar"); @@ -315,7 +331,7 @@ TermWindow::_SetupMenu() fEncodingmenu = new BMenu("Text Encoding"); fEncodingmenu->SetRadioMode(true); - MakeEncodingMenu(fEncodingmenu, false); + _MakeEncodingMenu(fEncodingmenu, false); fSizeMenu = new BMenu("Text Size"); diff --git a/src/apps/terminal/TermWindow.h b/src/apps/terminal/TermWindow.h index 0656b6bb01..a9fc6439ab 100644 --- a/src/apps/terminal/TermWindow.h +++ b/src/apps/terminal/TermWindow.h @@ -70,6 +70,7 @@ private: void _SetTermColors(TermViewContainerView *termView); void _InitWindow(); void _SetupMenu(); + static void _MakeEncodingMenu(BMenu *eMenu, bool withShortcuts); void _GetPreferredFont(BFont &font); status_t _DoPageSetup(); void _DoPrint();