Forgot to commit Jamfile before: removed AboutWindow.cpp.

Cleaned up ShellPrefView a little.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13739 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2005-07-18 08:11:43 +00:00
parent 716af53244
commit e98e8fe256
3 changed files with 130 additions and 200 deletions
-1
View File
@@ -1,7 +1,6 @@
SubDir OBOS_TOP src apps terminal ; SubDir OBOS_TOP src apps terminal ;
App Terminal : App Terminal :
AboutWindow.cpp
AppearPrefView.cpp AppearPrefView.cpp
CodeConv.cpp CodeConv.cpp
CurPos.cpp CurPos.cpp
+33 -78
View File
@@ -1,32 +1,11 @@
/* /*
* Copyright (c) 2003-4 Kian Duffy <[email protected]> * Copyright (c) 2003-2004 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 <View.h> #include <View.h>
#include <Button.h> #include <Button.h>
#include <MenuField.h> #include <MenuField.h>
@@ -45,49 +24,44 @@
#include "MenuUtil.h" #include "MenuUtil.h"
#include "TTextControl.h" #include "TTextControl.h"
extern PrefHandler *gTermPref; extern PrefHandler *gTermPref;
////////////////////////////////////////////////////////////////////////////
// AparancePrefView ()
// Constructor.
////////////////////////////////////////////////////////////////////////////
ShellPrefView::ShellPrefView(BRect frame, const char *name, ShellPrefView::ShellPrefView(BRect frame, const char *name,
TermWindow *window) TermWindow *window)
: PrefView(frame, name) : PrefView(frame, name)
{ {
fTermWindow = window; fTermWindow = window;
mCols = new TTextControl(BRect(0, 0, 160, 20), "cols", "Columns", "", new BMessage(MSG_COLS_CHANGED)); mCols = new TTextControl(BRect(0, 0, 160, 20), "cols", "Columns", "",
new BMessage(MSG_COLS_CHANGED));
AddChild(mCols); AddChild(mCols);
mCols->SetText(gTermPref->getString(PREF_COLS)); mCols->SetText(gTermPref->getString(PREF_COLS));
mRows = new TTextControl(BRect(0, 30, 160, 50), "rows", "Rows", "", new BMessage(MSG_ROWS_CHANGED)); mRows = new TTextControl(BRect(0, 30, 160, 50), "rows", "Rows", "",
new BMessage(MSG_ROWS_CHANGED));
AddChild(mRows); AddChild(mRows);
mRows->SetText(gTermPref->getString(PREF_ROWS)); mRows->SetText(gTermPref->getString(PREF_ROWS));
mHistory = new TTextControl(BRect(0, 60, 160, 80), "history", "History", "", new BMessage(MSG_HISTORY_CHANGED)); mHistory = new TTextControl(BRect(0, 60, 160, 80), "history", "History", "",
new BMessage(MSG_HISTORY_CHANGED));
AddChild(mHistory); AddChild(mHistory);
mHistory->SetText(gTermPref->getString(PREF_HISTORY_SIZE)); mHistory->SetText(gTermPref->getString(PREF_HISTORY_SIZE));
} }
////////////////////////////////////////////////////////////////////////////
//
//
////////////////////////////////////////////////////////////////////////////
void void
ShellPrefView::Revert (void) ShellPrefView::Revert()
{ {
mCols->SetText(gTermPref->getString(PREF_COLS)); mCols->SetText(gTermPref->getString(PREF_COLS));
mRows->SetText(gTermPref->getString(PREF_ROWS)); mRows->SetText(gTermPref->getString(PREF_ROWS));
mHistory->SetText(gTermPref->getString(PREF_HISTORY_SIZE)); mHistory->SetText(gTermPref->getString(PREF_HISTORY_SIZE));
} }
////////////////////////////////////////////////////////////////////////////
// SaveIfModified (void)
//
////////////////////////////////////////////////////////////////////////////
void void
ShellPrefView::SaveIfModified (void) ShellPrefView::SaveIfModified()
{ {
BMessenger messenger(fTermWindow); BMessenger messenger(fTermWindow);
@@ -105,20 +79,19 @@ ShellPrefView::SaveIfModified (void)
// gTermPref->setString (PREF_SHELL, mShell->Text()); // gTermPref->setString (PREF_SHELL, mShell->Text());
if (mHistory->IsModified()) { if (mHistory->IsModified()) {
int size; int size = atoi(mHistory->Text());
size = atoi(mHistory->Text()); if (size < 512)
if (size < 512) mHistory->SetText("512"); mHistory->SetText("512");
if (size > 1048575) mHistory->SetText("1048575"); if (size > 1048575)
mHistory->SetText("1048575");
gTermPref->setString (PREF_HISTORY_SIZE, mHistory->Text()); gTermPref->setString (PREF_HISTORY_SIZE, mHistory->Text());
} }
} }
//////////////////////////////////////////////////////////////////////////////
//
//
//////////////////////////////////////////////////////////////////////////////
void void
ShellPrefView::SetControlLabels (PrefHandler &Labels) ShellPrefView::SetControlLabels(PrefHandler& labels)
{ {
mCols->SetLabel("Columns"); mCols->SetLabel("Columns");
mRows->SetLabel("Rows"); mRows->SetLabel("Rows");
@@ -126,31 +99,17 @@ ShellPrefView::SetControlLabels (PrefHandler &Labels)
mHistory->SetLabel("History Size"); mHistory->SetLabel("History Size");
} }
/*
*
* PRIVATE MEMBER FUNCTIONS
*
*/
////////////////////////////////////////////////////////////////////////////
//
//
////////////////////////////////////////////////////////////////////////////
void void
ShellPrefView::AttachedToWindow (void) ShellPrefView::AttachedToWindow()
{ {
mCols->SetTarget(this); mCols->SetTarget(this);
mRows->SetTarget(this); mRows->SetTarget(this);
//mShell->SetTarget(this); //mShell->SetTarget(this);
mHistory->SetTarget(this); mHistory->SetTarget(this);
} }
////////////////////////////////////////////////////////////////////////////
//
//
////////////////////////////////////////////////////////////////////////////
void void
ShellPrefView::MessageReceived(BMessage *msg) ShellPrefView::MessageReceived(BMessage *msg)
{ {
@@ -158,7 +117,6 @@ ShellPrefView::MessageReceived (BMessage *msg)
int size; int size;
switch (msg->what) { switch (msg->what) {
case MSG_COLS_CHANGED: case MSG_COLS_CHANGED:
size = atoi (mCols->Text()); size = atoi (mCols->Text());
if (size >= MAX_COLS || size < MIN_COLS) { if (size >= MAX_COLS || size < MIN_COLS) {
@@ -168,7 +126,6 @@ ShellPrefView::MessageReceived (BMessage *msg)
gTermPref->setString (PREF_COLS, mCols->Text()); gTermPref->setString (PREF_COLS, mCols->Text());
modified = true; modified = true;
} }
break; break;
case MSG_ROWS_CHANGED: case MSG_ROWS_CHANGED:
@@ -180,12 +137,11 @@ ShellPrefView::MessageReceived (BMessage *msg)
gTermPref->setString(PREF_ROWS, mRows->Text()); gTermPref->setString(PREF_ROWS, mRows->Text());
modified = true; modified = true;
} }
break; break;
// case MSG_SHELL_CHANGED: // case MSG_SHELL_CHANGED:
// gTermPref->setString (PREF_SHELL, mShell->Text()); // gTermPref->setString (PREF_SHELL, mShell->Text());
// (this->Window())->PostMessage(MSG_PREF_MODIFIED); // Window()->PostMessage(MSG_PREF_MODIFIED);
// break; // break;
case MSG_HISTORY_CHANGED: case MSG_HISTORY_CHANGED:
@@ -196,9 +152,8 @@ ShellPrefView::MessageReceived (BMessage *msg)
beep (); beep ();
} else { } else {
gTermPref->setString(PREF_HISTORY_SIZE, mHistory->Text()); gTermPref->setString(PREF_HISTORY_SIZE, mHistory->Text());
(this->Window())->PostMessage(MSG_PREF_MODIFIED); Window()->PostMessage(MSG_PREF_MODIFIED);
} }
break; break;
default: default:
@@ -208,6 +163,6 @@ ShellPrefView::MessageReceived (BMessage *msg)
if (modified) { if (modified) {
fTermWindow->PostMessage(msg); fTermWindow->PostMessage(msg);
(this->Window())->PostMessage(MSG_PREF_MODIFIED); Window()->PostMessage(MSG_PREF_MODIFIED);
} }
} }
+13 -37
View File
@@ -1,53 +1,30 @@
/* /*
* Copyright (c) 2003-4 Kian Duffy <[email protected]> * Copyright (c) 2003-2004 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 SHELLPREFVIEW_H
#define SHELLPREFVIEW_H_
#ifndef ShellPrefView__H_INCLUDED
#define ShellPrefView__H_INCLUDED
#include "PrefView.h" #include "PrefView.h"
class TermWindow; class TermWindow;
class TTextControl; class TTextControl;
class ShellPrefView : public PrefView class ShellPrefView : public PrefView {
{
public: public:
ShellPrefView (BRect r, const char *name, TermWindow *window); ShellPrefView(BRect frame, const char* name, TermWindow* window);
virtual void SaveIfModified (void); virtual void AttachedToWindow();
virtual void MessageReceived(BMessage* message);
void Revert (void); void Revert();
void SetControlLabels(PrefHandler& Labels); void SetControlLabels(PrefHandler& Labels);
void AttachedToWindow (void); virtual void SaveIfModified();
void MessageReceived (BMessage *);
private: private:
TTextControl* mCols; TTextControl* mCols;
@@ -57,7 +34,6 @@ class ShellPrefView : public PrefView
TTextControl* mHistory; TTextControl* mHistory;
TermWindow* fTermWindow; TermWindow* fTermWindow;
}; };
#endif //ShellPrefView_H_INCLUDED #endif // SHELLPREFVIEW_H