fixed some initializations and edit menu initialization

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4269 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
shatty
2003-08-10 12:47:05 +00:00
parent 62e7938594
commit d85db6a722
4 changed files with 44 additions and 12 deletions
+12 -7
View File
@@ -2,19 +2,25 @@
#include <Messenger.h>
#include <Rect.h>
#include "TerminalTextView.h"
#include "Constants.h"
#include <TerminalTextView.h>
#include <Constants.h>
TerminalTextView::TerminalTextView(BRect viewFrame, BRect textBounds, BHandler *handler)
TerminalTextView::TerminalTextView(BRect viewFrame, BRect textBounds,
const BFont * initialFont,
const rgb_color * initialColor,
BHandler *handler)
: BTextView(viewFrame, "textview", textBounds,
B_FOLLOW_ALL, B_FRAME_EVENTS|B_WILL_DRAW)
initialFont, initialColor,
B_FOLLOW_ALL, B_FRAME_EVENTS|B_WILL_DRAW)
{
fHandler = handler;
fMessenger = new BMessenger(handler);
SetWordWrap(false);
}
TerminalTextView::~TerminalTextView(){
TerminalTextView::~TerminalTextView()
{
delete fMessenger;
}
void
@@ -31,12 +37,11 @@ TerminalTextView::Select(int32 start, int32 finish)
void
TerminalTextView::FrameResized(float width, float height)
{
BRect oldText = TextRect();
BTextView::FrameResized(width, height);
BRect textRect;
textRect = Bounds();
textRect.OffsetTo(B_ORIGIN);
textRect.InsetBy(TEXT_INSET,TEXT_INSET);
SetTextRect(textRect);
}
+3 -1
View File
@@ -5,7 +5,9 @@
class TerminalTextView : public BTextView {
public:
TerminalTextView(BRect viewframe, BRect textframe, BHandler *handler);
TerminalTextView(BRect viewframe, BRect textframe,
const BFont * initialFont, const rgb_color * initialColor,
BHandler *handler);
~TerminalTextView();
virtual void Select(int32 start, int32 finish);
+27 -4
View File
@@ -76,16 +76,20 @@ TerminalWindow::InitWindow(int32 id, entry_ref * settingsRef)
viewFrame = Bounds();
viewFrame.top = fMenuBar->Bounds().Height()+1;
viewFrame.right -= B_V_SCROLL_BAR_WIDTH;
viewFrame.left = 0;
textBounds = viewFrame;
textBounds.OffsetTo(B_ORIGIN);
textBounds.InsetBy(TEXT_INSET, TEXT_INSET);
fTextView = new TerminalTextView(viewFrame, textBounds, this);
BFont textFont(be_plain_font);
textFont.SetSpacing(B_FIXED_SPACING);
rgb_color black = {0,0,0,0};
fTextView = new TerminalTextView(viewFrame, textBounds, &textFont, &black, this);
fTextView->SetStylable(true);
fScrollView = new BScrollView("scrollview", fTextView, 0, false, true, B_PLAIN_BORDER);
fScrollView = new BScrollView("scrollview", fTextView, B_FOLLOW_ALL, true, false, B_PLAIN_BORDER);
AddChild(fScrollView);
fTextView->MakeFocus(true);
@@ -110,6 +114,7 @@ TerminalWindow::InitWindow(int32 id, entry_ref * settingsRef)
fCopy = new BMenuItem("Copy", new BMessage(B_COPY), 'C');
fEdit->AddItem(fCopy);
fCopy->SetTarget(fTextView);
fCopy->SetEnabled(false);
fPaste = new BMenuItem("Paste", new BMessage(B_PASTE), 'V');
fEdit->AddItem(fPaste);
@@ -126,7 +131,6 @@ TerminalWindow::InitWindow(int32 id, entry_ref * settingsRef)
fClearAll = new BMenuItem("Clear All", new BMessage(EDIT_CLEAR_ALL), 'L');
fEdit->AddItem(fClearAll);
fClearAll->SetTarget(fTextView);
fEdit->AddSeparatorItem();
@@ -247,7 +251,13 @@ TerminalWindow::MessageReceived(BMessage *message)
break;
case TERMINAL_SWITCH_TERMINAL:
SwitchTerminals(message);
break;
break;
case ENABLE_ITEMS:
EnableEditItems(message);
break;
case DISABLE_ITEMS:
DisableEditItems(message);
break;
case B_COPY:
EditCopy(message);
break;
@@ -357,6 +367,18 @@ TerminalWindow::SwitchTerminals(BMessage * message)
} while (result != B_OK);
}
void
TerminalWindow::EnableEditItems(BMessage * message)
{
fCopy->SetEnabled(true);
}
void
TerminalWindow::DisableEditItems(BMessage * message)
{
fCopy->SetEnabled(false);
}
void
TerminalWindow::EditCopy(BMessage * message)
{
@@ -372,5 +394,6 @@ TerminalWindow::EditPaste(BMessage * message)
void
TerminalWindow::EditClearAll(BMessage * message)
{
fTextView->SelectAll();
fTextView->Clear();
}
+2
View File
@@ -32,6 +32,8 @@ private:
// message received helpers
void StartNewTerminal(BMessage * message);
void SwitchTerminals(BMessage * message);
void EnableEditItems(BMessage * message);
void DisableEditItems(BMessage * message);
void EditCopy(BMessage * message);
void EditPaste(BMessage * message);
void EditClearAll(BMessage * message);