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:
parent
37f1324431
commit
5df2084053
|
@ -49,6 +49,7 @@
|
||||||
#include "Server.h"
|
#include "Server.h"
|
||||||
#include "StatusView.h"
|
#include "StatusView.h"
|
||||||
|
|
||||||
|
|
||||||
const uint32 kLogin = 'LOGI';
|
const uint32 kLogin = 'LOGI';
|
||||||
const uint32 kSearchContact = 'SRCH';
|
const uint32 kSearchContact = 'SRCH';
|
||||||
|
|
||||||
|
@ -60,8 +61,8 @@ MainWindow::MainWindow()
|
||||||
{
|
{
|
||||||
fStatusView = new StatusView("statusView");
|
fStatusView = new StatusView("statusView");
|
||||||
|
|
||||||
SearchBarTextControl* searchBox = new SearchBarTextControl(
|
SearchBarTextControl* searchBox =
|
||||||
new BMessage(kSearchContact));
|
new SearchBarTextControl(new BMessage(kSearchContact));
|
||||||
|
|
||||||
fListView = new RosterListView("buddyView");
|
fListView = new RosterListView("buddyView");
|
||||||
fListView->SetInvocationMessage(new BMessage(CAYA_OPEN_CHAT_WINDOW));
|
fListView->SetInvocationMessage(new BMessage(CAYA_OPEN_CHAT_WINDOW));
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2009, Pier Luigi Fiorini. All rights reserved.
|
* Copyright 2009-2011, Pier Luigi Fiorini. All rights reserved.
|
||||||
* Copyright 2011, Pier Luigi Fiorini. All rights reserved.
|
* Copyright 2011-2012, Dario Casalinuovo. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2009, Pier Luigi Fiorini. All rights reserved.
|
* Copyright 2009-2011, Pier Luigi Fiorini. All rights reserved.
|
||||||
* Copyright 2011, Dario Casalinuovo. All rights reserved.
|
* Copyright 2011-2012, Dario Casalinuovo. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef _STATUS_MENU_ITEM_H
|
#ifndef _STATUS_MENU_ITEM_H
|
||||||
|
|
|
@ -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.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
|
@ -42,7 +42,8 @@ extern "C" _EXPORT BView *instantiate_deskbar_item(void);
|
||||||
class ReplicantHandler : public BHandler {
|
class ReplicantHandler : public BHandler {
|
||||||
public:
|
public:
|
||||||
ReplicantHandler(const char* name, ReplicantStatusView* target)
|
ReplicantHandler(const char* name, ReplicantStatusView* target)
|
||||||
: BHandler(name)
|
:
|
||||||
|
BHandler(name)
|
||||||
{
|
{
|
||||||
fTarget = target;
|
fTarget = target;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
|
|
|
@ -15,59 +15,20 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
const char* kSearchText = "Search...";
|
|
||||||
|
|
||||||
|
|
||||||
SearchBarTextControl::SearchBarTextControl(BMessage* message)
|
SearchBarTextControl::SearchBarTextControl(BMessage* message)
|
||||||
:
|
:
|
||||||
BTextControl("searchBox", NULL, NULL, message)
|
BTextControl("searchBox", NULL, NULL, message)
|
||||||
{
|
{
|
||||||
SetEventMask(B_POINTER_EVENTS);
|
|
||||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
rgb_color color = tint_color(ViewColor(), B_DARKEN_1_TINT);
|
rgb_color color = tint_color(ViewColor(), B_DARKEN_3_TINT);
|
||||||
SetText(kSearchText);
|
|
||||||
TextView()->SetName("SearchBoxTextView");
|
|
||||||
TextView()->SetFontAndColor(NULL, B_FONT_ALL, &color);
|
TextView()->SetFontAndColor(NULL, B_FONT_ALL, &color);
|
||||||
TextView()->MakeSelectable(false);
|
TextView()->MakeSelectable(false);
|
||||||
}
|
SetModificationMessage(message);
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
SearchBarTextControl::MouseDown(BPoint position)
|
|
||||||
{
|
|
||||||
BString text(Text());
|
|
||||||
BPoint currentPosition;
|
|
||||||
uint32 buttons;
|
|
||||||
GetMouse(¤tPosition, &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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SearchBarTextControl::KeyDown(const char* bytes, int32 numBytes)
|
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
class SearchBarTextControl : public BTextControl {
|
class SearchBarTextControl : public BTextControl {
|
||||||
public:
|
public:
|
||||||
SearchBarTextControl(BMessage* message);
|
SearchBarTextControl(BMessage* message);
|
||||||
virtual void MouseDown(BPoint position);
|
|
||||||
virtual void KeyDown(const char* bytes, int32 numBytes);
|
virtual void KeyDown(const char* bytes, int32 numBytes);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -33,10 +33,12 @@ StatusView::StatusView(const char* name)
|
||||||
BView(name, B_WILL_DRAW)
|
BView(name, B_WILL_DRAW)
|
||||||
{
|
{
|
||||||
// Nick name
|
// Nick name
|
||||||
fPersonalMessage = new NicknameTextControl("Nickname",
|
fNickname = new NicknameTextControl("Nickname",
|
||||||
new BMessage(kSetNickname));
|
new BMessage(kSetNickname));
|
||||||
|
|
||||||
BStringView* personalMessageLabel = new BStringView("Nickname","Nickname:", B_WILL_DRAW);
|
BStringView* nicknameLabel = new BStringView("Nickname",
|
||||||
|
"Nickname:", B_WILL_DRAW);
|
||||||
|
|
||||||
// Status menu
|
// Status menu
|
||||||
fStatusMenu = new BPopUpMenu("-");
|
fStatusMenu = new BPopUpMenu("-");
|
||||||
|
|
||||||
|
@ -76,8 +78,8 @@ StatusView::StatusView(const char* name)
|
||||||
.AddGroup(B_VERTICAL)
|
.AddGroup(B_VERTICAL)
|
||||||
.Add(statusField)
|
.Add(statusField)
|
||||||
.AddGroup(B_HORIZONTAL)
|
.AddGroup(B_HORIZONTAL)
|
||||||
.Add(personalMessageLabel)
|
.Add(nicknameLabel)
|
||||||
.Add(fPersonalMessage)
|
.Add(fNickname)
|
||||||
.End()
|
.End()
|
||||||
.End()
|
.End()
|
||||||
.Add(fAvatar)
|
.Add(fAvatar)
|
||||||
|
@ -98,12 +100,12 @@ void
|
||||||
StatusView::MessageReceived(BMessage* msg)
|
StatusView::MessageReceived(BMessage* msg)
|
||||||
{
|
{
|
||||||
switch (msg->what) {
|
switch (msg->what) {
|
||||||
/*case kSetNickname:
|
case kSetNickname:
|
||||||
{
|
{
|
||||||
AccountManager* accountManager = AccountManager::Get();
|
AccountManager* accountManager = AccountManager::Get();
|
||||||
accountManager->SetNickname(fNickname->Text());
|
accountManager->SetNickname(fNickname->Text());
|
||||||
break;
|
break;
|
||||||
}*/
|
}
|
||||||
case kSetStatus:
|
case kSetStatus:
|
||||||
{
|
{
|
||||||
int32 status;
|
int32 status;
|
||||||
|
@ -124,7 +126,7 @@ StatusView::MessageReceived(BMessage* msg)
|
||||||
void
|
void
|
||||||
StatusView::SetName(BString name)
|
StatusView::SetName(BString name)
|
||||||
{
|
{
|
||||||
fPersonalMessage->SetText(name.String());
|
fNickname->SetText(name.String());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BPopUpMenu* fStatusMenu;
|
BPopUpMenu* fStatusMenu;
|
||||||
NicknameTextControl* fPersonalMessage;
|
NicknameTextControl* fNickname;
|
||||||
BitmapView* fAvatar;
|
BitmapView* fAvatar;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Ŝarĝante…
Reference in New Issue