Small style clean-up.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35675 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -63,23 +63,23 @@ enum {
|
|||||||
|
|
||||||
static BString sPreviousFind = "";
|
static BString sPreviousFind = "";
|
||||||
|
|
||||||
FindWindow* FindWindow::mFindWindow = NULL;
|
FindWindow* FindWindow::fFindWindow = NULL;
|
||||||
BRect FindWindow::mLastPosition(BRect(100,300,300,374));
|
BRect FindWindow::fLastPosition(BRect(100, 300, 300, 374));
|
||||||
|
|
||||||
void FindWindow::DoFind(BWindow *window, const char *text)
|
void FindWindow::DoFind(BWindow* window, const char* text)
|
||||||
{
|
{
|
||||||
if (window == NULL) {
|
if (window == NULL) {
|
||||||
long i=0;
|
long i = 0;
|
||||||
while ((window = be_app->WindowAt(i++)) != NULL) {
|
while ((window = be_app->WindowAt(i++)) != NULL) {
|
||||||
// Send the text to a waiting window
|
// Send the text to a waiting window
|
||||||
if (window != mFindWindow)
|
if (window != fFindWindow)
|
||||||
if (dynamic_cast<TMailWindow *>(window) != NULL)
|
if (dynamic_cast<TMailWindow*>(window) != NULL)
|
||||||
break; // Found a window
|
break; // Found a window
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ask that window who is in the front */
|
/* ask that window who is in the front */
|
||||||
window = dynamic_cast<TMailWindow *>(window)->FrontmostWindow();
|
window = dynamic_cast<TMailWindow*>(window)->FrontmostWindow();
|
||||||
if (window == NULL)
|
if (window == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ void FindWindow::DoFind(BWindow *window, const char *text)
|
|||||||
|
|
||||||
if (!window->Lock())
|
if (!window->Lock())
|
||||||
return;
|
return;
|
||||||
BView *focus = window->FindView("m_content");
|
BView* focus = window->FindView("m_content");
|
||||||
window->Unlock();
|
window->Unlock();
|
||||||
|
|
||||||
if (focus)
|
if (focus)
|
||||||
@@ -98,83 +98,89 @@ void FindWindow::DoFind(BWindow *window, const char *text)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FindPanel::FindPanel(BRect rect)
|
|
||||||
: BBox(rect, "FindPanel", B_FOLLOW_LEFT_RIGHT,
|
|
||||||
B_WILL_DRAW)
|
|
||||||
{
|
|
||||||
BRect r = Bounds().InsetByCopy(10,10);
|
|
||||||
|
|
||||||
mBTextControl = new BTextControl(r, "BTextControl", NULL,
|
FindPanel::FindPanel(BRect rect)
|
||||||
|
:
|
||||||
|
BBox(rect, "FindPanel", B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW)
|
||||||
|
{
|
||||||
|
BRect r = Bounds().InsetByCopy(10, 10);
|
||||||
|
|
||||||
|
fTextControl = new BTextControl(r, "BTextControl", NULL,
|
||||||
sPreviousFind.String(), new BMessage(M_FIND_STRING_CHANGED),
|
sPreviousFind.String(), new BMessage(M_FIND_STRING_CHANGED),
|
||||||
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
|
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
|
||||||
|
|
||||||
mBTextControl->SetText(sPreviousFind.String());
|
fTextControl->SetText(sPreviousFind.String());
|
||||||
mBTextControl->MakeFocus();
|
fTextControl->MakeFocus();
|
||||||
AddChild(mBTextControl);
|
AddChild(fTextControl);
|
||||||
|
|
||||||
mFindButton = new BButton(BRect(0,0,90,20),"FINDBUTTON",
|
fFindButton = new BButton(BRect(0, 0, 90, 20),"FINDBUTTON", TR("Find"),
|
||||||
TR("Find"),
|
|
||||||
new BMessage(FINDBUTTON),B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
|
new BMessage(FINDBUTTON),B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
|
||||||
mFindButton->ResizeToPreferred();
|
fFindButton->ResizeToPreferred();
|
||||||
AddChild(mFindButton);
|
AddChild(fFindButton);
|
||||||
r = mFindButton->Bounds();
|
r = fFindButton->Bounds();
|
||||||
|
|
||||||
mFindButton->MoveTo(Bounds().right - r.Width() - 8,
|
fFindButton->MoveTo(Bounds().right - r.Width() - 8,
|
||||||
Bounds().bottom - r.Height() - 8);
|
Bounds().bottom - r.Height() - 8);
|
||||||
mFindButton->SetEnabled(sPreviousFind.Length());
|
fFindButton->SetEnabled(sPreviousFind.Length());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FindPanel::~FindPanel()
|
FindPanel::~FindPanel()
|
||||||
{
|
{
|
||||||
sPreviousFind = mBTextControl->Text();
|
sPreviousFind = fTextControl->Text();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FindPanel::AttachedToWindow()
|
void FindPanel::AttachedToWindow()
|
||||||
{
|
{
|
||||||
BView::AttachedToWindow();
|
BView::AttachedToWindow();
|
||||||
SetViewColor(216,216,216);
|
SetViewColor(216, 216, 216);
|
||||||
Window()->SetDefaultButton(mFindButton);
|
Window()->SetDefaultButton(fFindButton);
|
||||||
mFindButton->SetTarget(this);
|
fFindButton->SetTarget(this);
|
||||||
|
|
||||||
mBTextControl->SetTarget(this);
|
fTextControl->SetTarget(this);
|
||||||
mBTextControl->ResizeToPreferred();
|
fTextControl->ResizeToPreferred();
|
||||||
mBTextControl->ResizeTo(Bounds().Width() - 20,
|
fTextControl->ResizeTo(Bounds().Width() - 20,
|
||||||
mBTextControl->Frame().Height());
|
fTextControl->Frame().Height());
|
||||||
|
|
||||||
mBTextControl->MakeFocus(true);
|
fTextControl->MakeFocus(true);
|
||||||
mBTextControl->TextView()->SelectAll();
|
fTextControl->TextView()->SelectAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FindPanel::MouseDown(BPoint point)
|
void FindPanel::MouseDown(BPoint point)
|
||||||
{
|
{
|
||||||
Window()->Activate();
|
Window()->Activate();
|
||||||
BView::MouseDown(point);
|
BView::MouseDown(point);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FindPanel::Draw(BRect)
|
void FindPanel::Draw(BRect)
|
||||||
{
|
{
|
||||||
// TextBevel(*this,mBTextView->Frame());
|
// TextBevel(*this, mBTextView->Frame());
|
||||||
}
|
}
|
||||||
|
|
||||||
void FindPanel::KeyDown(const char *, int32)
|
|
||||||
|
void FindPanel::KeyDown(const char*, int32)
|
||||||
{
|
{
|
||||||
int32 length = mBTextControl->TextView()->TextLength();
|
int32 length = fTextControl->TextView()->TextLength();
|
||||||
bool enabled = mFindButton->IsEnabled();
|
bool enabled = fFindButton->IsEnabled();
|
||||||
|
|
||||||
if (length > 0 && !enabled)
|
if (length > 0 && !enabled)
|
||||||
mFindButton->SetEnabled(true);
|
fFindButton->SetEnabled(true);
|
||||||
else if (length == 0 && enabled)
|
else if (length == 0 && enabled)
|
||||||
mFindButton->SetEnabled(false);
|
fFindButton->SetEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FindPanel::MessageReceived(BMessage *msg)
|
|
||||||
|
void FindPanel::MessageReceived(BMessage* msg)
|
||||||
{
|
{
|
||||||
switch (msg->what) {
|
switch (msg->what) {
|
||||||
case M_FIND_STRING_CHANGED: {
|
case M_FIND_STRING_CHANGED: {
|
||||||
if (strlen(mBTextControl->Text()) == 0)
|
if (strlen(fTextControl->Text()) == 0)
|
||||||
mFindButton->SetEnabled(false);
|
fFindButton->SetEnabled(false);
|
||||||
else
|
else
|
||||||
mFindButton->SetEnabled(true);
|
fFindButton->SetEnabled(true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case FINDBUTTON: {
|
case FINDBUTTON: {
|
||||||
@@ -190,15 +196,15 @@ void FindPanel::MessageReceived(BMessage *msg)
|
|||||||
|
|
||||||
void FindPanel::Find()
|
void FindPanel::Find()
|
||||||
{
|
{
|
||||||
mBTextControl->TextView()->SelectAll();
|
fTextControl->TextView()->SelectAll();
|
||||||
const char *text = mBTextControl->Text();
|
const char* text = fTextControl->Text();
|
||||||
if (text == NULL || text[0] == 0) return;
|
if (text == NULL || text[0] == 0) return;
|
||||||
|
|
||||||
BWindow *window = NULL;
|
BWindow* window = NULL;
|
||||||
long i=0;
|
long i = 0;
|
||||||
while ((bool)(window = be_app->WindowAt(i++))) {
|
while ((bool)(window = be_app->WindowAt(i++))) {
|
||||||
// Send the text to a waiting window
|
// Send the text to a waiting window
|
||||||
if (window != FindWindow::mFindWindow)
|
if (window != FindWindow::fFindWindow)
|
||||||
break; // Found a window
|
break; // Found a window
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,42 +214,42 @@ void FindPanel::Find()
|
|||||||
|
|
||||||
|
|
||||||
FindWindow::FindWindow()
|
FindWindow::FindWindow()
|
||||||
: BWindow(FindWindow::mLastPosition, TR("Find"), B_FLOATING_WINDOW,
|
: BWindow(FindWindow::fLastPosition, TR("Find"), B_FLOATING_WINDOW,
|
||||||
B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_WILL_ACCEPT_FIRST_CLICK
|
B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_WILL_ACCEPT_FIRST_CLICK
|
||||||
| B_CLOSE_ON_ESCAPE)
|
| B_CLOSE_ON_ESCAPE)
|
||||||
{
|
{
|
||||||
mFindPanel = new FindPanel(Bounds());
|
fFindPanel = new FindPanel(Bounds());
|
||||||
AddChild(mFindPanel);
|
AddChild(fFindPanel);
|
||||||
mFindWindow = this;
|
fFindWindow = this;
|
||||||
Show();
|
Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FindWindow::~FindWindow()
|
FindWindow::~FindWindow()
|
||||||
{
|
{
|
||||||
FindWindow::mLastPosition = Frame();
|
FindWindow::fLastPosition = Frame();
|
||||||
mFindWindow = NULL;
|
fFindWindow = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FindWindow::Find(BWindow *window)
|
void FindWindow::Find(BWindow* window)
|
||||||
{
|
{
|
||||||
// eliminate unused parameter warning
|
// eliminate unused parameter warning
|
||||||
(void)window;
|
(void)window;
|
||||||
|
|
||||||
if (mFindWindow == NULL) {
|
if (fFindWindow == NULL) {
|
||||||
mFindWindow = new FindWindow();
|
fFindWindow = new FindWindow();
|
||||||
} else
|
} else
|
||||||
mFindWindow->Activate();
|
fFindWindow->Activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FindWindow::FindAgain(BWindow *window)
|
void FindWindow::FindAgain(BWindow* window)
|
||||||
{
|
{
|
||||||
if (mFindWindow) {
|
if (fFindWindow) {
|
||||||
mFindWindow->Lock();
|
fFindWindow->Lock();
|
||||||
mFindWindow->mFindPanel->Find();
|
fFindWindow->fFindPanel->Find();
|
||||||
mFindWindow->Unlock();
|
fFindWindow->Unlock();
|
||||||
} else if (sPreviousFind.Length() != 0)
|
} else if (sPreviousFind.Length() != 0)
|
||||||
DoFind(window, sPreviousFind.String());
|
DoFind(window, sPreviousFind.String());
|
||||||
else
|
else
|
||||||
@@ -251,13 +257,13 @@ void FindWindow::FindAgain(BWindow *window)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FindWindow::SetFindString(const char *string)
|
void FindWindow::SetFindString(const char* string)
|
||||||
{
|
{
|
||||||
sPreviousFind = string;
|
sPreviousFind = string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char *FindWindow::GetFindString()
|
const char* FindWindow::GetFindString()
|
||||||
{
|
{
|
||||||
return sPreviousFind.String();
|
return sPreviousFind.String();
|
||||||
}
|
}
|
||||||
|
|||||||
+27
-24
@@ -36,7 +36,6 @@ All rights reserved.
|
|||||||
// FindWindow.h
|
// FindWindow.h
|
||||||
// Copyright 1996 by Peter Barrett, All rights reserved.
|
// Copyright 1996 by Peter Barrett, All rights reserved.
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
#ifndef _FINDWINDOW_H
|
#ifndef _FINDWINDOW_H
|
||||||
#define _FINDWINDOW_H
|
#define _FINDWINDOW_H
|
||||||
|
|
||||||
@@ -45,45 +44,49 @@ All rights reserved.
|
|||||||
#include <TextControl.h>
|
#include <TextControl.h>
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
|
|
||||||
class FindPanel;
|
class FindPanel;
|
||||||
|
|
||||||
|
|
||||||
class FindWindow : public BWindow {
|
class FindWindow : public BWindow {
|
||||||
friend class FindPanel;
|
friend class FindPanel;
|
||||||
public:
|
public:
|
||||||
FindWindow();
|
FindWindow();
|
||||||
virtual ~FindWindow();
|
virtual ~FindWindow();
|
||||||
|
|
||||||
static void FindAgain(BWindow *window);
|
static void FindAgain(BWindow* window);
|
||||||
static void Find(BWindow *window);
|
static void Find(BWindow* window);
|
||||||
static bool IsFindWindowOpen() {return mFindWindow;}
|
static bool IsFindWindowOpen() { return fFindWindow; }
|
||||||
static void Close()
|
static void Close() {
|
||||||
{ if (mFindWindow) mFindWindow->PostMessage(B_QUIT_REQUESTED); }
|
if (fFindWindow)
|
||||||
static void SetFindString(const char *string);
|
fFindWindow->PostMessage(B_QUIT_REQUESTED);
|
||||||
static const char* GetFindString();
|
}
|
||||||
|
static void SetFindString(const char* string);
|
||||||
|
static const char* GetFindString();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void DoFind(BWindow *window, const char *text);
|
static void DoFind(BWindow* window, const char* text);
|
||||||
|
|
||||||
static FindWindow* mFindWindow;
|
static FindWindow* fFindWindow;
|
||||||
FindPanel* mFindPanel;
|
FindPanel* fFindPanel;
|
||||||
static BRect mLastPosition;
|
static BRect fLastPosition;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class FindPanel : public BBox {
|
class FindPanel : public BBox {
|
||||||
public:
|
public:
|
||||||
FindPanel(BRect rect);
|
FindPanel(BRect rect);
|
||||||
virtual ~FindPanel();
|
virtual ~FindPanel();
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
virtual void MessageReceived(BMessage *msg);
|
virtual void MessageReceived(BMessage* msg);
|
||||||
virtual void Draw(BRect updateRect);
|
virtual void Draw(BRect updateRect);
|
||||||
virtual void KeyDown(const char *bytes, int32 numBytes);
|
virtual void KeyDown(const char* bytes, int32 numBytes);
|
||||||
void Find();
|
void Find();
|
||||||
virtual void MouseDown(BPoint point);
|
virtual void MouseDown(BPoint point);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BButton* mFindButton;
|
BButton* fFindButton;
|
||||||
BTextControl* mBTextControl;
|
BTextControl* fTextControl;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user