improved soft wrapping, now saves alignment and wrapping states
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2061 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include <Messenger.h>
|
||||
#include <Rect.h>
|
||||
#include <TranslationUtils.h>
|
||||
#include <Node.h>
|
||||
|
||||
#include "StyledEditView.h"
|
||||
#include "Constants.h"
|
||||
@@ -24,12 +25,12 @@ StyledEditView::FrameResized(float width, float height)
|
||||
{
|
||||
BTextView::FrameResized(width, height);
|
||||
|
||||
if(DoesWordWrap()){
|
||||
BRect textRect;
|
||||
textRect= Bounds();
|
||||
textRect.OffsetTo(B_ORIGIN);
|
||||
textRect.InsetBy(TEXT_INSET,TEXT_INSET);
|
||||
SetTextRect(textRect);
|
||||
BRect textRect;
|
||||
textRect = Bounds();
|
||||
textRect.OffsetTo(B_ORIGIN);
|
||||
textRect.InsetBy(TEXT_INSET,TEXT_INSET);
|
||||
if (DoesWordWrap() || (textRect.Width() > TextRect().Width())) {
|
||||
SetTextRect(textRect);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,10 +40,43 @@ StyledEditView::GetStyledText(BPositionIO * stream)
|
||||
status_t result = B_OK;
|
||||
fSuppressChanges = true;
|
||||
result = BTranslationUtils::GetStyledText(stream, this, NULL);
|
||||
|
||||
BNode * node = dynamic_cast<BNode*>(stream);
|
||||
if (node != 0) {
|
||||
ssize_t bytesRead;
|
||||
// restore alignment
|
||||
alignment align;
|
||||
bytesRead = node->ReadAttr("alignment",0,0,&align,sizeof(align));
|
||||
if (bytesRead > 0) {
|
||||
SetAlignment(align);
|
||||
}
|
||||
// restore wrapping
|
||||
bool wrap;
|
||||
bytesRead = node->ReadAttr("wrap",0,0,&wrap,sizeof(wrap));
|
||||
if (bytesRead > 0) {
|
||||
SetWordWrap(wrap);
|
||||
}
|
||||
}
|
||||
|
||||
fSuppressChanges = false;
|
||||
return result;
|
||||
}
|
||||
|
||||
status_t
|
||||
StyledEditView::WriteStyledEditFile(BFile * file)
|
||||
{
|
||||
status_t result = B_OK;
|
||||
result = BTranslationUtils::WriteStyledEditFile(this,file);
|
||||
if (result != B_OK) {
|
||||
return result;
|
||||
}
|
||||
alignment align = Alignment();
|
||||
file->WriteAttr("alignment",B_INT32_TYPE,0,&align,sizeof(align));
|
||||
bool wrap = DoesWordWrap();
|
||||
file->WriteAttr("wrap",B_BOOL_TYPE,0,&wrap,sizeof(wrap));
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
StyledEditView::Reset()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user