Mail: layout-ify the Find panel

Fixes #13163

Change-Id: I2880b3dcd824087ee998a5dd67c5e9d904b5874d
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2629
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
Adrien Destugues 2020-05-09 20:11:09 +02:00 committed by waddlesplash
parent 2b4c59635f
commit 5ef5cba68a
2 changed files with 23 additions and 21 deletions

View File

@ -46,6 +46,7 @@ of their respective holders. All rights reserved.
#include <Box.h>
#include <Button.h>
#include <Catalog.h>
#include <LayoutBuilder.h>
#include <Locale.h>
#include <String.h>
#include <TextView.h>
@ -99,31 +100,30 @@ void FindWindow::DoFind(BWindow* window, const char* text)
}
FindPanel::FindPanel(BRect rect)
FindPanel::FindPanel()
:
BBox(rect, "FindPanel", B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW)
BGroupView("FindPanel", B_VERTICAL)
{
BRect r = Bounds().InsetByCopy(10, 10);
fTextControl = new BTextControl(r, "BTextControl", NULL,
sPreviousFind.String(), new BMessage(M_FIND_STRING_CHANGED),
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
fTextControl = new BTextControl("BTextControl", NULL,
sPreviousFind.String(), new BMessage(M_FIND_STRING_CHANGED));
fTextControl->SetModificationMessage(new BMessage(M_FIND_STRING_CHANGED));
fTextControl->SetText(sPreviousFind.String());
fTextControl->MakeFocus();
AddChild(fTextControl);
fFindButton = new BButton(BRect(0, 0, 90, 20),"FINDBUTTON",
B_TRANSLATE("Find"),
new BMessage(FINDBUTTON),B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
fFindButton->ResizeToPreferred();
AddChild(fFindButton);
r = fFindButton->Bounds();
fFindButton = new BButton("FINDBUTTON", B_TRANSLATE("Find"),
new BMessage(FINDBUTTON));
fFindButton->MoveTo(Bounds().right - r.Width() - 8,
Bounds().bottom - r.Height() - 8);
fFindButton->SetEnabled(sPreviousFind.Length());
BLayoutBuilder::Group<>(this, B_VERTICAL)
.SetInsets(B_USE_WINDOW_SPACING)
.Add(fTextControl)
.AddGroup(B_HORIZONTAL)
.AddGlue()
.Add(fFindButton)
.End()
.End();
}
@ -218,9 +218,11 @@ void FindPanel::Find()
FindWindow::FindWindow()
: BWindow(FindWindow::fLastPosition, B_TRANSLATE("Find"),
B_FLOATING_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE
| B_WILL_ACCEPT_FIRST_CLICK | B_CLOSE_ON_ESCAPE)
| B_WILL_ACCEPT_FIRST_CLICK | B_CLOSE_ON_ESCAPE
| B_AUTO_UPDATE_SIZE_LIMITS)
{
fFindPanel = new FindPanel(Bounds());
SetLayout(new BGroupLayout(B_VERTICAL));
fFindPanel = new FindPanel();
AddChild(fFindPanel);
fFindWindow = this;
Show();

View File

@ -40,7 +40,7 @@ All rights reserved.
#define _FINDWINDOW_H
#include <AppDefs.h>
#include <Box.h>
#include <GroupView.h>
#include <TextControl.h>
#include <Window.h>
@ -73,9 +73,9 @@ protected:
};
class FindPanel : public BBox {
class FindPanel : public BGroupView {
public:
FindPanel(BRect rect);
FindPanel();
virtual ~FindPanel();
virtual void AttachedToWindow();
virtual void MessageReceived(BMessage* msg);