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
+109 -154
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,169 +24,145 @@
#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,
TermWindow *window)
:PrefView (frame, name)
{
fTermWindow = window;
mCols = new TTextControl(BRect(0, 0, 160, 20), "cols", "Columns", "", new BMessage(MSG_COLS_CHANGED)); ShellPrefView::ShellPrefView(BRect frame, const char *name,
TermWindow *window)
: PrefView(frame, name)
{
fTermWindow = window;
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);
if (mCols->IsModified()) { if (mCols->IsModified()) {
gTermPref->setString (PREF_COLS, mCols->Text()); gTermPref->setString(PREF_COLS, mCols->Text());
messenger.SendMessage (MSG_COLS_CHANGED); messenger.SendMessage(MSG_COLS_CHANGED);
mCols->ModifiedText (false); mCols->ModifiedText(false);
} }
if (mRows->IsModified()) { if (mRows->IsModified()) {
gTermPref->setString (PREF_ROWS, mRows->Text()); gTermPref->setString(PREF_ROWS, mRows->Text());
messenger.SendMessage (MSG_ROWS_CHANGED); messenger.SendMessage(MSG_ROWS_CHANGED);
mRows->ModifiedText (false); mRows->ModifiedText(false);
} }
//if (mShell->IsModified()) //if (mShell->IsModified())
// 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)
gTermPref->setString (PREF_HISTORY_SIZE, mHistory->Text()); mHistory->SetText("1048575");
}
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");
// mShell->SetLabel("Shell"); //mShell->SetLabel("Shell");
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)
{ {
bool modified = false; bool modified = false;
int size; int size;
switch (msg->what) { switch (msg->what) {
case MSG_COLS_CHANGED:
size = atoi (mCols->Text());
if (size >= MAX_COLS || size < MIN_COLS) {
mCols->SetText (gTermPref->getString (PREF_COLS));
beep ();
} else {
gTermPref->setString (PREF_COLS, mCols->Text());
modified = true;
}
break;
case MSG_COLS_CHANGED: case MSG_ROWS_CHANGED:
size = atoi (mCols->Text()); size = atoi (mRows->Text());
if (size >= MAX_COLS || size < MIN_COLS) { if (size >= MAX_COLS || size < MIN_COLS) {
mCols->SetText (gTermPref->getString (PREF_COLS)); mRows->SetText(gTermPref->getString(PREF_ROWS));
beep (); beep ();
} else { } else {
gTermPref->setString (PREF_COLS, mCols->Text()); gTermPref->setString(PREF_ROWS, mRows->Text());
modified = true; modified = true;
} }
break;
break;
case MSG_ROWS_CHANGED: // case MSG_SHELL_CHANGED:
size = atoi (mRows->Text()); // gTermPref->setString (PREF_SHELL, mShell->Text());
if (size >= MAX_COLS || size < MIN_COLS) { // Window()->PostMessage(MSG_PREF_MODIFIED);
mRows->SetText (gTermPref->getString (PREF_ROWS)); // break;
beep ();
} else {
gTermPref->setString (PREF_ROWS, mRows->Text());
modified = true;
}
break;
// case MSG_SHELL_CHANGED: case MSG_HISTORY_CHANGED:
// gTermPref->setString (PREF_SHELL, mShell->Text()); size = atoi(mHistory->Text());
// (this->Window())->PostMessage(MSG_PREF_MODIFIED);
// break; if (size < 512 || size > 1048575) {
mHistory->SetText(gTermPref->getString(PREF_HISTORY_SIZE));
beep ();
} else {
gTermPref->setString(PREF_HISTORY_SIZE, mHistory->Text());
Window()->PostMessage(MSG_PREF_MODIFIED);
}
break;
case MSG_HISTORY_CHANGED: default:
size = atoi(mHistory->Text()); PrefView::MessageReceived(msg);
break;
if (size < 512 || size > 1048575) { }
mHistory->SetText(gTermPref->getString (PREF_HISTORY_SIZE));
beep ();
} else {
gTermPref->setString (PREF_HISTORY_SIZE, mHistory->Text());
(this->Window())->PostMessage(MSG_PREF_MODIFIED);
}
break;
default: if (modified) {
PrefView::MessageReceived(msg); fTermWindow->PostMessage(msg);
break; Window()->PostMessage(MSG_PREF_MODIFIED);
} }
if(modified){
fTermWindow->PostMessage (msg);
(this->Window())->PostMessage(MSG_PREF_MODIFIED);
}
} }
+21 -45
View File
@@ -1,63 +1,39 @@
/* /*
* 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 frame, const char* name, TermWindow* window);
ShellPrefView (BRect r, 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;
TTextControl *mRows; TTextControl* mRows;
TTextControl *mShell; TTextControl* mShell;
TTextControl *mHistory; TTextControl* mHistory;
TermWindow *fTermWindow; TermWindow* fTermWindow;
}; };
#endif //ShellPrefView_H_INCLUDED #endif // SHELLPREFVIEW_H