Patch by Vasilis Kaoutsis:

* Style issues.
* Renamed CenteredRect to _CenteredRect
since is private and removed the static keyword.
* Corrected copyright dates.
Thank you!



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20266 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2007-03-01 07:20:06 +00:00
parent 2df0aaea1d
commit 3e837bf6d0
2 changed files with 58 additions and 65 deletions
+35 -42
View File
@@ -1,85 +1,78 @@
/* /*
* Copyright 2001-2007, Haiku, Inc. * Copyright 2007, 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 "MenuUtil.h"
#include "PrefHandler.h"
#include "PrefDlg.h"
#include "PrefView.h"
#include "spawn.h"
#include "TermConst.h"
#include <Alert.h>
#include <Box.h> #include <Box.h>
#include <Button.h> #include <Button.h>
#include <FilePanel.h> #include <FilePanel.h>
#include <Path.h>
#include <Screen.h> #include <Screen.h>
#include <Alert.h>
#include <storage/Path.h>
#include <stdio.h> #include <stdio.h>
#include "PrefHandler.h"
#include "PrefDlg.h"
#include "TermConst.h"
#include "MenuUtil.h"
#include "AppearPrefView.h"
#include "PrefView.h"
#include "spawn.h"
// Global Preference Handler
extern PrefHandler *gTermPref; extern PrefHandler *gTermPref;
// Global Preference Handler
PrefDlg::PrefDlg(BMessenger messenger) PrefDlg::PrefDlg(BMessenger messenger)
: BWindow(CenteredRect(BRect(0, 0, 350, 215)), "Terminal Settings", : 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),
fPrefTemp(new PrefHandler(gTermPref)),
fSavePanel(NULL),
fDirty(false),
fPrefDlgMessenger(messenger) fPrefDlgMessenger(messenger)
{ {
fPrefTemp = new PrefHandler(gTermPref); BRect rect;
fDirty = false;
fSavePanel = NULL;
BRect r;
BView *top = new BView(Bounds(), "topview", B_FOLLOW_NONE, B_WILL_DRAW); BView *top = new BView(Bounds(), "topview", B_FOLLOW_NONE, B_WILL_DRAW);
top->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); top->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
AddChild(top); AddChild(top);
r=top->Bounds(); rect = top->Bounds();
r.bottom *= .75; rect.bottom *= .75;
AppearancePrefView *prefView= new AppearancePrefView(r, "Appearance", AppearancePrefView *prefView= new AppearancePrefView(rect, "Appearance",
fPrefDlgMessenger); fPrefDlgMessenger);
top->AddChild(prefView); top->AddChild(prefView);
fSaveAsFileButton = new BButton(BRect(0,0,1,1), "savebutton", fSaveAsFileButton = new BButton(BRect(0, 0, 1, 1), "savebutton", "Save to File",
"Save to File", new BMessage(MSG_SAVEAS_PRESSED), B_FOLLOW_TOP, B_WILL_DRAW);
new BMessage(MSG_SAVEAS_PRESSED),
B_FOLLOW_TOP, B_WILL_DRAW);
fSaveAsFileButton->ResizeToPreferred(); fSaveAsFileButton->ResizeToPreferred();
fSaveAsFileButton->MoveTo(5, top->Bounds().Height() - 5 - fSaveAsFileButton->MoveTo(5, top->Bounds().Height() - 5 -
fSaveAsFileButton->Bounds().Height()); fSaveAsFileButton->Bounds().Height());
top->AddChild(fSaveAsFileButton); top->AddChild(fSaveAsFileButton);
fSaveButton = new BButton(BRect(0, 0, 1, 1), "okbutton", "OK",
fSaveButton = new BButton(BRect(0,0,1,1), "okbutton", "OK", new BMessage(MSG_SAVE_PRESSED), B_FOLLOW_TOP, B_WILL_DRAW);
new BMessage(MSG_SAVE_PRESSED), B_FOLLOW_TOP,
B_WILL_DRAW);
fSaveButton->ResizeToPreferred(); fSaveButton->ResizeToPreferred();
fSaveButton->MoveTo(top->Bounds().Width() - 5 - fSaveButton->Bounds().Width(), fSaveButton->MoveTo(top->Bounds().Width() - 5 - fSaveButton->Bounds().Width(),
top->Bounds().Height() - 5 - fSaveButton->Bounds().Height()); top->Bounds().Height() - 5 - fSaveButton->Bounds().Height());
fSaveButton->MakeDefault(true); fSaveButton->MakeDefault(true);
top->AddChild(fSaveButton); top->AddChild(fSaveButton);
fRevertButton = new BButton(BRect(0,0,1,1), "revertbutton", fRevertButton = new BButton(BRect(0, 0, 1, 1), "revertbutton",
"Cancel", new BMessage(MSG_REVERT_PRESSED), "Cancel", new BMessage(MSG_REVERT_PRESSED), B_FOLLOW_TOP, B_WILL_DRAW);
B_FOLLOW_TOP, B_WILL_DRAW);
fRevertButton->ResizeToPreferred(); fRevertButton->ResizeToPreferred();
fRevertButton->MoveTo(fSaveButton->Frame().left - 10 - fRevertButton->MoveTo(fSaveButton->Frame().left - 10 -
fRevertButton->Bounds().Width(), fRevertButton->Bounds().Width(), 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();
} }
@@ -213,16 +206,16 @@ PrefDlg::MessageReceived(BMessage *msg)
BRect BRect
PrefDlg::CenteredRect(BRect r) PrefDlg::_CenteredRect(BRect rect)
{ {
BRect screenRect = BScreen().Frame(); BRect screenRect = BScreen().Frame();
screenRect.InsetBy(10,10); screenRect.InsetBy(10,10);
float x = screenRect.left + (screenRect.Width() - r.Width()) / 2; float x = screenRect.left + (screenRect.Width() - rect.Width()) / 2;
float y = screenRect.top + (screenRect.Height() - r.Height()) / 3; float y = screenRect.top + (screenRect.Height() - rect.Height()) / 3;
r.OffsetTo(x, y); rect.OffsetTo(x, y);
return r; return rect;
} }
+15 -15
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2001-2007, Haiku, Inc. * Copyright 2007, 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.
@@ -7,25 +7,26 @@
#ifndef PREFDLG_H_INCLUDED #ifndef PREFDLG_H_INCLUDED
#define PREFDLG_H_INCLUDED #define PREFDLG_H_INCLUDED
#include <Box.h>
#include <Window.h>
#include "PrefHandler.h" #include "PrefHandler.h"
// local message, so these are in .cpp files.... #include <Box.h>
#include <Window.h>
// local messages
const ulong MSG_SAVE_PRESSED = 'okok'; const ulong MSG_SAVE_PRESSED = 'okok';
const ulong MSG_SAVEAS_PRESSED = 'canl'; const ulong MSG_SAVEAS_PRESSED = 'canl';
const ulong MSG_REVERT_PRESSED = 'revt'; const ulong MSG_REVERT_PRESSED = 'revt';
const ulong MSG_PREF_CLOSED = 'mspc'; const ulong MSG_PREF_CLOSED = 'mspc';
// Notify PrefDlg closed to TermWindow
class BRect;
class BMessage;
class BTextControl;
class BButton; class BButton;
class PrefHandler;
class BFilePanel; class BFilePanel;
class BMessage;
class BRect;
class BTextControl;
class PrefHandler;
class PrefDlg : public BWindow class PrefDlg : public BWindow
{ {
@@ -42,9 +43,9 @@ class PrefDlg : public BWindow
void _SaveAs(); void _SaveAs();
void _Revert(); void _Revert();
void _SaveRequested(BMessage *msg); void _SaveRequested(BMessage *msg);
BRect _CenteredRect(BRect rect);
static BRect CenteredRect(BRect r); private:
PrefHandler *fPrefTemp; PrefHandler *fPrefTemp;
BFilePanel *fSavePanel; BFilePanel *fSavePanel;
@@ -53,8 +54,7 @@ class PrefDlg : public BWindow
*fSaveButton; *fSaveButton;
bool fDirty; bool fDirty;
BMessenger fPrefDlgMessenger; BMessenger fPrefDlgMessenger;
}; };
#endif //PREFDLG_H_INCLUDED #endif // PREFDLG_H_INCLUDED