Some style fixes and updated some copyrights. Removed the experimental code around SearchBarTextControl, and restored it to the previous functionality (i.e. no placeholder, until i finish my BTextControl patch to allow it), added also a 'instant search' like functionality to such class (every time you press a character the list is refreshed). This revision will be probably the next candidate for the Caya's optional package.

This commit is contained in:
barrett 2012-09-25 21:45:29 +00:00
parent 37f1324431
commit 5df2084053
9 changed files with 23 additions and 59 deletions

View File

@ -49,6 +49,7 @@
#include "Server.h"
#include "StatusView.h"
const uint32 kLogin = 'LOGI';
const uint32 kSearchContact = 'SRCH';
@ -60,8 +61,8 @@ MainWindow::MainWindow()
{
fStatusView = new StatusView("statusView");
SearchBarTextControl* searchBox = new SearchBarTextControl(
new BMessage(kSearchContact));
SearchBarTextControl* searchBox =
new SearchBarTextControl(new BMessage(kSearchContact));
fListView = new RosterListView("buddyView");
fListView->SetInvocationMessage(new BMessage(CAYA_OPEN_CHAT_WINDOW));

View File

@ -1,6 +1,6 @@
/*
* Copyright 2009, Pier Luigi Fiorini. All rights reserved.
* Copyright 2011, Pier Luigi Fiorini. All rights reserved.
* Copyright 2009-2011, Pier Luigi Fiorini. All rights reserved.
* Copyright 2011-2012, Dario Casalinuovo. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:

View File

@ -1,6 +1,6 @@
/*
* Copyright 2009, Pier Luigi Fiorini. All rights reserved.
* Copyright 2011, Dario Casalinuovo. All rights reserved.
* Copyright 2009-2011, Pier Luigi Fiorini. All rights reserved.
* Copyright 2011-2012, Dario Casalinuovo. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _STATUS_MENU_ITEM_H

View File

@ -1,5 +1,5 @@
/*
* Copyright 2011, Dario Casalinuovo. All rights reserved.
* Copyright 2011-2012, Dario Casalinuovo. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
@ -42,7 +42,8 @@ extern "C" _EXPORT BView *instantiate_deskbar_item(void);
class ReplicantHandler : public BHandler {
public:
ReplicantHandler(const char* name, ReplicantStatusView* target)
: BHandler(name)
:
BHandler(name)
{
fTarget = target;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2011, Dario Casalinuovo. All rights reserved.
* Copyright 2011-2012, Dario Casalinuovo. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:

View File

@ -15,59 +15,20 @@
#include <stdio.h>
const char* kSearchText = "Search...";
SearchBarTextControl::SearchBarTextControl(BMessage* message)
:
BTextControl("searchBox", NULL, NULL, message)
{
SetEventMask(B_POINTER_EVENTS);
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
rgb_color color = tint_color(ViewColor(), B_DARKEN_1_TINT);
SetText(kSearchText);
TextView()->SetName("SearchBoxTextView");
rgb_color color = tint_color(ViewColor(), B_DARKEN_3_TINT);
TextView()->SetFontAndColor(NULL, B_FONT_ALL, &color);
TextView()->MakeSelectable(false);
}
void
SearchBarTextControl::MouseDown(BPoint position)
{
BString text(Text());
BPoint currentPosition;
uint32 buttons;
GetMouse(&currentPosition, &buttons);
BView* view = Window()->FindView(currentPosition);
if (view != NULL && (view->Name() == TextView()->Name()
|| view->Name() == Name())) {
BTextControl::MouseDown(position);
SetText("");
}
if (TextView()->IsFocus()) {
SetText("");
} else if (!TextView()->IsFocus()) {
SetText(kSearchText);
}
SetModificationMessage(message);
}
void
SearchBarTextControl::KeyDown(const char* bytes, int32 numBytes)
{
if (TextView()->IsFocus()) {
if (Text() == kSearchText)
SetText("");
BTextControl::KeyDown(bytes, numBytes);
BString text(Text());
if (TextView()->IsFocus() && text.Length() > 0) {
BMessage* msg = ModificationMessage();
msg->AddPointer("source", this);
Window()->MessageReceived(msg);
}
}
}

View File

@ -10,7 +10,6 @@
class SearchBarTextControl : public BTextControl {
public:
SearchBarTextControl(BMessage* message);
virtual void MouseDown(BPoint position);
virtual void KeyDown(const char* bytes, int32 numBytes);
};

View File

@ -33,10 +33,12 @@ StatusView::StatusView(const char* name)
BView(name, B_WILL_DRAW)
{
// Nick name
fPersonalMessage = new NicknameTextControl("Nickname",
fNickname = new NicknameTextControl("Nickname",
new BMessage(kSetNickname));
BStringView* personalMessageLabel = new BStringView("Nickname","Nickname:", B_WILL_DRAW);
BStringView* nicknameLabel = new BStringView("Nickname",
"Nickname:", B_WILL_DRAW);
// Status menu
fStatusMenu = new BPopUpMenu("-");
@ -76,8 +78,8 @@ StatusView::StatusView(const char* name)
.AddGroup(B_VERTICAL)
.Add(statusField)
.AddGroup(B_HORIZONTAL)
.Add(personalMessageLabel)
.Add(fPersonalMessage)
.Add(nicknameLabel)
.Add(fNickname)
.End()
.End()
.Add(fAvatar)
@ -98,12 +100,12 @@ void
StatusView::MessageReceived(BMessage* msg)
{
switch (msg->what) {
/*case kSetNickname:
case kSetNickname:
{
AccountManager* accountManager = AccountManager::Get();
accountManager->SetNickname(fNickname->Text());
break;
}*/
}
case kSetStatus:
{
int32 status;
@ -124,7 +126,7 @@ StatusView::MessageReceived(BMessage* msg)
void
StatusView::SetName(BString name)
{
fPersonalMessage->SetText(name.String());
fNickname->SetText(name.String());
}

View File

@ -27,7 +27,7 @@ public:
private:
BPopUpMenu* fStatusMenu;
NicknameTextControl* fPersonalMessage;
NicknameTextControl* fNickname;
BitmapView* fAvatar;
};