diff --git a/src/apps/resedit/InternalEditors.h b/src/apps/resedit/InternalEditors.h index 8c28069059..e244bca2b3 100644 --- a/src/apps/resedit/InternalEditors.h +++ b/src/apps/resedit/InternalEditors.h @@ -8,9 +8,11 @@ #ifndef INTERNALEDITORS_H #define INTERNALEDITORS_H -#include -#include #include +#include +#include +#include + #include "Editor.h" class StringEditView : public BView @@ -27,8 +29,8 @@ public: const char * GetName(void) const { return fNameBox->Text(); } void SetName(const char *name) { fNameBox->SetText(name); } - const char * GetValue(void) const { return fValueBox->Text(); } - void SetValue(const char *value) { fValueBox->SetText(value); } + const char * GetValue(void) const { return fValueView->Text(); } + void SetValue(const char *value) { fValueView->SetText(value); } void EnableID(const bool &value) { fIDBox->SetEnabled(value); } bool IsIDEnabled(void) const { return fIDBox->IsEnabled(); } @@ -38,8 +40,8 @@ public: private: BTextControl *fIDBox, - *fNameBox, - *fValueBox; + *fNameBox; + BTextView *fValueView; BButton *fCancel, *fOK; diff --git a/src/apps/resedit/MiscEditors.cpp b/src/apps/resedit/MiscEditors.cpp index 21482576a3..406169a510 100644 --- a/src/apps/resedit/MiscEditors.cpp +++ b/src/apps/resedit/MiscEditors.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include @@ -30,8 +31,6 @@ StringEditor::StringEditor(const BRect &frame, ResourceData *data, fView->SetID(data->GetIDString()); fView->SetName(data->GetName()); fView->SetValue(data->GetData()); - - SetFlags(Flags() | B_NOT_V_RESIZABLE); } @@ -103,23 +102,26 @@ StringEditView::StringEditView(const BRect &frame) r.OffsetBy(0, r.Height() + 10); r.left = 10; - fValueBox = new BTextControl(r, "value", "Value: ", "", NULL, - B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP); - fValueBox->SetDivider(be_plain_font->StringWidth("Value: ") + 5); - AddChild(fValueBox); + r.right -= B_V_SCROLL_BAR_WIDTH; + BRect textRect(r.OffsetToCopy(0.0, 0.0)); + textRect.InsetBy(5.0, 5.0); + fValueView = new BTextView(r, "value", textRect, B_FOLLOW_ALL); + + BScrollView *scrollView = new BScrollView("scrollView", fValueView, + B_FOLLOW_ALL, 0, false, true); + AddChild(scrollView); fOK = new BButton(BRect(10, 10, 11, 11), "ok", "Cancel", new BMessage(M_UPDATE_RESOURCE), - B_FOLLOW_RIGHT); + B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); fOK->ResizeToPreferred(); fOK->SetLabel("OK"); - fOK->MakeDefault(true); AddChild(fOK); fOK->MoveTo(r.right - fOK->Bounds().Width(), r.bottom + 10); r = fOK->Frame(); r.OffsetBy(-r.Width() - 10, 0); fCancel = new BButton(r, "cancel", "Cancel", new BMessage(B_QUIT_REQUESTED), - B_FOLLOW_RIGHT); + B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); AddChild(fCancel); } @@ -132,8 +134,16 @@ StringEditView::~StringEditView(void) void StringEditView::AttachedToWindow(void) { - if (Bounds().Height() < fCancel->Frame().bottom + 10) + if (Bounds().Height() < fCancel->Frame().bottom + 10) { + BView *view = FindView("scrollView"); + view->SetResizingMode(B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP); + fOK->SetResizingMode(B_FOLLOW_RIGHT); + fCancel->SetResizingMode(B_FOLLOW_RIGHT); Window()->ResizeTo(Window()->Bounds().Width(), fCancel->Frame().bottom + 10); + view->SetResizingMode(B_FOLLOW_ALL); + fOK->SetResizingMode(B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); + fCancel->SetResizingMode(B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); + } Window()->SetSizeLimits(Window()->Bounds().Width(), 30000, Window()->Bounds().Height(), 30000); @@ -144,9 +154,9 @@ float StringEditView::GetPreferredWidth(void) const { float idwidth = be_plain_font->StringWidth("ID: ") + - be_plain_font->StringWidth("(attr) ") + 15; + be_plain_font->StringWidth("(attr) ") + 15.0; float namewidth = be_plain_font->StringWidth("Name: ") + - be_plain_font->StringWidth(fNameBox->Text()) + 15; + be_plain_font->StringWidth(fNameBox->Text()) + 15.0; return idwidth + namewidth + 100; } @@ -157,6 +167,7 @@ StringEditView::GetPreferredHeight(void) const font_height fh; be_plain_font->GetHeight(&fh); float strheight = fh.ascent + fh.descent + fh.leading + 5; - return fOK->Frame().Height() + (strheight * 2) + 40; + float lineCount = fValueView->CountLines() < 5.0 ? fValueView->CountLines() : 5.0; + return fOK->Frame().Height() + (strheight * lineCount) + 40.0; } diff --git a/src/apps/resedit/ResView.cpp b/src/apps/resedit/ResView.cpp index 21ea79967c..a16ba4daec 100644 --- a/src/apps/resedit/ResView.cpp +++ b/src/apps/resedit/ResView.cpp @@ -358,13 +358,16 @@ ResView::UpdateRow(BRow *row) strField->SetString(resData->GetIDString()); strField = (BStringField *)row->GetField(2); - strField->SetString(resData->GetName()); + if (strField) + strField->SetString(resData->GetName()); PreviewField *preField = (PreviewField*)row->GetField(3); - preField->SetData(resData->GetData(), resData->GetLength()); + if (preField) + preField->SetData(resData->GetData(), resData->GetLength()); BSizeField *sizeField = (BSizeField*)row->GetField(4); - sizeField->SetSize(resData->GetLength()); + if (sizeField) + sizeField->SetSize(resData->GetLength()); } diff --git a/src/apps/resedit/ResourceRoster.cpp b/src/apps/resedit/ResourceRoster.cpp index b058ba8384..0a87ced397 100644 --- a/src/apps/resedit/ResourceRoster.cpp +++ b/src/apps/resedit/ResourceRoster.cpp @@ -152,6 +152,7 @@ ResourceRoster::SpawnEditor(ResourceData *data, BHandler *handler) { // temporary code until editors are done switch (data->GetType()) { + case B_STRING_TYPE: case B_MIME_STRING_TYPE: { StringEditor *strEd = new StringEditor(BRect(100, 100, 400, 200), data, handler);