* Fixed warnings.
* Automatic whitespace cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30267 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,26 +1,27 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2007, Haiku, Inc.
|
* Copyright 2001-2009, Haiku, Inc.
|
||||||
* Copyright 2003-2004 Kian Duffy, [email protected]
|
* Copyright 2003-2004 Kian Duffy, [email protected]
|
||||||
* Parts Copyright 1998-1999 Kazuho Okui and Takashi Murai.
|
* Parts Copyright 1998-1999 Kazuho Okui and Takashi Murai.
|
||||||
* All rights reserved. Distributed under the terms of the MIT license.
|
* All rights reserved. Distributed under the terms of the MIT license.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "AppearPrefView.h"
|
#include "AppearPrefView.h"
|
||||||
#include "MenuUtil.h"
|
|
||||||
#include "PrefHandler.h"
|
|
||||||
#include "TermConst.h"
|
|
||||||
|
|
||||||
#include <View.h>
|
|
||||||
#include <Button.h>
|
|
||||||
#include <MenuField.h>
|
|
||||||
#include <Menu.h>
|
|
||||||
#include <MenuItem.h>
|
|
||||||
#include <PopUpMenu.h>
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <Button.h>
|
||||||
|
#include <Menu.h>
|
||||||
|
#include <MenuField.h>
|
||||||
|
#include <MenuItem.h>
|
||||||
|
#include <PopUpMenu.h>
|
||||||
|
#include <View.h>
|
||||||
|
|
||||||
|
#include "MenuUtil.h"
|
||||||
|
#include "PrefHandler.h"
|
||||||
|
#include "TermConst.h"
|
||||||
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
IsFontUsable(const BFont &font)
|
IsFontUsable(const BFont &font)
|
||||||
@@ -33,47 +34,49 @@ IsFontUsable(const BFont &font)
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
bool widthOk = true;
|
bool widthOk = true;
|
||||||
int lastWidth;
|
int lastWidth = 0;
|
||||||
|
char buffer[2] = {0, 0};
|
||||||
for (int c = 0x20 ; c <= 0x7e; c++){
|
for (int c = 0x20 ; c <= 0x7e; c++){
|
||||||
char buf[4];
|
buffer[1] = c;
|
||||||
snprintf(buf, sizeof(buf), "%c", c);
|
|
||||||
int tmpWidth = (int)font.StringWidth(buf);
|
int width = (int)ceilf(font.StringWidth(buffer));
|
||||||
if (c > 0x20 &&(tmpWidth != lastWidth))
|
if (c > 0x20 && width != lastWidth)
|
||||||
widthOk = false;
|
widthOk = false;
|
||||||
lastWidth = tmpWidth;
|
lastWidth = width;
|
||||||
}
|
}
|
||||||
|
|
||||||
return widthOk;
|
return widthOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
AppearancePrefView::AppearancePrefView(BRect frame, const char *name,
|
AppearancePrefView::AppearancePrefView(BRect frame, const char *name,
|
||||||
BMessenger messenger)
|
BMessenger messenger)
|
||||||
: PrefView(frame, name),
|
: PrefView(frame, name),
|
||||||
fAppearancePrefViewMessenger(messenger)
|
fAppearancePrefViewMessenger(messenger)
|
||||||
{
|
{
|
||||||
const char *color_tbl[] = {
|
const char *color_tbl[] = {
|
||||||
PREF_TEXT_FORE_COLOR,
|
PREF_TEXT_FORE_COLOR,
|
||||||
PREF_TEXT_BACK_COLOR,
|
PREF_TEXT_BACK_COLOR,
|
||||||
PREF_CURSOR_FORE_COLOR,
|
PREF_CURSOR_FORE_COLOR,
|
||||||
PREF_CURSOR_BACK_COLOR,
|
PREF_CURSOR_BACK_COLOR,
|
||||||
PREF_SELECT_FORE_COLOR,
|
PREF_SELECT_FORE_COLOR,
|
||||||
PREF_SELECT_BACK_COLOR,
|
PREF_SELECT_BACK_COLOR,
|
||||||
#if 0
|
#if 0
|
||||||
"",
|
"",
|
||||||
PREF_IM_FORE_COLOR,
|
PREF_IM_FORE_COLOR,
|
||||||
PREF_IM_BACK_COLOR,
|
PREF_IM_BACK_COLOR,
|
||||||
PREF_IM_SELECT_COLOR,
|
PREF_IM_SELECT_COLOR,
|
||||||
"",
|
"",
|
||||||
PREF_ANSI_BLACK_COLOR,
|
PREF_ANSI_BLACK_COLOR,
|
||||||
PREF_ANSI_RED_COLOR,
|
PREF_ANSI_RED_COLOR,
|
||||||
PREF_ANSI_GREEN_COLOR,
|
PREF_ANSI_GREEN_COLOR,
|
||||||
PREF_ANSI_YELLOW_COLOR,
|
PREF_ANSI_YELLOW_COLOR,
|
||||||
PREF_ANSI_BLUE_COLOR,
|
PREF_ANSI_BLUE_COLOR,
|
||||||
PREF_ANSI_MAGENTA_COLOR,
|
PREF_ANSI_MAGENTA_COLOR,
|
||||||
PREF_ANSI_CYAN_COLOR,
|
PREF_ANSI_CYAN_COLOR,
|
||||||
PREF_ANSI_WHITE_COLOR,
|
PREF_ANSI_WHITE_COLOR,
|
||||||
#endif
|
#endif
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
float fontDividerSize = StringWidth("Font:") + 8.0;
|
float fontDividerSize = StringWidth("Font:") + 8.0;
|
||||||
@@ -122,7 +125,7 @@ AppearancePrefView::Revert()
|
|||||||
{
|
{
|
||||||
fColorField->Menu()->ItemAt(0)->SetMarked(true);
|
fColorField->Menu()->ItemAt(0)->SetMarked(true);
|
||||||
fColorControl->SetValue(PrefHandler::Default()->getRGB(PREF_TEXT_FORE_COLOR));
|
fColorControl->SetValue(PrefHandler::Default()->getRGB(PREF_TEXT_FORE_COLOR));
|
||||||
|
|
||||||
fFont->Menu()->FindItem(PrefHandler::Default()->getString(PREF_HALF_FONT_FAMILY))->SetMarked(true);
|
fFont->Menu()->FindItem(PrefHandler::Default()->getString(PREF_HALF_FONT_FAMILY))->SetMarked(true);
|
||||||
fFontSize->Menu()->FindItem(PrefHandler::Default()->getString(PREF_HALF_FONT_FAMILY))->SetMarked(true);
|
fFontSize->Menu()->FindItem(PrefHandler::Default()->getString(PREF_HALF_FONT_FAMILY))->SetMarked(true);
|
||||||
}
|
}
|
||||||
@@ -144,7 +147,7 @@ AppearancePrefView::MessageReceived(BMessage *msg)
|
|||||||
{
|
{
|
||||||
bool modified = false;
|
bool modified = false;
|
||||||
|
|
||||||
switch (msg->what) {
|
switch (msg->what) {
|
||||||
case MSG_HALF_FONT_CHANGED:
|
case MSG_HALF_FONT_CHANGED:
|
||||||
PrefHandler::Default()->setString(PREF_HALF_FONT_FAMILY,
|
PrefHandler::Default()->setString(PREF_HALF_FONT_FAMILY,
|
||||||
fFont->Menu()->FindMarked()->Label());
|
fFont->Menu()->FindMarked()->Label());
|
||||||
@@ -159,7 +162,7 @@ AppearancePrefView::MessageReceived(BMessage *msg)
|
|||||||
|
|
||||||
case MSG_COLOR_CHANGED:
|
case MSG_COLOR_CHANGED:
|
||||||
PrefHandler::Default()->setRGB(fColorField->Menu()->FindMarked()->Label(),
|
PrefHandler::Default()->setRGB(fColorField->Menu()->FindMarked()->Label(),
|
||||||
fColorControl->ValueAsColor());
|
fColorControl->ValueAsColor());
|
||||||
modified = true;
|
modified = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -175,7 +178,7 @@ AppearancePrefView::MessageReceived(BMessage *msg)
|
|||||||
|
|
||||||
if (modified) {
|
if (modified) {
|
||||||
fAppearancePrefViewMessenger.SendMessage(msg);
|
fAppearancePrefViewMessenger.SendMessage(msg);
|
||||||
|
|
||||||
BMessenger messenger(this);
|
BMessenger messenger(this);
|
||||||
messenger.SendMessage(MSG_PREF_MODIFIED);
|
messenger.SendMessage(MSG_PREF_MODIFIED);
|
||||||
}
|
}
|
||||||
@@ -186,7 +189,7 @@ BMenu *
|
|||||||
AppearancePrefView::_MakeFontMenu(uint32 command, const char *defaultFontName)
|
AppearancePrefView::_MakeFontMenu(uint32 command, const char *defaultFontName)
|
||||||
{
|
{
|
||||||
BPopUpMenu *menu = new BPopUpMenu("");
|
BPopUpMenu *menu = new BPopUpMenu("");
|
||||||
int32 numFamilies = count_font_families();
|
int32 numFamilies = count_font_families();
|
||||||
|
|
||||||
for (int32 i = 0; i < numFamilies; i++) {
|
for (int32 i = 0; i < numFamilies; i++) {
|
||||||
font_family family;
|
font_family family;
|
||||||
@@ -213,7 +216,7 @@ AppearancePrefView::_MakeSizeMenu(uint32 command, uint8 defaultSize)
|
|||||||
{
|
{
|
||||||
BPopUpMenu *menu = new BPopUpMenu("size");
|
BPopUpMenu *menu = new BPopUpMenu("size");
|
||||||
int32 sizes[] = {9, 10, 11, 12, 14, 16, 18, 0};
|
int32 sizes[] = {9, 10, 11, 12, 14, 16, 18, 0};
|
||||||
|
|
||||||
for (uint32 i = 0; sizes[i]; i++) {
|
for (uint32 i = 0; sizes[i]; i++) {
|
||||||
BString string;
|
BString string;
|
||||||
string << sizes[i];
|
string << sizes[i];
|
||||||
|
|||||||
@@ -543,10 +543,10 @@ BasicTerminalBuffer::InsertChar(UTF8Char c, uint32 width, uint32 attributes)
|
|||||||
//(int)c.ByteCount(), c.bytes, c.bytes[0], attributes);
|
//(int)c.ByteCount(), c.bytes, c.bytes[0], attributes);
|
||||||
// TODO: Check if this method can be removed completely
|
// TODO: Check if this method can be removed completely
|
||||||
//int width = CodeConv::UTF8GetFontWidth(c.bytes);
|
//int width = CodeConv::UTF8GetFontWidth(c.bytes);
|
||||||
if (width == FULL_WIDTH)
|
if ((int32)width == FULL_WIDTH)
|
||||||
attributes |= A_WIDTH;
|
attributes |= A_WIDTH;
|
||||||
|
|
||||||
if (fSoftWrappedCursor || fCursor.x + width > fWidth)
|
if (fSoftWrappedCursor || fCursor.x + (int32)width > fWidth)
|
||||||
_SoftBreakLine();
|
_SoftBreakLine();
|
||||||
else
|
else
|
||||||
_PadLineToCursor();
|
_PadLineToCursor();
|
||||||
@@ -903,7 +903,7 @@ BasicTerminalBuffer::_ResizeHistory(int32 width, int32 historyCapacity)
|
|||||||
if (line->length > width)
|
if (line->length > width)
|
||||||
_TruncateLine(line, width);
|
_TruncateLine(line, width);
|
||||||
history->AddLine(line);
|
history->AddLine(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delete fHistory;
|
delete fHistory;
|
||||||
|
|||||||
Reference in New Issue
Block a user