2002-09-23 23:01:55 +00:00
|
|
|
#include <Message.h>
|
|
|
|
|
#include <Messenger.h>
|
|
|
|
|
#include <Rect.h>
|
2002-11-05 09:24:25 +00:00
|
|
|
#include <TranslationUtils.h>
|
2002-09-23 23:01:55 +00:00
|
|
|
|
2002-11-05 09:24:25 +00:00
|
|
|
#include "StyledEditView.h"
|
|
|
|
|
#include "Constants.h"
|
2002-09-23 23:01:55 +00:00
|
|
|
|
2002-11-05 09:24:25 +00:00
|
|
|
StyledEditView::StyledEditView(BRect viewFrame, BRect textBounds, BHandler *handler)
|
|
|
|
|
: BTextView(viewFrame, "textview", textBounds,
|
|
|
|
|
B_FOLLOW_ALL, B_FRAME_EVENTS|B_WILL_DRAW)
|
|
|
|
|
{
|
|
|
|
|
fHandler= handler;
|
|
|
|
|
fMessenger= new BMessenger(handler);
|
|
|
|
|
fSuppressChanges = false;
|
|
|
|
|
}/***StyledEditView()***/
|
2002-09-23 23:01:55 +00:00
|
|
|
|
2002-11-05 09:24:25 +00:00
|
|
|
StyledEditView::~StyledEditView(){
|
2002-09-23 23:01:55 +00:00
|
|
|
|
2002-11-05 09:24:25 +00:00
|
|
|
}/***~StyledEditView***/
|
2002-09-23 23:01:55 +00:00
|
|
|
|
2002-11-05 09:24:25 +00:00
|
|
|
void
|
|
|
|
|
StyledEditView::FrameResized(float width, float height)
|
|
|
|
|
{
|
2002-09-23 23:01:55 +00:00
|
|
|
BTextView::FrameResized(width, height);
|
|
|
|
|
|
|
|
|
|
if(DoesWordWrap()){
|
|
|
|
|
BRect textRect;
|
|
|
|
|
textRect= Bounds();
|
|
|
|
|
textRect.OffsetTo(B_ORIGIN);
|
|
|
|
|
textRect.InsetBy(TEXT_INSET,TEXT_INSET);
|
|
|
|
|
SetTextRect(textRect);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-05 09:24:25 +00:00
|
|
|
status_t
|
|
|
|
|
StyledEditView::GetStyledText(BPositionIO * stream)
|
|
|
|
|
{
|
|
|
|
|
status_t result = B_OK;
|
|
|
|
|
fSuppressChanges = true;
|
|
|
|
|
result = BTranslationUtils::GetStyledText(stream, this, NULL);
|
|
|
|
|
fSuppressChanges = false;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
StyledEditView::Reset()
|
|
|
|
|
{
|
|
|
|
|
fSuppressChanges = true;
|
|
|
|
|
SetText("");
|
|
|
|
|
fSuppressChanges = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
StyledEditView::Select(int32 start, int32 finish)
|
|
|
|
|
{
|
2002-09-23 23:01:55 +00:00
|
|
|
if(start==finish)
|
|
|
|
|
fChangeMessage= new BMessage(DISABLE_ITEMS);
|
|
|
|
|
else
|
|
|
|
|
fChangeMessage= new BMessage(ENABLE_ITEMS);
|
|
|
|
|
|
|
|
|
|
fMessenger->SendMessage(fChangeMessage);
|
|
|
|
|
|
|
|
|
|
BTextView::Select(start, finish);
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-05 09:24:25 +00:00
|
|
|
void StyledEditView::InsertText(const char *text, int32 length, int32 offset, const text_run_array *runs)
|
|
|
|
|
{
|
|
|
|
|
if (!fSuppressChanges)
|
|
|
|
|
fMessenger-> SendMessage(new BMessage(TEXT_CHANGED));
|
2002-09-23 23:01:55 +00:00
|
|
|
|
|
|
|
|
BTextView::InsertText(text, length, offset, runs);
|
|
|
|
|
|
|
|
|
|
}/****StyledEditView::InsertText()***/
|
|
|
|
|
|
2002-11-05 09:24:25 +00:00
|
|
|
void StyledEditView::DeleteText(int32 start, int32 finish)
|
|
|
|
|
{
|
|
|
|
|
if (!fSuppressChanges)
|
|
|
|
|
fMessenger-> SendMessage(new BMessage(TEXT_CHANGED));
|
2002-09-23 23:01:55 +00:00
|
|
|
|
|
|
|
|
BTextView::DeleteText(start, finish);
|
|
|
|
|
|
|
|
|
|
}/***StyledEditView::DeleteText***/
|