* Removed "full font" vs. "half font" setting (in the GUI only for now) - this
should better be handled by the app_server (ie. via font overlays). * Fixed compilation under Dano. * Fixed some broken headers. * Cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14861 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,32 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2003-4 Kian Duffy <[email protected]>
|
* Copyright (c) 2003-4 Kian Duffy <[email protected]>
|
||||||
* Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
|
* Copyright (c) 1998,99 Kazuho Okui and Takashi Murai.
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files or portions
|
|
||||||
* thereof (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge,
|
|
||||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so, subject
|
|
||||||
* to the following conditions:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright notice
|
|
||||||
* in the binary, as well as this list of conditions and the following
|
|
||||||
* disclaimer in the documentation and/or other materials provided with
|
|
||||||
* the distribution.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*
|
*
|
||||||
|
* Distributed unter the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "AppearPrefView.h"
|
||||||
|
#include "MenuUtil.h"
|
||||||
|
#include "PrefHandler.h"
|
||||||
|
#include "TermWindow.h"
|
||||||
|
#include "TermConst.h"
|
||||||
|
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
#include <Button.h>
|
#include <Button.h>
|
||||||
#include <MenuField.h>
|
#include <MenuField.h>
|
||||||
@@ -36,20 +21,13 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "AppearPrefView.h"
|
|
||||||
#include "MenuUtil.h"
|
|
||||||
#include "PrefHandler.h"
|
|
||||||
#include "TermWindow.h"
|
|
||||||
#include "TermConst.h"
|
|
||||||
|
|
||||||
BPopUpMenu *MakeFontMenu(ulong msg, const char *defaultFontName);
|
AppearancePrefView::AppearancePrefView(BRect frame, const char *name,
|
||||||
BPopUpMenu *MakeSizeMenu(ulong msg, uint8 defaultSize);
|
TermWindow *window)
|
||||||
|
: PrefView(frame, name),
|
||||||
AppearancePrefView::AppearancePrefView (BRect frame, const char *name, TermWindow *window)
|
fTermWindow(window)
|
||||||
:PrefView (frame, name)
|
|
||||||
{
|
{
|
||||||
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,
|
||||||
@@ -59,182 +37,149 @@ AppearancePrefView::AppearancePrefView (BRect frame, const char *name, TermWindo
|
|||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
fTermWindow = window;
|
float fontDividerSize = StringWidth("Font:") + 8.0;
|
||||||
|
float sizeDividerSize = StringWidth("Size:") + 8.0;
|
||||||
float fontDividerSize = StringWidth("Half Size Font") + 15.0;
|
|
||||||
float sizeDividerSize = StringWidth("Size") + 15.0;
|
|
||||||
|
|
||||||
BRect r(5,5,225,25);
|
|
||||||
|
|
||||||
BMenu *menu = MakeFontMenu(MSG_HALF_FONT_CHANGED, gTermPref->getString(PREF_HALF_FONT_FAMILY));
|
|
||||||
fHalfFont = new BMenuField(r, "halffont", "Half Width Font", menu, B_WILL_DRAW);
|
|
||||||
AddChild(fHalfFont);
|
|
||||||
fHalfFont->SetDivider(fontDividerSize);
|
|
||||||
|
|
||||||
r.OffsetBy(r.Width() + 10, 0);
|
|
||||||
menu = MakeSizeMenu(MSG_HALF_SIZE_CHANGED, 12);
|
|
||||||
fHalfFontSize = new BMenuField(r, "halfsize", "Size", menu, B_WILL_DRAW);
|
|
||||||
fHalfFontSize->SetDivider(sizeDividerSize);
|
|
||||||
AddChild(fHalfFontSize);
|
|
||||||
|
|
||||||
r.OffsetBy(-r.Width() - 10,r.Height() + 5);
|
|
||||||
menu = MakeFontMenu(MSG_FULL_FONT_CHANGED, gTermPref->getString(PREF_FULL_FONT_FAMILY));
|
|
||||||
fFullFont = new BMenuField(r, "fullfont", "Full Width Font", menu, B_WILL_DRAW);
|
|
||||||
AddChild(fFullFont);
|
|
||||||
fFullFont->SetDivider(fontDividerSize);
|
|
||||||
|
|
||||||
r.OffsetBy(r.Width() + 10, 0);
|
|
||||||
menu = MakeSizeMenu(MSG_FULL_SIZE_CHANGED, 12);
|
|
||||||
fFullFontSize = new BMenuField(r, "fullsize", "Size", menu, B_WILL_DRAW);
|
|
||||||
fFullFontSize->SetDivider(sizeDividerSize);
|
|
||||||
AddChild(fFullFontSize);
|
|
||||||
|
|
||||||
r.OffsetBy(-r.Width() - 10,r.Height() + 25);
|
|
||||||
fColorField = new BMenuField(r, NULL, NULL, MakeMenu (MSG_COLOR_FIELD_CHANGED, color_tbl, color_tbl[0]), B_WILL_DRAW);
|
|
||||||
AddChild(fColorField);
|
|
||||||
|
|
||||||
fColorCtl = SetupBColorControl(BPoint(r.left, r.bottom + 10), B_CELLS_32x8, 6,
|
BRect r(5, 5, 225, 25);
|
||||||
MSG_COLOR_CHANGED);
|
|
||||||
fColorCtl->SetValue(gTermPref->getRGB(PREF_TEXT_FORE_COLOR));
|
BMenu *menu = _MakeFontMenu(MSG_HALF_FONT_CHANGED,
|
||||||
|
gTermPref->getString(PREF_HALF_FONT_FAMILY));
|
||||||
|
fFont = new BMenuField(r, "font", "Font:", menu, B_WILL_DRAW);
|
||||||
|
fFont->SetDivider(fontDividerSize);
|
||||||
|
AddChild(fFont);
|
||||||
|
|
||||||
|
r.OffsetBy(r.Width() + 10, 0);
|
||||||
|
menu = _MakeSizeMenu(MSG_HALF_SIZE_CHANGED, 12);
|
||||||
|
fFontSize = new BMenuField(r, "size", "Size:", menu, B_WILL_DRAW);
|
||||||
|
fFontSize->SetDivider(sizeDividerSize);
|
||||||
|
AddChild(fFontSize);
|
||||||
|
|
||||||
|
r.OffsetBy(-r.Width() - 10,r.Height() + 25);
|
||||||
|
fColorField = new BMenuField(r, "color", "Change:",
|
||||||
|
MakeMenu(MSG_COLOR_FIELD_CHANGED, color_tbl, color_tbl[0]), B_WILL_DRAW);
|
||||||
|
fColorField->SetDivider(StringWidth(fColorField->Label()) + 8.0);
|
||||||
|
AddChild(fColorField);
|
||||||
|
|
||||||
|
fColorControl = SetupBColorControl(BPoint(r.left, r.bottom + 10),
|
||||||
|
B_CELLS_32x8, 6, MSG_COLOR_CHANGED);
|
||||||
|
fColorControl->SetValue(gTermPref->getRGB(PREF_TEXT_FORE_COLOR));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AppearancePrefView::Revert (void)
|
AppearancePrefView::GetPreferredSize(float *_width, float *_height)
|
||||||
{
|
{
|
||||||
fColorField->Menu()->ItemAt(0)->SetMarked (true);
|
if (_width)
|
||||||
fColorCtl->SetValue (gTermPref->getRGB(PREF_TEXT_FORE_COLOR));
|
*_width = Bounds().Width();
|
||||||
|
|
||||||
fHalfFont->Menu()->FindItem (gTermPref->getString(PREF_HALF_FONT_FAMILY))->SetMarked(true);
|
if (*_height)
|
||||||
fFullFont->Menu()->FindItem (gTermPref->getString(PREF_FULL_FONT_FAMILY))->SetMarked(true);
|
*_height = fColorControl->Frame().bottom;
|
||||||
fHalfFontSize->Menu()->FindItem (gTermPref->getString(PREF_HALF_FONT_FAMILY))->SetMarked(true);
|
|
||||||
fFullFontSize->Menu()->FindItem (gTermPref->getString(PREF_FULL_FONT_FAMILY))->SetMarked(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
AppearancePrefView::AttachedToWindow (void)
|
|
||||||
{
|
|
||||||
fHalfFontSize->Menu()->SetTargetForItems(this);
|
|
||||||
fFullFontSize->Menu()->SetTargetForItems(this);
|
|
||||||
|
|
||||||
fHalfFont->Menu()->SetTargetForItems(this);
|
|
||||||
fFullFont->Menu()->SetTargetForItems(this);
|
|
||||||
|
|
||||||
fColorCtl->SetTarget (this);
|
void
|
||||||
|
AppearancePrefView::Revert()
|
||||||
|
{
|
||||||
|
fColorField->Menu()->ItemAt(0)->SetMarked(true);
|
||||||
|
fColorControl->SetValue(gTermPref->getRGB(PREF_TEXT_FORE_COLOR));
|
||||||
|
|
||||||
|
fFont->Menu()->FindItem(gTermPref->getString(PREF_HALF_FONT_FAMILY))->SetMarked(true);
|
||||||
|
fFontSize->Menu()->FindItem(gTermPref->getString(PREF_HALF_FONT_FAMILY))->SetMarked(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AppearancePrefView::AttachedToWindow()
|
||||||
|
{
|
||||||
|
fFontSize->Menu()->SetTargetForItems(this);
|
||||||
|
fFont->Menu()->SetTargetForItems(this);
|
||||||
|
|
||||||
|
fColorControl->SetTarget(this);
|
||||||
fColorField->Menu()->SetTargetForItems(this);
|
fColorField->Menu()->SetTargetForItems(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AppearancePrefView::MessageReceived (BMessage *msg)
|
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:
|
||||||
{
|
gTermPref->setString (PREF_HALF_FONT_FAMILY,
|
||||||
gTermPref->setString (PREF_HALF_FONT_FAMILY, fHalfFont->Menu()->FindMarked()->Label());
|
fFont->Menu()->FindMarked()->Label());
|
||||||
modified = true;
|
modified = true;
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case MSG_HALF_SIZE_CHANGED:
|
case MSG_HALF_SIZE_CHANGED:
|
||||||
{
|
gTermPref->setString(PREF_HALF_FONT_SIZE,
|
||||||
gTermPref->setString (PREF_HALF_FONT_SIZE, fHalfFontSize->Menu()->FindMarked()->Label());
|
fFontSize->Menu()->FindMarked()->Label());
|
||||||
modified = true;
|
modified = true;
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case MSG_FULL_FONT_CHANGED:
|
|
||||||
{
|
|
||||||
gTermPref->setString (PREF_FULL_FONT_FAMILY, fFullFont->Menu()->FindMarked()->Label());
|
|
||||||
modified = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case MSG_FULL_SIZE_CHANGED:
|
|
||||||
{
|
|
||||||
gTermPref->setString (PREF_FULL_FONT_SIZE, fFullFontSize->Menu()->FindMarked()->Label());
|
|
||||||
modified = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case MSG_COLOR_CHANGED:
|
case MSG_COLOR_CHANGED:
|
||||||
{
|
gTermPref->setRGB(fColorField->Menu()->FindMarked()->Label(),
|
||||||
gTermPref->setRGB(fColorField->Menu()->FindMarked()->Label(), fColorCtl->ValueAsColor());
|
fColorControl->ValueAsColor());
|
||||||
modified = true;
|
modified = true;
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case MSG_COLOR_FIELD_CHANGED:
|
case MSG_COLOR_FIELD_CHANGED:
|
||||||
{
|
fColorControl->SetValue(gTermPref->getRGB(
|
||||||
fColorCtl->SetValue(gTermPref->getRGB (fColorField->Menu()->FindMarked()->Label()));
|
fColorField->Menu()->FindMarked()->Label()));
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
{
|
|
||||||
PrefView::MessageReceived(msg);
|
PrefView::MessageReceived(msg);
|
||||||
return; // Oh !
|
return;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(modified)
|
if (modified) {
|
||||||
{
|
fTermWindow->PostMessage(msg);
|
||||||
fTermWindow->PostMessage(msg);
|
Window()->PostMessage(MSG_PREF_MODIFIED);
|
||||||
Window()->PostMessage(MSG_PREF_MODIFIED);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BPopUpMenu *
|
|
||||||
MakeFontMenu(ulong msg, const char *defaultFontName)
|
BMenu *
|
||||||
|
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;
|
uint32 flags;
|
||||||
uint32 flags;
|
|
||||||
|
if (get_font_family(i, &family, &flags) == B_OK) {
|
||||||
if ( get_font_family(i, &family, &flags) == B_OK )
|
menu->AddItem(new BMenuItem(family, new BMessage(command)));
|
||||||
{
|
if (!strcmp(defaultFontName, family)) {
|
||||||
menu->AddItem(new BMenuItem(family, new BMessage(msg)));
|
BMenuItem* item = menu->ItemAt(i);
|
||||||
if(!strcmp(defaultFontName, family))
|
|
||||||
{
|
|
||||||
BMenuItem *item=menu->ItemAt(i);
|
|
||||||
item->SetMarked(true);
|
item->SetMarked(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return menu;
|
return menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
BPopUpMenu *
|
|
||||||
MakeSizeMenu(ulong msg, uint8 defaultSize)
|
BMenu *
|
||||||
|
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};
|
||||||
|
|
||||||
BMenuItem *item;
|
for (uint32 i = 0; sizes[i]; i++) {
|
||||||
|
|
||||||
for(uint8 i=9; i<13; i++)
|
|
||||||
{
|
|
||||||
BString string;
|
BString string;
|
||||||
string << i;
|
string << sizes[i];
|
||||||
|
|
||||||
item = new BMenuItem(string.String(), new BMessage(msg));
|
BMenuItem* item = new BMenuItem(string.String(), new BMessage(command));
|
||||||
menu->AddItem(item);
|
menu->AddItem(item);
|
||||||
|
|
||||||
if(i == defaultSize)
|
if (sizes[i] == defaultSize)
|
||||||
item->SetMarked(true);
|
item->SetMarked(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
item = new BMenuItem("14", new BMessage(msg));
|
|
||||||
menu->AddItem(item);
|
|
||||||
|
|
||||||
if(defaultSize == 14)
|
|
||||||
item->SetMarked(true);
|
|
||||||
|
|
||||||
item = new BMenuItem("16", new BMessage(msg));
|
|
||||||
menu->AddItem(item);
|
|
||||||
|
|
||||||
if(defaultSize == 16)
|
|
||||||
item->SetMarked(true);
|
|
||||||
|
|
||||||
return menu;
|
return menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,61 +1,45 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2003-4 Kian Duffy <[email protected]>
|
* Copyright (c) 2003-4 Kian Duffy <[email protected]>
|
||||||
* Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
|
* Copyright (c) 1998,99 Kazuho Okui and Takashi Murai.
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files or portions
|
|
||||||
* thereof (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge,
|
|
||||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so, subject
|
|
||||||
* to the following conditions:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright notice
|
|
||||||
* in the binary, as well as this list of conditions and the following
|
|
||||||
* disclaimer in the documentation and/or other materials provided with
|
|
||||||
* the distribution.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*
|
*
|
||||||
|
* Distributed unter the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
#ifndef APPEARANCE_PREF_VIEW_H
|
||||||
|
#define APPEARANCE_PREF_VIEW_H
|
||||||
|
|
||||||
#ifndef AppearancePrefView_H_INCLUDED
|
|
||||||
#define ApperaancePrefView_H_INCLUDED
|
|
||||||
|
|
||||||
#include "PrefView.h"
|
#include "PrefView.h"
|
||||||
|
|
||||||
|
class BColorControl;
|
||||||
|
class BMenu;
|
||||||
|
class BMenuField;
|
||||||
|
|
||||||
class TermWindow;
|
class TermWindow;
|
||||||
class TTextControl;
|
class TTextControl;
|
||||||
|
|
||||||
class AppearancePrefView : public PrefView
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AppearancePrefView(BRect r, const char *name,
|
|
||||||
TermWindow *window);
|
|
||||||
|
|
||||||
virtual void Revert (void);
|
class AppearancePrefView : public PrefView {
|
||||||
virtual void MessageReceived (BMessage *);
|
public:
|
||||||
virtual void AttachedToWindow (void);
|
AppearancePrefView(BRect frame, const char *name,
|
||||||
|
TermWindow *window);
|
||||||
|
|
||||||
private:
|
virtual void Revert();
|
||||||
BMenuField *fHalfFont,
|
virtual void MessageReceived(BMessage *message);
|
||||||
*fHalfFontSize,
|
virtual void AttachedToWindow();
|
||||||
*fFullFont,
|
|
||||||
*fFullFontSize;
|
virtual void GetPreferredSize(float *_width, float *_height);
|
||||||
|
|
||||||
BMenuField *fColorField;
|
private:
|
||||||
BColorControl *fColorCtl;
|
BMenu* _MakeFontMenu(uint32 command, const char *defaultFont);
|
||||||
|
BMenu* _MakeSizeMenu(uint32 command, uint8 defaultSize);
|
||||||
TermWindow *fTermWindow;
|
|
||||||
|
BMenuField *fFont;
|
||||||
|
BMenuField *fFontSize;
|
||||||
|
|
||||||
|
BMenuField *fColorField;
|
||||||
|
BColorControl *fColorControl;
|
||||||
|
|
||||||
|
TermWindow *fTermWindow;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //AppearancePrefView_H_INCLUDED
|
#endif // APPEARANCE_PREF_VIEW_H
|
||||||
|
|||||||
@@ -1,32 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2003-4 Kian Duffy <[email protected]>
|
* Copyright (c) 2003-4 Kian Duffy <[email protected]>
|
||||||
* Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
|
* Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files or portions
|
|
||||||
* thereof (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge,
|
|
||||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so, subject
|
|
||||||
* to the following conditions:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright notice
|
|
||||||
* in the binary, as well as this list of conditions and the following
|
|
||||||
* disclaimer in the documentation and/or other materials provided with
|
|
||||||
* the distribution.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*
|
*
|
||||||
|
* Distributed unter the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <Box.h>
|
#include <Box.h>
|
||||||
#include <Button.h>
|
#include <Button.h>
|
||||||
#include <FilePanel.h>
|
#include <FilePanel.h>
|
||||||
@@ -51,9 +30,9 @@
|
|||||||
extern PrefHandler *gTermPref;
|
extern PrefHandler *gTermPref;
|
||||||
|
|
||||||
PrefDlg::PrefDlg(TermWindow *inWindow)
|
PrefDlg::PrefDlg(TermWindow *inWindow)
|
||||||
: BWindow(CenteredRect(BRect(0, 0, 350, 215)), "Preference",
|
: BWindow(CenteredRect(BRect(0, 0, 350, 215)), "Terminal Settings",
|
||||||
B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
|
B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
|
||||||
B_NOT_RESIZABLE|B_NOT_ZOOMABLE)
|
B_NOT_RESIZABLE|B_NOT_ZOOMABLE)
|
||||||
{
|
{
|
||||||
fTermWindow = inWindow;
|
fTermWindow = inWindow;
|
||||||
fPrefTemp = new PrefHandler(gTermPref);
|
fPrefTemp = new PrefHandler(gTermPref);
|
||||||
@@ -100,17 +79,19 @@ PrefDlg::PrefDlg(TermWindow *inWindow)
|
|||||||
top->Bounds().Height() - 5 -
|
top->Bounds().Height() - 5 -
|
||||||
fRevertButton->Bounds().Height());
|
fRevertButton->Bounds().Height());
|
||||||
top->AddChild(fRevertButton);
|
top->AddChild(fRevertButton);
|
||||||
|
|
||||||
AddShortcut ((ulong)'Q', (ulong)B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED));
|
AddShortcut ((ulong)'Q', (ulong)B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED));
|
||||||
AddShortcut ((ulong)'W', (ulong)B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED));
|
AddShortcut ((ulong)'W', (ulong)B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED));
|
||||||
|
|
||||||
Show();
|
Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
PrefDlg::~PrefDlg (void)
|
|
||||||
|
PrefDlg::~PrefDlg()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PrefDlg::Quit()
|
PrefDlg::Quit()
|
||||||
{
|
{
|
||||||
@@ -120,39 +101,42 @@ PrefDlg::Quit()
|
|||||||
BWindow::Quit();
|
BWindow::Quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
PrefDlg::QuitRequested()
|
PrefDlg::QuitRequested()
|
||||||
{
|
{
|
||||||
if(!fDirty)
|
if (!fDirty)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
BAlert *alert = new BAlert("", "Save changes to this preference panel?",
|
BAlert *alert = new BAlert("", "Save changes to this preference panel?",
|
||||||
"Cancel", "Don't Save", "Save",
|
"Cancel", "Don't Save", "Save",
|
||||||
B_WIDTH_AS_USUAL, B_OFFSET_SPACING,
|
B_WIDTH_AS_USUAL, B_OFFSET_SPACING,
|
||||||
B_WARNING_ALERT);
|
B_WARNING_ALERT);
|
||||||
alert->SetShortcut(0, B_ESCAPE);
|
alert->SetShortcut(0, B_ESCAPE);
|
||||||
alert->SetShortcut(1, 'd');
|
alert->SetShortcut(1, 'd');
|
||||||
alert->SetShortcut(2, 's');
|
alert->SetShortcut(2, 's');
|
||||||
int32 button_index = alert->Go();
|
|
||||||
|
int32 index = alert->Go();
|
||||||
if(button_index==0)
|
if (index == 0)
|
||||||
return false;
|
return false;
|
||||||
else
|
|
||||||
if(button_index==2)
|
if (index == 2)
|
||||||
doSave();
|
doSave();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PrefDlg::doSaveAs (void)
|
PrefDlg::doSaveAs()
|
||||||
{
|
{
|
||||||
if(!fSavePanel)
|
if (!fSavePanel)
|
||||||
fSavePanel = new BFilePanel(B_SAVE_PANEL, new BMessenger(this));
|
fSavePanel = new BFilePanel(B_SAVE_PANEL, new BMessenger(this));
|
||||||
|
|
||||||
fSavePanel->Show();
|
fSavePanel->Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PrefDlg::SaveRequested(BMessage *msg)
|
PrefDlg::SaveRequested(BMessage *msg)
|
||||||
{
|
{
|
||||||
@@ -199,11 +183,11 @@ PrefDlg::doRevert()
|
|||||||
fDirty = false;
|
fDirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PrefDlg::MessageReceived(BMessage *msg)
|
PrefDlg::MessageReceived(BMessage *msg)
|
||||||
{
|
{
|
||||||
switch (msg->what)
|
switch (msg->what) {
|
||||||
{
|
|
||||||
case MSG_SAVE_PRESSED:
|
case MSG_SAVE_PRESSED:
|
||||||
{
|
{
|
||||||
doSave();
|
doSave();
|
||||||
@@ -239,6 +223,7 @@ PrefDlg::MessageReceived(BMessage *msg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BRect
|
BRect
|
||||||
PrefDlg::CenteredRect(BRect r)
|
PrefDlg::CenteredRect(BRect r)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,33 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2003-4 Kian Duffy <[email protected]>
|
|
||||||
* Copyright (c) 2004 Daniel Furrer <[email protected]>
|
* Copyright (c) 2004 Daniel Furrer <[email protected]>
|
||||||
* Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
|
* Copyright (c) 2003-4 Kian Duffy <[email protected]>
|
||||||
|
* Copyright (c) 1998,99 Kazuho Okui and Takashi Murai.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
* Distributed unter the terms of the MIT License.
|
||||||
* a copy of this software and associated documentation files or portions
|
|
||||||
* thereof (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge,
|
|
||||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so, subject
|
|
||||||
* to the following conditions:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright notice
|
|
||||||
* in the binary, as well as this list of conditions and the following
|
|
||||||
* disclaimer in the documentation and/or other materials provided with
|
|
||||||
* the distribution.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "Coding.h"
|
#include "Coding.h"
|
||||||
#include "PrefHandler.h"
|
#include "PrefHandler.h"
|
||||||
#include "TermConst.h"
|
#include "TermConst.h"
|
||||||
@@ -181,9 +160,15 @@ PrefHandler::SaveAsText(const char *path, const char *mimetype,
|
|||||||
BFile file(path, B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE);
|
BFile file(path, B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE);
|
||||||
char buffer[512];
|
char buffer[512];
|
||||||
type_code type;
|
type_code type;
|
||||||
char *key;
|
const char *key;
|
||||||
|
|
||||||
for (int32 i = 0; fContainer.GetInfo(B_STRING_TYPE, i, &key, &type) == B_OK; i++) {
|
for (int32 i = 0;
|
||||||
|
#ifdef B_BEOS_VERSION_DANO
|
||||||
|
fContainer.GetInfo(B_STRING_TYPE, i, &key, &type) == B_OK;
|
||||||
|
#else
|
||||||
|
fContainer.GetInfo(B_STRING_TYPE, i, (char**)&key, &type) == B_OK;
|
||||||
|
#endif
|
||||||
|
i++) {
|
||||||
int len = snprintf(buffer, sizeof(buffer), "\"%s\" , \"%s\"\n", key, getString(key));
|
int len = snprintf(buffer, sizeof(buffer), "\"%s\" , \"%s\"\n", key, getString(key));
|
||||||
file.Write(buffer, len);
|
file.Write(buffer, len);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,41 +1,22 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2003-4 Kian Duffy <[email protected]>
|
|
||||||
* Copyright (c) 2004 Daniel Furrer <[email protected]>
|
* Copyright (c) 2004 Daniel Furrer <[email protected]>
|
||||||
* Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
|
* Copyright (c) 2003-4 Kian Duffy <[email protected]>
|
||||||
*
|
* Copyright (c) 1998,99 Kazuho Okui and Takashi Murai.
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files or portions
|
|
||||||
* thereof (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge,
|
|
||||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so, subject
|
|
||||||
* to the following conditions:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright notice
|
|
||||||
* in the binary, as well as this list of conditions and the following
|
|
||||||
* disclaimer in the documentation and/or other materials provided with
|
|
||||||
* the distribution.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*
|
*
|
||||||
|
* Distributed unter the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef PREFHANDLER_H_INCLUDED
|
#ifndef PREF_HANDLER_H
|
||||||
#define PREFHANDLER_H_INCLUDED
|
#define PREF_HANDLER_H
|
||||||
|
|
||||||
|
|
||||||
#include <SupportDefs.h>
|
#include <SupportDefs.h>
|
||||||
#include <Errors.h>
|
|
||||||
#include <GraphicsDefs.h>
|
#include <GraphicsDefs.h>
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
|
|
||||||
|
class BFont;
|
||||||
|
class BPath;
|
||||||
|
|
||||||
|
|
||||||
#define TP_MAGIC 0xf1f2f3f4
|
#define TP_MAGIC 0xf1f2f3f4
|
||||||
#define TP_VERSION 0x02
|
#define TP_VERSION 0x02
|
||||||
#define TP_FONT_NAME_SZ 128
|
#define TP_FONT_NAME_SZ 128
|
||||||
@@ -110,4 +91,4 @@ class PrefHandler {
|
|||||||
BMessage fContainer;
|
BMessage fContainer;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PREFHANDLER_H_INCLUDED
|
#endif // PREF_HANDLER_H
|
||||||
|
|||||||
Reference in New Issue
Block a user