* 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:
parent
25922abe74
commit
723de034c6
@ -1,32 +1,17 @@
|
||||
/*
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* Parts 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.
|
||||
* Copyright (c) 1998,99 Kazuho Okui and Takashi Murai.
|
||||
*
|
||||
* 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 <Button.h>
|
||||
#include <MenuField.h>
|
||||
@ -36,20 +21,13 @@
|
||||
|
||||
#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);
|
||||
BPopUpMenu *MakeSizeMenu(ulong msg, uint8 defaultSize);
|
||||
|
||||
AppearancePrefView::AppearancePrefView (BRect frame, const char *name, TermWindow *window)
|
||||
:PrefView (frame, name)
|
||||
AppearancePrefView::AppearancePrefView(BRect frame, const char *name,
|
||||
TermWindow *window)
|
||||
: PrefView(frame, name),
|
||||
fTermWindow(window)
|
||||
{
|
||||
const char *color_tbl[]=
|
||||
{
|
||||
const char *color_tbl[] = {
|
||||
PREF_TEXT_FORE_COLOR,
|
||||
PREF_TEXT_BACK_COLOR,
|
||||
PREF_CURSOR_FORE_COLOR,
|
||||
@ -59,182 +37,149 @@ AppearancePrefView::AppearancePrefView (BRect frame, const char *name, TermWindo
|
||||
NULL
|
||||
};
|
||||
|
||||
fTermWindow = window;
|
||||
|
||||
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);
|
||||
float fontDividerSize = StringWidth("Font:") + 8.0;
|
||||
float sizeDividerSize = StringWidth("Size:") + 8.0;
|
||||
|
||||
fColorCtl = SetupBColorControl(BPoint(r.left, r.bottom + 10), B_CELLS_32x8, 6,
|
||||
MSG_COLOR_CHANGED);
|
||||
fColorCtl->SetValue(gTermPref->getRGB(PREF_TEXT_FORE_COLOR));
|
||||
BRect r(5, 5, 225, 25);
|
||||
|
||||
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
|
||||
AppearancePrefView::Revert (void)
|
||||
AppearancePrefView::GetPreferredSize(float *_width, float *_height)
|
||||
{
|
||||
fColorField->Menu()->ItemAt(0)->SetMarked (true);
|
||||
fColorCtl->SetValue (gTermPref->getRGB(PREF_TEXT_FORE_COLOR));
|
||||
|
||||
fHalfFont->Menu()->FindItem (gTermPref->getString(PREF_HALF_FONT_FAMILY))->SetMarked(true);
|
||||
fFullFont->Menu()->FindItem (gTermPref->getString(PREF_FULL_FONT_FAMILY))->SetMarked(true);
|
||||
fHalfFontSize->Menu()->FindItem (gTermPref->getString(PREF_HALF_FONT_FAMILY))->SetMarked(true);
|
||||
fFullFontSize->Menu()->FindItem (gTermPref->getString(PREF_FULL_FONT_FAMILY))->SetMarked(true);
|
||||
if (_width)
|
||||
*_width = Bounds().Width();
|
||||
|
||||
if (*_height)
|
||||
*_height = fColorControl->Frame().bottom;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AppearancePrefView::MessageReceived (BMessage *msg)
|
||||
AppearancePrefView::MessageReceived(BMessage *msg)
|
||||
{
|
||||
bool modified = false;
|
||||
|
||||
switch (msg->what)
|
||||
{
|
||||
bool modified = false;
|
||||
|
||||
switch (msg->what) {
|
||||
case MSG_HALF_FONT_CHANGED:
|
||||
{
|
||||
gTermPref->setString (PREF_HALF_FONT_FAMILY, fHalfFont->Menu()->FindMarked()->Label());
|
||||
gTermPref->setString (PREF_HALF_FONT_FAMILY,
|
||||
fFont->Menu()->FindMarked()->Label());
|
||||
modified = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case MSG_HALF_SIZE_CHANGED:
|
||||
{
|
||||
gTermPref->setString (PREF_HALF_FONT_SIZE, fHalfFontSize->Menu()->FindMarked()->Label());
|
||||
gTermPref->setString(PREF_HALF_FONT_SIZE,
|
||||
fFontSize->Menu()->FindMarked()->Label());
|
||||
modified = true;
|
||||
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:
|
||||
{
|
||||
gTermPref->setRGB(fColorField->Menu()->FindMarked()->Label(), fColorCtl->ValueAsColor());
|
||||
gTermPref->setRGB(fColorField->Menu()->FindMarked()->Label(),
|
||||
fColorControl->ValueAsColor());
|
||||
modified = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case MSG_COLOR_FIELD_CHANGED:
|
||||
{
|
||||
fColorCtl->SetValue(gTermPref->getRGB (fColorField->Menu()->FindMarked()->Label()));
|
||||
fColorControl->SetValue(gTermPref->getRGB(
|
||||
fColorField->Menu()->FindMarked()->Label()));
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
PrefView::MessageReceived(msg);
|
||||
return; // Oh !
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if(modified)
|
||||
{
|
||||
fTermWindow->PostMessage(msg);
|
||||
Window()->PostMessage(MSG_PREF_MODIFIED);
|
||||
|
||||
if (modified) {
|
||||
fTermWindow->PostMessage(msg);
|
||||
Window()->PostMessage(MSG_PREF_MODIFIED);
|
||||
}
|
||||
}
|
||||
|
||||
BPopUpMenu *
|
||||
MakeFontMenu(ulong msg, const char *defaultFontName)
|
||||
|
||||
BMenu *
|
||||
AppearancePrefView::_MakeFontMenu(uint32 command, const char *defaultFontName)
|
||||
{
|
||||
BPopUpMenu *menu = new BPopUpMenu("");
|
||||
int32 numFamilies = count_font_families();
|
||||
|
||||
for ( int32 i = 0; i < numFamilies; i++ )
|
||||
{
|
||||
font_family family;
|
||||
uint32 flags;
|
||||
|
||||
if ( get_font_family(i, &family, &flags) == B_OK )
|
||||
{
|
||||
menu->AddItem(new BMenuItem(family, new BMessage(msg)));
|
||||
if(!strcmp(defaultFontName, family))
|
||||
{
|
||||
BMenuItem *item=menu->ItemAt(i);
|
||||
|
||||
for (int32 i = 0; i < numFamilies; i++) {
|
||||
font_family family;
|
||||
uint32 flags;
|
||||
|
||||
if (get_font_family(i, &family, &flags) == B_OK) {
|
||||
menu->AddItem(new BMenuItem(family, new BMessage(command)));
|
||||
if (!strcmp(defaultFontName, family)) {
|
||||
BMenuItem* item = menu->ItemAt(i);
|
||||
item->SetMarked(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
||||
BPopUpMenu *
|
||||
MakeSizeMenu(ulong msg, uint8 defaultSize)
|
||||
|
||||
BMenu *
|
||||
AppearancePrefView::_MakeSizeMenu(uint32 command, uint8 defaultSize)
|
||||
{
|
||||
BPopUpMenu *menu = new BPopUpMenu("size");
|
||||
int32 sizes[] = {9, 10, 11, 12, 14, 16, 18, 0};
|
||||
|
||||
BMenuItem *item;
|
||||
|
||||
for(uint8 i=9; i<13; i++)
|
||||
{
|
||||
for (uint32 i = 0; sizes[i]; i++) {
|
||||
BString string;
|
||||
string << i;
|
||||
|
||||
item = new BMenuItem(string.String(), new BMessage(msg));
|
||||
string << sizes[i];
|
||||
|
||||
BMenuItem* item = new BMenuItem(string.String(), new BMessage(command));
|
||||
menu->AddItem(item);
|
||||
|
||||
if(i == defaultSize)
|
||||
|
||||
if (sizes[i] == defaultSize)
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -1,61 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* Parts 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.
|
||||
* Copyright (c) 1998,99 Kazuho Okui and Takashi Murai.
|
||||
*
|
||||
* 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"
|
||||
|
||||
class BColorControl;
|
||||
class BMenu;
|
||||
class BMenuField;
|
||||
|
||||
class TermWindow;
|
||||
class TTextControl;
|
||||
|
||||
class AppearancePrefView : public PrefView
|
||||
{
|
||||
public:
|
||||
AppearancePrefView(BRect r, const char *name,
|
||||
TermWindow *window);
|
||||
|
||||
virtual void Revert (void);
|
||||
virtual void MessageReceived (BMessage *);
|
||||
virtual void AttachedToWindow (void);
|
||||
class AppearancePrefView : public PrefView {
|
||||
public:
|
||||
AppearancePrefView(BRect frame, const char *name,
|
||||
TermWindow *window);
|
||||
|
||||
private:
|
||||
BMenuField *fHalfFont,
|
||||
*fHalfFontSize,
|
||||
*fFullFont,
|
||||
*fFullFontSize;
|
||||
|
||||
BMenuField *fColorField;
|
||||
BColorControl *fColorCtl;
|
||||
|
||||
TermWindow *fTermWindow;
|
||||
virtual void Revert();
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
virtual void AttachedToWindow();
|
||||
|
||||
virtual void GetPreferredSize(float *_width, float *_height);
|
||||
|
||||
private:
|
||||
BMenu* _MakeFontMenu(uint32 command, const char *defaultFont);
|
||||
BMenu* _MakeSizeMenu(uint32 command, uint8 defaultSize);
|
||||
|
||||
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 <myob@users.sourceforge.net>
|
||||
* Parts 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.
|
||||
* Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
|
||||
*
|
||||
* Distributed unter the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include <Box.h>
|
||||
#include <Button.h>
|
||||
#include <FilePanel.h>
|
||||
@ -51,9 +30,9 @@
|
||||
extern PrefHandler *gTermPref;
|
||||
|
||||
PrefDlg::PrefDlg(TermWindow *inWindow)
|
||||
: BWindow(CenteredRect(BRect(0, 0, 350, 215)), "Preference",
|
||||
B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
|
||||
B_NOT_RESIZABLE|B_NOT_ZOOMABLE)
|
||||
: BWindow(CenteredRect(BRect(0, 0, 350, 215)), "Terminal Settings",
|
||||
B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
|
||||
B_NOT_RESIZABLE|B_NOT_ZOOMABLE)
|
||||
{
|
||||
fTermWindow = inWindow;
|
||||
fPrefTemp = new PrefHandler(gTermPref);
|
||||
@ -100,17 +79,19 @@ PrefDlg::PrefDlg(TermWindow *inWindow)
|
||||
top->Bounds().Height() - 5 -
|
||||
fRevertButton->Bounds().Height());
|
||||
top->AddChild(fRevertButton);
|
||||
|
||||
|
||||
AddShortcut ((ulong)'Q', (ulong)B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED));
|
||||
AddShortcut ((ulong)'W', (ulong)B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED));
|
||||
|
||||
|
||||
Show();
|
||||
}
|
||||
|
||||
PrefDlg::~PrefDlg (void)
|
||||
|
||||
PrefDlg::~PrefDlg()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PrefDlg::Quit()
|
||||
{
|
||||
@ -120,39 +101,42 @@ PrefDlg::Quit()
|
||||
BWindow::Quit();
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
PrefDlg::QuitRequested()
|
||||
{
|
||||
if(!fDirty)
|
||||
return true;
|
||||
|
||||
if (!fDirty)
|
||||
return true;
|
||||
|
||||
BAlert *alert = new BAlert("", "Save changes to this preference panel?",
|
||||
"Cancel", "Don't Save", "Save",
|
||||
B_WIDTH_AS_USUAL, B_OFFSET_SPACING,
|
||||
B_WARNING_ALERT);
|
||||
"Cancel", "Don't Save", "Save",
|
||||
B_WIDTH_AS_USUAL, B_OFFSET_SPACING,
|
||||
B_WARNING_ALERT);
|
||||
alert->SetShortcut(0, B_ESCAPE);
|
||||
alert->SetShortcut(1, 'd');
|
||||
alert->SetShortcut(2, 's');
|
||||
int32 button_index = alert->Go();
|
||||
|
||||
if(button_index==0)
|
||||
|
||||
int32 index = alert->Go();
|
||||
if (index == 0)
|
||||
return false;
|
||||
else
|
||||
if(button_index==2)
|
||||
|
||||
if (index == 2)
|
||||
doSave();
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PrefDlg::doSaveAs (void)
|
||||
PrefDlg::doSaveAs()
|
||||
{
|
||||
if(!fSavePanel)
|
||||
if (!fSavePanel)
|
||||
fSavePanel = new BFilePanel(B_SAVE_PANEL, new BMessenger(this));
|
||||
|
||||
fSavePanel->Show();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PrefDlg::SaveRequested(BMessage *msg)
|
||||
{
|
||||
@ -199,11 +183,11 @@ PrefDlg::doRevert()
|
||||
fDirty = false;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PrefDlg::MessageReceived(BMessage *msg)
|
||||
{
|
||||
switch (msg->what)
|
||||
{
|
||||
switch (msg->what) {
|
||||
case MSG_SAVE_PRESSED:
|
||||
{
|
||||
doSave();
|
||||
@ -239,6 +223,7 @@ PrefDlg::MessageReceived(BMessage *msg)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BRect
|
||||
PrefDlg::CenteredRect(BRect r)
|
||||
{
|
||||
|
@ -1,33 +1,12 @@
|
||||
/*
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* Copyright (c) 2004 Daniel Furrer <assimil8or@users.sourceforge.net>
|
||||
* Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* 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 "Coding.h"
|
||||
#include "PrefHandler.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);
|
||||
char buffer[512];
|
||||
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));
|
||||
file.Write(buffer, len);
|
||||
}
|
||||
|
@ -1,41 +1,22 @@
|
||||
/*
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* Copyright (c) 2004 Daniel Furrer <assimil8or@users.sourceforge.net>
|
||||
* 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.
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* Copyright (c) 1998,99 Kazuho Okui and Takashi Murai.
|
||||
*
|
||||
* Distributed unter the terms of the MIT License.
|
||||
*/
|
||||
#ifndef PREFHANDLER_H_INCLUDED
|
||||
#define PREFHANDLER_H_INCLUDED
|
||||
#ifndef PREF_HANDLER_H
|
||||
#define PREF_HANDLER_H
|
||||
|
||||
|
||||
#include <SupportDefs.h>
|
||||
#include <Errors.h>
|
||||
#include <GraphicsDefs.h>
|
||||
#include <Message.h>
|
||||
|
||||
class BFont;
|
||||
class BPath;
|
||||
|
||||
|
||||
#define TP_MAGIC 0xf1f2f3f4
|
||||
#define TP_VERSION 0x02
|
||||
#define TP_FONT_NAME_SZ 128
|
||||
@ -110,4 +91,4 @@ class PrefHandler {
|
||||
BMessage fContainer;
|
||||
};
|
||||
|
||||
#endif // PREFHANDLER_H_INCLUDED
|
||||
#endif // PREF_HANDLER_H
|
||||
|
Loading…
Reference in New Issue
Block a user