Made the Find Window a bit wider by default, moved some functions around,

got rid of MenuUtil.h/cpp.
Some style change.
 


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34173 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2009-11-21 16:03:20 +00:00
parent d73033ce64
commit 6b87afd360
8 changed files with 83 additions and 139 deletions
+26 -2
View File
@@ -22,7 +22,6 @@
#include <TextControl.h> #include <TextControl.h>
#include <View.h> #include <View.h>
#include "MenuUtil.h"
#include "PrefHandler.h" #include "PrefHandler.h"
#include "TermConst.h" #include "TermConst.h"
@@ -73,7 +72,7 @@ AppearancePrefView::AppearancePrefView(const char *name,
.Add(fFont = new BMenuField("font", "Font:", fontMenu)) .Add(fFont = new BMenuField("font", "Font:", fontMenu))
.Add(fFontSize = new BMenuField("size", "Size:", sizeMenu)) .Add(fFontSize = new BMenuField("size", "Size:", sizeMenu))
.Add(fColorField = new BMenuField("color", "Color:", .Add(fColorField = new BMenuField("color", "Color:",
MakeMenu(MSG_COLOR_FIELD_CHANGED, kColorTable, _MakeMenu(MSG_COLOR_FIELD_CHANGED, kColorTable,
kColorTable[0]))) kColorTable[0])))
.Add(BSpaceLayoutItem::CreateGlue()) .Add(BSpaceLayoutItem::CreateGlue())
.Add(fColorControl = new BColorControl(BPoint(10, 10), .Add(fColorControl = new BColorControl(BPoint(10, 10),
@@ -228,6 +227,7 @@ IsFontUsable(const BFont &font)
} }
/* static */
BMenu * BMenu *
AppearancePrefView::_MakeFontMenu(uint32 command, AppearancePrefView::_MakeFontMenu(uint32 command,
const char *defaultFamily, const char *defaultStyle) const char *defaultFamily, const char *defaultStyle)
@@ -271,6 +271,7 @@ AppearancePrefView::_MakeFontMenu(uint32 command,
} }
/* static */
BMenu * BMenu *
AppearancePrefView::_MakeSizeMenu(uint32 command, uint8 defaultSize) AppearancePrefView::_MakeSizeMenu(uint32 command, uint8 defaultSize)
{ {
@@ -306,3 +307,26 @@ AppearancePrefView::_MakeSizeMenu(uint32 command, uint8 defaultSize)
return menu; 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;
}
+23 -19
View File
@@ -13,9 +13,6 @@
#include <View.h> #include <View.h>
//
// Appearance Message
//
const ulong MSG_HALF_FONT_CHANGED = 'mchf'; const ulong MSG_HALF_FONT_CHANGED = 'mchf';
const ulong MSG_HALF_SIZE_CHANGED = 'mchs'; const ulong MSG_HALF_SIZE_CHANGED = 'mchs';
const ulong MSG_FULL_FONT_CHANGED = 'mcff'; const ulong MSG_FULL_FONT_CHANGED = 'mcff';
@@ -30,33 +27,40 @@ const ulong MSG_HISTORY_CHANGED = 'mhst';
const ulong MSG_PREF_MODIFIED = 'mpmo'; const ulong MSG_PREF_MODIFIED = 'mpmo';
class BColorControl; class BColorControl;
class BMenu; class BMenu;
class BMenuField; class BMenuField;
class BPopUpMenu;
class AppearancePrefView : public BView { class AppearancePrefView : public BView {
public: public:
AppearancePrefView(const char *name, const BMessenger &messenger); AppearancePrefView(const char *name,
const BMessenger &messenger);
virtual void Revert(); virtual void Revert();
virtual void MessageReceived(BMessage *message); virtual void MessageReceived(BMessage *message);
virtual void AttachedToWindow(); virtual void AttachedToWindow();
virtual void GetPreferredSize(float *_width, float *_height); virtual void GetPreferredSize(float *_width,
float *_height);
private: private:
BMenu* _MakeFontMenu(uint32 command, const char *defaultFamily, static BMenu* _MakeFontMenu(uint32 command,
const char *defaultStyle); const char *defaultFamily,
BMenu* _MakeSizeMenu(uint32 command, uint8 defaultSize); const char *defaultStyle);
static BMenu* _MakeSizeMenu(uint32 command,
uint8 defaultSize);
BMenuField *fFont; static BPopUpMenu* _MakeMenu(uint32 msg, const char **items,
BMenuField *fFontSize; const char *defaultItemName);
BMenuField *fColorField; BMenuField *fFont;
BColorControl *fColorControl; BMenuField *fFontSize;
BMessenger fTerminalMessenger; BMenuField *fColorField;
BColorControl *fColorControl;
BMessenger fTerminalMessenger;
}; };
#endif // APPEARANCE_PREF_VIEW_H #endif // APPEARANCE_PREF_VIEW_H
+10 -7
View File
@@ -21,18 +21,19 @@
const uint32 MSG_FIND_HIDE = 'Fhid'; const uint32 MSG_FIND_HIDE = 'Fhid';
FindWindow::FindWindow(BRect frame, BMessenger messenger , BString &str, FindWindow::FindWindow(BRect frame, BMessenger messenger, BString &str,
bool findSelection, bool matchWord, bool matchCase, bool forwardSearch) bool findSelection, bool matchWord, bool matchCase,
bool forwardSearch)
: :
BWindow(frame, "Find", B_FLOATING_WINDOW, BWindow(frame, "Find", B_FLOATING_WINDOW,
B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_CLOSE_ON_ESCAPE B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_CLOSE_ON_ESCAPE
| B_AUTO_UPDATE_SIZE_LIMITS), | B_AUTO_UPDATE_SIZE_LIMITS),
fFindDlgMessenger(messenger) fFindDlgMessenger(messenger)
{ {
AddShortcut((ulong)'W', (ulong)B_COMMAND_KEY, new BMessage(MSG_FIND_HIDE));
SetLayout(new BGroupLayout(B_VERTICAL)); SetLayout(new BGroupLayout(B_VERTICAL));
BBox *separator = new BBox("separator"); BBox *separator = new BBox("separator");
separator->SetExplicitMinSize(BSize(200, B_SIZE_UNSET));
separator->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1)); separator->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1));
BView *layoutView = BGroupLayoutBuilder(B_VERTICAL, 10) BView *layoutView = BGroupLayoutBuilder(B_VERTICAL, 10)
@@ -79,6 +80,9 @@ FindWindow::FindWindow(BRect frame, BMessenger messenger , BString &str,
fFindButton->MakeDefault(true); fFindButton->MakeDefault(true);
AddShortcut((ulong)'W', (ulong)B_COMMAND_KEY,
new BMessage(MSG_FIND_HIDE));
Show(); Show();
} }
@@ -131,8 +135,8 @@ FindWindow::_SendFindMessage()
message.AddBool("findselection", true); message.AddBool("findselection", true);
//Add the other parameters //Add the other parameters
// TODO: "usetext" is never checked for elsewhere and seems redundant with // TODO: "usetext" is never checked for elsewhere and seems
// "findselection", why is it here? // redundant with "findselection", why is it here?
message.AddBool("usetext", fTextRadio->Value() == B_CONTROL_ON); message.AddBool("usetext", fTextRadio->Value() == B_CONTROL_ON);
message.AddBool("forwardsearch", fForwardSearchBox->Value() == B_CONTROL_ON); message.AddBool("forwardsearch", fForwardSearchBox->Value() == B_CONTROL_ON);
message.AddBool("matchcase", fMatchCaseBox->Value() == B_CONTROL_ON); message.AddBool("matchcase", fMatchCaseBox->Value() == B_CONTROL_ON);
@@ -140,4 +144,3 @@ FindWindow::_SendFindMessage()
fFindDlgMessenger.SendMessage(&message); fFindDlgMessenger.SendMessage(&message);
} }
-1
View File
@@ -13,7 +13,6 @@ Application Terminal :
FindWindow.cpp FindWindow.cpp
Globals.cpp Globals.cpp
HistoryBuffer.cpp HistoryBuffer.cpp
MenuUtil.cpp
PrefHandler.cpp PrefHandler.cpp
PrefWindow.cpp PrefWindow.cpp
Shell.cpp Shell.cpp
-78
View File
@@ -1,78 +0,0 @@
/*
* Copyright (c) 2001-2009, Haiku, Inc.
* Copyright (c) 2003-4 Kian Duffy <[email protected]>
* Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
* Distributed under the terms of the MIT license.
*
* Authors:
* Kian Duffy <[email protected]>
*/
#include "MenuUtil.h"
#include <stdio.h>
#include <string.h>
#include <Font.h>
#include <Menu.h>
#include <MenuItem.h>
#include <PopUpMenu.h>
#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);
}
-25
View File
@@ -1,25 +0,0 @@
/*
* Copyright (c) 2001-2009, Haiku, Inc.
* Copyright (c) 2003-4 Kian Duffy <[email protected]>
* Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
* Distributed under the terms of the MIT license.
*
* Authors:
* Kian Duffy <[email protected]>
*/
#ifndef MENU_UTIL_H
#define MENU_UTIL_H
#include <SupportDefs.h>
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
+22 -6
View File
@@ -31,7 +31,6 @@
#include "Arguments.h" #include "Arguments.h"
#include "AppearPrefView.h" #include "AppearPrefView.h"
#include "Coding.h" #include "Coding.h"
#include "MenuUtil.h"
#include "FindWindow.h" #include "FindWindow.h"
#include "PrefWindow.h" #include "PrefWindow.h"
#include "PrefHandler.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 void
TermWindow::_SetupMenu() TermWindow::_SetupMenu()
{ {
PrefHandler menuText;
LoadLocaleFile(&menuText);
// Menu bar object. // Menu bar object.
fMenubar = new BMenuBar(Bounds(), "mbar"); fMenubar = new BMenuBar(Bounds(), "mbar");
@@ -315,7 +331,7 @@ TermWindow::_SetupMenu()
fEncodingmenu = new BMenu("Text Encoding"); fEncodingmenu = new BMenu("Text Encoding");
fEncodingmenu->SetRadioMode(true); fEncodingmenu->SetRadioMode(true);
MakeEncodingMenu(fEncodingmenu, false); _MakeEncodingMenu(fEncodingmenu, false);
fSizeMenu = new BMenu("Text Size"); fSizeMenu = new BMenu("Text Size");
+1
View File
@@ -70,6 +70,7 @@ private:
void _SetTermColors(TermViewContainerView *termView); void _SetTermColors(TermViewContainerView *termView);
void _InitWindow(); void _InitWindow();
void _SetupMenu(); void _SetupMenu();
static void _MakeEncodingMenu(BMenu *eMenu, bool withShortcuts);
void _GetPreferredFont(BFont &font); void _GetPreferredFont(BFont &font);
status_t _DoPageSetup(); status_t _DoPageSetup();
void _DoPrint(); void _DoPrint();