Imported Deskbar from OpenTracker-current.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15774 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -118,15 +118,15 @@ TBarApp::TBarApp()
|
||||
|
||||
sSubscribers.MakeEmpty();
|
||||
|
||||
fSwitcherMess = BMessenger(new TSwitchMgr(fSettings.switcherLoc));
|
||||
fSwitcherMessenger = BMessenger(new TSwitchManager(fSettings.switcherLoc));
|
||||
|
||||
fBarWindow = new TBarWindow();
|
||||
fBarWindow->Show();
|
||||
|
||||
// this messenger now targets the barview instead of the
|
||||
// statusview so that all additions to the tray
|
||||
// follow the same path
|
||||
fStatusViewMess = BMessenger(fBarWindow->FindView("BarView"));
|
||||
// this messenger now targets the barview instead of the
|
||||
// statusview so that all additions to the tray
|
||||
// follow the same path
|
||||
fStatusViewMessenger = BMessenger(fBarWindow->FindView("BarView"));
|
||||
}
|
||||
|
||||
|
||||
@@ -372,8 +372,9 @@ TBarApp::MessageReceived(BMessage *message)
|
||||
}
|
||||
|
||||
case B_ARCHIVED_OBJECT:
|
||||
// TODO: what's this???
|
||||
message->AddString("special", "Alex Osadzinski");
|
||||
fStatusViewMess.SendMessage(message);
|
||||
fStatusViewMessenger.SendMessage(message);
|
||||
break;
|
||||
|
||||
case msg_Be:
|
||||
@@ -459,7 +460,7 @@ TBarApp::MessageReceived(BMessage *message)
|
||||
}
|
||||
|
||||
case 'TASK':
|
||||
fSwitcherMess.SendMessage(message);
|
||||
fSwitcherMessenger.SendMessage(message);
|
||||
break;
|
||||
|
||||
#if __HAIKU__
|
||||
|
||||
+37
-39
@@ -31,14 +31,15 @@ of Be Incorporated in the United States and other countries. Other brand product
|
||||
names are registered trademarks or trademarks of their respective holders.
|
||||
All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef BAR_APP_H
|
||||
#define BAR_APP_H
|
||||
|
||||
|
||||
#include <Application.h>
|
||||
#include <List.h>
|
||||
#include "BarWindow.h"
|
||||
|
||||
|
||||
/* ------------------------------------ */
|
||||
// Private app_server defines that I need to use
|
||||
|
||||
@@ -46,6 +47,7 @@ All rights reserved.
|
||||
#define _FLOATER_W_TYPE_ 4
|
||||
#define _STD_W_TYPE_ 0
|
||||
|
||||
|
||||
class BarTeamInfo {
|
||||
public:
|
||||
BarTeamInfo(BList *teams, uint32 flags, char *sig, BBitmap *icon,
|
||||
@@ -86,7 +88,7 @@ const uint32 CMD_SUSPEND_SYSTEM = 304;
|
||||
// if you want to extend this structure, maintain the
|
||||
// constants below (used in TBarApp::InitSettings())
|
||||
|
||||
struct desk_settings {
|
||||
struct desk_settings {
|
||||
bool vertical; // version 1
|
||||
bool left;
|
||||
bool top;
|
||||
@@ -126,53 +128,49 @@ class TBarView;
|
||||
class BFile;
|
||||
|
||||
namespace BPrivate {
|
||||
|
||||
class TFavoritesConfigWindow;
|
||||
|
||||
class TFavoritesConfigWindow;
|
||||
}
|
||||
|
||||
using namespace BPrivate;
|
||||
|
||||
class TBarApp : public BApplication {
|
||||
public:
|
||||
TBarApp();
|
||||
virtual ~TBarApp();
|
||||
public:
|
||||
TBarApp();
|
||||
virtual ~TBarApp();
|
||||
|
||||
virtual bool QuitRequested();
|
||||
virtual void MessageReceived(BMessage *);
|
||||
virtual bool QuitRequested();
|
||||
virtual void MessageReceived(BMessage *);
|
||||
|
||||
desk_settings *Settings()
|
||||
{ return &fSettings; };
|
||||
TBarView *BarView() const
|
||||
{ return fBarWindow->BarView(); };
|
||||
|
||||
static void Subscribe(const BMessenger &subscriber, BList *);
|
||||
static void Unsubscribe(const BMessenger &subscriber);
|
||||
|
||||
private:
|
||||
void AddTeam(team_id team, uint32 flags, const char *sig, entry_ref *);
|
||||
void RemoveTeam(team_id);
|
||||
desk_settings *Settings()
|
||||
{ return &fSettings; }
|
||||
TBarView *BarView() const
|
||||
{ return fBarWindow->BarView(); }
|
||||
TBarWindow *BarWindow() const
|
||||
{ return fBarWindow; }
|
||||
|
||||
void InitSettings();
|
||||
void SaveSettings();
|
||||
|
||||
void ShowConfigWindow();
|
||||
static void Subscribe(const BMessenger &subscriber, BList *);
|
||||
static void Unsubscribe(const BMessenger &subscriber);
|
||||
|
||||
#if __HAIKU__
|
||||
static int32 _shutdown(void* cookie);
|
||||
#endif
|
||||
private:
|
||||
void AddTeam(team_id team, uint32 flags, const char *sig, entry_ref *);
|
||||
void RemoveTeam(team_id);
|
||||
|
||||
TBarWindow *fBarWindow;
|
||||
BMessenger fSwitcherMess;
|
||||
BMessenger fStatusViewMess;
|
||||
BFile *fSettingsFile;
|
||||
desk_settings fSettings;
|
||||
|
||||
TFavoritesConfigWindow *fConfigWindow;
|
||||
|
||||
static BLocker sSubscriberLock;
|
||||
static BList sBarTeamInfoList;
|
||||
static BList sSubscribers;
|
||||
void InitSettings();
|
||||
void SaveSettings();
|
||||
|
||||
void ShowConfigWindow();
|
||||
|
||||
TBarWindow *fBarWindow;
|
||||
BMessenger fSwitcherMessenger;
|
||||
BMessenger fStatusViewMessenger;
|
||||
BFile *fSettingsFile;
|
||||
desk_settings fSettings;
|
||||
|
||||
TFavoritesConfigWindow *fConfigWindow;
|
||||
|
||||
static BLocker sSubscriberLock;
|
||||
static BList sBarTeamInfoList;
|
||||
static BList sSubscribers;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -48,15 +48,15 @@ All rights reserved.
|
||||
|
||||
|
||||
TBarMenuBar::TBarMenuBar(TBarView *bar, BRect frame, const char *name)
|
||||
: BMenuBar(frame, name, B_FOLLOW_NONE, B_ITEMS_IN_ROW, false),
|
||||
fBarView(bar),
|
||||
fAppListMenuItem(NULL)
|
||||
: BMenuBar(frame, name, B_FOLLOW_NONE, B_ITEMS_IN_ROW, false),
|
||||
fBarView(bar),
|
||||
fAppListMenuItem(NULL)
|
||||
{
|
||||
SetItemMargins(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
|
||||
|
||||
TBeMenu *beMenu = new TBeMenu(bar);
|
||||
TBarWindow::SetBeMenu(beMenu);
|
||||
|
||||
|
||||
fBeMenuItem = new TBarMenuTitle(frame.Width(), frame.Height(),
|
||||
AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_BeLogoIcon), beMenu);
|
||||
AddItem(fBeMenuItem);
|
||||
@@ -71,14 +71,13 @@ TBarMenuBar::~TBarMenuBar()
|
||||
void
|
||||
TBarMenuBar::SmartResize(float width, float height)
|
||||
{
|
||||
if ((width == -1.0f) && (height == -1.0f)) {
|
||||
if (width == -1.0f && height == -1.0f) {
|
||||
BRect frame = Frame();
|
||||
width = frame.Width();
|
||||
height = frame.Height();
|
||||
} else
|
||||
ResizeTo(width, height);
|
||||
|
||||
|
||||
width -= 1;
|
||||
|
||||
int32 count = CountItems();
|
||||
@@ -99,7 +98,7 @@ TBarMenuBar::AddTeamMenu()
|
||||
|
||||
BRect frame(Frame());
|
||||
delete fAppListMenuItem;
|
||||
|
||||
|
||||
fAppListMenuItem = new TBarMenuTitle(0.0f, 0.0f,
|
||||
AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_TeamIcon), new TTeamMenu());
|
||||
AddItem(fAppListMenuItem);
|
||||
@@ -118,7 +117,7 @@ TBarMenuBar::RemoveTeamMenu()
|
||||
delete fAppListMenuItem;
|
||||
fAppListMenuItem = NULL;
|
||||
}
|
||||
|
||||
|
||||
BRect frame = Frame();
|
||||
SmartResize(frame.Width(), frame.Height());
|
||||
}
|
||||
@@ -139,50 +138,53 @@ TBarMenuBar::DrawBackground(BRect rect)
|
||||
}
|
||||
|
||||
|
||||
// the following code parallels that in ExpandoMenuBar for DnD tracking
|
||||
void
|
||||
TBarMenuBar::MouseMoved(BPoint where, uint32 code, const BMessage *message)
|
||||
{
|
||||
// the following code parallels that in ExpandoMenuBar for DnD tracking
|
||||
|
||||
if (!message) {
|
||||
// force a cleanup
|
||||
// force a cleanup
|
||||
fBarView->DragStop(true);
|
||||
BMenuBar::MouseMoved(where, code, message);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
switch (code) {
|
||||
case B_ENTERED_VIEW:
|
||||
{
|
||||
BPoint loc;
|
||||
uint32 buttons;
|
||||
GetMouse(&loc, &buttons);
|
||||
// attempt to start Dnd tracking
|
||||
if (message && buttons != 0) {
|
||||
fBarView->CacheDragData(const_cast<BMessage *>(message));
|
||||
MouseDown(loc);
|
||||
}
|
||||
{
|
||||
BPoint loc;
|
||||
uint32 buttons;
|
||||
GetMouse(&loc, &buttons);
|
||||
// attempt to start DnD tracking
|
||||
if (message && buttons != 0) {
|
||||
fBarView->CacheDragData(const_cast<BMessage *>(message));
|
||||
MouseDown(loc);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
BMenuBar::MouseMoved(where, code, message);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
init_tracking_hook(BMenuItem *item,bool (*hookfunction)(BMenu *, void *), void *state)
|
||||
init_tracking_hook(BMenuItem *item, bool (*hookFunction)(BMenu *, void *),
|
||||
void *state)
|
||||
{
|
||||
if (!item)
|
||||
return;
|
||||
|
||||
BMenu *windowmenu = item->Submenu();
|
||||
if (windowmenu)
|
||||
|
||||
BMenu *windowMenu = item->Submenu();
|
||||
if (windowMenu)
|
||||
// have a menu, set the tracking hook
|
||||
windowmenu->SetTrackingHook(hookfunction, state);
|
||||
windowMenu->SetTrackingHook(hookFunction, state);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarMenuBar::InitTrackingHook(bool (*hookfunction)(BMenu *, void *), void *state, bool both)
|
||||
TBarMenuBar::InitTrackingHook(bool (*hookFunction)(BMenu *, void *),
|
||||
void *state, bool both)
|
||||
{
|
||||
BPoint loc;
|
||||
uint32 buttons;
|
||||
@@ -191,8 +193,8 @@ TBarMenuBar::InitTrackingHook(bool (*hookfunction)(BMenu *, void *), void *state
|
||||
// will always have the be menu
|
||||
// may have the app menu as well (mini mode)
|
||||
if (fBeMenuItem->Frame().Contains(loc) || both)
|
||||
init_tracking_hook(fBeMenuItem, hookfunction, state);
|
||||
init_tracking_hook(fBeMenuItem, hookFunction, state);
|
||||
|
||||
if (fAppListMenuItem && (fAppListMenuItem->Frame().Contains(loc) || both))
|
||||
init_tracking_hook(fAppListMenuItem, hookfunction, state);
|
||||
init_tracking_hook(fAppListMenuItem, hookFunction, state);
|
||||
}
|
||||
|
||||
@@ -110,13 +110,7 @@ TBarView::AttachedToWindow()
|
||||
|
||||
SetViewColor(ui_color(B_MENU_BACKGROUND_COLOR));
|
||||
SetFont(be_plain_font);
|
||||
|
||||
#if SA_CLOCK
|
||||
fClock = new TTimeView(this, false, false, false, false, fShowInterval);
|
||||
if (fShowClock)
|
||||
AddChild(fClock);
|
||||
#endif
|
||||
|
||||
|
||||
fReplicantTray = new TReplicantTray(this, fVertical);
|
||||
fDragRegion = new TDragRegion(this, fReplicantTray);
|
||||
fDragRegion->AddChild(fReplicantTray);
|
||||
@@ -241,7 +235,7 @@ TBarView::PlaceTray(bool, bool, BRect screenFrame)
|
||||
|
||||
if (!fReplicantTray->IsHidden())
|
||||
fReplicantTray->Hide();
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -254,12 +248,7 @@ TBarView::PlaceTray(bool, bool, BRect screenFrame)
|
||||
fDragRegion->ResizeToPreferred();
|
||||
|
||||
if (fVertical) {
|
||||
#if SA_CLOCK
|
||||
if (fShowClock)
|
||||
statusLoc.y = fClock->Frame().bottom + 1;
|
||||
else
|
||||
#endif
|
||||
statusLoc.y = fBarMenuBar->Frame().bottom + 1;
|
||||
statusLoc.y = fBarMenuBar->Frame().bottom + 1;
|
||||
statusLoc.x = 0;
|
||||
if (Left() && Vertical())
|
||||
fReplicantTray->MoveTo(5, 2);
|
||||
@@ -275,38 +264,6 @@ TBarView::PlaceTray(bool, bool, BRect screenFrame)
|
||||
}
|
||||
|
||||
|
||||
#if SA_CLOCK
|
||||
void
|
||||
TBarView::PlaceClock()
|
||||
{
|
||||
if (fState == kFullState) {
|
||||
if (!fClock->IsHidden())
|
||||
fClock->Hide();
|
||||
return;
|
||||
}
|
||||
|
||||
if (fShowClock) {
|
||||
fClock->SetOrientation(fVertical);
|
||||
|
||||
BPoint loc;
|
||||
if (fVertical) {
|
||||
fClock->ResizeTo(kMinimumWindowWidth, kMenuBarHeight);
|
||||
loc.x = 0;
|
||||
loc.y = fBarMenuBar->Frame().bottom + 1;
|
||||
} else {
|
||||
float width, height;
|
||||
fClock->GetPreferredSize(&width, &height);
|
||||
fClock->ResizeTo(width, kMenuBarHeight);
|
||||
loc = fDragRegion->Frame().LeftTop();
|
||||
loc.x -= fClock->Frame().Width();
|
||||
loc.y = 0;
|
||||
}
|
||||
fClock->MoveTo(loc);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void
|
||||
TBarView::PlaceApplicationBar(BRect screenFrame)
|
||||
{
|
||||
@@ -324,12 +281,7 @@ TBarView::PlaceApplicationBar(BRect screenFrame)
|
||||
if (fTrayLocation != 0)
|
||||
expandoFrame.top = fDragRegion->Frame().bottom + 2;
|
||||
else {
|
||||
#if SA_CLOCK
|
||||
if (fShowClock)
|
||||
expandoFrame.top = fClock->Frame().bottom + 2;
|
||||
else
|
||||
#endif
|
||||
expandoFrame.top = fBarMenuBar->Frame().bottom + 2;
|
||||
expandoFrame.top = fBarMenuBar->Frame().bottom + 2;
|
||||
}
|
||||
|
||||
expandoFrame.bottom = expandoFrame.top + 1;
|
||||
@@ -342,12 +294,7 @@ TBarView::PlaceApplicationBar(BRect screenFrame)
|
||||
expandoFrame.top = -1;
|
||||
expandoFrame.bottom = kHModeHeight;
|
||||
if (fTrayLocation != 0) {
|
||||
#if SA_CLOCK
|
||||
if (fShowClock)
|
||||
expandoFrame.right = fClock->Frame().left;
|
||||
else
|
||||
#endif
|
||||
expandoFrame.right = fDragRegion->Frame().left;
|
||||
expandoFrame.right = fDragRegion->Frame().left;
|
||||
} else
|
||||
expandoFrame.right = screenFrame.Width();
|
||||
|
||||
@@ -463,17 +410,7 @@ TBarView::ChangeState(int32 state, bool vertical, bool left, bool top)
|
||||
BRect screenFrame = (BScreen(Window())).Frame();
|
||||
|
||||
PlaceBeMenu();
|
||||
if (fVertical){
|
||||
#if SA_CLOCK
|
||||
PlaceClock(); // tray dependent on clock location
|
||||
#endif
|
||||
PlaceTray(vertSwap, leftSwap, screenFrame);
|
||||
} else {
|
||||
PlaceTray(vertSwap, leftSwap, screenFrame);
|
||||
#if SA_CLOCK
|
||||
PlaceClock(); // clock is dependent on tray location
|
||||
#endif
|
||||
}
|
||||
PlaceTray(vertSwap, leftSwap, screenFrame);
|
||||
|
||||
// We need to keep track of what apps are expanded.
|
||||
BList expandedItems;
|
||||
@@ -601,25 +538,7 @@ TBarView::ShowingClock() const
|
||||
}
|
||||
|
||||
|
||||
#if SA_CLOCK
|
||||
void
|
||||
TBarView::ToggleClock()
|
||||
{
|
||||
fShowClock = !fShowClock;
|
||||
|
||||
#if SA_CLOCK
|
||||
if (fShowClock)
|
||||
AddChild(fClock);
|
||||
else
|
||||
fClock->RemoveSelf();
|
||||
#endif
|
||||
|
||||
UpdatePlacement();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// Drag and Drop
|
||||
// #pragma mark - Drag and Drop
|
||||
|
||||
void
|
||||
TBarView::CacheDragData(BMessage *incoming)
|
||||
@@ -920,7 +839,7 @@ TBarView::HandleBeMenu(BMessage *messagewithdestination)
|
||||
}
|
||||
|
||||
|
||||
// Add-on convenience functions
|
||||
// #pragma mark - Add-ons
|
||||
|
||||
// shelf is ignored for now,
|
||||
// it exists in anticipation of having other 'shelves' for
|
||||
|
||||
@@ -57,16 +57,11 @@ const float kHModeHeight = 21.0f;
|
||||
const float kMenuBarHeight = 21.0f;
|
||||
const float kStatusHeight = 22.0f;
|
||||
|
||||
#define SA_CLOCK 0
|
||||
|
||||
class BShelf;
|
||||
class TBarMenuBar;
|
||||
class TExpandoMenuBar;
|
||||
class TReplicantTray;
|
||||
class TDragRegion;
|
||||
#if SA_CLOCK
|
||||
class TTimeView;
|
||||
#endif
|
||||
class TTeamMenuItem;
|
||||
|
||||
|
||||
@@ -95,9 +90,6 @@ class TBarView : public BView {
|
||||
bool MilTime() const;
|
||||
void ShowClock(bool);
|
||||
bool ShowingClock() const;
|
||||
#if SA_CLOCK
|
||||
void ToggleClock();
|
||||
#endif
|
||||
|
||||
void CacheDragData(BMessage *incoming);
|
||||
status_t DragStart();
|
||||
@@ -144,9 +136,6 @@ class TBarView : public BView {
|
||||
|
||||
void PlaceBeMenu();
|
||||
void PlaceTray(bool vertSwap, bool leftSwap, BRect screenFrame);
|
||||
#if SA_CLOCK
|
||||
void PlaceClock();
|
||||
#endif
|
||||
void PlaceApplicationBar(BRect screenFrame);
|
||||
|
||||
TBarMenuBar *fBarMenuBar;
|
||||
@@ -158,9 +147,6 @@ class TBarView : public BView {
|
||||
|
||||
bool fShowInterval;
|
||||
bool fShowClock;
|
||||
#if SA_CLOCK
|
||||
TTimeView *fClock;
|
||||
#endif
|
||||
bool fVertical;
|
||||
bool fTop;
|
||||
bool fLeft;
|
||||
|
||||
@@ -86,9 +86,6 @@ TBarWindow::TBarWindow()
|
||||
AddChild(fBarView);
|
||||
|
||||
AddShortcut('F', B_COMMAND_KEY, new BMessage(kFindButton));
|
||||
#if SA_CLOCK
|
||||
AddShortcut('H', B_COMMAND_KEY, new BMessage('clok'));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -164,12 +161,6 @@ TBarWindow::MessageReceived(BMessage *message)
|
||||
break;
|
||||
}
|
||||
|
||||
#if SA_CLOCK
|
||||
case 'clok':
|
||||
fBarView->ToggleClock();
|
||||
break;
|
||||
#endif
|
||||
|
||||
case 'gloc':
|
||||
GetLocation(message);
|
||||
break;
|
||||
|
||||
+22
-22
@@ -88,8 +88,8 @@ using namespace BPrivate;
|
||||
|
||||
TBeMenu::TBeMenu(TBarView *barview)
|
||||
: BNavMenu("BeMenu", B_REFS_RECEIVED, BMessenger(kTrackerSignature)),
|
||||
fAddState(kStart),
|
||||
fBarView(barview)
|
||||
fAddState(kStart),
|
||||
fBarView(barview)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -128,10 +128,8 @@ TBeMenu::DetachedFromWindow()
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// don't call BNavMenu::DetachedFromWindow
|
||||
// it sets the TypesList to NULL
|
||||
//
|
||||
// don't call BNavMenu::DetachedFromWindow
|
||||
// it sets the TypesList to NULL
|
||||
BMenu::DetachedFromWindow();
|
||||
}
|
||||
|
||||
@@ -185,7 +183,7 @@ TBeMenu::AddNextItem()
|
||||
}
|
||||
if (count > 0) {
|
||||
AddSeparatorItem();
|
||||
|
||||
|
||||
for (int i = 0;i < recentTypes;i++) {
|
||||
if (!recentItem[i])
|
||||
continue;
|
||||
@@ -207,10 +205,10 @@ TBeMenu::AddNextItem()
|
||||
fAddState = kAddingBeMenu;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (fAddState == kAddingBeMenu) {
|
||||
// keep reentering and adding items
|
||||
// until this returns false
|
||||
// keep reentering and adding items
|
||||
// until this returns false
|
||||
bool done = BNavMenu::AddNextItem();
|
||||
BMenuItem *item = ItemAt(CountItems() - 1);
|
||||
if (item) {
|
||||
@@ -228,7 +226,7 @@ TBeMenu::AddNextItem()
|
||||
fAddState = kDone;
|
||||
return done;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -236,9 +234,10 @@ TBeMenu::AddNextItem()
|
||||
bool
|
||||
TBeMenu::AddStandardBeMenuItems()
|
||||
{
|
||||
bool dragging=false;
|
||||
bool dragging = false;
|
||||
if (fBarView)
|
||||
dragging = fBarView->Dragging();
|
||||
|
||||
#ifdef __HAIKU__
|
||||
BMenuItem* item = new BMenuItem("About Haiku", new BMessage(kShowSplash));
|
||||
#else
|
||||
@@ -246,7 +245,7 @@ TBeMenu::AddStandardBeMenuItems()
|
||||
#endif
|
||||
item->SetEnabled(!dragging);
|
||||
AddItem(item);
|
||||
|
||||
|
||||
#ifdef SHOW_RECENT_FIND_ITEMS
|
||||
item = new BMenuItem(TrackerBuildRecentFindItemsMenu("Find"B_UTF8_ELLIPSIS),
|
||||
new BMessage(kFindButton));
|
||||
@@ -278,21 +277,22 @@ TBeMenu::AddStandardBeMenuItems()
|
||||
item = new BMenuItem("Always on Top", new BMessage(msg_AlwaysTop));
|
||||
item->SetTarget(be_app);
|
||||
// set checkbox based on current state of Deskbar's main window feel
|
||||
item->SetMarked((be_app->WindowAt(1)->Feel() & B_FLOATING_ALL_WINDOW_FEEL) != 0);
|
||||
if (BWindow *window = static_cast<TBarApp *>(be_app)->BarWindow())
|
||||
item->SetMarked((window->Feel() & B_FLOATING_ALL_WINDOW_FEEL) != 0);
|
||||
subMenu->AddItem(item);
|
||||
|
||||
item = new BMenuItem("Sort Running Applications", new BMessage(msg_sortRunningApps));
|
||||
item->SetTarget(be_app);
|
||||
item->SetMarked( static_cast<TBarApp *>(be_app)->Settings()->sortRunningApps);
|
||||
item->SetMarked(static_cast<TBarApp *>(be_app)->Settings()->sortRunningApps);
|
||||
subMenu->AddItem(item);
|
||||
|
||||
item = new BMenuItem("Tracker Always First", new BMessage(msg_trackerFirst));
|
||||
item->SetTarget(be_app);
|
||||
item->SetMarked( static_cast<TBarApp *>(be_app)->Settings()->trackerAlwaysFirst);
|
||||
item->SetMarked(static_cast<TBarApp *>(be_app)->Settings()->trackerAlwaysFirst);
|
||||
subMenu->AddItem(item);
|
||||
|
||||
subMenu->AddSeparatorItem();
|
||||
|
||||
|
||||
TReplicantTray *replicantTray = ((TBarApp *)be_app)->BarView()->fReplicantTray;
|
||||
|
||||
item = new BMenuItem("24 Hour Clock", new BMessage(kMsgMilTime));
|
||||
@@ -323,17 +323,17 @@ TBeMenu::AddStandardBeMenuItems()
|
||||
|
||||
item = new BMenuItem("Show Application Expander", new BMessage(msg_superExpando));
|
||||
item->SetTarget(be_app);
|
||||
item->SetMarked( static_cast<TBarApp *>(be_app)->Settings()->superExpando);
|
||||
item->SetMarked(static_cast<TBarApp *>(be_app)->Settings()->superExpando);
|
||||
subMenu->AddItem(item);
|
||||
|
||||
item = new BMenuItem("Expand New Applications", new BMessage(msg_expandNewTeams));
|
||||
item->SetTarget(be_app);
|
||||
item->SetMarked( static_cast<TBarApp *>(be_app)->Settings()->expandNewTeams);
|
||||
item->SetMarked(static_cast<TBarApp *>(be_app)->Settings()->expandNewTeams);
|
||||
item->SetEnabled(static_cast<TBarApp *>(be_app)->Settings()->superExpando);
|
||||
subMenu->AddItem(item);
|
||||
|
||||
subMenu->SetFont(be_plain_font);
|
||||
AddItem(subMenu);
|
||||
|
||||
subMenu->SetFont(be_plain_font);
|
||||
AddItem(subMenu);
|
||||
|
||||
if ((modifiers() & (B_LEFT_SHIFT_KEY|B_LEFT_CONTROL_KEY|B_LEFT_COMMAND_KEY))
|
||||
== (B_LEFT_SHIFT_KEY|B_LEFT_CONTROL_KEY|B_LEFT_COMMAND_KEY)) {
|
||||
|
||||
@@ -156,12 +156,12 @@ CalendarMenuItem::GetContentSize(float *_width, float *_height)
|
||||
font.SetSize(kTitleFontSize);
|
||||
font_height fontHeight;
|
||||
font.GetHeight(&fontHeight);
|
||||
fTitleHeight = ceil(fontHeight.ascent + fontHeight.descent + fontHeight.leading);
|
||||
fTitleHeight = ceilf(fontHeight.ascent + fontHeight.descent + fontHeight.leading);
|
||||
|
||||
font = be_plain_font;
|
||||
font.GetHeight(&fontHeight);
|
||||
fRowHeight = ceil(fontHeight.ascent + fontHeight.descent + fontHeight.leading + kRowGap);
|
||||
fFontHeight = ceil(fontHeight.ascent);
|
||||
fRowHeight = ceilf(fontHeight.ascent + fontHeight.descent + fontHeight.leading + kRowGap);
|
||||
fFontHeight = ceilf(fontHeight.ascent);
|
||||
fColumnWidth = font.StringWidth("99") + kColumnGap;
|
||||
|
||||
fFirstWeekday = first_weekday_of_month(tm);
|
||||
|
||||
+180
-148
@@ -112,8 +112,8 @@ DumpList(BList *itemlist)
|
||||
#endif /* DB_ADDONS */
|
||||
|
||||
|
||||
// don't change the name of this view to anything other than
|
||||
// Status
|
||||
// don't change the name of this view to anything other than "Status"!
|
||||
|
||||
TReplicantTray::TReplicantTray(TBarView *parent, bool vertical)
|
||||
: BView(BRect(0, 0, 1, 1), "Status", B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||
B_WILL_DRAW | B_FRAME_EVENTS),
|
||||
@@ -136,16 +136,17 @@ void
|
||||
TReplicantTray::AttachedToWindow()
|
||||
{
|
||||
BView::AttachedToWindow();
|
||||
|
||||
|
||||
SetViewColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DARKEN_1_TINT));
|
||||
SetDrawingMode(B_OP_COPY);
|
||||
Window()->SetPulseRate(1000000);
|
||||
DealWithClock(fBarView->ShowingClock());
|
||||
DealWithClock(fBarView->ShowingClock());
|
||||
|
||||
#ifdef DB_ADDONS
|
||||
// load addons and rehydrate archives
|
||||
#ifdef DB_ADDONS
|
||||
// load addons and rehydrate archives
|
||||
#if !defined(__HAIKU__) && !defined(HAIKU_TARGET_PLATFORM_LIBBE_TEST)
|
||||
InitAddOnSupport();
|
||||
// TODO: fix me!
|
||||
InitAddOnSupport();
|
||||
#endif
|
||||
#endif
|
||||
ResizeToPreferred();
|
||||
@@ -156,9 +157,9 @@ void
|
||||
TReplicantTray::DetachedFromWindow()
|
||||
{
|
||||
#ifdef DB_ADDONS
|
||||
// clean up add-on support
|
||||
// clean up add-on support
|
||||
DeleteAddOnSupport();
|
||||
#endif
|
||||
#endif
|
||||
BView::DetachedFromWindow();
|
||||
}
|
||||
|
||||
@@ -261,43 +262,34 @@ TReplicantTray::GetPreferredSize(float *preferredWidth, float *preferredHeight)
|
||||
{
|
||||
float width = 0, height = kMinimumTrayHeight;
|
||||
|
||||
uint32 id;
|
||||
BView *view;
|
||||
fShelf->ReplicantAt(IconCount() - 1, &view, &id);
|
||||
if (fMultiRowMode) {
|
||||
if (view)
|
||||
height = view->Frame().bottom;
|
||||
|
||||
// the height will be uniform for the number of rows
|
||||
// necessary to show all the reps + any gutters
|
||||
// necessary for spacing
|
||||
if (fShelf->CountReplicants() > 0)
|
||||
height = fRightBottomReplicant.bottom;
|
||||
|
||||
// the height will be uniform for the number of rows
|
||||
// necessary to show all the reps + any gutters
|
||||
// necessary for spacing
|
||||
int32 rowCount = (int32)(height / kMaxReplicantHeight);
|
||||
height = kGutter + (rowCount * kMaxReplicantHeight)
|
||||
+ ((rowCount - 1) * kIconGap) + kGutter;
|
||||
// if new replicant budges into clock's area on clock row, add a row
|
||||
if (view && fBarView->ShowingClock()
|
||||
&& view->Frame().right >= fClock->Frame().left
|
||||
&& view->Frame().top == fClock->Frame().top)
|
||||
height += kMaxReplicantHeight;
|
||||
height = max (kMinimumTrayHeight, height);
|
||||
height = max(kMinimumTrayHeight, height);
|
||||
width = kMinimumTrayWidth;
|
||||
} else {
|
||||
// if last replicant overruns clock then
|
||||
// resize to accomodate
|
||||
if (view) {
|
||||
BRect viewFrame(view->Frame());
|
||||
if (fShelf->CountReplicants() > 0) {
|
||||
if (fBarView->ShowingClock()
|
||||
&& viewFrame.right + 6 >= fClock->Frame().left) {
|
||||
width = viewFrame.right + 6 + fClock->Frame().Width();
|
||||
&& fRightBottomReplicant.right + 6 >= fClock->Frame().left) {
|
||||
width = fRightBottomReplicant.right + 6 + fClock->Frame().Width();
|
||||
} else
|
||||
width = viewFrame.right + 3;
|
||||
width = fRightBottomReplicant.right + 3;
|
||||
}
|
||||
// this view has a fixed minimum width
|
||||
// this view has a fixed minimum width
|
||||
width = max(kMinimumTrayWidth, width);
|
||||
}
|
||||
|
||||
*preferredWidth = width;
|
||||
// add 2 for the border
|
||||
// add 2 for the border
|
||||
*preferredHeight = height + 1;
|
||||
}
|
||||
|
||||
@@ -305,10 +297,10 @@ TReplicantTray::GetPreferredSize(float *preferredWidth, float *preferredHeight)
|
||||
void
|
||||
TReplicantTray::AdjustPlacement()
|
||||
{
|
||||
// called when an add-on has been added or removed
|
||||
// need to resize the parent of this accordingly
|
||||
// called when an add-on has been added or removed
|
||||
// need to resize the parent of this accordingly
|
||||
//
|
||||
// call to Parent will call ResizeToPreferred
|
||||
// call to Parent will call ResizeToPreferred
|
||||
BRect bounds = Bounds();
|
||||
float width, height;
|
||||
GetPreferredSize(&width, &height);
|
||||
@@ -429,14 +421,14 @@ TReplicantTray::MouseDown(BPoint where)
|
||||
|
||||
do {
|
||||
if (fabs(where.x - save.x) > 4 || fabs(where.y - save.y) > 4)
|
||||
// user moved out of bounds of click area
|
||||
// user moved out of bounds of click area
|
||||
break;
|
||||
|
||||
|
||||
if ((system_time() - start) > (2 * doubleClickSpeed)) {
|
||||
ShowReplicantMenu(where);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
snooze(50000);
|
||||
GetMouse(&where, &buttons);
|
||||
} while (buttons);
|
||||
@@ -479,8 +471,8 @@ TReplicantTray::InitAddOnSupport()
|
||||
file.Write(&fDeskbarSecurityCode, sizeof(fDeskbarSecurityCode));
|
||||
}
|
||||
}
|
||||
|
||||
// for each volume currently mounted
|
||||
|
||||
// for each volume currently mounted
|
||||
// index the volume with our indices
|
||||
BVolumeRoster roster;
|
||||
BVolume volume;
|
||||
@@ -489,7 +481,7 @@ TReplicantTray::InitAddOnSupport()
|
||||
RunAddOnQuery(&volume, kEnabledPredicate);
|
||||
}
|
||||
|
||||
// we also watch for volumes mounted and unmounted
|
||||
// we also watch for volumes mounted and unmounted
|
||||
watch_node(NULL, B_WATCH_MOUNT | B_WATCH_ATTR, this, Window());
|
||||
}
|
||||
|
||||
@@ -508,7 +500,7 @@ TReplicantTray::DeleteAddOnSupport()
|
||||
}
|
||||
delete fItemList;
|
||||
|
||||
// stop the volume mount/unmount watch
|
||||
// stop the volume mount/unmount watch
|
||||
stop_watching(this, Window());
|
||||
}
|
||||
|
||||
@@ -533,11 +525,12 @@ TReplicantTray::RunAddOnQuery(BVolume *volume, const char *predicate)
|
||||
|
||||
int32 id;
|
||||
BEntry entry;
|
||||
while (query.GetNextEntry(&entry) == B_OK)
|
||||
// scan any entries returned
|
||||
// attempt to load them as add-ons
|
||||
// collisions are handled in LoadAddOn
|
||||
while (query.GetNextEntry(&entry) == B_OK) {
|
||||
// scan any entries returned
|
||||
// attempt to load them as add-ons
|
||||
// collisions are handled in LoadAddOn
|
||||
LoadAddOn(&entry, &id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -605,19 +598,19 @@ TReplicantTray::HandleEntryUpdate(BMessage *message)
|
||||
BPath path;
|
||||
switch (opcode) {
|
||||
case B_ENTRY_CREATED:
|
||||
// entry was just listed, matches live query
|
||||
// entry was just listed, matches live query
|
||||
{
|
||||
const char *name;
|
||||
ino_t directory;
|
||||
dev_t device;
|
||||
// received when an app adds a ref to the
|
||||
// Deskbar add-ons folder
|
||||
// received when an app adds a ref to the
|
||||
// Deskbar add-ons folder
|
||||
if (message->FindString("name", &name) == B_OK
|
||||
&& message->FindInt64("directory", &directory) == B_OK
|
||||
&& message->FindInt32("device", &device) == B_OK) {
|
||||
entry_ref ref(device, directory, name);
|
||||
// see if this item has the attribute
|
||||
// that we expect
|
||||
// see if this item has the attribute
|
||||
// that we expect
|
||||
if (IsAddOn(ref)) {
|
||||
int32 id;
|
||||
BEntry entry(&ref);
|
||||
@@ -628,8 +621,8 @@ TReplicantTray::HandleEntryUpdate(BMessage *message)
|
||||
break;
|
||||
|
||||
case B_ATTR_CHANGED:
|
||||
// from node watch on individual items
|
||||
// (node_watch added in LoadAddOn)
|
||||
// from node watch on individual items
|
||||
// (node_watch added in LoadAddOn)
|
||||
{
|
||||
node_ref nodeRef;
|
||||
if (message->FindInt32("device", &(nodeRef.device)) == B_OK
|
||||
@@ -675,8 +668,8 @@ TReplicantTray::HandleEntryUpdate(BMessage *message)
|
||||
break;
|
||||
|
||||
ref.set_name(name);
|
||||
// change the directory reference to
|
||||
// the new directory
|
||||
// change the directory reference to
|
||||
// the new directory
|
||||
MoveItem(&ref, todirectory);
|
||||
}
|
||||
}
|
||||
@@ -684,7 +677,7 @@ TReplicantTray::HandleEntryUpdate(BMessage *message)
|
||||
|
||||
case B_ENTRY_REMOVED:
|
||||
{
|
||||
// entry was rm'd from the device
|
||||
// entry was rm'd from the device
|
||||
node_ref nodeRef;
|
||||
if (message->FindInt32("device", &(nodeRef.device)) == B_OK
|
||||
&& message->FindInt64("node", &(nodeRef.node)) == B_OK) {
|
||||
@@ -704,7 +697,7 @@ TReplicantTray::HandleEntryUpdate(BMessage *message)
|
||||
|
||||
case B_DEVICE_MOUNTED:
|
||||
{
|
||||
// run a new query on the new device
|
||||
// run a new query on the new device
|
||||
dev_t device;
|
||||
if (message->FindInt32("new device", &device) != B_OK)
|
||||
break;
|
||||
@@ -714,10 +707,10 @@ TReplicantTray::HandleEntryUpdate(BMessage *message)
|
||||
break;
|
||||
case B_DEVICE_UNMOUNTED:
|
||||
{
|
||||
// remove all items associated with the device
|
||||
// unmounted
|
||||
// contrary to what the BeBook says, the item is called "device",
|
||||
// not "new device" like it is for B_DEVICE_MOUNTED
|
||||
// remove all items associated with the device
|
||||
// unmounted
|
||||
// contrary to what the BeBook says, the item is called "device",
|
||||
// not "new device" like it is for B_DEVICE_MOUNTED
|
||||
dev_t device;
|
||||
if (message->FindInt32("device", &device) != B_OK)
|
||||
break;
|
||||
@@ -729,9 +722,10 @@ TReplicantTray::HandleEntryUpdate(BMessage *message)
|
||||
}
|
||||
|
||||
|
||||
// the add-ons must support the exported C function API
|
||||
// if they do, they will be loaded and added to deskbar
|
||||
// primary function is the Instantiate function
|
||||
/** The add-ons must support the exported C function API
|
||||
* if they do, they will be loaded and added to deskbar
|
||||
* primary function is the Instantiate function
|
||||
*/
|
||||
|
||||
status_t
|
||||
TReplicantTray::LoadAddOn(BEntry *entry, int32 *id, bool force)
|
||||
@@ -741,7 +735,7 @@ TReplicantTray::LoadAddOn(BEntry *entry, int32 *id, bool force)
|
||||
|
||||
node_ref nodeRef;
|
||||
entry->GetNodeRef(&nodeRef);
|
||||
// no duplicates
|
||||
// no duplicates
|
||||
if (NodeExists(nodeRef))
|
||||
return B_ERROR;
|
||||
|
||||
@@ -763,12 +757,12 @@ TReplicantTray::LoadAddOn(BEntry *entry, int32 *id, bool force)
|
||||
BPath path;
|
||||
entry->GetPath(&path);
|
||||
|
||||
// load the add-on
|
||||
// load the add-on
|
||||
image_id image = load_add_on(path.Path());
|
||||
if (image < 0)
|
||||
return (status_t)image;
|
||||
|
||||
// get the view loading function symbol
|
||||
// get the view loading function symbol
|
||||
// we first look for a symbol that takes an image_id
|
||||
// and entry_ref pointer, if not found, go with normal
|
||||
// instantiate function
|
||||
@@ -895,9 +889,9 @@ TReplicantTray::MoveItem(entry_ref *ref, ino_t toDirectory)
|
||||
if (!ref)
|
||||
return;
|
||||
|
||||
// scan for a matching entry_ref and update it
|
||||
// scan for a matching entry_ref and update it
|
||||
//
|
||||
// don't need to change node info as it does not change
|
||||
// don't need to change node info as it does not change
|
||||
|
||||
for (int32 i = fItemList->CountItems(); i-- > 0 ;) {
|
||||
DeskbarItemInfo *item = (DeskbarItemInfo *)fItemList->ItemAt(i);
|
||||
@@ -945,8 +939,10 @@ TReplicantTray::ItemInfo(int32 id, const char **name)
|
||||
}
|
||||
|
||||
|
||||
// for a specific name
|
||||
// return the id (internal to Deskbar)
|
||||
/** for a specific name
|
||||
* return the id (internal to Deskbar)
|
||||
*/
|
||||
|
||||
status_t
|
||||
TReplicantTray::ItemInfo(const char *name, int32 *id)
|
||||
{
|
||||
@@ -962,8 +958,10 @@ TReplicantTray::ItemInfo(const char *name, int32 *id)
|
||||
}
|
||||
|
||||
|
||||
// at a specific index
|
||||
// return both the name and the id of the replicant
|
||||
/** at a specific index
|
||||
* return both the name and the id of the replicant
|
||||
*/
|
||||
|
||||
status_t
|
||||
TReplicantTray::ItemInfo(int32 index, const char **name, int32 *id)
|
||||
{
|
||||
@@ -981,7 +979,8 @@ TReplicantTray::ItemInfo(int32 index, const char **name, int32 *id)
|
||||
}
|
||||
|
||||
|
||||
// replicant exists, by id/index
|
||||
/** replicant exists, by id/index */
|
||||
|
||||
bool
|
||||
TReplicantTray::IconExists(int32 target, bool byIndex)
|
||||
{
|
||||
@@ -992,7 +991,8 @@ TReplicantTray::IconExists(int32 target, bool byIndex)
|
||||
}
|
||||
|
||||
|
||||
// replicant exists, by name
|
||||
/** replicant exists, by name */
|
||||
|
||||
bool
|
||||
TReplicantTray::IconExists(const char *name)
|
||||
{
|
||||
@@ -1013,9 +1013,11 @@ TReplicantTray::IconCount() const
|
||||
}
|
||||
|
||||
|
||||
// message must contain an archivable view
|
||||
// in the Archives folder for later rehydration
|
||||
// returns the current boot id
|
||||
/** message must contain an archivable view
|
||||
* in the Archives folder for later rehydration
|
||||
* returns the current boot id
|
||||
*/
|
||||
|
||||
status_t
|
||||
TReplicantTray::AddIcon(BMessage *icon, int32 *id, const entry_ref *addOn)
|
||||
{
|
||||
@@ -1026,27 +1028,28 @@ TReplicantTray::AddIcon(BMessage *icon, int32 *id, const entry_ref *addOn)
|
||||
if (icon->what == B_ARCHIVED_OBJECT)
|
||||
icon->what = 0;
|
||||
|
||||
// !! check for name collisions?
|
||||
// !! check for name collisions?
|
||||
status_t err = fShelf->AddReplicant(icon, BPoint(1, 1));
|
||||
if (err != B_OK)
|
||||
return err;
|
||||
|
||||
|
||||
float oldWidth = Bounds().Width();
|
||||
float oldHeight = Bounds().Height();
|
||||
float width, height;
|
||||
GetPreferredSize(&width, &height);
|
||||
if (oldWidth != width || oldHeight != height)
|
||||
AdjustPlacement();
|
||||
|
||||
|
||||
int32 count = fShelf->CountReplicants();
|
||||
BView *view;
|
||||
fShelf->ReplicantAt(count-1, &view, (uint32 *)id, NULL);
|
||||
|
||||
// add the item to the add-on list
|
||||
// add the item to the add-on list
|
||||
entry_ref ref;
|
||||
if (addOn) // Use it if we got it
|
||||
if (addOn) {
|
||||
// Use it if we got it
|
||||
ref = *addOn;
|
||||
else {
|
||||
} else {
|
||||
const char *appsig;
|
||||
icon->FindString("add_on", &appsig);
|
||||
BRoster roster;
|
||||
@@ -1076,11 +1079,11 @@ TReplicantTray::RemoveIcon(int32 target, bool byIndex)
|
||||
int32 index, id;
|
||||
BView *view = ViewAt(&index, &id, target, byIndex);
|
||||
if (view && index >= 0) {
|
||||
// remove the reference from the item list
|
||||
// remove the reference from the item list & the shelf
|
||||
RemoveItem(id);
|
||||
// remove the replicant from the shelf
|
||||
fShelf->DeleteReplicant(index);
|
||||
// force a placement update, !! need to fix BShelf
|
||||
|
||||
// force a placement update, !! need to fix BShelf
|
||||
RealReplicantAdjustment(index);
|
||||
}
|
||||
}
|
||||
@@ -1095,38 +1098,44 @@ TReplicantTray::RemoveIcon(const char *name)
|
||||
int32 id, index;
|
||||
BView *view = ViewAt(&index, &id, name);
|
||||
if (view && index >= 0) {
|
||||
// remove the reference from the item list
|
||||
// remove the reference from the item list & shelf
|
||||
RemoveItem(id);
|
||||
// remove the replicant from the shelf
|
||||
fShelf->DeleteReplicant(index);
|
||||
// force a placement update, !! need to fix BShelf
|
||||
|
||||
// force a placement update, !! need to fix BShelf
|
||||
RealReplicantAdjustment(index);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TReplicantTray::RealReplicantAdjustment(int32 startindex)
|
||||
TReplicantTray::RealReplicantAdjustment(int32 startIndex)
|
||||
{
|
||||
if (startindex < 0)
|
||||
if (startIndex < 0)
|
||||
return;
|
||||
// reset the locations of all replicants after the one deleted
|
||||
RealignReplicants(startindex);
|
||||
|
||||
if (startIndex == fLastReplicant)
|
||||
startIndex = 0;
|
||||
|
||||
// reset the locations of all replicants after the one deleted
|
||||
RealignReplicants(startIndex);
|
||||
|
||||
float oldWidth = Bounds().Width();
|
||||
float oldHeight = Bounds().Height();
|
||||
float width, height;
|
||||
GetPreferredSize(&width, &height);
|
||||
if (oldWidth != width || oldHeight != height) {
|
||||
// resize view to accomodate the replicants
|
||||
// redraw as necessary
|
||||
// resize view to accomodate the replicants
|
||||
// redraw as necessary
|
||||
AdjustPlacement();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// looking for a replicant by id/index
|
||||
// return the view and index
|
||||
/** looking for a replicant by id/index
|
||||
* return the view and index
|
||||
*/
|
||||
|
||||
BView *
|
||||
TReplicantTray::ViewAt(int32 *index, int32 *id, int32 target, bool byIndex)
|
||||
{
|
||||
@@ -1157,8 +1166,10 @@ TReplicantTray::ViewAt(int32 *index, int32 *id, int32 target, bool byIndex)
|
||||
}
|
||||
|
||||
|
||||
// looking for a replicant with a view by name
|
||||
// return the view, index and the id of the replicant
|
||||
/** looking for a replicant with a view by name
|
||||
* return the view, index and the id of the replicant
|
||||
*/
|
||||
|
||||
BView *
|
||||
TReplicantTray::ViewAt(int32 *index, int32 *id, const char *name)
|
||||
{
|
||||
@@ -1179,14 +1190,16 @@ TReplicantTray::ViewAt(int32 *index, int32 *id, const char *name)
|
||||
}
|
||||
|
||||
|
||||
// Shelf will call to determine where and if
|
||||
// the replicant is to be added
|
||||
/** Shelf will call to determine where and if
|
||||
* the replicant is to be added
|
||||
*/
|
||||
|
||||
bool
|
||||
TReplicantTray::AcceptAddon(BRect replicantFrame, BMessage *message)
|
||||
{
|
||||
if (!message)
|
||||
return false;
|
||||
|
||||
|
||||
if (replicantFrame.Height() > kMaxReplicantHeight)
|
||||
return false;
|
||||
|
||||
@@ -1203,12 +1216,11 @@ TReplicantTray::AcceptAddon(BRect replicantFrame, BMessage *message)
|
||||
message->FindInt32("deskbar:private_align", (int32 *)&align);
|
||||
else
|
||||
align = B_ALIGN_LEFT;
|
||||
|
||||
int32 count = fShelf->CountReplicants();
|
||||
BPoint loc = LocForReplicant(count+1, count, replicantFrame.Width());
|
||||
|
||||
message->AddPoint("_pjp_loc", loc);
|
||||
|
||||
BPoint loc = LocationForReplicant(fShelf->CountReplicants(),
|
||||
replicantFrame.Width());
|
||||
|
||||
message->AddPoint("_pjp_loc", loc);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1219,35 +1231,52 @@ TReplicantTray::AcceptAddon(BRect replicantFrame, BMessage *message)
|
||||
*/
|
||||
|
||||
BPoint
|
||||
TReplicantTray::LocForReplicant(int32, int32 index, float width)
|
||||
TReplicantTray::LocationForReplicant(int32 index, float width)
|
||||
{
|
||||
BPoint loc(kIconGap + 1, kGutter + 1);
|
||||
|
||||
if (index > 0) {
|
||||
// get the last replicant added for placement reference
|
||||
BView *view = NULL;
|
||||
fShelf->ReplicantAt((index-1), &view);
|
||||
if (view) {
|
||||
// push this rep placement past the last one
|
||||
loc.x = view->Frame().right + kIconGap+1;
|
||||
loc.y = view->Frame().top;
|
||||
if (fMultiRowMode) {
|
||||
// try to find free space in every row
|
||||
for (int32 row = 0; ; loc.y += kMaxReplicantHeight + kIconGap, row++) {
|
||||
// determine free space in this row
|
||||
BRect rect(loc.x, loc.y, loc.x + kMinimumTrayWidth + 2, kMaxReplicantHeight);
|
||||
if (row == 0 && fBarView->ShowingClock())
|
||||
rect.right -= fClock->Frame().Width() + kIconGap;
|
||||
|
||||
for (int32 i = 0; i < index; i++) {
|
||||
BView *view = NULL;
|
||||
fShelf->ReplicantAt(i, &view);
|
||||
if (view == NULL || view->Frame().top != rect.top)
|
||||
continue;
|
||||
|
||||
rect.left = view->Frame().right + kIconGap + 1;
|
||||
}
|
||||
|
||||
if (rect.Width() >= width) {
|
||||
// the icon fits in this row
|
||||
loc = rect.LeftTop();
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (index > 0) {
|
||||
// get the last replicant added for placement reference
|
||||
BView *view = NULL;
|
||||
fShelf->ReplicantAt(index - 1, &view);
|
||||
if (view) {
|
||||
// push this rep placement past the last one
|
||||
loc.x = view->Frame().right + kIconGap + 1;
|
||||
loc.y = view->Frame().top;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (fMultiRowMode) {
|
||||
// if on first row, don't cover the clock
|
||||
// if on any other row, don't go past right edge
|
||||
if ((loc.x + width + 2 >= kMinimumTrayWidth)
|
||||
|| (fBarView->ShowingClock()
|
||||
&& (loc.x + width + 6 >= kMinimumTrayWidth - fClock->Frame().Width())
|
||||
&& (loc.y == kGutter + 1))) {
|
||||
// make the vertical placement uniform
|
||||
// based on the maximum height provided for each
|
||||
// replicant
|
||||
loc.y += kMaxReplicantHeight + kIconGap;
|
||||
loc.x = kIconGap + 1;
|
||||
}
|
||||
if ((loc.y == fRightBottomReplicant.top && loc.x > fRightBottomReplicant.left)
|
||||
|| loc.y > fRightBottomReplicant.top) {
|
||||
fRightBottomReplicant.Set(loc.x, loc.y, loc.x + width, loc.y + kMaxReplicantHeight);
|
||||
fLastReplicant = index;
|
||||
}
|
||||
|
||||
return loc;
|
||||
}
|
||||
|
||||
@@ -1269,18 +1298,18 @@ TReplicantTray::IconFrame(const char *name)
|
||||
{
|
||||
if (!name)
|
||||
return BRect(0, 0, 0, 0);
|
||||
|
||||
|
||||
int32 id, index;
|
||||
BView *view = ViewAt(&index, &id, name);
|
||||
if (view)
|
||||
return view->Frame();
|
||||
|
||||
|
||||
return BRect(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
/** scan from the startIndex and reset the location
|
||||
* as defined in LocForReplicant
|
||||
/** Scan from the startIndex and reset the location
|
||||
* as defined in LocationForReplicant()
|
||||
*/
|
||||
|
||||
void
|
||||
@@ -1288,15 +1317,18 @@ TReplicantTray::RealignReplicants(int32 startIndex)
|
||||
{
|
||||
if (startIndex < 0)
|
||||
startIndex = 0;
|
||||
|
||||
|
||||
int32 count = fShelf->CountReplicants();
|
||||
if (count <= 0)
|
||||
return;
|
||||
|
||||
if (startIndex == 0)
|
||||
fRightBottomReplicant.Set(0, 0, 0, 0);
|
||||
|
||||
BView *view = NULL;
|
||||
for (int32 i = startIndex ; i < count ; i++){
|
||||
fShelf->ReplicantAt(i, &view);
|
||||
BPoint loc = LocForReplicant(count, i, view->Frame().Width());
|
||||
BPoint loc = LocationForReplicant(i, view->Frame().Width());
|
||||
if (view && (view->Frame().LeftTop() != loc)) {
|
||||
view->MoveTo(loc);
|
||||
}
|
||||
@@ -1319,8 +1351,10 @@ TReplicantTray::SetMultiRow(bool state)
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
// draggable region that is asynchronous so that
|
||||
// dragging does not block other activities
|
||||
/** draggable region that is asynchronous so that
|
||||
* dragging does not block other activities
|
||||
*/
|
||||
|
||||
TDragRegion::TDragRegion(TBarView *parent, BView *child)
|
||||
: BControl(BRect(0, 0, 0, 0), "", "", NULL, B_FOLLOW_NONE,
|
||||
B_WILL_DRAW | B_FRAME_EVENTS),
|
||||
@@ -1475,12 +1509,13 @@ TDragRegion::MouseDown(BPoint thePoint)
|
||||
ulong buttons;
|
||||
BPoint where;
|
||||
BRect dragRegion(DragRegion());
|
||||
|
||||
dragRegion.InsetBy(-2.0f, -2.0f); // DragRegion() is designed for drawing, not clicking
|
||||
|
||||
|
||||
dragRegion.InsetBy(-2.0f, -2.0f);
|
||||
// DragRegion() is designed for drawing, not clicking
|
||||
|
||||
if (!dragRegion.Contains(thePoint))
|
||||
return;
|
||||
|
||||
|
||||
while(true) {
|
||||
GetMouse(&where, &buttons);
|
||||
if (!buttons)
|
||||
@@ -1525,9 +1560,8 @@ TDragRegion::SwitchModeForRect(BPoint mouse, BRect rect,
|
||||
&& newState == fBarView->State())
|
||||
// already in the correct mode
|
||||
return true;
|
||||
|
||||
|
||||
fBarView->ChangeState(newState, newVertical, newLeft, newTop);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1549,7 +1583,7 @@ TDragRegion::MouseMoved(BPoint where, uint32 code, const BMessage *message)
|
||||
BRect topLeft(frame.left, frame.top, frame.left + hDivider, miniDivider);
|
||||
BRect topMiddle(frame.left + hDivider, frame.top, frame.right - hDivider, vDivider);
|
||||
BRect topRight(frame.right - hDivider, frame.top, frame.right, miniDivider);
|
||||
|
||||
|
||||
#ifdef FULL_MODE
|
||||
vDivider = miniDivider + thirdScreen;
|
||||
#endif
|
||||
@@ -1559,7 +1593,7 @@ TDragRegion::MouseMoved(BPoint where, uint32 code, const BMessage *message)
|
||||
#ifdef FULL_MODE
|
||||
BRect leftSide(frame.left, vDivider, frame.left + hDivider, frame.bottom - thirdScreen);
|
||||
BRect rightSide(frame.right - hDivider, vDivider, frame.right, frame.bottom - thirdScreen);
|
||||
|
||||
|
||||
vDivider = frame.bottom - thirdScreen;
|
||||
#endif
|
||||
BRect bottomLeft(frame.left, vDivider, frame.left + hDivider, frame.bottom);
|
||||
@@ -1584,11 +1618,9 @@ TDragRegion::MouseMoved(BPoint where, uint32 code, const BMessage *message)
|
||||
#endif
|
||||
|| SwitchModeForRect(where, bottomLeft, true, true, false, kMiniState)
|
||||
|| SwitchModeForRect(where, bottomMiddle, false, true, false, kExpandoState)
|
||||
|| SwitchModeForRect(where, bottomRight, true, false, false, kMiniState)
|
||||
)
|
||||
|| SwitchModeForRect(where, bottomRight, true, false, false, kMiniState))
|
||||
;
|
||||
}
|
||||
|
||||
} else
|
||||
BControl::MouseMoved(where, code, message);
|
||||
}
|
||||
|
||||
@@ -149,17 +149,19 @@ private:
|
||||
void MoveItem(entry_ref *, ino_t toDirectory);
|
||||
#endif
|
||||
|
||||
BPoint LocForReplicant(int32 replicantCount, int32 index, float width);
|
||||
BPoint LocationForReplicant(int32 index, float width);
|
||||
BShelf *Shelf() const;
|
||||
|
||||
|
||||
friend class TReplicantShelf;
|
||||
|
||||
TTimeView *fClock;
|
||||
TBarView *fBarView;
|
||||
TReplicantShelf *fShelf;
|
||||
|
||||
BRect fRightBottomReplicant;
|
||||
int32 fLastReplicant;
|
||||
|
||||
bool fMultiRowMode;
|
||||
|
||||
|
||||
bool fAlignmentSupport;
|
||||
#ifdef DB_ADDONS
|
||||
BList *fItemList;
|
||||
|
||||
+423
-368
File diff suppressed because it is too large
Load Diff
+177
-164
@@ -31,8 +31,6 @@ of Be Incorporated in the United States and other countries. Other brand product
|
||||
names are registered trademarks or trademarks of their respective holders.
|
||||
All rights reserved.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SWITCHER_H
|
||||
#define SWITCHER_H
|
||||
|
||||
@@ -42,35 +40,35 @@ All rights reserved.
|
||||
#include <StringView.h>
|
||||
#include <Window.h>
|
||||
|
||||
|
||||
class TTeamGroup {
|
||||
public:
|
||||
TTeamGroup();
|
||||
TTeamGroup(BList *teams, uint32 flags, char *name, const char *sig);
|
||||
virtual ~TTeamGroup();
|
||||
public:
|
||||
TTeamGroup();
|
||||
TTeamGroup(BList *teams, uint32 flags, char *name, const char *sig);
|
||||
virtual ~TTeamGroup();
|
||||
|
||||
void Draw(BView *, BRect bounds, bool main);
|
||||
void Draw(BView *, BRect bounds, bool main);
|
||||
|
||||
BList *TeamList() const
|
||||
{ return fTeams; }
|
||||
const char *Name() const
|
||||
{ return fName; }
|
||||
const char *Sig() const
|
||||
{ return fSig; }
|
||||
uint32 Flags() const
|
||||
{ return fFlags; }
|
||||
const BBitmap *SmallIcon() const
|
||||
{ return fSmallIcon; }
|
||||
const BBitmap *LargeIcon() const
|
||||
{ return fLargeIcon; }
|
||||
BList *TeamList() const
|
||||
{ return fTeams; }
|
||||
const char *Name() const
|
||||
{ return fName; }
|
||||
const char *Signature() const
|
||||
{ return fSignature; }
|
||||
uint32 Flags() const
|
||||
{ return fFlags; }
|
||||
const BBitmap *SmallIcon() const
|
||||
{ return fSmallIcon; }
|
||||
const BBitmap *LargeIcon() const
|
||||
{ return fLargeIcon; }
|
||||
|
||||
|
||||
private:
|
||||
BList *fTeams;
|
||||
uint32 fFlags;
|
||||
char fSig[B_MIME_TYPE_LENGTH];
|
||||
char *fName;
|
||||
BBitmap *fSmallIcon;
|
||||
BBitmap *fLargeIcon;
|
||||
private:
|
||||
BList *fTeams;
|
||||
uint32 fFlags;
|
||||
char fSignature[B_MIME_TYPE_LENGTH];
|
||||
char *fName;
|
||||
BBitmap *fSmallIcon;
|
||||
BBitmap *fLargeIcon;
|
||||
};
|
||||
|
||||
class TIconView;
|
||||
@@ -79,175 +77,190 @@ class TWindowView;
|
||||
class TSwitcherWindow;
|
||||
struct window_info;
|
||||
|
||||
class TSwitchMgr : public BHandler {
|
||||
public:
|
||||
TSwitchMgr(BPoint where);
|
||||
virtual ~TSwitchMgr();
|
||||
class TSwitchManager : public BHandler {
|
||||
public:
|
||||
TSwitchManager(BPoint where);
|
||||
virtual ~TSwitchManager();
|
||||
|
||||
virtual void MessageReceived(BMessage *);
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
|
||||
void Stop(bool doAction, uint32 mods);
|
||||
void Unblock();
|
||||
int32 CurIndex();
|
||||
int32 CurWindow();
|
||||
int32 CurSlot();
|
||||
BList *GroupList();
|
||||
int32 CountVisibleGroups();
|
||||
void CycleApp(bool forward, bool activate = false);
|
||||
void CycleWindow(bool forward, bool wrap = true);
|
||||
void SwitchToApp(int32 prevIndex, int32 newIndex, bool forward);
|
||||
void Touch(bool zero = false);
|
||||
bigtime_t IdleTime();
|
||||
void Stop(bool doAction, uint32 mods);
|
||||
void Unblock();
|
||||
int32 CurrentIndex();
|
||||
int32 CurrentWindow();
|
||||
int32 CurrentSlot();
|
||||
BList *GroupList();
|
||||
int32 CountVisibleGroups();
|
||||
|
||||
window_info *WindowInfo(int32 groupIndex, int32 wdIndex);
|
||||
int32 CountWindows(int32 groupIndex, bool inCurrentWorkspace = false);
|
||||
TTeamGroup *FindTeam(team_id, int32 *index);
|
||||
|
||||
private:
|
||||
void MainEntry(BMessage *);
|
||||
void Process(bool forward, bool byWindow = false);
|
||||
void QuickSwitch(BMessage *);
|
||||
void SwitchWindow(team_id , bool forward, bool activate);
|
||||
bool ActivateApp(bool forceShow, bool allowWorkspaceSwitch);
|
||||
void ActivateWindow(int32 windowID = -1);
|
||||
void QuitApp();
|
||||
void CycleApp(bool forward, bool activate = false);
|
||||
void CycleWindow(bool forward, bool wrap = true);
|
||||
void SwitchToApp(int32 prevIndex, int32 newIndex, bool forward);
|
||||
|
||||
TSwitcherWindow *fWindow;
|
||||
sem_id fMainMonitor;
|
||||
bool fBlock;
|
||||
bigtime_t fSkipUntil;
|
||||
BList fGroupList;
|
||||
int32 fCurIndex;
|
||||
int32 fCurWindow;
|
||||
int32 fCurSlot;
|
||||
int32 fWindowID;
|
||||
bigtime_t fLastActivity;
|
||||
void Touch(bool zero = false);
|
||||
bigtime_t IdleTime();
|
||||
|
||||
window_info *WindowInfo(int32 groupIndex, int32 wdIndex);
|
||||
int32 CountWindows(int32 groupIndex, bool inCurrentWorkspace = false);
|
||||
TTeamGroup *FindTeam(team_id, int32 *index);
|
||||
|
||||
private:
|
||||
void MainEntry(BMessage *message);
|
||||
void Process(bool forward, bool byWindow = false);
|
||||
void QuickSwitch(BMessage *message);
|
||||
void SwitchWindow(team_id team, bool forward, bool activate);
|
||||
bool ActivateApp(bool forceShow, bool allowWorkspaceSwitch);
|
||||
void ActivateWindow(int32 windowID = -1);
|
||||
|
||||
TSwitcherWindow *fWindow;
|
||||
sem_id fMainMonitor;
|
||||
bool fBlock;
|
||||
bigtime_t fSkipUntil;
|
||||
BList fGroupList;
|
||||
int32 fCurrentIndex;
|
||||
int32 fCurrentWindow;
|
||||
int32 fCurrentSlot;
|
||||
int32 fWindowID;
|
||||
bigtime_t fLastActivity;
|
||||
};
|
||||
|
||||
class TSwitcherWindow : public BWindow {
|
||||
public:
|
||||
TSwitcherWindow(BRect frame, TSwitchMgr *mgr);
|
||||
virtual ~TSwitcherWindow();
|
||||
public:
|
||||
TSwitcherWindow(BRect frame, TSwitchManager *mgr);
|
||||
virtual ~TSwitcherWindow();
|
||||
|
||||
virtual bool QuitRequested();
|
||||
virtual void DispatchMessage(BMessage *, BHandler *);
|
||||
virtual void MessageReceived(BMessage *);
|
||||
virtual void Show();
|
||||
virtual void Hide();
|
||||
virtual void WindowActivated(bool state);
|
||||
virtual bool QuitRequested();
|
||||
virtual void DispatchMessage(BMessage *message, BHandler *target);
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
virtual void Show();
|
||||
virtual void Hide();
|
||||
virtual void WindowActivated(bool state);
|
||||
|
||||
void DoKey(uint32 key, uint32 mods);
|
||||
TIconView *IconView();
|
||||
TWindowView *WindowView();
|
||||
TBox *TopView();
|
||||
bool HairTrigger();
|
||||
void Update(int32 prev, int32 cur, int32 prevSlot, int32 curSlot, bool forward);
|
||||
int32 SlotOf(int32);
|
||||
void Redraw(int32 index);
|
||||
void DoKey(uint32 key, uint32 mods);
|
||||
TIconView *IconView();
|
||||
TWindowView *WindowView();
|
||||
TBox *TopView();
|
||||
bool HairTrigger();
|
||||
void Update(int32 previous, int32 current, int32 prevSlot,
|
||||
int32 currentSlot, bool forward);
|
||||
int32 SlotOf(int32);
|
||||
void Redraw(int32 index);
|
||||
|
||||
private:
|
||||
|
||||
TSwitchMgr *fMgr;
|
||||
TIconView *fIconView;
|
||||
TBox *fTopView;
|
||||
TWindowView *fWindowView;
|
||||
bool fHairTrigger;
|
||||
private:
|
||||
TSwitchManager *fManager;
|
||||
TIconView *fIconView;
|
||||
TBox *fTopView;
|
||||
TWindowView *fWindowView;
|
||||
bool fHairTrigger;
|
||||
};
|
||||
|
||||
class TWindowView : public BView {
|
||||
public:
|
||||
TWindowView(BRect, TSwitchMgr *, TSwitcherWindow *);
|
||||
public:
|
||||
TWindowView(BRect frame, TSwitchManager *manager, TSwitcherWindow *switcher);
|
||||
|
||||
void UpdateGroup(int32 groupIndex, int32 windowIndex);
|
||||
void UpdateGroup(int32 groupIndex, int32 windowIndex);
|
||||
|
||||
virtual void Draw(BRect update);
|
||||
virtual void Pulse();
|
||||
virtual void GetPreferredSize(float *w, float *h);
|
||||
void ScrollTo(float x, float y)
|
||||
{ ScrollTo(BPoint(x,y)); }
|
||||
virtual void ScrollTo(BPoint where);
|
||||
virtual void AttachedToWindow();
|
||||
virtual void Draw(BRect update);
|
||||
virtual void Pulse();
|
||||
virtual void GetPreferredSize(float *w, float *h);
|
||||
void ScrollTo(float x, float y)
|
||||
{ ScrollTo(BPoint(x,y)); }
|
||||
virtual void ScrollTo(BPoint where);
|
||||
|
||||
void ShowIndex(int32 windex);
|
||||
BRect FrameOf(int32 index) const;
|
||||
void ShowIndex(int32 windex);
|
||||
BRect FrameOf(int32 index) const;
|
||||
|
||||
private:
|
||||
|
||||
int32 fCurToken;
|
||||
float fItemHeight;
|
||||
TSwitcherWindow *fSwitcher;
|
||||
TSwitchMgr *fMgr;
|
||||
bool fLocal;
|
||||
private:
|
||||
int32 fCurrentToken;
|
||||
float fItemHeight;
|
||||
TSwitcherWindow *fSwitcher;
|
||||
TSwitchManager *fManager;
|
||||
bool fLocal;
|
||||
};
|
||||
|
||||
class TIconView : public BView {
|
||||
public:
|
||||
TIconView(BRect , TSwitchMgr *, TSwitcherWindow *);
|
||||
~TIconView();
|
||||
public:
|
||||
TIconView(BRect frame, TSwitchManager *manager, TSwitcherWindow *switcher);
|
||||
~TIconView();
|
||||
|
||||
void Showing();
|
||||
void Hiding();
|
||||
void Showing();
|
||||
void Hiding();
|
||||
|
||||
virtual void KeyDown(const char *bytes, int32 numBytes);
|
||||
virtual void Pulse();
|
||||
virtual void MouseDown(BPoint );
|
||||
virtual void Draw(BRect );
|
||||
|
||||
void ScrollTo(float x, float y)
|
||||
{ ScrollTo(BPoint(x,y)); }
|
||||
virtual void ScrollTo(BPoint where);
|
||||
void Update(int32 prev, int32 cur, int32 prevSlot, int32 curSlot, bool forward);
|
||||
void DrawTeams(BRect update);
|
||||
int32 SlotOf(int32) const;
|
||||
BRect FrameOf(int32) const;
|
||||
int32 ItemAtPoint(BPoint) const;
|
||||
int32 IndexAt(int32 slot) const;
|
||||
void CenterOn(int32 index);
|
||||
virtual void KeyDown(const char *bytes, int32 numBytes);
|
||||
virtual void Pulse();
|
||||
virtual void MouseDown(BPoint );
|
||||
virtual void Draw(BRect );
|
||||
|
||||
private:
|
||||
|
||||
void CacheIcons(TTeamGroup *);
|
||||
void AnimateIcon(BBitmap *startIcon, BBitmap *endIcon);
|
||||
void ScrollTo(float x, float y)
|
||||
{ ScrollTo(BPoint(x,y)); }
|
||||
virtual void ScrollTo(BPoint where);
|
||||
void Update(int32 previous, int32 current, int32 previousSlot,
|
||||
int32 currentSlot, bool forward);
|
||||
void DrawTeams(BRect update);
|
||||
int32 SlotOf(int32) const;
|
||||
BRect FrameOf(int32) const;
|
||||
int32 ItemAtPoint(BPoint) const;
|
||||
int32 IndexAt(int32 slot) const;
|
||||
void CenterOn(int32 index);
|
||||
|
||||
bool fAutoScrolling;
|
||||
bool fCapsState;
|
||||
TSwitcherWindow *fSwitcher;
|
||||
TSwitchMgr *fMgr;
|
||||
BBitmap *fOffBitmap;
|
||||
BView *fOffView;
|
||||
BBitmap *fCurSmall;
|
||||
BBitmap *fCurLarge;
|
||||
private:
|
||||
void CacheIcons(TTeamGroup *);
|
||||
void AnimateIcon(BBitmap *startIcon, BBitmap *endIcon);
|
||||
|
||||
bool fAutoScrolling;
|
||||
bool fCapsState;
|
||||
TSwitcherWindow *fSwitcher;
|
||||
TSwitchManager *fManager;
|
||||
BBitmap *fOffBitmap;
|
||||
BView *fOffView;
|
||||
BBitmap *fCurrentSmall;
|
||||
BBitmap *fCurrentLarge;
|
||||
};
|
||||
|
||||
class TBox : public BBox {
|
||||
public:
|
||||
TBox(BRect bounds, TSwitchMgr *manager, TSwitcherWindow *, TIconView *iconView);
|
||||
public:
|
||||
TBox(BRect bounds, TSwitchManager *manager, TSwitcherWindow *, TIconView *iconView);
|
||||
|
||||
virtual void Draw(BRect update);
|
||||
virtual void AllAttached();
|
||||
virtual void DrawIconScrollers(bool force);
|
||||
virtual void DrawWindowScrollers(bool force);
|
||||
virtual void MouseDown(BPoint where);
|
||||
virtual void Draw(BRect update);
|
||||
virtual void AllAttached();
|
||||
virtual void DrawIconScrollers(bool force);
|
||||
virtual void DrawWindowScrollers(bool force);
|
||||
virtual void MouseDown(BPoint where);
|
||||
|
||||
private:
|
||||
TSwitchMgr *fMgr;
|
||||
TSwitcherWindow *fWindow;
|
||||
TIconView *fIconView;
|
||||
BRect fCenter;
|
||||
bool fLeftScroller;
|
||||
bool fRightScroller;
|
||||
bool fUpScroller;
|
||||
bool fDownScroller;
|
||||
private:
|
||||
TSwitchManager *fManager;
|
||||
TSwitcherWindow *fWindow;
|
||||
TIconView *fIconView;
|
||||
BRect fCenter;
|
||||
bool fLeftScroller;
|
||||
bool fRightScroller;
|
||||
bool fUpScroller;
|
||||
bool fDownScroller;
|
||||
};
|
||||
|
||||
inline int32 TSwitcherWindow::SlotOf(int32 i)
|
||||
{ return fIconView->SlotOf(i); }
|
||||
inline int32
|
||||
TSwitcherWindow::SlotOf(int32 i)
|
||||
{
|
||||
return fIconView->SlotOf(i);
|
||||
}
|
||||
|
||||
inline TIconView *TSwitcherWindow::IconView()
|
||||
{ return fIconView; }
|
||||
inline TIconView *
|
||||
TSwitcherWindow::IconView()
|
||||
{
|
||||
return fIconView;
|
||||
}
|
||||
|
||||
inline TWindowView *TSwitcherWindow::WindowView()
|
||||
{ return fWindowView; }
|
||||
inline TWindowView *
|
||||
TSwitcherWindow::WindowView()
|
||||
{
|
||||
return fWindowView;
|
||||
}
|
||||
|
||||
inline void TSwitchMgr::Touch(bool zero)
|
||||
{ fLastActivity = zero ? 0 : system_time(); }
|
||||
inline void
|
||||
TSwitchManager::Touch(bool zero)
|
||||
{
|
||||
fLastActivity = zero ? 0 : system_time();
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif /* SWITCHER_H */
|
||||
|
||||
@@ -335,9 +335,6 @@ TTimeView::MouseDown(BPoint point)
|
||||
Pulse();
|
||||
|
||||
#ifdef _SHOW_CALENDAR_MENU_ITEM
|
||||
if (!fShowingDate)
|
||||
return;
|
||||
|
||||
// see if the user holds down the button long enough to show him the calendar
|
||||
|
||||
bigtime_t startTime = system_time();
|
||||
|
||||
@@ -61,7 +61,8 @@ TWindowMenuItem::TWindowMenuItem(const char *title, int32 id,
|
||||
fDragging(dragging),
|
||||
fExpanded(false),
|
||||
fRequireUpdate(false),
|
||||
fModified(false)
|
||||
fModified(false),
|
||||
fFullTitle("")
|
||||
{
|
||||
Initialize(title);
|
||||
}
|
||||
@@ -111,6 +112,25 @@ TWindowMenuItem::ChangedState()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TWindowMenuItem::SetLabel(const char* string)
|
||||
{
|
||||
fFullTitle = string;
|
||||
BString truncatedTitle = fFullTitle;
|
||||
|
||||
if (fExpanded && Menu()) {
|
||||
BPoint contLoc = ContentLocation() + BPoint(kHPad, kVPad);
|
||||
contLoc.x += kIconRect.Width() + kLabelOffset;
|
||||
|
||||
be_plain_font->TruncateString(&truncatedTitle, B_TRUNCATE_MIDDLE,
|
||||
Frame().Width() - contLoc.x - 3.0f);
|
||||
}
|
||||
|
||||
if (strcmp(Label(), truncatedTitle.String()) != 0)
|
||||
BMenuItem::SetLabel(truncatedTitle.String());
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
TWindowMenuItem::ID()
|
||||
{
|
||||
@@ -126,10 +146,12 @@ TWindowMenuItem::GetContentSize(float *width, float *height)
|
||||
if (fID >= 0)
|
||||
*width += fBitmap->Bounds().Width() + kLabelOffset;
|
||||
} else
|
||||
*width = Frame().Width() - kHPad;
|
||||
*width = Frame().Width()/* - kHPad*/;
|
||||
|
||||
// ToDo: label width is not correct yet - the text label is
|
||||
// always written completely, if it fits or not!
|
||||
// Note: when the item is in "expanded mode", ie embedded into
|
||||
// the Deskbar itself, then a truncated label is used in SetLabel()
|
||||
// The code here is ignorant of this fact, but it doesn't seem to
|
||||
// hurt anything.
|
||||
|
||||
*height = (fID >= 0) ? fBitmap->Bounds().Height() : 0.0f;
|
||||
float labelHeight = fTitleAscent + fTitleDescent;
|
||||
@@ -155,7 +177,7 @@ TWindowMenuItem::Draw()
|
||||
menu->FillRect(frame);
|
||||
|
||||
if (fExpanded) {
|
||||
rgb_color shadow = tint_color(menuColor, B_DARKEN_1_TINT);
|
||||
rgb_color shadow = tint_color(menuColor, (B_NO_TINT + B_DARKEN_1_TINT) / 2.0f);
|
||||
menu->SetHighColor(shadow);
|
||||
frame.right = frame.left + kHPad / 2;
|
||||
menu->FillRect(frame);
|
||||
@@ -169,7 +191,6 @@ TWindowMenuItem::Draw()
|
||||
} else
|
||||
menu->SetLowColor(menuColor);
|
||||
|
||||
menu->MovePenTo(ContentLocation());
|
||||
DrawContent();
|
||||
menu->PopState();
|
||||
}
|
||||
@@ -185,8 +206,8 @@ TWindowMenuItem::DrawContent()
|
||||
|
||||
BRect frame(Frame());
|
||||
BPoint contLoc = ContentLocation() + BPoint(kHPad, kVPad);
|
||||
if (fExpanded)
|
||||
contLoc.x += kHPad;
|
||||
// if (fExpanded)
|
||||
// contLoc.x += kHPad;
|
||||
menu->SetDrawingMode(B_OP_COPY);
|
||||
|
||||
if (fID >= 0) {
|
||||
@@ -213,6 +234,7 @@ TWindowMenuItem::DrawContent()
|
||||
menu->MovePenTo(contLoc);
|
||||
// Set the pen color so that the label is always visible.
|
||||
menu->SetHighColor(0, 0, 0);
|
||||
|
||||
BMenuItem::DrawContent();
|
||||
}
|
||||
|
||||
@@ -249,7 +271,10 @@ TWindowMenuItem::Invoke(BMessage *)
|
||||
void
|
||||
TWindowMenuItem::ExpandedItem(bool status)
|
||||
{
|
||||
fExpanded = status;
|
||||
if (fExpanded != status) {
|
||||
fExpanded = status;
|
||||
SetLabel(fFullTitle.String());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -59,6 +59,8 @@ class TWindowMenuItem : public BMenuItem {
|
||||
bool RequiresUpdate();
|
||||
bool ChangedState();
|
||||
|
||||
virtual void SetLabel(const char* string);
|
||||
|
||||
protected:
|
||||
void Initialize(const char *title);
|
||||
virtual void GetContentSize(float *width, float *height);
|
||||
@@ -67,17 +69,18 @@ class TWindowMenuItem : public BMenuItem {
|
||||
virtual void Draw();
|
||||
|
||||
private:
|
||||
int32 fID;
|
||||
bool fMini;
|
||||
bool fCurrentWorkSpace;
|
||||
const BBitmap *fBitmap;
|
||||
float fTitleWidth;
|
||||
float fTitleAscent;
|
||||
float fTitleDescent;
|
||||
bool fDragging;
|
||||
bool fExpanded;
|
||||
bool fRequireUpdate;
|
||||
bool fModified;
|
||||
int32 fID;
|
||||
bool fMini;
|
||||
bool fCurrentWorkSpace;
|
||||
const BBitmap* fBitmap;
|
||||
float fTitleWidth;
|
||||
float fTitleAscent;
|
||||
float fTitleDescent;
|
||||
bool fDragging;
|
||||
bool fExpanded;
|
||||
bool fRequireUpdate;
|
||||
bool fModified;
|
||||
BString fFullTitle;
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
Reference in New Issue
Block a user