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:
parent
d73033ce64
commit
6b87afd360
@ -22,7 +22,6 @@
|
||||
#include <TextControl.h>
|
||||
#include <View.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
|
@ -13,9 +13,6 @@
|
||||
#include <View.h>
|
||||
|
||||
|
||||
//
|
||||
// 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
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,6 @@ Application Terminal :
|
||||
FindWindow.cpp
|
||||
Globals.cpp
|
||||
HistoryBuffer.cpp
|
||||
MenuUtil.cpp
|
||||
PrefHandler.cpp
|
||||
PrefWindow.cpp
|
||||
Shell.cpp
|
||||
|
@ -1,78 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2009, Haiku, Inc.
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
|
||||
* Distributed under the terms of the MIT license.
|
||||
*
|
||||
* Authors:
|
||||
* Kian Duffy <myob@users.sourceforge.net>
|
||||
*/
|
||||
|
||||
#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);
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2009, Haiku, Inc.
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
|
||||
* Distributed under the terms of the MIT license.
|
||||
*
|
||||
* Authors:
|
||||
* Kian Duffy <myob@users.sourceforge.net>
|
||||
*/
|
||||
#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
|
@ -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");
|
||||
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user