Added Tracker and Deskbar from OpenTracker-current to the repository.
They both build fine. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12773 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -4,6 +4,7 @@ SubInclude OBOS_TOP src apps bemail ;
|
||||
SubInclude OBOS_TOP src apps cdplayer ;
|
||||
SubInclude OBOS_TOP src apps clock ;
|
||||
SubInclude OBOS_TOP src apps codycam ;
|
||||
SubInclude OBOS_TOP src apps deskbar ;
|
||||
SubInclude OBOS_TOP src apps diskprobe ;
|
||||
SubInclude OBOS_TOP src apps expander ;
|
||||
SubInclude OBOS_TOP src apps magnify ;
|
||||
@@ -15,3 +16,4 @@ SubInclude OBOS_TOP src apps pulse ;
|
||||
SubInclude OBOS_TOP src apps showimage ;
|
||||
SubInclude OBOS_TOP src apps stylededit ;
|
||||
SubInclude OBOS_TOP src apps terminal ;
|
||||
SubInclude OBOS_TOP src apps tracker ;
|
||||
|
||||
@@ -0,0 +1,660 @@
|
||||
/*
|
||||
Open Tracker License
|
||||
|
||||
Terms and Conditions
|
||||
|
||||
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice applies to all licensees
|
||||
and shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of Be Incorporated shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings in
|
||||
this Software without prior written authorization from Be Incorporated.
|
||||
|
||||
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
||||
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.
|
||||
*/
|
||||
|
||||
#include <Debug.h>
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <AppFileInfo.h>
|
||||
#include <Autolock.h>
|
||||
#include <Bitmap.h>
|
||||
#include <Directory.h>
|
||||
#include <Dragger.h>
|
||||
#include <File.h>
|
||||
#include <FindDirectory.h>
|
||||
#include <Mime.h>
|
||||
#include <Path.h>
|
||||
#include <Roster.h>
|
||||
|
||||
#include "FavoritesConfig.h"
|
||||
|
||||
#include "icons.h"
|
||||
#include "tracker_private.h"
|
||||
#include "BarApp.h"
|
||||
#include "BarView.h"
|
||||
#include "BarWindow.h"
|
||||
#include "DeskBarUtils.h"
|
||||
#include "TeamMenu.h"
|
||||
#include "Switcher.h"
|
||||
#include "ResourceSet.h"
|
||||
#include "WindowMenuItem.h"
|
||||
|
||||
|
||||
// private Be API
|
||||
extern void __set_window_decor(int32 theme);
|
||||
|
||||
BLocker TBarApp::sSubscriberLock;
|
||||
BList TBarApp::sBarTeamInfoList;
|
||||
BList TBarApp::sSubscribers;
|
||||
|
||||
|
||||
const uint32 kShowBeMenu = 'BeMn';
|
||||
const uint32 kShowTeamMenu = 'TmMn';
|
||||
|
||||
const BRect kIconSize(0.0f, 0.0f, 15.0f, 15.0f);
|
||||
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
TBarApp app;
|
||||
app.Run();
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
TBarApp::TBarApp()
|
||||
: BApplication(kDeskbarSignature),
|
||||
fSettingsFile(NULL),
|
||||
fConfigWindow(NULL)
|
||||
{
|
||||
InitSettings();
|
||||
InitIconPreloader();
|
||||
|
||||
sBarTeamInfoList.MakeEmpty();
|
||||
|
||||
BList teamList;
|
||||
int32 numTeams;
|
||||
be_roster->GetAppList(&teamList);
|
||||
numTeams = teamList.CountItems();
|
||||
for (int32 i = 0; i < numTeams; i++) {
|
||||
app_info appInfo;
|
||||
team_id tID = (team_id)teamList.ItemAt(i);
|
||||
if (be_roster->GetRunningAppInfo(tID, &appInfo) == B_OK)
|
||||
AddTeam(appInfo.team, appInfo.flags, appInfo.signature,
|
||||
&appInfo.ref);
|
||||
}
|
||||
|
||||
sSubscribers.MakeEmpty();
|
||||
|
||||
fSwitcherMess = BMessenger(new TSwitchMgr(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"));
|
||||
}
|
||||
|
||||
|
||||
TBarApp::~TBarApp()
|
||||
{
|
||||
int32 teamCount = sBarTeamInfoList.CountItems();
|
||||
for (int32 i = 0; i < teamCount; i++) {
|
||||
BarTeamInfo *barInfo = (BarTeamInfo *)sBarTeamInfoList.ItemAt(i);
|
||||
delete barInfo->teams;
|
||||
free(barInfo->sig);
|
||||
delete barInfo->icon;
|
||||
free(barInfo->name);
|
||||
free(barInfo);
|
||||
}
|
||||
|
||||
int32 subsCount = sSubscribers.CountItems();
|
||||
for (int32 i = 0; i < subsCount; i++) {
|
||||
BMessenger *messenger = static_cast<BMessenger *>(sSubscribers.ItemAt(i));
|
||||
delete messenger;
|
||||
}
|
||||
SaveSettings();
|
||||
delete fSettingsFile;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
TBarApp::QuitRequested()
|
||||
{
|
||||
if (CurrentMessage() && CurrentMessage()->FindBool("shortcut"))
|
||||
// don't allow user quitting
|
||||
return false;
|
||||
|
||||
// system quitting, call inherited to notify all loopers
|
||||
fBarWindow->SaveSettings();
|
||||
BApplication::QuitRequested();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarApp::SaveSettings()
|
||||
{
|
||||
if (fSettingsFile->InitCheck() == B_OK) {
|
||||
fSettingsFile->Seek(0, SEEK_SET);
|
||||
fSettingsFile->Write(&fSettings.vertical, sizeof(bool));
|
||||
fSettingsFile->Write(&fSettings.left, sizeof(bool));
|
||||
fSettingsFile->Write(&fSettings.top, sizeof(bool));
|
||||
fSettingsFile->Write(&fSettings.ampmMode, sizeof(bool));
|
||||
fSettingsFile->Write(&fSettings.state, sizeof(uint32));
|
||||
fSettingsFile->Write(&fSettings.width, sizeof(float));
|
||||
fSettingsFile->Write(&fSettings.showTime, sizeof(bool));
|
||||
fSettingsFile->Write(&fSettings.switcherLoc, sizeof(BPoint));
|
||||
fSettingsFile->Write(&fSettings.recentAppsCount, sizeof(int32));
|
||||
fSettingsFile->Write(&fSettings.recentDocsCount, sizeof(int32));
|
||||
fSettingsFile->Write(&fSettings.timeShowSeconds, sizeof(bool));
|
||||
fSettingsFile->Write(&fSettings.timeShowMil, sizeof(bool));
|
||||
fSettingsFile->Write(&fSettings.recentFoldersCount, sizeof(int32));
|
||||
fSettingsFile->Write(&fSettings.timeShowEuro, sizeof(bool));
|
||||
fSettingsFile->Write(&fSettings.alwaysOnTop, sizeof(bool));
|
||||
fSettingsFile->Write(&fSettings.timeFullDate, sizeof(bool));
|
||||
fSettingsFile->Write(&fSettings.trackerAlwaysFirst, sizeof(bool));
|
||||
fSettingsFile->Write(&fSettings.sortRunningApps, sizeof(bool));
|
||||
fSettingsFile->Write(&fSettings.superExpando, sizeof(bool));
|
||||
fSettingsFile->Write(&fSettings.expandNewTeams, sizeof(bool));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarApp::InitSettings()
|
||||
{
|
||||
desk_settings settings;
|
||||
settings.vertical = true;
|
||||
settings.left = false;
|
||||
settings.top = true;
|
||||
settings.ampmMode = true;
|
||||
settings.showTime = true;
|
||||
settings.state = kExpandoState;
|
||||
settings.width = 0;
|
||||
settings.switcherLoc = BPoint(5000, 5000);
|
||||
settings.recentAppsCount = 10;
|
||||
settings.recentDocsCount = 10;
|
||||
settings.timeShowSeconds = false;
|
||||
settings.timeShowMil = false;
|
||||
settings.recentFoldersCount = 0; // default is hidden
|
||||
settings.timeShowEuro = false;
|
||||
settings.alwaysOnTop = false;
|
||||
settings.timeFullDate = false;
|
||||
settings.trackerAlwaysFirst = false;
|
||||
settings.sortRunningApps = false;
|
||||
settings.superExpando = false;
|
||||
settings.expandNewTeams = false;
|
||||
|
||||
BPath dirPath;
|
||||
const char *settingsFileName = "Deskbar_settings";
|
||||
|
||||
find_directory(B_USER_DESKBAR_DIRECTORY, &dirPath, true);
|
||||
// just make it
|
||||
|
||||
if (find_directory (B_USER_SETTINGS_DIRECTORY, &dirPath, true) == B_OK) {
|
||||
BPath filePath = dirPath;
|
||||
filePath.Append(settingsFileName);
|
||||
fSettingsFile = new BFile(filePath.Path(), O_RDWR);
|
||||
if (fSettingsFile->InitCheck() != B_OK) {
|
||||
BDirectory theDir(dirPath.Path());
|
||||
if (theDir.InitCheck() == B_OK)
|
||||
theDir.CreateFile(settingsFileName, fSettingsFile);
|
||||
}
|
||||
|
||||
if (fSettingsFile->InitCheck() == B_OK) {
|
||||
off_t theSize = 0;
|
||||
fSettingsFile->GetSize(&theSize);
|
||||
|
||||
if (theSize >= kValidSettingsSize1) {
|
||||
fSettingsFile->Seek(0, SEEK_SET);
|
||||
fSettingsFile->Read(&settings.vertical, sizeof(bool));
|
||||
fSettingsFile->Read(&settings.left, sizeof(bool));
|
||||
fSettingsFile->Read(&settings.top, sizeof(bool));
|
||||
fSettingsFile->Read(&settings.ampmMode, sizeof(bool));
|
||||
fSettingsFile->Read(&settings.state, sizeof(uint32));
|
||||
fSettingsFile->Read(&settings.width, sizeof(float));
|
||||
fSettingsFile->Read(&settings.showTime, sizeof(bool));
|
||||
}
|
||||
if (theSize >= kValidSettingsSize2)
|
||||
fSettingsFile->Read(&settings.switcherLoc, sizeof(BPoint));
|
||||
if (theSize >= kValidSettingsSize3) {
|
||||
fSettingsFile->Read(&settings.recentAppsCount, sizeof(int32));
|
||||
fSettingsFile->Read(&settings.recentDocsCount, sizeof(int32));
|
||||
}
|
||||
if (theSize >= kValidSettingsSize4) {
|
||||
fSettingsFile->Read(&settings.timeShowSeconds, sizeof(bool));
|
||||
fSettingsFile->Read(&settings.timeShowMil, sizeof(bool));
|
||||
}
|
||||
if (theSize >= kValidSettingsSize5)
|
||||
fSettingsFile->Read(&settings.recentFoldersCount, sizeof(int32));
|
||||
if (theSize >= kValidSettingsSize6) {
|
||||
fSettingsFile->Read(&settings.timeShowEuro, sizeof(bool));
|
||||
fSettingsFile->Read(&settings.alwaysOnTop, sizeof(bool));
|
||||
}
|
||||
if (theSize >= kValidSettingsSize7)
|
||||
fSettingsFile->Read(&settings.timeFullDate, sizeof(bool));
|
||||
if (theSize >= kValidSettingsSize8) {
|
||||
fSettingsFile->Read(&settings.trackerAlwaysFirst, sizeof(bool));
|
||||
fSettingsFile->Read(&settings.sortRunningApps, sizeof(bool));
|
||||
}
|
||||
if (theSize >= kValidSettingsSize9) {
|
||||
fSettingsFile->Read(&settings.superExpando, sizeof(bool));
|
||||
fSettingsFile->Read(&settings.expandNewTeams, sizeof(bool));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fSettings = settings;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarApp::MessageReceived(BMessage *message)
|
||||
{
|
||||
int32 count;
|
||||
switch (message->what) {
|
||||
case 'gloc':
|
||||
case 'sloc':
|
||||
case 'gexp':
|
||||
case 'sexp':
|
||||
case 'info':
|
||||
case 'exst':
|
||||
case 'cwnt':
|
||||
case 'icon':
|
||||
case 'remv':
|
||||
case 'adon':
|
||||
// pass any BDeskbar originating messages on to the window
|
||||
fBarWindow->PostMessage(message);
|
||||
break;
|
||||
|
||||
case kConfigShow:
|
||||
if (message->FindInt32("count", &count) == B_OK)
|
||||
fSettings.recentDocsCount = count;
|
||||
break;
|
||||
|
||||
case kUpdateAppsCount:
|
||||
if (message->FindInt32("count", &count) == B_OK)
|
||||
fSettings.recentAppsCount = count;
|
||||
break;
|
||||
|
||||
case kShowBeMenu:
|
||||
if (fBarWindow->Lock()) {
|
||||
fBarWindow->ShowBeMenu();
|
||||
fBarWindow->Unlock();
|
||||
}
|
||||
break;
|
||||
|
||||
case kShowTeamMenu:
|
||||
if (fBarWindow->Lock()) {
|
||||
fBarWindow->ShowTeamMenu();
|
||||
fBarWindow->Unlock();
|
||||
}
|
||||
break;
|
||||
|
||||
case msg_config_db:
|
||||
ShowConfigWindow();
|
||||
break;
|
||||
|
||||
case kConfigClose:
|
||||
if (message->FindInt32("applications", &count) == B_OK)
|
||||
fSettings.recentAppsCount = count;
|
||||
if (message->FindInt32("folders", &count) == B_OK)
|
||||
fSettings.recentFoldersCount = count;
|
||||
if (message->FindInt32("documents", &count) == B_OK)
|
||||
fSettings.recentDocsCount = count;
|
||||
|
||||
fConfigWindow = NULL;
|
||||
break;
|
||||
|
||||
case B_SOME_APP_LAUNCHED:
|
||||
{
|
||||
team_id team = -1;
|
||||
message->FindInt32("be:team", &team);
|
||||
|
||||
uint32 flags = 0;
|
||||
message->FindInt32("be:flags", (long *)&flags);
|
||||
|
||||
const char *sig = NULL;
|
||||
message->FindString("be:signature", &sig);
|
||||
|
||||
entry_ref ref;
|
||||
message->FindRef("be:ref", &ref);
|
||||
|
||||
AddTeam(team, flags, sig, &ref);
|
||||
break;
|
||||
}
|
||||
|
||||
case B_SOME_APP_QUIT:
|
||||
{
|
||||
team_id team = -1;
|
||||
message->FindInt32("be:team", &team);
|
||||
RemoveTeam(team);
|
||||
break;
|
||||
}
|
||||
|
||||
case B_ARCHIVED_OBJECT:
|
||||
message->AddString("special", "Alex Osadzinski");
|
||||
fStatusViewMess.SendMessage(message);
|
||||
break;
|
||||
|
||||
case msg_Be:
|
||||
__set_window_decor(0);
|
||||
break;
|
||||
|
||||
case msg_Win95:
|
||||
__set_window_decor(2);
|
||||
break;
|
||||
|
||||
case msg_Amiga:
|
||||
__set_window_decor(1);
|
||||
break;
|
||||
|
||||
case msg_Mac:
|
||||
__set_window_decor(3);
|
||||
break;
|
||||
|
||||
case msg_ToggleDraggers:
|
||||
if (BDragger::AreDraggersDrawn())
|
||||
BDragger::HideAllDraggers();
|
||||
else
|
||||
BDragger::ShowAllDraggers();
|
||||
break;
|
||||
|
||||
case msg_AlwaysTop:
|
||||
fSettings.alwaysOnTop = !fSettings.alwaysOnTop;
|
||||
|
||||
fBarWindow->SetFeel(fSettings.alwaysOnTop ?
|
||||
B_FLOATING_ALL_WINDOW_FEEL : B_NORMAL_WINDOW_FEEL);
|
||||
break;
|
||||
|
||||
case msg_trackerFirst:
|
||||
{
|
||||
fSettings.trackerAlwaysFirst = !fSettings.trackerAlwaysFirst;
|
||||
|
||||
TBarView *barView = static_cast<TBarApp *>(be_app)->BarView();
|
||||
fBarWindow->Lock();
|
||||
barView->UpdatePlacement();
|
||||
fBarWindow->Unlock();
|
||||
break;
|
||||
}
|
||||
|
||||
case msg_sortRunningApps:
|
||||
{
|
||||
fSettings.sortRunningApps = !fSettings.sortRunningApps;
|
||||
|
||||
TBarView *barView = static_cast<TBarApp *>(be_app)->BarView();
|
||||
fBarWindow->Lock();
|
||||
barView->UpdatePlacement();
|
||||
fBarWindow->Unlock();
|
||||
break;
|
||||
}
|
||||
|
||||
case msg_Unsubscribe:
|
||||
{
|
||||
BMessenger messenger;
|
||||
if (message->FindMessenger("messenger", &messenger) == B_OK)
|
||||
Unsubscribe(messenger);
|
||||
break;
|
||||
}
|
||||
|
||||
case msg_superExpando:
|
||||
{
|
||||
fSettings.superExpando = !fSettings.superExpando;
|
||||
|
||||
TBarView *barView = static_cast<TBarApp *>(be_app)->BarView();
|
||||
fBarWindow->Lock();
|
||||
barView->UpdatePlacement();
|
||||
fBarWindow->Unlock();
|
||||
break;
|
||||
}
|
||||
|
||||
case msg_expandNewTeams:
|
||||
{
|
||||
fSettings.expandNewTeams = !fSettings.expandNewTeams;
|
||||
|
||||
TBarView *barView = static_cast<TBarApp *>(be_app)->BarView();
|
||||
fBarWindow->Lock();
|
||||
barView->UpdatePlacement();
|
||||
fBarWindow->Unlock();
|
||||
break;
|
||||
}
|
||||
|
||||
case 'TASK':
|
||||
fSwitcherMess.SendMessage(message);
|
||||
break;
|
||||
|
||||
default:
|
||||
BApplication::MessageReceived(message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// called when ExpandoMenuBar, TeamMenu or Switcher are built/rebuilt
|
||||
void
|
||||
TBarApp::Subscribe(const BMessenger &subscriber, BList *list)
|
||||
{
|
||||
list->MakeEmpty();
|
||||
|
||||
BAutolock autolock(sSubscriberLock);
|
||||
if (!autolock.IsLocked())
|
||||
return;
|
||||
|
||||
int32 numTeams = sBarTeamInfoList.CountItems();
|
||||
for (int32 i = 0; i < numTeams; i++) {
|
||||
BarTeamInfo *barInfo = (BarTeamInfo *)sBarTeamInfoList.ItemAt(i);
|
||||
BList *tList = new BList(*(barInfo->teams));
|
||||
BBitmap *icon = new BBitmap(kIconSize, B_COLOR_8_BIT);
|
||||
ASSERT(icon);
|
||||
icon->SetBits(barInfo->icon->Bits(), icon->BitsLength(), 0, B_COLOR_8_BIT);
|
||||
list->AddItem(new BarTeamInfo(tList, barInfo->flags, strdup(barInfo->sig), icon, strdup(barInfo->name)));
|
||||
}
|
||||
|
||||
int32 subsCount = sSubscribers.CountItems();
|
||||
for (int32 i = 0; i < subsCount; i++) {
|
||||
BMessenger *messenger = (BMessenger *)sSubscribers.ItemAt(i);
|
||||
if (*messenger == subscriber)
|
||||
return;
|
||||
}
|
||||
|
||||
sSubscribers.AddItem(new BMessenger(subscriber));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarApp::Unsubscribe(const BMessenger &subscriber)
|
||||
{
|
||||
BAutolock autolock(sSubscriberLock);
|
||||
if (!autolock.IsLocked())
|
||||
return;
|
||||
|
||||
int32 count = sSubscribers.CountItems();
|
||||
for (int32 i = 0; i < count; i++) {
|
||||
BMessenger *messenger = (BMessenger *)sSubscribers.ItemAt(i);
|
||||
if (*messenger == subscriber) {
|
||||
sSubscribers.RemoveItem(i);
|
||||
delete (messenger);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarApp::AddTeam(team_id team, uint32 flags, const char *sig, entry_ref *ref)
|
||||
{
|
||||
BAutolock autolock(sSubscriberLock);
|
||||
if (!autolock.IsLocked())
|
||||
return;
|
||||
|
||||
// have we already seen this team, is this another instance of
|
||||
// a known app?
|
||||
BarTeamInfo *multiLaunchTeam = NULL;
|
||||
int32 teamCount = sBarTeamInfoList.CountItems();
|
||||
for (int32 i = 0; i < teamCount; i++) {
|
||||
BarTeamInfo *barInfo = (BarTeamInfo *)sBarTeamInfoList.ItemAt(i);
|
||||
if (barInfo->teams->HasItem((void *)team))
|
||||
return;
|
||||
if (strcasecmp(barInfo->sig, sig) == 0)
|
||||
multiLaunchTeam = barInfo;
|
||||
}
|
||||
|
||||
if (multiLaunchTeam != NULL) {
|
||||
multiLaunchTeam->teams->AddItem((void *)team);
|
||||
|
||||
int32 subsCount = sSubscribers.CountItems();
|
||||
if (subsCount > 0) {
|
||||
BMessage message(msg_AddTeam);
|
||||
message.AddInt32("team", team);
|
||||
message.AddString("sig", multiLaunchTeam->sig);
|
||||
|
||||
for (int32 i = 0; i < subsCount; i++)
|
||||
((BMessenger *)sSubscribers.ItemAt(i))->SendMessage(&message);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
BFile theFile(ref, O_RDONLY);
|
||||
BAppFileInfo appMime(&theFile);
|
||||
|
||||
BarTeamInfo *barInfo = new BarTeamInfo(new BList(), flags, strdup(sig),
|
||||
new BBitmap(kIconSize, B_COLOR_8_BIT), strdup(ref->name));
|
||||
|
||||
barInfo->teams->AddItem((void *)team);
|
||||
if (appMime.GetIcon(barInfo->icon, B_MINI_ICON) != B_OK) {
|
||||
const BBitmap* generic = AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_GenericAppIcon);
|
||||
if (generic)
|
||||
barInfo->icon->SetBits(generic->Bits(), barInfo->icon->BitsLength(),
|
||||
0, B_COLOR_8_BIT);
|
||||
}
|
||||
|
||||
sBarTeamInfoList.AddItem(barInfo);
|
||||
|
||||
int32 subsCount = sSubscribers.CountItems();
|
||||
if (subsCount > 0) {
|
||||
for (int32 i = 0; i < subsCount; i++) {
|
||||
BMessenger *messenger = (BMessenger *)sSubscribers.ItemAt(i);
|
||||
BMessage message(B_SOME_APP_LAUNCHED);
|
||||
|
||||
BList *tList = new BList(*(barInfo->teams));
|
||||
message.AddPointer("teams", tList);
|
||||
|
||||
BBitmap *icon = new BBitmap(kIconSize, B_COLOR_8_BIT);
|
||||
ASSERT(icon);
|
||||
|
||||
icon->SetBits(barInfo->icon->Bits(), icon->BitsLength(), 0, B_COLOR_8_BIT);
|
||||
message.AddPointer("icon", icon);
|
||||
|
||||
message.AddInt32("flags", static_cast<int32>(barInfo->flags));
|
||||
message.AddString("name", barInfo->name);
|
||||
message.AddString("sig", barInfo->sig);
|
||||
|
||||
messenger->SendMessage(&message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarApp::RemoveTeam(team_id team)
|
||||
{
|
||||
BAutolock autolock(sSubscriberLock);
|
||||
if (!autolock.IsLocked())
|
||||
return;
|
||||
|
||||
int32 teamCount = sBarTeamInfoList.CountItems();
|
||||
for (int32 i = 0; i < teamCount; i++) {
|
||||
BarTeamInfo *barInfo = (BarTeamInfo *)sBarTeamInfoList.ItemAt(i);
|
||||
if (barInfo->teams->HasItem((void *)team)) {
|
||||
int32 subsCount = sSubscribers.CountItems();
|
||||
if (subsCount > 0) {
|
||||
BMessage message((barInfo->teams->CountItems() == 1) ?
|
||||
B_SOME_APP_QUIT : msg_RemoveTeam);
|
||||
|
||||
message.AddInt32("team", team);
|
||||
for (int32 i = 0; i < subsCount; i++) {
|
||||
BMessenger *messenger = (BMessenger *)sSubscribers.ItemAt(i);
|
||||
messenger->SendMessage(&message);
|
||||
}
|
||||
}
|
||||
|
||||
barInfo->teams->RemoveItem((void *)team);
|
||||
if (barInfo->teams->CountItems() < 1) {
|
||||
delete (BarTeamInfo *)sBarTeamInfoList.RemoveItem(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarApp::ShowConfigWindow()
|
||||
{
|
||||
if (fConfigWindow)
|
||||
fConfigWindow->Activate();
|
||||
else {
|
||||
// always start at top, could be cached and we could start
|
||||
// where we left off.
|
||||
BPath path;
|
||||
find_directory (B_USER_DESKBAR_DIRECTORY, &path);
|
||||
entry_ref startref;
|
||||
get_ref_for_path(path.Path(), &startref);
|
||||
|
||||
fConfigWindow = new TFavoritesConfigWindow(BRect(0, 0, 320, 240),
|
||||
"Configure Be Menu", false, B_ANY_NODE,
|
||||
BMessenger(this), &startref,
|
||||
fSettings.recentAppsCount, fSettings.recentDocsCount,
|
||||
fSettings.recentFoldersCount);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
BarTeamInfo::BarTeamInfo(BList *teams, uint32 flags, char *sig, BBitmap *icon, char *name)
|
||||
: teams(teams),
|
||||
flags(flags),
|
||||
sig(sig),
|
||||
icon(icon),
|
||||
name(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
BarTeamInfo::~BarTeamInfo()
|
||||
{
|
||||
delete teams;
|
||||
free(sig);
|
||||
delete icon;
|
||||
free(name);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,170 @@
|
||||
/*
|
||||
Open Tracker License
|
||||
|
||||
Terms and Conditions
|
||||
|
||||
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice applies to all licensees
|
||||
and shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of Be Incorporated shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings in
|
||||
this Software without prior written authorization from Be Incorporated.
|
||||
|
||||
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
||||
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
|
||||
|
||||
#define _DESKTOP_W_TYPE_ 1024
|
||||
#define _FLOATER_W_TYPE_ 4
|
||||
#define _STD_W_TYPE_ 0
|
||||
|
||||
|
||||
class BarTeamInfo {
|
||||
public:
|
||||
BarTeamInfo(BList *teams, uint32 flags, char *sig, BBitmap *icon,
|
||||
char *name);
|
||||
~BarTeamInfo();
|
||||
|
||||
BList *teams;
|
||||
uint32 flags;
|
||||
char *sig;
|
||||
BBitmap *icon;
|
||||
char *name;
|
||||
};
|
||||
|
||||
const uint32 msg_Win95 = 'Bill';
|
||||
const uint32 msg_Amiga = 'Ncro';
|
||||
const uint32 msg_Mac = 'WcOS';
|
||||
const uint32 msg_Be = 'Tabs';
|
||||
const uint32 msg_AlwaysTop = 'TTop';
|
||||
const uint32 msg_ToggleDraggers = 'TDra';
|
||||
const uint32 msg_config_db = 'cnfg';
|
||||
const uint32 msg_Unsubscribe = 'Unsb';
|
||||
const uint32 msg_AddTeam = 'AdTm';
|
||||
const uint32 msg_RemoveTeam = 'RmTm';
|
||||
const uint32 msg_Restart = 'Rtrt';
|
||||
const uint32 msg_ShutDown = 'ShDn';
|
||||
const uint32 msg_trackerFirst = 'TkFt';
|
||||
const uint32 msg_sortRunningApps = 'SAps';
|
||||
const uint32 msg_superExpando = 'SprE';
|
||||
const uint32 msg_expandNewTeams = 'ExTm';
|
||||
|
||||
/* --------------------------------------------- */
|
||||
|
||||
// if you want to extend this structure, maintain the
|
||||
// constants below (used in TBarApp::InitSettings())
|
||||
|
||||
struct desk_settings {
|
||||
bool vertical; // version 1
|
||||
bool left;
|
||||
bool top;
|
||||
bool ampmMode;
|
||||
bool showTime;
|
||||
uint32 state;
|
||||
float width;
|
||||
BPoint switcherLoc; // version 2
|
||||
int32 recentAppsCount; // version 3
|
||||
int32 recentDocsCount;
|
||||
bool timeShowSeconds; // version 4
|
||||
bool timeShowMil;
|
||||
int32 recentFoldersCount; // version 5
|
||||
bool timeShowEuro; // version 6
|
||||
bool alwaysOnTop;
|
||||
bool timeFullDate; // version 7
|
||||
bool trackerAlwaysFirst; // version 8
|
||||
bool sortRunningApps;
|
||||
bool superExpando; // version 9
|
||||
bool expandNewTeams;
|
||||
};
|
||||
|
||||
// the following structures are defined to compute
|
||||
// valid sizes for "struct desk_settings"
|
||||
|
||||
const uint32 kValidSettingsSize1 = 5 * sizeof(bool) + sizeof(uint32) + sizeof(float);
|
||||
const uint32 kValidSettingsSize2 = sizeof(BPoint) + kValidSettingsSize1;
|
||||
const uint32 kValidSettingsSize3 = 2 * sizeof(int32) + kValidSettingsSize2;
|
||||
const uint32 kValidSettingsSize4 = 2 * sizeof(bool) + kValidSettingsSize3;
|
||||
const uint32 kValidSettingsSize5 = sizeof(int32) + kValidSettingsSize4;
|
||||
const uint32 kValidSettingsSize6 = 2 * sizeof(bool) + kValidSettingsSize5;
|
||||
const uint32 kValidSettingsSize7 = sizeof(bool) + kValidSettingsSize6;
|
||||
const uint32 kValidSettingsSize8 = 2 * sizeof(bool) + kValidSettingsSize7;
|
||||
const uint32 kValidSettingsSize9 = 2 * sizeof(bool) + kValidSettingsSize8;
|
||||
|
||||
class TBarView;
|
||||
class BFile;
|
||||
|
||||
namespace BPrivate {
|
||||
|
||||
class TFavoritesConfigWindow;
|
||||
|
||||
}
|
||||
|
||||
using namespace BPrivate;
|
||||
|
||||
class TBarApp : public BApplication {
|
||||
public:
|
||||
TBarApp();
|
||||
virtual ~TBarApp();
|
||||
|
||||
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);
|
||||
|
||||
void InitSettings();
|
||||
void SaveSettings();
|
||||
|
||||
void ShowConfigWindow();
|
||||
|
||||
TBarWindow *fBarWindow;
|
||||
BMessenger fSwitcherMess;
|
||||
BMessenger fStatusViewMess;
|
||||
BFile *fSettingsFile;
|
||||
desk_settings fSettings;
|
||||
|
||||
TFavoritesConfigWindow *fConfigWindow;
|
||||
|
||||
static BLocker sSubscriberLock;
|
||||
static BList sBarTeamInfoList;
|
||||
static BList sSubscribers;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,198 @@
|
||||
/*
|
||||
Open Tracker License
|
||||
|
||||
Terms and Conditions
|
||||
|
||||
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice applies to all licensees
|
||||
and shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of Be Incorporated shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings in
|
||||
this Software without prior written authorization from Be Incorporated.
|
||||
|
||||
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
||||
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.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <Debug.h>
|
||||
#include <Bitmap.h>
|
||||
#include <NodeInfo.h>
|
||||
|
||||
#include "icons.h"
|
||||
#include "icons_logo.h"
|
||||
#include "BarMenuBar.h"
|
||||
#include "BarWindow.h"
|
||||
#include "BeMenu.h"
|
||||
#include "DeskBarUtils.h"
|
||||
#include "ResourceSet.h"
|
||||
#include "TeamMenu.h"
|
||||
|
||||
|
||||
TBarMenuBar::TBarMenuBar(TBarView *bar, BRect frame, const char *name)
|
||||
: 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);
|
||||
}
|
||||
|
||||
|
||||
TBarMenuBar::~TBarMenuBar()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarMenuBar::SmartResize(float width, float height)
|
||||
{
|
||||
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();
|
||||
if (fBeMenuItem)
|
||||
fBeMenuItem->SetWidthHeight(width / count, height);
|
||||
if (fAppListMenuItem)
|
||||
fAppListMenuItem->SetWidthHeight(width / count, height);
|
||||
|
||||
InvalidateLayout();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarMenuBar::AddTeamMenu()
|
||||
{
|
||||
if (CountItems() > 1)
|
||||
return;
|
||||
|
||||
BRect frame(Frame());
|
||||
delete fAppListMenuItem;
|
||||
|
||||
fAppListMenuItem = new TBarMenuTitle(0.0f, 0.0f,
|
||||
AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_TeamIcon), new TTeamMenu());
|
||||
AddItem(fAppListMenuItem);
|
||||
SmartResize(frame.Width() - 1.0f, frame.Height());
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarMenuBar::RemoveTeamMenu()
|
||||
{
|
||||
if (CountItems() < 2)
|
||||
return;
|
||||
|
||||
if (fAppListMenuItem) {
|
||||
RemoveItem((BMenuItem *)fAppListMenuItem);
|
||||
delete fAppListMenuItem;
|
||||
fAppListMenuItem = NULL;
|
||||
}
|
||||
|
||||
BRect frame = Frame();
|
||||
SmartResize(frame.Width(), frame.Height());
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarMenuBar::Draw(BRect rect)
|
||||
{
|
||||
// want to skip the fancy BMenuBar drawing code.
|
||||
BMenu::Draw(rect);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarMenuBar::DrawBackground(BRect rect)
|
||||
{
|
||||
BMenu::DrawBackground(rect);
|
||||
}
|
||||
|
||||
|
||||
// the following code parallels that in ExpandoMenuBar for DnD tracking
|
||||
void
|
||||
TBarMenuBar::MouseMoved(BPoint where, uint32 code, const BMessage *message)
|
||||
{
|
||||
if (!message) {
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
BMenuBar::MouseMoved(where, code, message);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
init_tracking_hook(BMenuItem *item,bool (*hookfunction)(BMenu *, void *), void *state)
|
||||
{
|
||||
if (!item)
|
||||
return;
|
||||
|
||||
BMenu *windowmenu = item->Submenu();
|
||||
if (windowmenu)
|
||||
// have a menu, set the tracking hook
|
||||
windowmenu->SetTrackingHook(hookfunction, state);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarMenuBar::InitTrackingHook(bool (*hookfunction)(BMenu *, void *), void *state, bool both)
|
||||
{
|
||||
BPoint loc;
|
||||
uint32 buttons;
|
||||
GetMouse(&loc, &buttons);
|
||||
// set the hook functions for the two menus
|
||||
// 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);
|
||||
|
||||
if (fAppListMenuItem && (fAppListMenuItem->Frame().Contains(loc) || both))
|
||||
init_tracking_hook(fAppListMenuItem, hookfunction, state);
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
Open Tracker License
|
||||
|
||||
Terms and Conditions
|
||||
|
||||
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice applies to all licensees
|
||||
and shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of Be Incorporated shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings in
|
||||
this Software without prior written authorization from Be Incorporated.
|
||||
|
||||
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
||||
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.
|
||||
*/
|
||||
|
||||
// Be Menu, used in vertical mode, expanded and mini
|
||||
// in mini mode will have team menu next to Be menu
|
||||
// Be menu in horizontal mode is embedded in ExpandoMenuBar
|
||||
|
||||
#ifndef BARMENUBAR_H
|
||||
#define BARMENUBAR_H
|
||||
|
||||
#include <MenuBar.h>
|
||||
|
||||
#include "BarView.h"
|
||||
#include "BarMenuTitle.h"
|
||||
#include "TimeView.h"
|
||||
|
||||
|
||||
class TBarMenuBar : public BMenuBar {
|
||||
public:
|
||||
TBarMenuBar(TBarView *bar, BRect frame, const char *name);
|
||||
virtual ~TBarMenuBar();
|
||||
|
||||
virtual void MouseMoved(BPoint where, uint32 code, const BMessage *message);
|
||||
virtual void Draw(BRect);
|
||||
|
||||
void DrawBackground(BRect);
|
||||
void SmartResize(float width = -1.0f, float height = -1.0f);
|
||||
|
||||
void AddTeamMenu();
|
||||
void RemoveTeamMenu();
|
||||
|
||||
void InitTrackingHook(bool (* hookfunction)(BMenu *, void *), void *state,
|
||||
bool both = false);
|
||||
|
||||
private:
|
||||
TBarView *fBarView;
|
||||
TBarMenuTitle *fBeMenuItem;
|
||||
TBarMenuTitle *fAppListMenuItem;
|
||||
};
|
||||
|
||||
#endif /* BARMENUBAR_H */
|
||||
|
||||
@@ -0,0 +1,163 @@
|
||||
/*
|
||||
Open Tracker License
|
||||
|
||||
Terms and Conditions
|
||||
|
||||
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice applies to all licensees
|
||||
and shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of Be Incorporated shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings in
|
||||
this Software without prior written authorization from Be Incorporated.
|
||||
|
||||
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
||||
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.
|
||||
*/
|
||||
|
||||
#include <Debug.h>
|
||||
#include <Bitmap.h>
|
||||
|
||||
#include "BarApp.h"
|
||||
#include "BarMenuTitle.h"
|
||||
#include "BarView.h"
|
||||
#include "BarWindow.h"
|
||||
#include "ExpandoMenuBar.h"
|
||||
|
||||
|
||||
TBarMenuTitle::TBarMenuTitle(float width, float height, const BBitmap *icon,
|
||||
BMenu *menu, bool inexpando)
|
||||
: BMenuItem(menu, new BMessage(B_REFS_RECEIVED)),
|
||||
fWidth(width),
|
||||
fHeight(height),
|
||||
fInExpando(inexpando),
|
||||
fIcon(icon)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
TBarMenuTitle::~TBarMenuTitle()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarMenuTitle::SetWidthHeight(float width, float height)
|
||||
{
|
||||
fWidth = width;
|
||||
fHeight = height;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarMenuTitle::GetContentSize(float *width, float *height)
|
||||
{
|
||||
*width = fWidth;
|
||||
*height = fHeight;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarMenuTitle::Draw()
|
||||
{
|
||||
BMenuItem::Draw();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarMenuTitle::DrawContent()
|
||||
{
|
||||
BMenu *menu = Menu();
|
||||
BRect frame(Frame());
|
||||
rgb_color menuColor = ui_color(B_MENU_BACKGROUND_COLOR);
|
||||
rgb_color dark = tint_color(menuColor, B_DARKEN_1_TINT);
|
||||
rgb_color light = tint_color(menuColor, B_LIGHTEN_2_TINT);
|
||||
rgb_color black = {0, 0, 0, 255};
|
||||
|
||||
bool inExpandoMode = dynamic_cast<TExpandoMenuBar*>(menu) != NULL;
|
||||
|
||||
BRect bounds(menu->Window()->Bounds());
|
||||
if (bounds.right < frame.right)
|
||||
frame.right = bounds.right;
|
||||
|
||||
menu->SetDrawingMode(B_OP_COPY);
|
||||
|
||||
if (!IsSelected() && !menu->IsRedrawAfterSticky()) {
|
||||
menu->BeginLineArray(8);
|
||||
menu->AddLine(frame.RightTop(), frame.LeftTop(), light);
|
||||
menu->AddLine(frame.LeftBottom(), frame.RightBottom(), dark);
|
||||
menu->AddLine(frame.LeftTop(),
|
||||
frame.LeftBottom()+BPoint(0, inExpandoMode ? 0 : -1), light);
|
||||
menu->AddLine(frame.RightBottom(), frame.RightTop(), dark);
|
||||
if (inExpandoMode) {
|
||||
frame.top += 1;
|
||||
menu->AddLine(frame.LeftTop(), frame.RightTop() + BPoint(-1, 0), light);
|
||||
}
|
||||
|
||||
menu->EndLineArray();
|
||||
|
||||
frame.InsetBy(1, 1);
|
||||
menu->SetHighColor(menuColor);
|
||||
menu->FillRect(frame);
|
||||
menu->SetHighColor(black);
|
||||
frame.InsetBy(-1, -1);
|
||||
if (inExpandoMode)
|
||||
frame.top -= 1;
|
||||
}
|
||||
|
||||
ASSERT(IsEnabled());
|
||||
if (IsSelected() && !menu->IsRedrawAfterSticky()) {
|
||||
menu->SetHighColor(tint_color(menuColor, B_HIGHLIGHT_BACKGROUND_TINT));
|
||||
menu->FillRect(frame);
|
||||
|
||||
if (menu->IndexOf(this) > 0) {
|
||||
menu->SetHighColor(tint_color(menuColor, B_DARKEN_4_TINT));
|
||||
menu->StrokeLine(frame.LeftTop(), frame.LeftBottom());
|
||||
}
|
||||
|
||||
menu->SetHighColor(black);
|
||||
}
|
||||
|
||||
menu->SetDrawingMode(B_OP_OVER);
|
||||
|
||||
BRect dstRect(fIcon->Bounds());
|
||||
dstRect.OffsetTo(frame.LeftTop());
|
||||
dstRect.OffsetBy(rintf(((frame.Width() - dstRect.Width()) / 2) - 1.0f),
|
||||
rintf(((frame.Height() - dstRect.Height()) / 2) - 0.0f));
|
||||
|
||||
menu->DrawBitmapAsync(fIcon, dstRect);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
TBarMenuTitle::Invoke(BMessage *message)
|
||||
{
|
||||
TBarView *barview = dynamic_cast<TBarApp *>(be_app)->BarView();
|
||||
if (barview) {
|
||||
BLooper *looper = barview->Looper();
|
||||
if (looper->Lock()) {
|
||||
// tell barview to add the refs to the be menu
|
||||
barview->HandleBeMenu(NULL);
|
||||
looper->Unlock();
|
||||
}
|
||||
}
|
||||
|
||||
return BMenuItem::Invoke(message);
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
Open Tracker License
|
||||
|
||||
Terms and Conditions
|
||||
|
||||
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice applies to all licensees
|
||||
and shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of Be Incorporated shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings in
|
||||
this Software without prior written authorization from Be Incorporated.
|
||||
|
||||
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
||||
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.
|
||||
*/
|
||||
|
||||
//
|
||||
// Be Menu - Be Logo menu item in expanded mode
|
||||
// Team/App menu item in mini mode
|
||||
|
||||
#ifndef BARMENUTITLE_H
|
||||
#define BARMENUTITLE_H
|
||||
|
||||
#include <MenuItem.h>
|
||||
|
||||
class BBitmap;
|
||||
class BMenu;
|
||||
|
||||
class TBarMenuTitle : public BMenuItem {
|
||||
public:
|
||||
TBarMenuTitle(float width,float height, const BBitmap* icon,
|
||||
BMenu* menu, bool inexpando = false);
|
||||
virtual ~TBarMenuTitle();
|
||||
|
||||
void SetWidthHeight(float width, float height);
|
||||
void Draw();
|
||||
|
||||
status_t Invoke(BMessage* message);
|
||||
|
||||
protected:
|
||||
void DrawContent();
|
||||
void GetContentSize(float *width, float *height);
|
||||
|
||||
private:
|
||||
float fWidth;
|
||||
float fHeight;
|
||||
bool fInExpando;
|
||||
const BBitmap* fIcon;
|
||||
};
|
||||
|
||||
#endif /* BARMENUTITLE_H */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,218 @@
|
||||
/*
|
||||
Open Tracker License
|
||||
|
||||
Terms and Conditions
|
||||
|
||||
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice applies to all licensees
|
||||
and shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of Be Incorporated shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings in
|
||||
this Software without prior written authorization from Be Incorporated.
|
||||
|
||||
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
||||
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 BARVIEW_H
|
||||
#define BARVIEW_H
|
||||
|
||||
#include <Deskbar.h>
|
||||
#include <View.h>
|
||||
|
||||
#include "NavMenu.h"
|
||||
#include "ObjectList.h"
|
||||
|
||||
enum DeskbarShelf {
|
||||
B_DESKBAR_ANY_SHELF = 0,
|
||||
B_DESKBAR_TRAY = 1
|
||||
};
|
||||
|
||||
enum {
|
||||
kMiniState = 0,
|
||||
kExpandoState = 1,
|
||||
kFullState = 2
|
||||
};
|
||||
|
||||
const float kMiniHeight = 46.0f;
|
||||
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;
|
||||
|
||||
|
||||
class TBarView : public BView {
|
||||
public:
|
||||
TBarView(BRect frame, bool vertical, bool left, bool top,
|
||||
bool ampmMode, uint32 state, float width, bool showClock);
|
||||
~TBarView();
|
||||
|
||||
virtual void AttachedToWindow();
|
||||
virtual void Draw(BRect);
|
||||
virtual void MessageReceived(BMessage *);
|
||||
|
||||
void SaveSettings();
|
||||
void UpdatePlacement();
|
||||
void ChangeState(int32 state, bool vertical, bool left, bool top);
|
||||
|
||||
bool Vertical() const;
|
||||
bool Left() const;
|
||||
bool Top() const;
|
||||
bool AcrossTop() const;
|
||||
bool AcrossBottom() const;
|
||||
bool Expando() const;
|
||||
int32 State() const;
|
||||
|
||||
bool MilTime() const;
|
||||
void ShowClock(bool);
|
||||
bool ShowingClock() const;
|
||||
#if SA_CLOCK
|
||||
void ToggleClock();
|
||||
#endif
|
||||
|
||||
void CacheDragData(BMessage *incoming);
|
||||
status_t DragStart();
|
||||
static bool MenuTrackingHook(BMenu *menu, void *castToThis);
|
||||
void DragStop(bool full=false);
|
||||
TrackingHookData *GetTrackingHookData();
|
||||
bool Dragging() const;
|
||||
const BMessage *DragMessage() const;
|
||||
BObjectList<BString> *CachedTypesList() const;
|
||||
bool AppCanHandleTypes(const char *signature);
|
||||
void SetDragOverride(bool);
|
||||
bool DragOverride();
|
||||
bool InvokeItem(const char *signature);
|
||||
|
||||
void HandleBeMenu(BMessage *targetmessage);
|
||||
|
||||
status_t ItemInfo(int32 id, const char **name, DeskbarShelf *shelf);
|
||||
status_t ItemInfo(const char *name, int32 *id, DeskbarShelf *shelf);
|
||||
|
||||
bool ItemExists(int32 id, DeskbarShelf shelf);
|
||||
bool ItemExists(const char *name, DeskbarShelf shelf);
|
||||
|
||||
int32 CountItems(DeskbarShelf shelf);
|
||||
|
||||
status_t AddItem(BMessage *, DeskbarShelf shelf, int32 *id);
|
||||
|
||||
void RemoveItem(int32 id);
|
||||
void RemoveItem(const char *name, DeskbarShelf shelf);
|
||||
|
||||
BRect OffsetIconFrame(BRect rect) const;
|
||||
BRect IconFrame(int32 id) const;
|
||||
BRect IconFrame(const char *name) const;
|
||||
|
||||
void GetPreferredWindowSize(BRect screenFrame, float *width, float *height);
|
||||
void SizeWindow(BRect screenFrame);
|
||||
void PositionWindow(BRect screenFrame);
|
||||
|
||||
TExpandoMenuBar *ExpandoMenuBar() const;
|
||||
TBarMenuBar *BarMenuBar() const;
|
||||
friend class TBeMenu;
|
||||
|
||||
private:
|
||||
status_t SendDragMessage(const char *signature, entry_ref *ref = NULL);
|
||||
|
||||
void PlaceBeMenu();
|
||||
void PlaceTray(bool vertSwap, bool leftSwap, BRect screenFrame);
|
||||
#if SA_CLOCK
|
||||
void PlaceClock();
|
||||
#endif
|
||||
void PlaceApplicationBar(BRect screenFrame);
|
||||
|
||||
TBarMenuBar *fBarMenuBar;
|
||||
TExpandoMenuBar *fExpando;
|
||||
|
||||
int32 fTrayLocation;
|
||||
TDragRegion *fDragRegion;
|
||||
TReplicantTray *fReplicantTray;
|
||||
|
||||
bool fShowInterval;
|
||||
bool fShowClock;
|
||||
#if SA_CLOCK
|
||||
TTimeView *fClock;
|
||||
#endif
|
||||
bool fVertical;
|
||||
bool fTop;
|
||||
bool fLeft;
|
||||
|
||||
int32 fState;
|
||||
|
||||
bigtime_t fPulseRate;
|
||||
bool fRefsRcvdOnly;
|
||||
BMessage *fDragMessage;
|
||||
BObjectList<BString> *fCachedTypesList;
|
||||
TrackingHookData fTrackingHookData;
|
||||
|
||||
uint32 fMaxRecentDocs;
|
||||
uint32 fMaxRecentApps;
|
||||
|
||||
TTeamMenuItem *fLastDragItem;
|
||||
bool fClickToOpen;
|
||||
};
|
||||
|
||||
|
||||
inline TExpandoMenuBar *
|
||||
TBarView::ExpandoMenuBar() const
|
||||
{
|
||||
return fExpando;
|
||||
}
|
||||
|
||||
|
||||
inline TBarMenuBar *
|
||||
TBarView::BarMenuBar() const
|
||||
{
|
||||
return fBarMenuBar;
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
TBarView::Dragging() const
|
||||
{
|
||||
return (fCachedTypesList && fDragMessage);
|
||||
}
|
||||
|
||||
|
||||
inline const BMessage *
|
||||
TBarView::DragMessage() const
|
||||
{
|
||||
return fDragMessage;
|
||||
}
|
||||
|
||||
|
||||
inline BObjectList<BString> *
|
||||
TBarView::CachedTypesList() const
|
||||
{
|
||||
return fCachedTypesList;
|
||||
}
|
||||
|
||||
#endif /* BARVIEW_H */
|
||||
@@ -0,0 +1,589 @@
|
||||
/*
|
||||
Open Tracker License
|
||||
|
||||
Terms and Conditions
|
||||
|
||||
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice applies to all licensees
|
||||
and shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of Be Incorporated shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings in
|
||||
this Software without prior written authorization from Be Incorporated.
|
||||
|
||||
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
||||
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.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <Application.h>
|
||||
#include <Directory.h>
|
||||
#include <FindDirectory.h>
|
||||
#include <Path.h>
|
||||
#include <Debug.h>
|
||||
#include <File.h>
|
||||
#include <MenuItem.h>
|
||||
#include <MessageFilter.h>
|
||||
#include <Screen.h>
|
||||
|
||||
#include "BarWindow.h"
|
||||
#include "BarApp.h"
|
||||
#include "BarMenuBar.h"
|
||||
#include "BarView.h"
|
||||
#include "BeMenu.h"
|
||||
#include "PublicCommands.h"
|
||||
#include "StatusView.h"
|
||||
#include "tracker_private.h"
|
||||
|
||||
|
||||
// This is a very ugly hack to be able to call the private BMenuBar::StartMenuBar()
|
||||
// method from the TBarWindow::ShowBeMenu() method.
|
||||
// Don't do this at home -- but why the hell is this method private?
|
||||
#if __MWERKS__
|
||||
extern "C" void StartMenuBar__8BMenuBarFlbbP5BRect(BMenuBar *,int32,bool,bool,BRect *);
|
||||
#elif __GCC__ <= 2
|
||||
extern "C" void StartMenuBar__8BMenuBarlbT2P5BRect(BMenuBar *,int32,bool,bool,BRect *);
|
||||
#else
|
||||
# error "You may want to port this ugly hack to your compiler ABI"
|
||||
#endif
|
||||
|
||||
|
||||
TBeMenu *TBarWindow::sBeMenu = NULL;
|
||||
|
||||
|
||||
TBarWindow::TBarWindow()
|
||||
: BWindow(BRect(-1000.0f, -1000.0f, -1000.0f, -1000.0f), "Deskbar",
|
||||
B_BORDERED_WINDOW,
|
||||
B_WILL_ACCEPT_FIRST_CLICK | B_NOT_ZOOMABLE | B_NOT_CLOSABLE
|
||||
| B_NOT_MOVABLE | B_AVOID_FRONT | B_ASYNCHRONOUS_CONTROLS,
|
||||
B_ALL_WORKSPACES)
|
||||
{
|
||||
desk_settings *settings = ((TBarApp *)be_app)->Settings();
|
||||
if (settings->alwaysOnTop)
|
||||
SetFeel(B_FLOATING_ALL_WINDOW_FEEL);
|
||||
fBarView = new TBarView(Bounds(), settings->vertical,settings->left, settings->top,
|
||||
settings->ampmMode, settings->state, settings->width, settings->showTime);
|
||||
AddChild(fBarView);
|
||||
|
||||
AddShortcut('F', B_COMMAND_KEY, new BMessage(kFindButton));
|
||||
#if SA_CLOCK
|
||||
AddShortcut('H', B_COMMAND_KEY, new BMessage('clok'));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarWindow::DispatchMessage(BMessage *message, BHandler *handler)
|
||||
{
|
||||
// ToDo: check if the two following lines are doing anything...
|
||||
if (message->what == B_MOUSE_DOWN)
|
||||
Activate(true);
|
||||
|
||||
BWindow::DispatchMessage(message, handler);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarWindow::MenusBeginning()
|
||||
{
|
||||
BPath path;
|
||||
entry_ref ref;
|
||||
|
||||
find_directory (B_USER_DESKBAR_DIRECTORY, &path);
|
||||
get_ref_for_path(path.Path(), &ref);
|
||||
|
||||
BEntry entry(&ref, true);
|
||||
if (entry.InitCheck() == B_OK && entry.IsDirectory()) {
|
||||
// need the entry_ref to the actual item
|
||||
entry.GetRef(&ref);
|
||||
// set the nav directory to the be folder
|
||||
sBeMenu->SetNavDir(&ref);
|
||||
} else if (!entry.Exists()) {
|
||||
// the Be folder does not exist
|
||||
// create one now
|
||||
BDirectory dir;
|
||||
if (entry.GetParent(&dir) == B_OK) {
|
||||
BDirectory bedir;
|
||||
dir.CreateDirectory("be", &bedir);
|
||||
if (bedir.GetEntry(&entry) == B_OK
|
||||
&& entry.GetRef(&ref) == B_OK)
|
||||
sBeMenu->SetNavDir(&ref);
|
||||
}
|
||||
} else {
|
||||
// this really should never happen
|
||||
TRESPASS();
|
||||
return;
|
||||
}
|
||||
|
||||
sBeMenu->NeedsToRebuild();
|
||||
sBeMenu->ResetTargets();
|
||||
|
||||
BWindow::MenusBeginning();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarWindow::MenusEnded()
|
||||
{
|
||||
BWindow::MenusEnded();
|
||||
|
||||
BMenuItem *item = NULL;
|
||||
while ((item = sBeMenu->RemoveItem((int32)0)) != NULL)
|
||||
delete item;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarWindow::MessageReceived(BMessage *message)
|
||||
{
|
||||
switch (message->what) {
|
||||
case kFindButton:
|
||||
{
|
||||
BMessenger tracker(kTrackerSignature);
|
||||
tracker.SendMessage(message);
|
||||
break;
|
||||
}
|
||||
|
||||
#if SA_CLOCK
|
||||
case 'clok':
|
||||
fBarView->ToggleClock();
|
||||
break;
|
||||
#endif
|
||||
|
||||
case 'gloc':
|
||||
GetLocation(message);
|
||||
break;
|
||||
|
||||
case 'sloc':
|
||||
SetLocation(message);
|
||||
break;
|
||||
|
||||
case 'gexp':
|
||||
IsExpanded(message);
|
||||
break;
|
||||
|
||||
case 'sexp':
|
||||
Expand(message);
|
||||
break;
|
||||
|
||||
case 'info':
|
||||
ItemInfo(message);
|
||||
break;
|
||||
|
||||
case 'exst':
|
||||
ItemExists(message);
|
||||
break;
|
||||
|
||||
case 'cwnt':
|
||||
CountItems(message);
|
||||
break;
|
||||
|
||||
case 'adon':
|
||||
case 'icon':
|
||||
AddItem(message);
|
||||
break;
|
||||
|
||||
case 'remv':
|
||||
RemoveItem(message);
|
||||
break;
|
||||
|
||||
case 'iloc':
|
||||
GetIconFrame(message);
|
||||
break;
|
||||
|
||||
default:
|
||||
BWindow::MessageReceived(message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarWindow::SaveSettings()
|
||||
{
|
||||
fBarView->SaveSettings();
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
TBarWindow::QuitRequested()
|
||||
{
|
||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||
|
||||
return BWindow::QuitRequested();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarWindow::WorkspaceActivated(int32 workspace, bool active)
|
||||
{
|
||||
BWindow::WorkspaceActivated(workspace, active);
|
||||
|
||||
if (active && !(fBarView->Expando() && fBarView->Vertical()))
|
||||
fBarView->UpdatePlacement();
|
||||
else {
|
||||
BRect screenFrame = (BScreen(fBarView->Window())).Frame();
|
||||
fBarView->SizeWindow(screenFrame);
|
||||
fBarView->PositionWindow(screenFrame);
|
||||
fBarView->Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarWindow::ScreenChanged(BRect size, color_space depth)
|
||||
{
|
||||
BWindow::ScreenChanged(size, depth);
|
||||
|
||||
fBarView->UpdatePlacement();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarWindow::SetBeMenu(TBeMenu *menu)
|
||||
{
|
||||
sBeMenu = menu;
|
||||
}
|
||||
|
||||
|
||||
TBeMenu *
|
||||
TBarWindow::BeMenu()
|
||||
{
|
||||
return sBeMenu;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarWindow::ShowBeMenu()
|
||||
{
|
||||
BMenuBar *menuBar = fBarView->BarMenuBar();
|
||||
if (menuBar == NULL)
|
||||
menuBar = KeyMenuBar();
|
||||
|
||||
if (menuBar == NULL)
|
||||
return;
|
||||
|
||||
#if __MWERKS__
|
||||
StartMenuBar__8BMenuBarFlbbP5BRect(menuBar,0,true,true,NULL);
|
||||
#elif __GCC__ <= 2
|
||||
StartMenuBar__8BMenuBarlbT2P5BRect(menuBar,0,true,true,NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarWindow::ShowTeamMenu()
|
||||
{
|
||||
int32 index = 0;
|
||||
if (fBarView->BarMenuBar() == NULL)
|
||||
index = 2;
|
||||
|
||||
if (KeyMenuBar() == NULL)
|
||||
return;
|
||||
|
||||
#if __MWERKS__
|
||||
StartMenuBar__8BMenuBarFlbbP5BRect(KeyMenuBar(),index,true,true,NULL);
|
||||
#elif __GCC__ <= 2
|
||||
StartMenuBar__8BMenuBarlbT2P5BRect(KeyMenuBar(),index,true,true,NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/** determines the actual location of the window */
|
||||
|
||||
deskbar_location
|
||||
TBarWindow::DeskbarLocation() const
|
||||
{
|
||||
bool left = fBarView->Left();
|
||||
bool top = fBarView->Top();
|
||||
|
||||
if (fBarView->AcrossTop())
|
||||
return B_DESKBAR_TOP;
|
||||
|
||||
if (fBarView->AcrossBottom())
|
||||
return B_DESKBAR_BOTTOM;
|
||||
|
||||
if (left && top)
|
||||
return B_DESKBAR_LEFT_TOP;
|
||||
|
||||
if (!left && top)
|
||||
return B_DESKBAR_RIGHT_TOP;
|
||||
|
||||
if (left && !top)
|
||||
return B_DESKBAR_LEFT_BOTTOM;
|
||||
|
||||
return B_DESKBAR_RIGHT_BOTTOM;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarWindow::GetLocation(BMessage *message)
|
||||
{
|
||||
BMessage reply('rply');
|
||||
reply.AddInt32("location", (int32)DeskbarLocation());
|
||||
reply.AddBool("expanded", fBarView->Expando());
|
||||
|
||||
message->SendReply(&reply);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarWindow::SetDeskbarLocation(deskbar_location location, bool newExpandState)
|
||||
{
|
||||
// left top and right top are the only two that
|
||||
// currently pay attention to expand, ignore for all others
|
||||
|
||||
bool left = false, top = true, vertical, expand;
|
||||
|
||||
switch (location) {
|
||||
case B_DESKBAR_TOP:
|
||||
left = true;
|
||||
top = true;
|
||||
vertical = false;
|
||||
expand = true;
|
||||
break;
|
||||
|
||||
case B_DESKBAR_BOTTOM:
|
||||
left = true;
|
||||
top = false;
|
||||
vertical = false;
|
||||
expand = true;
|
||||
break;
|
||||
|
||||
case B_DESKBAR_LEFT_TOP:
|
||||
left = true;
|
||||
top = true;
|
||||
vertical = true;
|
||||
expand = newExpandState;
|
||||
break;
|
||||
|
||||
case B_DESKBAR_RIGHT_TOP:
|
||||
left = false;
|
||||
top = true;
|
||||
vertical = true;
|
||||
expand = newExpandState;
|
||||
break;
|
||||
|
||||
case B_DESKBAR_LEFT_BOTTOM:
|
||||
left = true;
|
||||
top = false;
|
||||
vertical = true;
|
||||
expand = false;
|
||||
break;
|
||||
|
||||
case B_DESKBAR_RIGHT_BOTTOM:
|
||||
left = false;
|
||||
top = false;
|
||||
vertical = true;
|
||||
expand = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
left = true;
|
||||
top = true;
|
||||
vertical = false;
|
||||
expand = true;
|
||||
break;
|
||||
}
|
||||
|
||||
fBarView->ChangeState(expand, vertical, left, top);
|
||||
}
|
||||
|
||||
void
|
||||
TBarWindow::SetLocation(BMessage *message)
|
||||
{
|
||||
deskbar_location location;
|
||||
bool expand;
|
||||
if (message->FindInt32("location", (int32 *)&location) == B_OK
|
||||
&& message->FindBool("expand", &expand) == B_OK)
|
||||
SetDeskbarLocation(location, expand);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarWindow::IsExpanded(BMessage *message)
|
||||
{
|
||||
BMessage reply('rply');
|
||||
reply.AddBool("expanded", fBarView->Expando());
|
||||
message->SendReply(&reply);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarWindow::Expand(BMessage *message)
|
||||
{
|
||||
bool expand;
|
||||
if (message->FindBool("expand", &expand) == B_OK) {
|
||||
bool vertical = fBarView->Vertical();
|
||||
bool left = fBarView->Left();
|
||||
bool top = fBarView->Top();
|
||||
fBarView->ChangeState(expand, vertical, left, top);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarWindow::ItemInfo(BMessage *message)
|
||||
{
|
||||
BMessage replyMsg;
|
||||
const char *name;
|
||||
int32 id;
|
||||
DeskbarShelf shelf;
|
||||
if (message->FindInt32("id", &id) == B_OK) {
|
||||
if (fBarView->ItemInfo(id, &name, &shelf) == B_OK) {
|
||||
replyMsg.AddString("name", name);
|
||||
#if SHELF_AWARE
|
||||
replyMsg.AddInt32("shelf", (int32)shelf);
|
||||
#endif
|
||||
}
|
||||
} else if (message->FindString("name", &name) == B_OK) {
|
||||
if (fBarView->ItemInfo(name, &id, &shelf) == B_OK) {
|
||||
replyMsg.AddInt32("id", id);
|
||||
#if SHELF_AWARE
|
||||
replyMsg.AddInt32("shelf", (int32)shelf);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
message->SendReply(&replyMsg);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarWindow::ItemExists(BMessage *message)
|
||||
{
|
||||
BMessage replyMsg;
|
||||
const char *name;
|
||||
int32 id;
|
||||
DeskbarShelf shelf;
|
||||
|
||||
#if SHELF_AWARE
|
||||
if (message->FindInt32("shelf", (int32 *)&shelf) != B_OK)
|
||||
#endif
|
||||
shelf = B_DESKBAR_TRAY;
|
||||
|
||||
bool exists = false;
|
||||
if (message->FindInt32("id", &id) == B_OK)
|
||||
exists = fBarView->ItemExists(id, shelf);
|
||||
else if (message->FindString("name", &name) == B_OK)
|
||||
exists = fBarView->ItemExists(name, shelf);
|
||||
|
||||
replyMsg.AddBool("exists", exists);
|
||||
message->SendReply(&replyMsg);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarWindow::CountItems(BMessage *message)
|
||||
{
|
||||
DeskbarShelf shelf;
|
||||
|
||||
#if SHELF_AWARE
|
||||
if (message->FindInt32("shelf", (int32 *)&shelf) != B_OK)
|
||||
#endif
|
||||
shelf = B_DESKBAR_TRAY;
|
||||
|
||||
BMessage reply('rply');
|
||||
reply.AddInt32("count", fBarView->CountItems(shelf));
|
||||
message->SendReply(&reply);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarWindow::AddItem(BMessage *message)
|
||||
{
|
||||
DeskbarShelf shelf;
|
||||
entry_ref ref;
|
||||
int32 id = 999;
|
||||
BMessage reply;
|
||||
status_t err = B_ERROR;
|
||||
|
||||
BMessage archivedView;
|
||||
if (message->FindMessage("view", &archivedView) == B_OK) {
|
||||
#if SHELF_AWARE
|
||||
if (message->FindInt32("shelf", (int32 *)&shelf) != B_OK)
|
||||
#endif
|
||||
shelf = B_DESKBAR_TRAY;
|
||||
|
||||
err = fBarView->AddItem(new BMessage(archivedView), shelf, &id);
|
||||
} else if (message->FindRef("addon", &ref) == B_OK) {
|
||||
//
|
||||
// exposing the name of the view here is not so great
|
||||
TReplicantTray *tray = dynamic_cast<TReplicantTray *>(FindView("Status"));
|
||||
if (tray) {
|
||||
// Force this into the deskbar even if the security code is wrong
|
||||
// This is OK because the user specifically asked for this replicant
|
||||
BEntry entry(&ref);
|
||||
err = tray->LoadAddOn(&entry, &id, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (err == B_OK)
|
||||
reply.AddInt32("id", id);
|
||||
else
|
||||
reply.AddInt32("error", err);
|
||||
|
||||
message->SendReply(&reply);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarWindow::RemoveItem(BMessage *message)
|
||||
{
|
||||
int32 id;
|
||||
const char *name;
|
||||
|
||||
// ids ought to be unique across all shelves, assuming, of course,
|
||||
// that sometime in the future there may be more than one
|
||||
#if SHELF_AWARE
|
||||
if (message->FindInt32("shelf", (int32 *)&shelf) == B_OK) {
|
||||
if (message->FindString("name", &name) == B_OK)
|
||||
fBarView->RemoveItem(name, shelf);
|
||||
} else {
|
||||
#endif
|
||||
if (message->FindInt32("id", &id) == B_OK) {
|
||||
fBarView->RemoveItem(id);
|
||||
// remove the following two lines if and when the
|
||||
// shelf option returns
|
||||
} else if (message->FindString("name", &name) == B_OK)
|
||||
fBarView->RemoveItem(name, B_DESKBAR_TRAY);
|
||||
|
||||
#if SHELF_AWARE
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarWindow::GetIconFrame(BMessage *message)
|
||||
{
|
||||
BRect frame(0, 0, 0, 0);
|
||||
|
||||
const char *name;
|
||||
int32 id;
|
||||
if (message->FindInt32("id", &id) == B_OK)
|
||||
frame = fBarView->IconFrame(id);
|
||||
else if (message->FindString("name", &name) == B_OK)
|
||||
frame = fBarView->IconFrame(name);
|
||||
|
||||
BMessage reply('rply');
|
||||
reply.AddRect("frame", frame);
|
||||
message->SendReply(&reply);
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
Open Tracker License
|
||||
|
||||
Terms and Conditions
|
||||
|
||||
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice applies to all licensees
|
||||
and shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of Be Incorporated shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings in
|
||||
this Software without prior written authorization from Be Incorporated.
|
||||
|
||||
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
||||
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_WINDOW_H
|
||||
#define BAR_WINDOW_H
|
||||
|
||||
#include <Deskbar.h>
|
||||
#include <Window.h>
|
||||
|
||||
class TBeMenu;
|
||||
class TBarView;
|
||||
|
||||
class TBarWindow : public BWindow {
|
||||
public:
|
||||
TBarWindow();
|
||||
|
||||
virtual void MenusBeginning();
|
||||
virtual void MenusEnded();
|
||||
virtual bool QuitRequested();
|
||||
virtual void WorkspaceActivated(int32 ws, bool activate);
|
||||
virtual void ScreenChanged(BRect size, color_space depth);
|
||||
virtual void DispatchMessage(BMessage *message, BHandler *handler);
|
||||
virtual void MessageReceived(BMessage *m);
|
||||
|
||||
void SaveSettings();
|
||||
TBarView* BarView() const { return fBarView; };
|
||||
static void SetBeMenu(TBeMenu *menu);
|
||||
TBeMenu* BeMenu();
|
||||
|
||||
void ShowBeMenu();
|
||||
void ShowTeamMenu();
|
||||
|
||||
void GetLocation(BMessage*);
|
||||
deskbar_location DeskbarLocation() const;
|
||||
void SetLocation(BMessage*);
|
||||
void SetDeskbarLocation(deskbar_location location, bool expand);
|
||||
|
||||
void IsExpanded(BMessage*);
|
||||
void Expand(BMessage*);
|
||||
|
||||
void ItemInfo(BMessage*);
|
||||
void ItemExists(BMessage*);
|
||||
|
||||
void CountItems(BMessage*);
|
||||
|
||||
void AddItem(BMessage*);
|
||||
void RemoveItem(BMessage*);
|
||||
|
||||
void GetIconFrame(BMessage*);
|
||||
|
||||
private:
|
||||
static TBeMenu *sBeMenu;
|
||||
TBarView *fBarView;
|
||||
};
|
||||
|
||||
#endif /* BAR_WINDOW_H */
|
||||
@@ -0,0 +1,805 @@
|
||||
/*
|
||||
Open Tracker License
|
||||
|
||||
Terms and Conditions
|
||||
|
||||
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice applies to all licensees
|
||||
and shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of Be Incorporated shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings in
|
||||
this Software without prior written authorization from Be Incorporated.
|
||||
|
||||
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
||||
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.
|
||||
*/
|
||||
|
||||
#include <Debug.h>
|
||||
#include <Bitmap.h>
|
||||
#include <Dragger.h>
|
||||
#include <Menu.h>
|
||||
#include <MenuItem.h>
|
||||
#include <Roster.h>
|
||||
|
||||
#include "BeMenu.h"
|
||||
#include "BarApp.h"
|
||||
#include "BarView.h"
|
||||
#include "DeskBarUtils.h"
|
||||
#include "PublicCommands.h"
|
||||
#include "RecentItems.h"
|
||||
#include "StatusView.h"
|
||||
#include "IconMenuItem.h"
|
||||
|
||||
// from roster_private.h
|
||||
const uint32 CMD_SHUTDOWN_SYSTEM = 301;
|
||||
const uint32 CMD_REBOOT_SYSTEM = 302;
|
||||
const uint32 CMD_SUSPEND_SYSTEM = 304;
|
||||
|
||||
#define ROSTER_SIG "application/x-vnd.Be-ROST"
|
||||
|
||||
#ifdef B_BEOS_VERSION_5
|
||||
void run_be_about();
|
||||
#endif
|
||||
|
||||
#ifdef MOUNT_MENU_IN_DESKBAR
|
||||
|
||||
class MountMenu : public BMenu {
|
||||
public:
|
||||
MountMenu(const char *name);
|
||||
virtual bool AddDynamicItem(add_state s);
|
||||
};
|
||||
|
||||
|
||||
class MountMenuItem : public BMenuItem {
|
||||
public:
|
||||
MountMenuItem(const char *label, BMessage *message, BBitmap *icon );
|
||||
virtual ~MountMenuItem();
|
||||
virtual void GetContentSize(float *width, float *height);
|
||||
virtual void DrawContent();
|
||||
|
||||
private:
|
||||
BBitmap *deviceIcon;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//#define SHOW_RECENT_FIND_ITEMS
|
||||
|
||||
namespace BPrivate {
|
||||
BMenu *TrackerBuildRecentFindItemsMenu(const char *);
|
||||
}
|
||||
using namespace BPrivate;
|
||||
|
||||
//********************************************************************************
|
||||
|
||||
|
||||
TBeMenu::TBeMenu(TBarView *barview)
|
||||
: BNavMenu("BeMenu", B_REFS_RECEIVED, BMessenger(kTrackerSignature)),
|
||||
fAddState(kStart),
|
||||
fBarView(barview)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBeMenu::AttachedToWindow()
|
||||
{
|
||||
if (fBarView && fBarView->LockLooper()) {
|
||||
if (fBarView->Dragging()) {
|
||||
SetTypesList(fBarView->CachedTypesList());
|
||||
SetTarget(BMessenger(fBarView));
|
||||
SetTrackingHookDeep(this, fBarView->MenuTrackingHook,
|
||||
fBarView->GetTrackingHookData());
|
||||
fBarView->DragStart();
|
||||
} else {
|
||||
SetTypesList(NULL);
|
||||
SetTarget(BMessenger(kTrackerSignature));
|
||||
SetTrackingHookDeep(this, NULL, NULL);
|
||||
}
|
||||
|
||||
fBarView->UnlockLooper();
|
||||
}
|
||||
|
||||
BNavMenu::AttachedToWindow();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBeMenu::DetachedFromWindow()
|
||||
{
|
||||
if (fBarView) {
|
||||
BLooper* looper = fBarView->Looper();
|
||||
if (looper && looper->Lock()) {
|
||||
fBarView->DragStop();
|
||||
looper->Unlock();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// don't call BNavMenu::DetachedFromWindow
|
||||
// it sets the TypesList to NULL
|
||||
//
|
||||
BMenu::DetachedFromWindow();
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
TBeMenu::StartBuildingItemList()
|
||||
{
|
||||
int32 count = CountItems()-1;
|
||||
for (int32 index = count; index >= 0; index--) {
|
||||
BMenuItem *item = ItemAt(index);
|
||||
ASSERT(item);
|
||||
|
||||
RemoveItem(index);
|
||||
delete item;
|
||||
}
|
||||
fAddState = kStart;
|
||||
return BNavMenu::StartBuildingItemList();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBeMenu::DoneBuildingItemList()
|
||||
{
|
||||
if (fItemList->CountItems() <= 0) {
|
||||
BMenuItem *item = new BMenuItem("<Be folder is empty>", 0);
|
||||
item->SetEnabled(false);
|
||||
AddItem(item);
|
||||
} else
|
||||
BNavMenu::DoneBuildingItemList();
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
TBeMenu::AddNextItem()
|
||||
{
|
||||
if (fAddState == kStart)
|
||||
return AddStandardBeMenuItems();
|
||||
|
||||
TrackingHookData *data = fBarView->GetTrackingHookData();
|
||||
if (fAddState == kAddingRecents) {
|
||||
const char *recentTitle[] = {"Recent Documents", "Recent Folders", "Recent Applications"};
|
||||
const int recentType[] = {kRecentDocuments, kRecentFolders, kRecentApplications};
|
||||
const int recentTypes = 3;
|
||||
TRecentsMenu *recentItem[recentTypes];
|
||||
int count = 0;
|
||||
|
||||
for (int i = 0; i < recentTypes; i++) {
|
||||
recentItem[i] = new TRecentsMenu(recentTitle[i], fBarView, recentType[i]);
|
||||
if (recentItem[i])
|
||||
count += recentItem[i]->RecentsCount();
|
||||
}
|
||||
if (count > 0) {
|
||||
AddSeparatorItem();
|
||||
|
||||
for (int i = 0;i < recentTypes;i++) {
|
||||
if (!recentItem[i])
|
||||
continue;
|
||||
|
||||
if (recentItem[i]->RecentsCount() > 0) {
|
||||
recentItem[i]->SetTypesList(TypesList());
|
||||
recentItem[i]->SetTarget(Target());
|
||||
AddItem(recentItem[i]);
|
||||
}
|
||||
|
||||
if (data && fBarView && fBarView->Dragging()) {
|
||||
recentItem[i]->InitTrackingHook(data->fTrackingHook,
|
||||
&data->fTarget, data->fDragMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AddSeparatorItem();
|
||||
fAddState = kAddingBeMenu;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (fAddState == kAddingBeMenu) {
|
||||
// keep reentering and adding items
|
||||
// until this returns false
|
||||
bool done = BNavMenu::AddNextItem();
|
||||
BMenuItem *item = ItemAt(CountItems() - 1);
|
||||
if (item) {
|
||||
BNavMenu *menu = dynamic_cast<BNavMenu *>(item->Menu());
|
||||
if (menu) {
|
||||
if (data && fBarView->Dragging()) {
|
||||
menu->InitTrackingHook(data->fTrackingHook,
|
||||
&data->fTarget, data->fDragMessage);
|
||||
} else
|
||||
menu->InitTrackingHook(0, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
if (!done)
|
||||
fAddState = kDone;
|
||||
return done;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
TBeMenu::AddStandardBeMenuItems()
|
||||
{
|
||||
bool dragging=false;
|
||||
if (fBarView)
|
||||
dragging = fBarView->Dragging();
|
||||
|
||||
BMenuItem* item = new BMenuItem("About BeOS", new BMessage(kShowSplash));
|
||||
item->SetEnabled(!dragging);
|
||||
AddItem(item);
|
||||
|
||||
#ifdef SHOW_RECENT_FIND_ITEMS
|
||||
item = new BMenuItem(TrackerBuildRecentFindItemsMenu("Find"B_UTF8_ELLIPSIS),
|
||||
new BMessage(kFindButton));
|
||||
#else
|
||||
item = new BMenuItem("Find"B_UTF8_ELLIPSIS, new BMessage(kFindButton));
|
||||
#endif
|
||||
item->SetEnabled(!dragging);
|
||||
AddItem(item);
|
||||
|
||||
item = new BMenuItem("Show Replicants", new BMessage(msg_ToggleDraggers));
|
||||
item->SetEnabled(!dragging);
|
||||
item->SetMarked(BDragger::AreDraggersDrawn());
|
||||
AddItem(item);
|
||||
|
||||
#ifdef MOUNT_MENU_IN_DESKBAR
|
||||
MountMenu *mountMenu = new MountMenu("Mount Disks");
|
||||
mountMenu->SetEnabled(!dragging);
|
||||
AddItem(mountMenu);
|
||||
#endif
|
||||
|
||||
// insert preferences menu
|
||||
BMenu *subMenu = new BMenu("Deskbar Settings");
|
||||
subMenu->SetEnabled(!dragging);
|
||||
|
||||
item = new BMenuItem("Configure Be Menu"B_UTF8_ELLIPSIS, new BMessage(msg_config_db));
|
||||
item->SetTarget(be_app);
|
||||
subMenu->AddItem(item);
|
||||
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
subMenu->AddItem(item);
|
||||
|
||||
subMenu->AddSeparatorItem();
|
||||
|
||||
TReplicantTray *replicantTray = ((TBarApp *)be_app)->BarView()->fReplicantTray;
|
||||
|
||||
item = new BMenuItem("24 Hour Clock", new BMessage(kMsgMilTime));
|
||||
item->SetTarget(replicantTray);
|
||||
item->SetEnabled(((TBarApp *)be_app)->BarView()->ShowingClock());
|
||||
item->SetMarked(replicantTray->ShowingMiltime());
|
||||
subMenu->AddItem(item);
|
||||
|
||||
item = new BMenuItem("Show Seconds", new BMessage(kMsgShowSeconds));
|
||||
item->SetTarget(replicantTray);
|
||||
item->SetEnabled(((TBarApp *)be_app)->BarView()->ShowingClock());
|
||||
item->SetMarked(replicantTray->ShowingSeconds());
|
||||
subMenu->AddItem(item);
|
||||
|
||||
item = new BMenuItem("European Date", new BMessage(kMsgEuroDate));
|
||||
item->SetTarget(replicantTray);
|
||||
item->SetEnabled(((TBarApp *)be_app)->BarView()->ShowingClock());
|
||||
item->SetMarked(replicantTray->ShowingEuroDate());
|
||||
subMenu->AddItem(item);
|
||||
|
||||
item = new BMenuItem("Full Date", new BMessage(kMsgFullDate));
|
||||
item->SetTarget(replicantTray);
|
||||
item->SetEnabled(replicantTray->CanShowFullDate());
|
||||
item->SetMarked(replicantTray->ShowingFullDate());
|
||||
subMenu->AddItem(item);
|
||||
|
||||
subMenu->AddSeparatorItem();
|
||||
|
||||
item = new BMenuItem("Show Application Expander", new BMessage(msg_superExpando));
|
||||
item->SetTarget(be_app);
|
||||
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->SetEnabled(static_cast<TBarApp *>(be_app)->Settings()->superExpando);
|
||||
subMenu->AddItem(item);
|
||||
|
||||
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)) {
|
||||
subMenu = new BMenu("Window Decor");
|
||||
subMenu->SetEnabled(!dragging);
|
||||
|
||||
item = new BMenuItem("BeOS", new BMessage(msg_Be));
|
||||
item->SetTarget(be_app);
|
||||
item->SetEnabled(!dragging);
|
||||
subMenu->AddItem(item);
|
||||
|
||||
item = new BMenuItem("AmigaOS", new BMessage(msg_Amiga));
|
||||
item->SetTarget(be_app);
|
||||
item->SetEnabled(!dragging);
|
||||
subMenu->AddItem(item);
|
||||
|
||||
item = new BMenuItem("MacOS 8", new BMessage(msg_Mac));
|
||||
item->SetTarget(be_app);
|
||||
item->SetEnabled(!dragging);
|
||||
subMenu->AddItem(item);
|
||||
|
||||
item = new BMenuItem("Windows 95/98", new BMessage(msg_Win95));
|
||||
item->SetTarget(be_app);
|
||||
item->SetEnabled(!dragging);
|
||||
subMenu->AddItem(item);
|
||||
|
||||
subMenu->SetFont(be_plain_font);
|
||||
AddItem(subMenu);
|
||||
};
|
||||
|
||||
AddSeparatorItem();
|
||||
|
||||
item = new BMenuItem("Restart", new BMessage(CMD_REBOOT_SYSTEM));
|
||||
item->SetEnabled(!dragging);
|
||||
AddItem(item);
|
||||
|
||||
#ifdef APM_SUPPORT
|
||||
if (_kapm_control_(APM_CHECK_ENABLED) == B_OK) {
|
||||
item = new BMenuItem("Suspend", new BMessage(CMD_SUSPEND_SYSTEM));
|
||||
item->SetEnabled(!dragging);
|
||||
AddItem(item);
|
||||
}
|
||||
#endif
|
||||
|
||||
item = new BMenuItem("Shut Down", new BMessage(CMD_SHUTDOWN_SYSTEM));
|
||||
item->SetEnabled(!dragging);
|
||||
AddItem(item);
|
||||
|
||||
fAddState = kAddingRecents;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBeMenu::ClearMenuBuildingState()
|
||||
{
|
||||
fAddState = kDone;
|
||||
fMenuBuilt = false;
|
||||
// force the menu to get rebuilt each time
|
||||
BNavMenu::ClearMenuBuildingState();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBeMenu::ResetTargets()
|
||||
{
|
||||
BNavMenu::ResetTargets();
|
||||
|
||||
//
|
||||
// if we are dragging, set the target to whatever was set
|
||||
// else set it to the default (Tracker)
|
||||
//
|
||||
if (!fBarView->Dragging())
|
||||
SetTarget(BMessenger(kTrackerSignature));
|
||||
//
|
||||
// now set the target for the menuitems to the currently
|
||||
// set target, which may or may not be tracker
|
||||
//
|
||||
SetTargetForItems(Target());
|
||||
|
||||
for (int32 i = 0; ; i++) {
|
||||
BMenuItem *item = ItemAt(i);
|
||||
if (item == NULL)
|
||||
break;
|
||||
|
||||
if (item->Message()) {
|
||||
switch (item->Message()->what) {
|
||||
case kShowSplash:
|
||||
#ifdef B_BEOS_VERSION_5
|
||||
#if 0
|
||||
run_be_about();
|
||||
// about box in libbe in BeOS R5
|
||||
#endif
|
||||
#endif
|
||||
break;
|
||||
case kFindButton:
|
||||
// about, find
|
||||
item->SetTarget(BMessenger(kTrackerSignature));
|
||||
break;
|
||||
|
||||
case msg_ToggleDraggers:
|
||||
case msg_config_db:
|
||||
case msg_AlwaysTop:
|
||||
case kMsgShowSeconds:
|
||||
case kMsgMilTime:
|
||||
case kMsgEuroDate:
|
||||
// show/hide replicants
|
||||
item->SetTarget(be_app);
|
||||
break;
|
||||
|
||||
case CMD_REBOOT_SYSTEM:
|
||||
case CMD_SUSPEND_SYSTEM:
|
||||
case CMD_SHUTDOWN_SYSTEM:
|
||||
// restart/shutdown
|
||||
item->SetTarget(BMessenger(ROSTER_SIG));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BPoint
|
||||
TBeMenu::ScreenLocation()
|
||||
{
|
||||
BPoint pt;
|
||||
BRect r;
|
||||
bool vertical = fBarView->Vertical();
|
||||
int32 expando = (fBarView->State() == kExpandoState);
|
||||
|
||||
r = Supermenu()->Bounds();
|
||||
Supermenu()->ConvertToScreen(&r);
|
||||
if (expando && vertical && fBarView->Left()) {
|
||||
PRINT(("Left\n"));
|
||||
pt = r.RightTop() + BPoint(0,3);
|
||||
} else if (expando && vertical && !fBarView->Left()) {
|
||||
PRINT(("Right\n"));
|
||||
pt = r.LeftTop() - BPoint(Bounds().Width(), 0) + BPoint(0,3);
|
||||
} else {
|
||||
pt = BMenu::ScreenLocation();
|
||||
}
|
||||
return pt;
|
||||
}
|
||||
|
||||
|
||||
//********************************************************************************
|
||||
// #pragma mark -
|
||||
//
|
||||
|
||||
|
||||
TRecentsMenu::TRecentsMenu(const char *name, TBarView *bar, int32 which, const char *signature, entry_ref *appRef)
|
||||
: BNavMenu(name, B_REFS_RECEIVED, BMessenger(kTrackerSignature)),
|
||||
fWhich(which),
|
||||
fAppRef(NULL),
|
||||
fSignature(NULL),
|
||||
fRecentsCount(0),
|
||||
fItemIndex(0),
|
||||
fBarView(bar)
|
||||
{
|
||||
TBarApp *app = dynamic_cast<TBarApp *>(be_app);
|
||||
if (app == NULL)
|
||||
return;
|
||||
|
||||
switch (which) {
|
||||
case kRecentDocuments:
|
||||
fRecentsCount = app->Settings()->recentDocsCount;
|
||||
break;
|
||||
case kRecentApplications:
|
||||
fRecentsCount = app->Settings()->recentAppsCount;
|
||||
break;
|
||||
case kRecentAppDocuments:
|
||||
fRecentsCount = app->Settings()->recentDocsCount;
|
||||
if (signature != NULL)
|
||||
fSignature = strdup(signature);
|
||||
if (appRef != NULL)
|
||||
fAppRef = new entry_ref(*appRef);
|
||||
break;
|
||||
case kRecentFolders:
|
||||
fRecentsCount = app->Settings()->recentFoldersCount;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TRecentsMenu::~TRecentsMenu()
|
||||
{
|
||||
delete fAppRef;
|
||||
free(fSignature);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TRecentsMenu::DetachedFromWindow()
|
||||
{
|
||||
//
|
||||
// BNavMenu::DetachedFromWindow sets the TypesList to NULL
|
||||
//
|
||||
BMenu::DetachedFromWindow();
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
TRecentsMenu::StartBuildingItemList()
|
||||
{
|
||||
int32 count = CountItems()-1;
|
||||
for (int32 index = count; index >= 0; index--) {
|
||||
BMenuItem *item = ItemAt(index);
|
||||
ASSERT(item);
|
||||
|
||||
RemoveItem(index);
|
||||
delete item;
|
||||
}
|
||||
//
|
||||
// !! note: don't call inherited from here
|
||||
// the navref is not set for this menu
|
||||
// but it still needs to be a draggable navmenu
|
||||
// simply return true so that AddNextItem is called
|
||||
//
|
||||
// return BNavMenu::StartBuildingItemList();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
TRecentsMenu::AddNextItem()
|
||||
{
|
||||
if (fRecentsCount > 0 && AddRecents(fRecentsCount))
|
||||
return true;
|
||||
|
||||
fItemIndex = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
TRecentsMenu::AddRecents(int32 count)
|
||||
{
|
||||
if (fItemIndex == 0) {
|
||||
fRecentList.MakeEmpty();
|
||||
BRoster roster;
|
||||
|
||||
switch (fWhich) {
|
||||
case kRecentDocuments:
|
||||
roster.GetRecentDocuments(&fRecentList, count);
|
||||
break;
|
||||
case kRecentApplications:
|
||||
roster.GetRecentApps(&fRecentList, count);
|
||||
break;
|
||||
case kRecentAppDocuments:
|
||||
roster.GetRecentDocuments(&fRecentList, count, NULL, fSignature);
|
||||
break;
|
||||
case kRecentFolders:
|
||||
roster.GetRecentFolders(&fRecentList, count);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
entry_ref ref;
|
||||
if (fRecentList.FindRef("refs", fItemIndex++, &ref) != B_OK)
|
||||
break;
|
||||
|
||||
if (ref.name && strlen(ref.name) > 0) {
|
||||
Model model(&ref, true);
|
||||
|
||||
if (fWhich != kRecentApplications) {
|
||||
BMessage *message = new BMessage(B_REFS_RECEIVED);
|
||||
if (fWhich == kRecentAppDocuments) {
|
||||
// add application as handler
|
||||
message->AddRef("handler", fAppRef);
|
||||
}
|
||||
|
||||
ModelMenuItem *item = BNavMenu::NewModelItem(&model,
|
||||
message, Target(), false, NULL, TypesList());
|
||||
|
||||
if (item)
|
||||
AddItem(item);
|
||||
} else {
|
||||
// The application items expand to a list of recent documents
|
||||
// for that application - so they must be handled extra
|
||||
BFile file(&ref, B_READ_ONLY);
|
||||
char signature[B_MIME_TYPE_LENGTH];
|
||||
|
||||
BAppFileInfo appInfo(&file);
|
||||
if (appInfo.InitCheck() != B_OK
|
||||
|| appInfo.GetSignature(signature) != B_OK)
|
||||
continue;
|
||||
|
||||
ModelMenuItem *item = NULL;
|
||||
BMessage doc;
|
||||
be_roster->GetRecentDocuments(&doc, 1, NULL, signature);
|
||||
// ToDo: check if the documents do exist at all to
|
||||
// avoid the creation of the submenu.
|
||||
|
||||
if (doc.CountNames(B_REF_TYPE) > 0) {
|
||||
// create recents menu that will contain the recent docs of this app
|
||||
TRecentsMenu *docs = new TRecentsMenu(ref.name, fBarView,
|
||||
kRecentAppDocuments, signature, &ref);
|
||||
docs->SetTypesList(TypesList());
|
||||
docs->SetTarget(Target());
|
||||
|
||||
item = new ModelMenuItem(&model, docs);
|
||||
} else
|
||||
item = new ModelMenuItem(&model, ref.name, NULL);
|
||||
|
||||
if (item) {
|
||||
// add refs-message so that the recent app can be launched
|
||||
BMessage *msg = new BMessage(B_REFS_RECEIVED);
|
||||
msg->AddRef("refs", &ref);
|
||||
item->SetMessage(msg);
|
||||
item->SetTarget(Target());
|
||||
|
||||
AddItem(item);
|
||||
}
|
||||
}
|
||||
|
||||
// return true so that we know to reenter this list
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// return false if we are done with this list
|
||||
//
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TRecentsMenu::DoneBuildingItemList()
|
||||
{
|
||||
//
|
||||
// !! note: don't call inherited here
|
||||
// the object list is not built
|
||||
// and this list does not need to be sorted
|
||||
// BNavMenu::DoneBuildingItemList();
|
||||
//
|
||||
|
||||
if (CountItems() > 0)
|
||||
SetTargetForItems(Target());
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TRecentsMenu::ClearMenuBuildingState()
|
||||
{
|
||||
fMenuBuilt = false;
|
||||
BNavMenu::ClearMenuBuildingState();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TRecentsMenu::ResetTargets()
|
||||
{
|
||||
BNavMenu::ResetTargets();
|
||||
//
|
||||
// if we are dragging, set the target to whatever was set
|
||||
// else set it to the default (Tracker)
|
||||
//
|
||||
if (!fBarView->Dragging())
|
||||
SetTarget(BMessenger(kTrackerSignature));
|
||||
//
|
||||
// now set the target for the menuitems to the currently
|
||||
// set target, which may or may not be tracker
|
||||
//
|
||||
SetTargetForItems(Target());
|
||||
}
|
||||
|
||||
|
||||
//********************************************************************************
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
#ifdef MOUNT_MENU_IN_DESKBAR
|
||||
|
||||
MountMenu::MountMenu(const char *name)
|
||||
: BMenu(name)
|
||||
{
|
||||
SetFont(be_plain_font);
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
MountMenu::AddDynamicItem(add_state s)
|
||||
{
|
||||
BMenuItem *item;
|
||||
while ((item = RemoveItem(0L)) != NULL)
|
||||
delete item;
|
||||
|
||||
//
|
||||
// Send message to tracker to get items.
|
||||
//
|
||||
BMessage request('gmtv');
|
||||
BMessage reply;
|
||||
BMessenger(kTrackerSignature).SendMessage(&request,
|
||||
&reply);
|
||||
|
||||
//
|
||||
// populate menu
|
||||
//
|
||||
type_code code;
|
||||
int32 countFound;
|
||||
reply.GetInfo("DisplayName", &code, &countFound);
|
||||
for (int32 vol = 0; vol < countFound; vol++) {
|
||||
BBitmap *icon = new BBitmap(BRect(0,0,15,15),B_COLOR_8_BIT);
|
||||
get_device_icon(reply.FindString("DeviceName", vol), icon->Bits(), B_MINI_ICON);
|
||||
BMessage *invokeMessage = new BMessage;
|
||||
reply.FindMessage("InvokeMessage", vol, invokeMessage);
|
||||
AddItem(new MountMenuItem(reply.FindString("DisplayName", vol),
|
||||
invokeMessage, icon));
|
||||
}
|
||||
|
||||
if (countFound > 0)
|
||||
AddSeparatorItem();
|
||||
|
||||
BMenuItem *mountAll = new BMenuItem("All Disks", new BMessage('mntn'));
|
||||
AddItem(mountAll);
|
||||
mountAll->SetEnabled(countFound > 0);
|
||||
BMenuItem *mountSettings = new BMenuItem("Settings", new BMessage('Tram'));
|
||||
AddItem(mountSettings);
|
||||
|
||||
SetTargetForItems(BMessenger(kTrackerSignature));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
MountMenuItem::MountMenuItem(const char *label, BMessage *message, BBitmap *icon)
|
||||
: BMenuItem(label,message),
|
||||
deviceIcon(icon)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
MountMenuItem::~MountMenuItem()
|
||||
{
|
||||
delete deviceIcon;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MountMenuItem::GetContentSize(float *width, float *height)
|
||||
{
|
||||
BMenuItem::GetContentSize(width, height);
|
||||
*width += 20;
|
||||
*height += 3;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MountMenuItem::DrawContent()
|
||||
{
|
||||
BPoint loc = ContentLocation();
|
||||
loc.x += 20;
|
||||
Menu()->MovePenTo(loc);
|
||||
BMenuItem::DrawContent();
|
||||
|
||||
BPoint where(ContentLocation());
|
||||
where.y = Frame().top;
|
||||
Menu()->SetDrawingMode(B_OP_OVER);
|
||||
Menu()->DrawBitmapAsync(deviceIcon, where);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
Open Tracker License
|
||||
|
||||
Terms and Conditions
|
||||
|
||||
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice applies to all licensees
|
||||
and shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of Be Incorporated shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings in
|
||||
this Software without prior written authorization from Be Incorporated.
|
||||
|
||||
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
||||
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 _BE_MENU_H_
|
||||
#define _BE_MENU_H_
|
||||
|
||||
|
||||
#include "NavMenu.h"
|
||||
|
||||
|
||||
class TBarView;
|
||||
|
||||
enum recent_type {
|
||||
kRecentDocuments = 0,
|
||||
kRecentApplications,
|
||||
kRecentFolders,
|
||||
kRecentAppDocuments
|
||||
};
|
||||
|
||||
class TRecentsMenu : public BNavMenu {
|
||||
public:
|
||||
TRecentsMenu(const char *name, TBarView *bar, int32 which,
|
||||
const char *signature = NULL, entry_ref *appRef = NULL);
|
||||
virtual ~TRecentsMenu();
|
||||
|
||||
void DetachedFromWindow();
|
||||
void ResetTargets();
|
||||
|
||||
int32 RecentsCount();
|
||||
|
||||
private:
|
||||
virtual bool StartBuildingItemList();
|
||||
virtual bool AddNextItem();
|
||||
bool AddRecents(int32 count);
|
||||
virtual void DoneBuildingItemList();
|
||||
virtual void ClearMenuBuildingState();
|
||||
|
||||
private:
|
||||
int32 fWhich;
|
||||
entry_ref *fAppRef;
|
||||
char *fSignature;
|
||||
int32 fRecentsCount;
|
||||
|
||||
int32 fItemIndex;
|
||||
BMessage fRecentList;
|
||||
|
||||
TBarView *fBarView;
|
||||
};
|
||||
|
||||
|
||||
inline int32
|
||||
TRecentsMenu::RecentsCount()
|
||||
{
|
||||
return fRecentsCount;
|
||||
}
|
||||
|
||||
|
||||
class TBeMenu : public BNavMenu {
|
||||
public:
|
||||
TBeMenu(TBarView *bar);
|
||||
|
||||
void AttachedToWindow();
|
||||
void DetachedFromWindow();
|
||||
|
||||
void ResetTargets();
|
||||
|
||||
private:
|
||||
enum State {
|
||||
kStart,
|
||||
kAddingRecents,
|
||||
kAddingBeMenu,
|
||||
kDone
|
||||
};
|
||||
protected:
|
||||
BPoint ScreenLocation();
|
||||
|
||||
bool AddStandardBeMenuItems();
|
||||
|
||||
private:
|
||||
virtual bool StartBuildingItemList();
|
||||
virtual void DoneBuildingItemList();
|
||||
virtual bool AddNextItem();
|
||||
virtual void ClearMenuBuildingState();
|
||||
|
||||
// to keep track of the menu building state
|
||||
State fAddState;
|
||||
TBarView *fBarView;
|
||||
};
|
||||
|
||||
#endif /* _BE_MENU_H_ */
|
||||
@@ -0,0 +1,176 @@
|
||||
/*
|
||||
* Copyright 2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#ifdef _SHOW_CALENDAR_MENU_ITEM
|
||||
// as specified in the makefile
|
||||
|
||||
#include "CalendarMenuItem.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
|
||||
static const int32 kDaysPerMonth[] = {31, 28, 31, 30, 31, 30, 30, 31, 30, 31, 30, 31};
|
||||
// Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
|
||||
|
||||
static const int32 kTitleFontSize = 9;
|
||||
|
||||
static const int32 kTitleGap = 3;
|
||||
static const int32 kColumnGap = 9;
|
||||
static const int32 kRowGap = 2;
|
||||
|
||||
|
||||
static bool
|
||||
is_leap_year(int32 year)
|
||||
{
|
||||
return !(year % 4) && (year % 100 || !(year % 400));
|
||||
}
|
||||
|
||||
|
||||
static int32
|
||||
days_per_month(struct tm &tm)
|
||||
{
|
||||
int32 days = kDaysPerMonth[tm.tm_mon];
|
||||
return days + (tm.tm_mon == 1 && is_leap_year(tm.tm_year + 1900) ? 1 : 0);
|
||||
}
|
||||
|
||||
|
||||
static int32
|
||||
first_weekday_of_month(struct tm &tm)
|
||||
{
|
||||
return (tm.tm_wday - ((tm.tm_mday - 1) % 7) + 7) % 7;
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
CalendarMenuItem::CalendarMenuItem()
|
||||
: BMenuItem("calendar", NULL)
|
||||
{
|
||||
SetEnabled(false);
|
||||
}
|
||||
|
||||
|
||||
CalendarMenuItem::~CalendarMenuItem()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CalendarMenuItem::DrawContent()
|
||||
{
|
||||
time_t currentTime = time(NULL);
|
||||
struct tm tm;
|
||||
localtime_r(¤tTime, &tm);
|
||||
|
||||
Menu()->PushState();
|
||||
Menu()->SetOrigin(ContentLocation());
|
||||
|
||||
rgb_color todayBackgroundColor = tint_color(Menu()->LowColor(), B_LIGHTEN_2_TINT);
|
||||
rgb_color dayColor = tint_color(Menu()->HighColor(), B_DARKEN_2_TINT);
|
||||
rgb_color titleColor = Menu()->HighColor();
|
||||
|
||||
BFont font;
|
||||
Menu()->GetFont(&font);
|
||||
font.SetSize(kTitleFontSize);
|
||||
Menu()->SetFont(&font, B_FONT_SIZE);
|
||||
|
||||
// Draw month name & year
|
||||
|
||||
Menu()->SetHighColor(titleColor);
|
||||
char text[64];
|
||||
strftime(text, sizeof(text), "%B, %Y", &tm);
|
||||
float width = Menu()->StringWidth(text);
|
||||
Menu()->DrawString(text, BPoint((fColumnWidth * 7 - width) / 2, fTitleHeight));
|
||||
|
||||
// Draw weekdays
|
||||
|
||||
for (tm.tm_wday = 0; tm.tm_wday < 7; tm.tm_wday++) {
|
||||
strftime(text, sizeof(text), "%a", &tm);
|
||||
|
||||
width = Menu()->StringWidth(text);
|
||||
Menu()->DrawString(text, BPoint(fColumnWidth * tm.tm_wday + (fColumnWidth - width) / 2,
|
||||
2 * fTitleHeight + kTitleGap));
|
||||
}
|
||||
|
||||
// Draw days
|
||||
|
||||
Menu()->SetHighColor(dayColor);
|
||||
Menu()->SetFont(be_plain_font);
|
||||
|
||||
Menu()->GetFont(&font);
|
||||
font.SetFace(B_BOLD_FACE);
|
||||
|
||||
int32 total = fFirstWeekday + days_per_month(tm);
|
||||
int32 day = 1;
|
||||
int32 row = 1;
|
||||
for (int32 i = fFirstWeekday; i < total; i++) {
|
||||
int32 column = i % 7;
|
||||
bool today = day == tm.tm_mday;
|
||||
|
||||
if (today)
|
||||
Menu()->SetFont(&font);
|
||||
|
||||
sprintf(text, "%ld", day);
|
||||
width = Menu()->StringWidth(text);
|
||||
BPoint point(fColumnWidth * column + (fColumnWidth - width) / 2,
|
||||
2 * (fTitleHeight + kTitleGap) + row * fRowHeight);
|
||||
|
||||
if (today) {
|
||||
// draw a rectangle around today's day number
|
||||
Menu()->SetLowColor(todayBackgroundColor);
|
||||
Menu()->FillRect(BRect(point.x - 2, point.y - 1 - fFontHeight,
|
||||
point.x + width + 1, point.y + 2), B_SOLID_LOW);
|
||||
|
||||
Menu()->SetHighColor(dayColor);
|
||||
}
|
||||
|
||||
Menu()->DrawString(text, point);
|
||||
|
||||
if (today) {
|
||||
Menu()->SetLowColor(ui_color(B_MENU_BACKGROUND_COLOR));
|
||||
Menu()->SetFont(be_plain_font);
|
||||
}
|
||||
|
||||
day++;
|
||||
if (column == 6)
|
||||
row++;
|
||||
}
|
||||
|
||||
Menu()->PopState();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CalendarMenuItem::GetContentSize(float *_width, float *_height)
|
||||
{
|
||||
time_t currentTime = time(NULL);
|
||||
struct tm tm;
|
||||
localtime_r(¤tTime, &tm);
|
||||
|
||||
BFont font;
|
||||
font.SetSize(kTitleFontSize);
|
||||
font_height fontHeight;
|
||||
font.GetHeight(&fontHeight);
|
||||
fTitleHeight = ceil(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);
|
||||
fColumnWidth = font.StringWidth("99") + kColumnGap;
|
||||
|
||||
fFirstWeekday = first_weekday_of_month(tm);
|
||||
fRows = (fFirstWeekday + days_per_month(tm) + 6) / 7;
|
||||
|
||||
if (_width)
|
||||
*_width = 7 * (fColumnWidth - 1);
|
||||
if (_height)
|
||||
*_height = fRows * fRowHeight + 2 * (fTitleHeight + 2 * kTitleGap);
|
||||
}
|
||||
|
||||
#endif // _SHOW_CALENDAR_MENU_ITEM
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef CALENDAR_MENU_ITEM_H
|
||||
#define CALENDAR_MENU_ITEM_H
|
||||
|
||||
|
||||
#include <MenuItem.h>
|
||||
|
||||
|
||||
class CalendarMenuItem : public BMenuItem {
|
||||
public:
|
||||
CalendarMenuItem();
|
||||
~CalendarMenuItem();
|
||||
|
||||
virtual void DrawContent();
|
||||
virtual void GetContentSize(float *_width, float *_height);
|
||||
|
||||
private:
|
||||
float fTitleHeight, fRowHeight, fColumnWidth, fFontHeight;
|
||||
int32 fRows, fFirstWeekday;
|
||||
};
|
||||
|
||||
#endif /* CALENDAR_MENU_ITEM_H */
|
||||
@@ -0,0 +1,189 @@
|
||||
/*
|
||||
Open Tracker License
|
||||
|
||||
Terms and Conditions
|
||||
|
||||
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice applies to all licensees
|
||||
and shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of Be Incorporated shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings in
|
||||
this Software without prior written authorization from Be Incorporated.
|
||||
|
||||
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
||||
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.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <Debug.h>
|
||||
#include <Window.h>
|
||||
#include <AppFileInfo.h>
|
||||
#include <Directory.h>
|
||||
#include <FilePanel.h>
|
||||
#include <List.h>
|
||||
#include <Mime.h>
|
||||
#include <NodeInfo.h>
|
||||
#include <Path.h>
|
||||
#include <Screen.h>
|
||||
#include <SymLink.h>
|
||||
|
||||
#include "BarMenuBar.h"
|
||||
#include "DeskBarUtils.h"
|
||||
#include "ExpandoMenuBar.h"
|
||||
|
||||
const char* const kBePath = "/boot/home/config/be";
|
||||
|
||||
BFilePanel*
|
||||
AskForRefLocation(BMessenger* target)
|
||||
{
|
||||
entry_ref startRef;
|
||||
get_ref_for_path(kBePath, &startRef);
|
||||
|
||||
BFilePanel* fp = new BFilePanel(B_OPEN_PANEL, target, &startRef,
|
||||
B_DIRECTORY_NODE | B_FILE_NODE,
|
||||
false, new BMessage(msg_be_container));
|
||||
fp->Show();
|
||||
|
||||
return fp;
|
||||
}
|
||||
|
||||
void
|
||||
AddRefsToBeMenu(const BMessage* m, entry_ref* subdirectory)
|
||||
{
|
||||
if (m) {
|
||||
int32 count = 0;
|
||||
uint32 type = 0;
|
||||
entry_ref ref;
|
||||
|
||||
m->GetInfo("refs", &type, &count);
|
||||
if (count <= 0)
|
||||
return;
|
||||
|
||||
BPath path;
|
||||
BSymLink link;
|
||||
BDirectory dir;
|
||||
if (subdirectory) {
|
||||
ref = *subdirectory;
|
||||
BEntry entry(&ref);
|
||||
if (entry.Exists()) {
|
||||
// if the ref is a file
|
||||
// get the parent and convert it to a ref
|
||||
if (entry.IsFile()) {
|
||||
BEntry parent;
|
||||
entry.GetParent(&parent);
|
||||
parent.GetRef(&ref);
|
||||
}
|
||||
} else
|
||||
return;
|
||||
|
||||
dir.SetTo(&ref);
|
||||
} else
|
||||
dir.SetTo(kBePath);
|
||||
|
||||
for (long i = 0; i < count; i++) {
|
||||
if (m->FindRef("refs", i, &ref) == B_NO_ERROR) {
|
||||
|
||||
BEntry entry(&ref);
|
||||
entry.GetPath(&path);
|
||||
|
||||
dir.CreateSymLink(ref.name, path.Path(), &link);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
SignatureForRef(const entry_ref* ref, char* signature)
|
||||
{
|
||||
BEntry entry(ref, true);
|
||||
if (entry.InitCheck()==B_OK && entry.Exists()) {
|
||||
if (entry.IsFile()) {
|
||||
BFile file(&entry, O_RDWR);
|
||||
BAppFileInfo finfo(&file);
|
||||
|
||||
finfo.GetSignature(signature);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
CenterWindowOnScreen(BWindow* w)
|
||||
{
|
||||
BRect screenFrame = (BScreen(B_MAIN_SCREEN_ID).Frame());
|
||||
BPoint pt;
|
||||
pt.x = screenFrame.Width()/2 - w->Bounds().Width()/2;
|
||||
pt.y = screenFrame.Height()/2 - w->Bounds().Height()/2;
|
||||
|
||||
if (screenFrame.Contains(pt))
|
||||
w->MoveTo(pt);
|
||||
}
|
||||
|
||||
float
|
||||
FontHeight(const BFont* font, bool full)
|
||||
{
|
||||
font_height finfo;
|
||||
font->GetHeight(&finfo);
|
||||
float h = finfo.ascent + finfo.descent;
|
||||
|
||||
if (full)
|
||||
h += finfo.leading;
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
#ifdef LOG
|
||||
const char* const kLogPath = "/boot/home/";
|
||||
const char* const kLogFile = "deskbar_log";
|
||||
void
|
||||
AddToLog(const char* str)
|
||||
{
|
||||
if (!str)
|
||||
return;
|
||||
|
||||
// BFile file;
|
||||
// BDirectory dir(kLogPath);
|
||||
// if (!dir.Contains(kLogFile))
|
||||
// dir.CreateFile(kLogFile, &file);
|
||||
// else {
|
||||
// BEntry entry;
|
||||
// dir.FindEntry(kLogFile, &entry);
|
||||
// file.SetTo(&entry, O_RDWR);
|
||||
// }
|
||||
//
|
||||
// if (file.InitCheck() != B_OK)
|
||||
// printf("Deskbar Log: can't add to log\n");
|
||||
//
|
||||
// off_t size;
|
||||
// file.GetSize(&size);
|
||||
// file.WriteAt(size, str, strlen(str));
|
||||
|
||||
char dstr[B_PATH_NAME_LENGTH+1024];
|
||||
sprintf(dstr, "Deskbar: %s\n", str);
|
||||
// printf("%s\n", str);
|
||||
SERIAL_PRINT((dstr));
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
Open Tracker License
|
||||
|
||||
Terms and Conditions
|
||||
|
||||
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice applies to all licensees
|
||||
and shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of Be Incorporated shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings in
|
||||
this Software without prior written authorization from Be Incorporated.
|
||||
|
||||
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
||||
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 DB_UTILS_H
|
||||
#define DB_UTILS_H
|
||||
|
||||
#include "tracker_private.h"
|
||||
|
||||
enum {
|
||||
msg_be_container
|
||||
};
|
||||
|
||||
BFilePanel* AskForRefLocation(BMessenger* target);
|
||||
void AddRefsToBeMenu(const BMessage* m, entry_ref* subdirectory);
|
||||
|
||||
bool SignatureForRef(const entry_ref* ref, char* signature);
|
||||
|
||||
void CenterWindowOnScreen(BWindow* w);
|
||||
float FontHeight(const BFont* font, bool full);
|
||||
|
||||
#ifdef LOG
|
||||
void AddToLog(const char*);
|
||||
#endif
|
||||
|
||||
#endif /* DB_UTILS_H */
|
||||
Binary file not shown.
@@ -0,0 +1,799 @@
|
||||
/*
|
||||
Open Tracker License
|
||||
|
||||
Terms and Conditions
|
||||
|
||||
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice applies to all licensees
|
||||
and shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of Be Incorporated shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings in
|
||||
this Software without prior written authorization from Be Incorporated.
|
||||
|
||||
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
||||
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.
|
||||
*/
|
||||
|
||||
#include <Debug.h>
|
||||
#include <string.h>
|
||||
#include <NodeInfo.h>
|
||||
#include <Roster.h>
|
||||
#include <Screen.h>
|
||||
#include <Bitmap.h>
|
||||
#include <Autolock.h>
|
||||
|
||||
#include "icons.h"
|
||||
#include "icons_logo.h"
|
||||
#include "BarApp.h"
|
||||
#include "BarMenuTitle.h"
|
||||
#include "BarView.h"
|
||||
#include "BeMenu.h"
|
||||
#include "DeskBarUtils.h"
|
||||
#include "ExpandoMenuBar.h"
|
||||
#include "ResourceSet.h"
|
||||
#include "ShowHideMenuItem.h"
|
||||
#include "StatusView.h"
|
||||
#include "TeamMenuItem.h"
|
||||
#include "WindowMenu.h"
|
||||
#include "WindowMenuItem.h"
|
||||
|
||||
const float kBeMenuWidth = 50.0f;
|
||||
const float kSepItemWidth = 5.0f;
|
||||
|
||||
const uint32 M_MINIMIZE_TEAM = 'mntm';
|
||||
const uint32 M_BRING_TEAM_TO_FRONT = 'bftm';
|
||||
|
||||
|
||||
bool TExpandoMenuBar::sDoMonitor = false;
|
||||
thread_id TExpandoMenuBar::sMonThread = B_ERROR;
|
||||
BLocker TExpandoMenuBar::sMonLocker("expando monitor");
|
||||
|
||||
|
||||
TExpandoMenuBar::TExpandoMenuBar(TBarView *bar, BRect frame, const char *name,
|
||||
bool vertical, bool drawLabel)
|
||||
: BMenuBar(frame, name, B_FOLLOW_NONE,
|
||||
vertical ? B_ITEMS_IN_COLUMN : B_ITEMS_IN_ROW, vertical),
|
||||
fVertical(vertical),
|
||||
fOverflow(false),
|
||||
fDrawLabel(drawLabel),
|
||||
fIsScrolling(false),
|
||||
fShowTeamExpander(static_cast<TBarApp *>(be_app)->Settings()->superExpando),
|
||||
fExpandNewTeams(static_cast<TBarApp *>(be_app)->Settings()->expandNewTeams),
|
||||
fBarView(bar),
|
||||
fFirstApp(0)
|
||||
{
|
||||
#ifdef DOUBLECLICKBRINGSTOFRONT
|
||||
fLastClickItem = -1;
|
||||
fLastClickTime = 0;
|
||||
#endif
|
||||
|
||||
SetItemMargins(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
SetFont(be_plain_font);
|
||||
SetMaxContentWidth(kMinimumWindowWidth);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
TExpandoMenuBar::CompareByName( const void *first, const void *second)
|
||||
{
|
||||
return strcasecmp(
|
||||
(*(static_cast<BarTeamInfo * const*>(first )))->name,
|
||||
(*(static_cast<BarTeamInfo * const*>(second)))->name);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TExpandoMenuBar::AttachedToWindow()
|
||||
{
|
||||
BMessenger self(this);
|
||||
BList teamList;
|
||||
TBarApp::Subscribe(self, &teamList);
|
||||
float width = fVertical ? Frame().Width() : kMinimumWindowWidth;
|
||||
float height = -1.0f;
|
||||
|
||||
// top or bottom mode, add be menu and sep for menubar tracking consistency
|
||||
if (!fVertical) {
|
||||
TBeMenu *beMenu = new TBeMenu(fBarView);
|
||||
TBarWindow::SetBeMenu(beMenu);
|
||||
fBeMenuItem = new TBarMenuTitle(kBeMenuWidth, Frame().Height(),
|
||||
AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_BeLogoIcon), beMenu, true);
|
||||
AddItem(fBeMenuItem);
|
||||
|
||||
fSeparatorItem = new TTeamMenuItem(kSepItemWidth, height, fVertical);
|
||||
AddItem(fSeparatorItem);
|
||||
fSeparatorItem->SetEnabled(false);
|
||||
fFirstApp = 2;
|
||||
} else {
|
||||
fBeMenuItem = NULL;
|
||||
fSeparatorItem = NULL;
|
||||
}
|
||||
|
||||
desk_settings *settings = ((TBarApp *)be_app)->Settings();
|
||||
|
||||
if (settings->sortRunningApps)
|
||||
teamList.SortItems(CompareByName);
|
||||
|
||||
int32 count = teamList.CountItems();
|
||||
for (int32 i = 0; i < count; i++) {
|
||||
BarTeamInfo *barInfo = (BarTeamInfo *)teamList.ItemAt(i);
|
||||
if ((barInfo->flags & B_BACKGROUND_APP) == 0
|
||||
&& strcasecmp(barInfo->sig, kDeskbarSignature) != 0) {
|
||||
if ((settings->trackerAlwaysFirst)
|
||||
&& (strcmp(barInfo->sig, kTrackerSignature)) == 0) {
|
||||
AddItem(new TTeamMenuItem(barInfo->teams, barInfo->icon,
|
||||
barInfo->name, barInfo->sig, width, height,
|
||||
fDrawLabel, fVertical), fFirstApp);
|
||||
} else {
|
||||
AddItem(new TTeamMenuItem(barInfo->teams, barInfo->icon,
|
||||
barInfo->name, barInfo->sig, width, height,
|
||||
fDrawLabel, fVertical));
|
||||
}
|
||||
|
||||
barInfo->teams = NULL;
|
||||
barInfo->icon = NULL;
|
||||
barInfo->name = NULL;
|
||||
barInfo->sig = NULL;
|
||||
}
|
||||
|
||||
delete barInfo;
|
||||
}
|
||||
|
||||
BMenuBar::AttachedToWindow();
|
||||
|
||||
if (fVertical) {
|
||||
sDoMonitor = true;
|
||||
sMonThread = spawn_thread(monitor_team_windows,
|
||||
"Expando Window Watcher", B_LOW_PRIORITY, this);
|
||||
resume_thread(sMonThread);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TExpandoMenuBar::DetachedFromWindow()
|
||||
{
|
||||
BMenuBar::DetachedFromWindow();
|
||||
|
||||
if (sMonThread != B_ERROR) {
|
||||
sDoMonitor = false;
|
||||
|
||||
status_t returnCode;
|
||||
wait_for_thread(sMonThread, &returnCode);
|
||||
|
||||
sMonThread = B_ERROR;
|
||||
}
|
||||
|
||||
BMessenger self(this);
|
||||
BMessage message(msg_Unsubscribe);
|
||||
message.AddMessenger("messenger", self);
|
||||
be_app->PostMessage(&message);
|
||||
|
||||
BMenuItem *item = NULL;
|
||||
while ((item = RemoveItem(0L)) != NULL)
|
||||
delete item;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TExpandoMenuBar::MessageReceived(BMessage *message)
|
||||
{
|
||||
int32 index;
|
||||
TTeamMenuItem *item;
|
||||
|
||||
switch (message->what) {
|
||||
case B_SOME_APP_LAUNCHED: {
|
||||
BList *teams = NULL;
|
||||
message->FindPointer("teams", (void **)&teams);
|
||||
|
||||
BBitmap *icon = NULL;
|
||||
message->FindPointer("icon", (void **)&icon);
|
||||
|
||||
const char *sig;
|
||||
if (message->FindString("sig", &sig) == B_OK
|
||||
&&strcasecmp(sig, kDeskbarSignature) == 0) {
|
||||
delete teams;
|
||||
delete icon;
|
||||
break;
|
||||
}
|
||||
|
||||
uint32 flags;
|
||||
if (message->FindInt32("flags", ((int32*) &flags)) == B_OK
|
||||
&& (flags & B_BACKGROUND_APP) != 0) {
|
||||
delete teams;
|
||||
delete icon;
|
||||
break;
|
||||
}
|
||||
|
||||
const char *name = NULL;
|
||||
message->FindString("name", &name);
|
||||
|
||||
AddTeam(teams, icon, strdup(name), strdup(sig));
|
||||
break;
|
||||
}
|
||||
|
||||
case msg_AddTeam:
|
||||
AddTeam(message->FindInt32("team"), message->FindString("sig"));
|
||||
break;
|
||||
|
||||
case msg_RemoveTeam:
|
||||
{
|
||||
team_id team = -1;
|
||||
message->FindInt32("team", &team);
|
||||
|
||||
RemoveTeam(team, true);
|
||||
break;
|
||||
}
|
||||
|
||||
case B_SOME_APP_QUIT:
|
||||
{
|
||||
team_id team = -1;
|
||||
message->FindInt32("team", &team);
|
||||
|
||||
RemoveTeam(team, false);
|
||||
break;
|
||||
}
|
||||
|
||||
case M_MINIMIZE_TEAM:
|
||||
{
|
||||
index = message->FindInt32("itemIndex");
|
||||
item = dynamic_cast<TTeamMenuItem *>(ItemAt(index));
|
||||
if (item == NULL)
|
||||
break;
|
||||
|
||||
TShowHideMenuItem::TeamShowHideCommon(B_MINIMIZE_WINDOW,
|
||||
item->Teams(),
|
||||
item->Menu()->ConvertToScreen(item->Frame()),
|
||||
true);
|
||||
break;
|
||||
}
|
||||
|
||||
case M_BRING_TEAM_TO_FRONT:
|
||||
{
|
||||
index = message->FindInt32("itemIndex");
|
||||
item = dynamic_cast<TTeamMenuItem *>(ItemAt(index));
|
||||
if (item == NULL)
|
||||
break;
|
||||
|
||||
TShowHideMenuItem::TeamShowHideCommon(B_BRING_TO_FRONT,
|
||||
item->Teams(),
|
||||
item->Menu()->ConvertToScreen(item->Frame()),
|
||||
true);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
BMenuBar::MessageReceived(message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TExpandoMenuBar::MouseDown(BPoint where)
|
||||
{
|
||||
BMessage *message = Window()->CurrentMessage();
|
||||
|
||||
// check for three finger salute, a.k.a. Vulcan Death Grip
|
||||
if (message != NULL) {
|
||||
int32 modifiers = 0;
|
||||
message->FindInt32("modifiers", &modifiers);
|
||||
|
||||
if ((modifiers & B_COMMAND_KEY) != 0
|
||||
&& (modifiers & B_OPTION_KEY) != 0
|
||||
&& (modifiers & B_SHIFT_KEY) != 0
|
||||
&& !fBarView->Dragging()) {
|
||||
|
||||
TTeamMenuItem *item = ItemAtPoint(where);
|
||||
if (item) {
|
||||
const BList *teams = item->Teams();
|
||||
int32 teamCount = teams->CountItems();
|
||||
|
||||
team_id teamID;
|
||||
for (int32 team = 0; team < teamCount; team++) {
|
||||
teamID = (team_id)teams->ItemAt(team);
|
||||
kill_team(teamID);
|
||||
// remove the team immediately
|
||||
// from display
|
||||
RemoveTeam(teamID, false);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const int32 count = CountItems();
|
||||
|
||||
// This feature is broken because the menu bar never receives
|
||||
// the second click
|
||||
#ifdef DOUBLECLICKBRINGSTOFRONT
|
||||
// doubleclick on an item brings all to front
|
||||
for (int32 i = fFirstApp; i < count; i++) {
|
||||
TTeamMenuItem *item = (TTeamMenuItem *)ItemAt(i);
|
||||
if (item->Frame().Contains(where)) {
|
||||
bigtime_t clickSpeed = 0;
|
||||
get_click_speed(&clickSpeed);
|
||||
if ( (fLastClickItem == i) &&
|
||||
(clickSpeed > (system_time() - fLastClickTime)) ) {
|
||||
// bring this team's window to the front
|
||||
BMessage showMessage(M_BRING_TEAM_TO_FRONT);
|
||||
showMessage.AddInt32("itemIndex", i);
|
||||
Window()->PostMessage(&showMessage, this);
|
||||
return;
|
||||
}
|
||||
|
||||
fLastClickItem = i;
|
||||
fLastClickTime = system_time();
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// control click - show all/hide all shortcut
|
||||
if (message != NULL) {
|
||||
int32 modifiers = 0;
|
||||
message->FindInt32("modifiers", &modifiers);
|
||||
if ((modifiers & B_CONTROL_KEY) != 0
|
||||
&& ! fBarView->Dragging()) {
|
||||
int32 lastApp = -1;
|
||||
|
||||
// find the clicked item
|
||||
for (int32 i = fFirstApp; i < count; i++) {
|
||||
const TTeamMenuItem *item = (TTeamMenuItem *)ItemAt(i);
|
||||
|
||||
// check if this item is really a team item (what a cruel way...)
|
||||
// "lastApp" will always point to the last application in
|
||||
// the list - the other entries might be windows (due to the team expander)
|
||||
if (item->Submenu())
|
||||
lastApp = i;
|
||||
|
||||
if (item->Frame().Contains(where)) {
|
||||
// show/hide item's teams
|
||||
BMessage showMessage((modifiers & B_SHIFT_KEY) != 0
|
||||
? M_MINIMIZE_TEAM : M_BRING_TEAM_TO_FRONT);
|
||||
showMessage.AddInt32("itemIndex", lastApp);
|
||||
Window()->PostMessage(&showMessage, this);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check the bounds of the expand Team icon
|
||||
if (fShowTeamExpander && fVertical && !fBarView->Dragging()) {
|
||||
TTeamMenuItem *item = ItemAtPoint(where);
|
||||
if (item->Submenu()) {
|
||||
BRect expanderRect = item->ExpanderBounds();
|
||||
if (expanderRect.Contains(where)) {
|
||||
// Let the update thread wait...
|
||||
BAutolock locker(sMonLocker);
|
||||
|
||||
// Toggle the item
|
||||
item->ToggleExpandState(true);
|
||||
item->Draw();
|
||||
|
||||
// Absorb the message.
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BMenuBar::MouseDown(where);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TExpandoMenuBar::MouseMoved(BPoint where, uint32 code, const BMessage *message)
|
||||
{
|
||||
if (!message) {
|
||||
// force a cleanup
|
||||
fBarView->DragStop(true);
|
||||
BMenuBar::MouseMoved(where, code, message);
|
||||
return;
|
||||
}
|
||||
|
||||
BPoint loc;
|
||||
uint32 buttons;
|
||||
GetMouse(&loc, &buttons);
|
||||
|
||||
switch (code) {
|
||||
case B_ENTERED_VIEW:
|
||||
if (message && buttons != 0) {
|
||||
fBarView->CacheDragData((BMessage *)message);
|
||||
MouseDown(loc);
|
||||
}
|
||||
break;
|
||||
|
||||
case B_EXITED_VIEW:
|
||||
if (fBarView->Dragging() && buttons != 0) {
|
||||
if (!ItemAtPoint(where)
|
||||
&& !InBeMenu(where)
|
||||
&& (fSeparatorItem && !fSeparatorItem->Frame().Contains(where))
|
||||
&& !Frame().Contains(where))
|
||||
fBarView->DragStop();
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
BMenuBar::MouseMoved(where, code, message);
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
TExpandoMenuBar::InBeMenu(BPoint loc) const
|
||||
{
|
||||
if (!fVertical) {
|
||||
if (fBeMenuItem && fBeMenuItem->Frame().Contains(loc))
|
||||
return true;
|
||||
} else {
|
||||
TBarWindow *window = dynamic_cast<TBarWindow*>(Window());
|
||||
if (window) {
|
||||
TBeMenu *bemenu = window->BeMenu();
|
||||
if (bemenu && bemenu->Frame().Contains(loc))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
TTeamMenuItem *
|
||||
TExpandoMenuBar::ItemAtPoint(BPoint point)
|
||||
{
|
||||
TTeamMenuItem *item = NULL;
|
||||
int32 count = CountItems();
|
||||
|
||||
for (int32 i = fFirstApp; i < count; i++) {
|
||||
item = (TTeamMenuItem *)ItemAt(i);
|
||||
if (item && item->Frame().Contains(point))
|
||||
return item;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TExpandoMenuBar::AddTeam(BList *team, BBitmap *icon, char *name, char *sig)
|
||||
{
|
||||
float itemWidth = fVertical ? Frame().Width() : kMinimumWindowWidth;
|
||||
float itemHeight = -1.0f;
|
||||
|
||||
desk_settings *settings = ((TBarApp *)be_app)->Settings();
|
||||
TTeamMenuItem *item = new TTeamMenuItem(team, icon, name, sig, itemWidth,
|
||||
itemHeight, fDrawLabel, fVertical);
|
||||
|
||||
if (settings->trackerAlwaysFirst && !strcmp( sig, kTrackerSignature)) {
|
||||
AddItem(item, fFirstApp);
|
||||
} else if (settings->sortRunningApps) {
|
||||
int32 firstApp = fFirstApp;
|
||||
|
||||
// if Tracker should always be the first item, we need to skip it
|
||||
// when sorting in the current item
|
||||
if ((settings->trackerAlwaysFirst)
|
||||
&& (strcmp(static_cast<TTeamMenuItem *>(ItemAt(fFirstApp))->Signature(),
|
||||
kTrackerSignature) == 0)) {
|
||||
firstApp++;
|
||||
}
|
||||
|
||||
int32 count = CountItems(), i;
|
||||
for (i = firstApp; i < count; i++) {
|
||||
TTeamMenuItem *teamItem = dynamic_cast<TTeamMenuItem *>(ItemAt(i));
|
||||
if (teamItem != NULL && strcasecmp(teamItem->Name(), name) > 0) {
|
||||
AddItem(item, i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// was the item added to the list yet?
|
||||
if (i == count)
|
||||
AddItem(item);
|
||||
} else
|
||||
AddItem(item);
|
||||
|
||||
if (fVertical) {
|
||||
if (item && fShowTeamExpander && fExpandNewTeams)
|
||||
item->ToggleExpandState(false);
|
||||
|
||||
fBarView->SizeWindow(BScreen(Window()).Frame());
|
||||
} else
|
||||
CheckItemSizes(1);
|
||||
|
||||
Window()->UpdateIfNeeded();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TExpandoMenuBar::AddTeam(team_id team, const char *sig)
|
||||
{
|
||||
int32 count = CountItems();
|
||||
for (int32 i = fFirstApp; i < count; i++) {
|
||||
// Only add to team menu items
|
||||
if (TTeamMenuItem *item = dynamic_cast<TTeamMenuItem *>(ItemAt(i))) {
|
||||
if (strcasecmp(item->Signature(), sig) == 0) {
|
||||
if (!(item->Teams()->HasItem((void *)team)))
|
||||
item->Teams()->AddItem((void *)team);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TExpandoMenuBar::RemoveTeam(team_id team, bool partial)
|
||||
{
|
||||
int32 count = CountItems();
|
||||
for (int32 i = fFirstApp; i < count; i++) {
|
||||
if (TTeamMenuItem *item = dynamic_cast<TTeamMenuItem *>(ItemAt(i))) {
|
||||
if (item->Teams()->HasItem((void *)team)) {
|
||||
item->Teams()->RemoveItem(team);
|
||||
|
||||
if (partial)
|
||||
return;
|
||||
|
||||
#ifdef DOUBLECLICKBRINGSTOFRONT
|
||||
if (fLastClickItem == i)
|
||||
fLastClickItem = -1;
|
||||
#endif
|
||||
|
||||
RemoveItem(i);
|
||||
|
||||
if (fVertical) {
|
||||
// instead of resizing the window here and there in the code
|
||||
// the resize method will be centered in one place
|
||||
// thus, the same behavior (good or bad) will be used whereever
|
||||
// window sizing is done
|
||||
fBarView->SizeWindow(BScreen(Window()).Frame());
|
||||
} else
|
||||
CheckItemSizes(-1);
|
||||
|
||||
Window()->UpdateIfNeeded();
|
||||
|
||||
delete item;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TExpandoMenuBar::CheckItemSizes(int32 delta)
|
||||
{
|
||||
float width = Frame().Width();
|
||||
int32 count = CountItems();
|
||||
bool reset = false;
|
||||
float newWidth = 0;
|
||||
float fullWidth = (kMinimumWindowWidth * count);
|
||||
|
||||
if (!fBarView->Vertical()) {
|
||||
// in this case there are 2 extra items:
|
||||
// The Be Menu
|
||||
// The little separator item
|
||||
fullWidth = fullWidth - (kMinimumWindowWidth * 2) + (kBeMenuWidth + kSepItemWidth);
|
||||
width -= (kBeMenuWidth + kSepItemWidth);
|
||||
count -= 2;
|
||||
}
|
||||
|
||||
if (delta >= 0 && fullWidth > width) {
|
||||
fOverflow = true;
|
||||
reset = true;
|
||||
newWidth = floorf(width/count);
|
||||
} else if (delta < 0 && fOverflow) {
|
||||
reset = true;
|
||||
if (fullWidth > width)
|
||||
newWidth = floorf(width/count);
|
||||
else
|
||||
newWidth = kMinimumWindowWidth;
|
||||
}
|
||||
if (newWidth > kMinimumWindowWidth)
|
||||
newWidth = kMinimumWindowWidth;
|
||||
|
||||
if (reset) {
|
||||
SetMaxContentWidth(newWidth);
|
||||
if (newWidth == kMinimumWindowWidth)
|
||||
fOverflow = false;
|
||||
InvalidateLayout();
|
||||
|
||||
for (int32 index = fFirstApp; ; index++) {
|
||||
TTeamMenuItem *item = (TTeamMenuItem *)ItemAt(index);
|
||||
if (!item)
|
||||
break;
|
||||
item->SetOverrideWidth(newWidth);
|
||||
}
|
||||
|
||||
Invalidate();
|
||||
Window()->UpdateIfNeeded();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
menu_layout
|
||||
TExpandoMenuBar::MenuLayout() const
|
||||
{
|
||||
return Layout();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TExpandoMenuBar::Draw(BRect update)
|
||||
{
|
||||
BMenu::Draw(update);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TExpandoMenuBar::DrawBackground(BRect)
|
||||
{
|
||||
BRect bounds(Bounds());
|
||||
rgb_color menuColor = ui_color(B_MENU_BACKGROUND_COLOR);
|
||||
rgb_color hilite = tint_color(menuColor, B_DARKEN_1_TINT);
|
||||
rgb_color dark = tint_color(menuColor, B_DARKEN_2_TINT);
|
||||
rgb_color vlight = tint_color(menuColor, B_LIGHTEN_2_TINT);
|
||||
int32 last = CountItems() - 1;
|
||||
float start;
|
||||
|
||||
if (last >= 0)
|
||||
start = ItemAt(last)->Frame().right + 1;
|
||||
else
|
||||
start = 0;
|
||||
|
||||
if (!fVertical) {
|
||||
SetHighColor(vlight);
|
||||
StrokeLine(BPoint(start, bounds.top+1), bounds.RightTop() + BPoint(0,1));
|
||||
StrokeLine(BPoint(start, bounds.top+1), BPoint(start, bounds.bottom));
|
||||
SetHighColor(hilite);
|
||||
StrokeLine(BPoint(start+1, bounds.bottom), bounds.RightBottom());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// something to help determine if we are showing too many apps
|
||||
// need to add in scrolling functionality
|
||||
|
||||
void
|
||||
TExpandoMenuBar::CheckForSizeOverrun()
|
||||
{
|
||||
BRect screenFrame = (BScreen(Window())).Frame();
|
||||
if (fVertical)
|
||||
fIsScrolling = Window()->Frame().bottom > screenFrame.bottom;
|
||||
else
|
||||
fIsScrolling = false;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TExpandoMenuBar::SizeWindow()
|
||||
{
|
||||
if (fVertical)
|
||||
fBarView->SizeWindow(BScreen(Window()).Frame());
|
||||
else
|
||||
CheckItemSizes(1);
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
TExpandoMenuBar::monitor_team_windows(void *arg)
|
||||
{
|
||||
TExpandoMenuBar *teamMenu = (TExpandoMenuBar *)arg;
|
||||
|
||||
while (teamMenu->sDoMonitor) {
|
||||
sMonLocker.Lock();
|
||||
|
||||
if (teamMenu->Window()->LockWithTimeout(50000) == B_OK) {
|
||||
int32 totalItems = teamMenu->CountItems();
|
||||
|
||||
// Set all WindowMenuItems to require an update.
|
||||
TWindowMenuItem *item = NULL;
|
||||
for (int32 i = 0; i < totalItems; i++) {
|
||||
if (!teamMenu->SubmenuAt(i)){
|
||||
item = static_cast<TWindowMenuItem *>(teamMenu->ItemAt(i));
|
||||
item->SetRequireUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
// Perform SetTo() on all the items that still exist as well as add new items.
|
||||
bool itemModified = false, resize = false;
|
||||
TTeamMenuItem *teamItem = NULL;
|
||||
|
||||
for (int32 i = 0; i < totalItems; i++) {
|
||||
if (teamMenu->SubmenuAt(i) == NULL)
|
||||
continue;
|
||||
|
||||
teamItem = static_cast<TTeamMenuItem *>(teamMenu->ItemAt(i));
|
||||
if (teamItem->IsExpanded()) {
|
||||
int32 teamCount = teamItem->Teams()->CountItems();
|
||||
for (int32 j = 0; j < teamCount; j++) {
|
||||
// The following code is almost a copy/paste from
|
||||
// WindowMenu.cpp
|
||||
team_id theTeam = (team_id)teamItem->Teams()->ItemAt(j);
|
||||
int32 count = 0;
|
||||
int32 *tokens = get_token_list(theTeam, &count);
|
||||
|
||||
for (int32 k = 0; k < count; k++) {
|
||||
window_info *wInfo = get_window_info(tokens[k]);
|
||||
if (wInfo == NULL)
|
||||
continue;
|
||||
|
||||
if (TWindowMenu::WindowShouldBeListed(wInfo->w_type)
|
||||
&& (wInfo->show_hide_level <= 0 || wInfo->is_mini)) {
|
||||
// Check if we have a matching window item...
|
||||
item = teamItem->ExpandedWindowItem(wInfo->id);
|
||||
if (item) {
|
||||
item->SetTo(wInfo->name, wInfo->id, wInfo->is_mini,
|
||||
((1 << current_workspace()) & wInfo->workspaces) != 0);
|
||||
|
||||
if (strcmp(wInfo->name, item->Label()) != 0)
|
||||
item->SetLabel(wInfo->name);
|
||||
|
||||
if (item->ChangedState())
|
||||
itemModified = true;
|
||||
} else if (teamItem->IsExpanded()) {
|
||||
// Add the item
|
||||
item = new TWindowMenuItem(wInfo->name, wInfo->id,
|
||||
wInfo->is_mini,
|
||||
((1 << current_workspace()) & wInfo->workspaces) != 0,
|
||||
false);
|
||||
item->ExpandedItem(true);
|
||||
teamMenu->AddItem(item, i + 1);
|
||||
resize = true;
|
||||
}
|
||||
}
|
||||
free(wInfo);
|
||||
}
|
||||
free(tokens);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Remove any remaining items which require an update.
|
||||
for (int32 i = 0; i < totalItems; i++) {
|
||||
if (!teamMenu->SubmenuAt(i)){
|
||||
item = static_cast<TWindowMenuItem *>(teamMenu->ItemAt(i));
|
||||
if (item && item->RequiresUpdate()) {
|
||||
item = static_cast<TWindowMenuItem *>(teamMenu->RemoveItem(i));
|
||||
delete item;
|
||||
totalItems--;
|
||||
|
||||
resize = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If any of the WindowMenuItems changed state, we need to force a repaint.
|
||||
if (itemModified || resize) {
|
||||
teamMenu->Invalidate();
|
||||
if (resize)
|
||||
teamMenu->SizeWindow();
|
||||
}
|
||||
|
||||
teamMenu->Window()->Unlock();
|
||||
}
|
||||
|
||||
sMonLocker.Unlock();
|
||||
|
||||
// sleep for a bit...
|
||||
snooze(150000);
|
||||
}
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
Open Tracker License
|
||||
|
||||
Terms and Conditions
|
||||
|
||||
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice applies to all licensees
|
||||
and shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of Be Incorporated shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings in
|
||||
this Software without prior written authorization from Be Incorporated.
|
||||
|
||||
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
||||
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 EXPANDOMENUBAR_H
|
||||
#define EXPANDOMENUBAR_H
|
||||
|
||||
// application list
|
||||
// top level at window
|
||||
// in expanded mode horizontal and vertical
|
||||
|
||||
|
||||
#include <MenuBar.h>
|
||||
#include <Locker.h>
|
||||
|
||||
class BBitmap;
|
||||
class TBarView;
|
||||
class TBarMenuTitle;
|
||||
class TTeamMenuItem;
|
||||
|
||||
//#define DOUBLECLICKBRINGSTOFRONT
|
||||
|
||||
enum drag_and_drop_selection {
|
||||
kNoSelection,
|
||||
kBeMenuSelection,
|
||||
kAppMenuSelection,
|
||||
kAnyMenuSelection
|
||||
};
|
||||
|
||||
class TExpandoMenuBar : public BMenuBar {
|
||||
public:
|
||||
TExpandoMenuBar(TBarView *bar, BRect frame, const char *name, bool vertical,
|
||||
bool drawLabel = true);
|
||||
|
||||
virtual void AttachedToWindow();
|
||||
virtual void DetachedFromWindow();
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
virtual void MouseDown(BPoint where);
|
||||
virtual void MouseMoved(BPoint where, uint32 code, const BMessage *);
|
||||
|
||||
virtual void Draw(BRect update);
|
||||
virtual void DrawBackground(BRect update);
|
||||
|
||||
bool InBeMenu(BPoint) const;
|
||||
TTeamMenuItem *ItemAtPoint(BPoint loc);
|
||||
|
||||
void CheckItemSizes(int32 delta);
|
||||
|
||||
menu_layout MenuLayout() const;
|
||||
|
||||
void SizeWindow();
|
||||
void CheckForSizeOverrun();
|
||||
|
||||
private:
|
||||
static int CompareByName( const void *first, const void *second);
|
||||
static int32 monitor_team_windows(void *arg);
|
||||
|
||||
void AddTeam(BList *team, BBitmap *icon, char *name, char *signature);
|
||||
void AddTeam(team_id team, const char *signature);
|
||||
void RemoveTeam(team_id team, bool partial);
|
||||
|
||||
void Hilite(drag_and_drop_selection which);
|
||||
|
||||
bool fVertical;
|
||||
bool fOverflow;
|
||||
bool fDrawLabel;
|
||||
bool fIsScrolling;
|
||||
bool fShowTeamExpander;
|
||||
bool fExpandNewTeams;
|
||||
|
||||
TBarView *fBarView;
|
||||
int32 fFirstApp;
|
||||
|
||||
TBarMenuTitle *fBeMenuItem;
|
||||
TTeamMenuItem *fSeparatorItem;
|
||||
|
||||
#ifdef DOUBLECLICKBRINGSTOFRONT
|
||||
int32 fLastClickItem;
|
||||
bigtime_t fLastClickTime;
|
||||
#endif
|
||||
|
||||
static bool sDoMonitor;
|
||||
static thread_id sMonThread;
|
||||
static BLocker sMonLocker;
|
||||
};
|
||||
|
||||
#endif /* EXPANDOMENUBAR_H */
|
||||
@@ -0,0 +1,37 @@
|
||||
SubDir OBOS_TOP src apps deskbar ;
|
||||
|
||||
UsePrivateHeaders shared ;
|
||||
UsePrivateHeaders tracker ;
|
||||
SubDirHdrs $(OBOS_TOP) src kits tracker ;
|
||||
|
||||
AddResources Deskbar : Deskbar.rsrc icon-freelogo.rsrc icons.rdef ;
|
||||
|
||||
SubDirC++Flags -DDB_ADDONS -DOPEN_TRACKER=1
|
||||
-D_INCLUDES_CLASS_DEVICE_MAP=1
|
||||
-D_SUPPORTS_RESOURCES=1
|
||||
-D_SUPPORTS_FEATURE_SCRIPTING=1
|
||||
-D_SHOW_CALENDAR_MENU_ITEM=1 ;
|
||||
|
||||
App Deskbar :
|
||||
BarApp.cpp
|
||||
BarMenuBar.cpp
|
||||
BarMenuTitle.cpp
|
||||
BarView.cpp
|
||||
BarWindow.cpp
|
||||
BeMenu.cpp
|
||||
CalendarMenuItem.cpp
|
||||
DeskBarUtils.cpp
|
||||
ExpandoMenuBar.cpp
|
||||
ShowHideMenuItem.cpp
|
||||
StatusView.cpp
|
||||
StatusViewShelf.cpp
|
||||
TeamMenu.cpp
|
||||
TeamMenuItem.cpp
|
||||
TimeView.cpp
|
||||
WindowMenu.cpp
|
||||
WindowMenuItem.cpp
|
||||
ResourceSet.cpp
|
||||
Switcher.cpp
|
||||
;
|
||||
|
||||
LinkSharedOSLibs Deskbar : libbe.so libtracker.so ;
|
||||
@@ -0,0 +1,31 @@
|
||||
Open Tracker License
|
||||
|
||||
Terms and Conditions
|
||||
|
||||
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice applies to all licensees
|
||||
and shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of Be Incorporated shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings in
|
||||
this Software without prior written authorization from Be Incorporated.
|
||||
|
||||
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
||||
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.
|
||||
@@ -0,0 +1,896 @@
|
||||
/*
|
||||
Open Tracker License
|
||||
|
||||
Terms and Conditions
|
||||
|
||||
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice applies to all licensees
|
||||
and shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of Be Incorporated shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings in
|
||||
this Software without prior written authorization from Be Incorporated.
|
||||
|
||||
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
||||
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.
|
||||
*/
|
||||
|
||||
#define USE_RESOURCES 1
|
||||
|
||||
#include "ResourceSet.h"
|
||||
|
||||
#include <Application.h>
|
||||
#include <Autolock.h>
|
||||
#include <Bitmap.h>
|
||||
#include <DataIO.h>
|
||||
#include <Debug.h>
|
||||
#include <Entry.h>
|
||||
#include <File.h>
|
||||
#include <Path.h>
|
||||
#include <String.h>
|
||||
|
||||
|
||||
#if USE_RESOURCES
|
||||
#include <Resources.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#if USE_RESOURCES
|
||||
#define RESOURCES_ONLY(x) x
|
||||
#else
|
||||
#define RESOURCES_ONLY(x)
|
||||
#endif
|
||||
|
||||
namespace TResourcePrivate {
|
||||
|
||||
class TypeObject {
|
||||
public:
|
||||
TypeObject()
|
||||
: fDeleteOK(false)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~TypeObject()
|
||||
{
|
||||
if (!fDeleteOK)
|
||||
debugger("deleting object owned by BResourceSet");
|
||||
}
|
||||
|
||||
void Delete()
|
||||
{
|
||||
fDeleteOK = true;
|
||||
}
|
||||
|
||||
private:
|
||||
TypeObject(const TypeObject &);
|
||||
TypeObject &operator=(const TypeObject &);
|
||||
bool operator==(const TypeObject &);
|
||||
bool operator!=(const TypeObject &);
|
||||
|
||||
bool fDeleteOK;
|
||||
};
|
||||
|
||||
class BitmapTypeItem : public BBitmap, public TypeObject {
|
||||
public:
|
||||
BitmapTypeItem(BRect bounds, uint32 flags, color_space depth,
|
||||
int32 bytesPerRow=B_ANY_BYTES_PER_ROW, screen_id screenID = B_MAIN_SCREEN_ID)
|
||||
: BBitmap(bounds, flags, depth, bytesPerRow, screenID)
|
||||
{
|
||||
}
|
||||
|
||||
BitmapTypeItem(const BBitmap* source, bool accepts_views = false,
|
||||
bool need_contiguous = false)
|
||||
: BBitmap(source, accepts_views, need_contiguous)
|
||||
{
|
||||
}
|
||||
|
||||
BitmapTypeItem(BMessage *data)
|
||||
: BBitmap(data)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~BitmapTypeItem()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class StringBlockTypeItem : public TStringBlock, public TypeObject {
|
||||
public:
|
||||
StringBlockTypeItem(BDataIO *data)
|
||||
: TStringBlock(data)
|
||||
{
|
||||
}
|
||||
|
||||
StringBlockTypeItem(const void *block, size_t size)
|
||||
: TStringBlock(block, size)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~StringBlockTypeItem()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class TypeItem {
|
||||
public:
|
||||
TypeItem(int32 id, const char *name, const void *data, size_t size)
|
||||
: fID(id), fName(name),
|
||||
fData(const_cast<void*>(data)), fSize(size), fObject(0),
|
||||
fOwnData(false), fSourceIsFile(false)
|
||||
{
|
||||
}
|
||||
|
||||
TypeItem(int32 id, const char *name, BFile *file)
|
||||
: fID(id),
|
||||
fName(name),
|
||||
fData(NULL),
|
||||
fSize(0),
|
||||
fObject(NULL),
|
||||
fOwnData(true),
|
||||
fSourceIsFile(false)
|
||||
{
|
||||
off_t size;
|
||||
if (file->GetSize(&size) == B_OK) {
|
||||
fSize = (size_t)size;
|
||||
fData = malloc(fSize);
|
||||
if (file->ReadAt(0, fData, fSize) < B_OK ) {
|
||||
free(fData);
|
||||
fData = NULL;
|
||||
fSize = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual ~TypeItem()
|
||||
{
|
||||
if (fOwnData) {
|
||||
free(fData);
|
||||
fData = NULL;
|
||||
fSize = 0;
|
||||
}
|
||||
SetObject(NULL);
|
||||
}
|
||||
|
||||
int32 ID() const
|
||||
{ return fID; }
|
||||
|
||||
const char *Name() const
|
||||
{ return fName.String(); }
|
||||
|
||||
const void *Data() const
|
||||
{ return fData; }
|
||||
|
||||
size_t Size() const
|
||||
{ return fSize; }
|
||||
|
||||
void SetObject(TypeObject *object)
|
||||
{
|
||||
if (object == fObject)
|
||||
return;
|
||||
if (fObject)
|
||||
fObject->Delete();
|
||||
fObject = object;
|
||||
}
|
||||
|
||||
TypeObject *Object() const
|
||||
{ return fObject; }
|
||||
|
||||
void SetSourceIsFile(bool state)
|
||||
{ fSourceIsFile = state; }
|
||||
|
||||
bool SourceIsFile() const
|
||||
{ return fSourceIsFile; }
|
||||
|
||||
private:
|
||||
int32 fID;
|
||||
BString fName;
|
||||
void *fData;
|
||||
size_t fSize;
|
||||
TypeObject *fObject;
|
||||
bool fOwnData;
|
||||
bool fSourceIsFile;
|
||||
};
|
||||
|
||||
static bool FreeTypeItemFunc(void *item)
|
||||
{
|
||||
delete reinterpret_cast<TypeItem *>(item);
|
||||
return false;
|
||||
}
|
||||
|
||||
class TypeList {
|
||||
public:
|
||||
TypeList(type_code type)
|
||||
: fType(type)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~TypeList()
|
||||
{
|
||||
fItems.DoForEach(FreeTypeItemFunc);
|
||||
fItems.MakeEmpty();
|
||||
}
|
||||
|
||||
type_code Type() const
|
||||
{ return fType; }
|
||||
|
||||
TypeItem *FindItemByID(int32 id)
|
||||
{
|
||||
for (int32 i = 0; i < fItems.CountItems(); i++ ) {
|
||||
TypeItem *it = (TypeItem *)fItems.ItemAt(i);
|
||||
if (it->ID() == id)
|
||||
return it;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TypeItem *FindItemByName(const char *name)
|
||||
{
|
||||
for (int32 i = 0; i < fItems.CountItems(); i++ ) {
|
||||
TypeItem *it = (TypeItem*)fItems.ItemAt(i);
|
||||
if (strcmp(it->Name(), name) == 0)
|
||||
return it;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void AddItem(TypeItem *item)
|
||||
{
|
||||
fItems.AddItem(item);
|
||||
}
|
||||
|
||||
private:
|
||||
type_code fType;
|
||||
BList fItems;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
using namespace TResourcePrivate;
|
||||
|
||||
// #pragma mark -
|
||||
// ----------------------------- TStringBlock -----------------------------
|
||||
|
||||
|
||||
TStringBlock::TStringBlock(BDataIO *data)
|
||||
: fNumEntries(0),
|
||||
fIndex(0),
|
||||
fStrings(NULL),
|
||||
fOwnData(true)
|
||||
{
|
||||
fStrings = (char*)malloc(1024);
|
||||
size_t pos = 0;
|
||||
ssize_t amount;
|
||||
while ((amount=data->Read(fStrings + pos, 1024)) == 1024) {
|
||||
pos += amount;
|
||||
fStrings = (char *)realloc(fStrings, pos + 1024);
|
||||
}
|
||||
if (amount > 0)
|
||||
pos += amount;
|
||||
|
||||
fNumEntries = PreIndex(fStrings, amount);
|
||||
fIndex = (size_t *)malloc(sizeof(size_t) * fNumEntries);
|
||||
MakeIndex(fStrings, amount, fNumEntries, fIndex);
|
||||
}
|
||||
|
||||
|
||||
TStringBlock::TStringBlock(const void *block, size_t size)
|
||||
:
|
||||
fNumEntries(0),
|
||||
fIndex(0),
|
||||
fStrings(NULL),
|
||||
fOwnData(false)
|
||||
{
|
||||
fIndex = (size_t *)const_cast<void *>(block);
|
||||
fStrings = (char *)const_cast<void *>(block);
|
||||
|
||||
// Figure out how many entries there are.
|
||||
size_t last_off = 0;
|
||||
while (fIndex[fNumEntries] > last_off && fIndex[fNumEntries] < size ) {
|
||||
last_off = fIndex[fNumEntries];
|
||||
fNumEntries++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TStringBlock::~TStringBlock()
|
||||
{
|
||||
if (fOwnData) {
|
||||
free(fIndex);
|
||||
free(fStrings);
|
||||
}
|
||||
fIndex = 0;
|
||||
fStrings = NULL;
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
TStringBlock::String(size_t index) const
|
||||
{
|
||||
if (index >= fNumEntries)
|
||||
return NULL;
|
||||
|
||||
return fStrings + fIndex[index];
|
||||
}
|
||||
|
||||
|
||||
size_t
|
||||
TStringBlock::PreIndex(char *strings, ssize_t len)
|
||||
{
|
||||
size_t count = 0;
|
||||
|
||||
char *orig = strings;
|
||||
char *end = strings + len;
|
||||
bool in_cr = false;
|
||||
bool first = true;
|
||||
bool skipping = false;
|
||||
while (orig < end) {
|
||||
if (*orig == '\n' || *orig == '\r' || *orig == 0) {
|
||||
if (!in_cr && *orig == '\r')
|
||||
in_cr = true;
|
||||
if (in_cr && *orig == '\n') {
|
||||
orig++;
|
||||
continue;
|
||||
}
|
||||
first = true;
|
||||
skipping = false;
|
||||
*strings = 0;
|
||||
count++;
|
||||
} else if (first && *orig == '#') {
|
||||
skipping = true;
|
||||
first = false;
|
||||
orig++;
|
||||
continue;
|
||||
} else if (skipping) {
|
||||
orig++;
|
||||
continue;
|
||||
} else if (*orig == '\\' && (orig + 1) < end) {
|
||||
orig++;
|
||||
switch (*orig) {
|
||||
case '\\':
|
||||
*strings = '\\';
|
||||
break;
|
||||
|
||||
case '\n':
|
||||
*strings = '\n';
|
||||
break;
|
||||
|
||||
case '\r':
|
||||
*strings = '\r';
|
||||
break;
|
||||
|
||||
case '\t':
|
||||
*strings = '\t';
|
||||
break;
|
||||
|
||||
default:
|
||||
*strings = *orig;
|
||||
break;
|
||||
}
|
||||
} else
|
||||
*strings = *orig;
|
||||
|
||||
orig++;
|
||||
strings++;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TStringBlock::MakeIndex(const char *strings, ssize_t len,
|
||||
size_t indexLength, size_t *resultingIndex)
|
||||
{
|
||||
*resultingIndex++ = 0;
|
||||
indexLength--;
|
||||
|
||||
ssize_t pos = 0;
|
||||
while (pos < len && indexLength > 0) {
|
||||
if (strings[pos] == 0 ) {
|
||||
*resultingIndex++ = (size_t)pos + 1;
|
||||
indexLength--;
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
#if USE_RESOURCES
|
||||
static bool
|
||||
FreeResourcesFunc(void *item)
|
||||
{
|
||||
delete reinterpret_cast<BResources *>(item);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static bool
|
||||
FreePathFunc(void *item)
|
||||
{
|
||||
delete reinterpret_cast<BPath *>(item);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
FreeTypeFunc(void *item)
|
||||
{
|
||||
delete reinterpret_cast<TypeList*>(item);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
// ----------------------------- TResourceSet -----------------------------
|
||||
|
||||
|
||||
TResourceSet::TResourceSet()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
TResourceSet::~TResourceSet()
|
||||
{
|
||||
BAutolock lock(&fLock);
|
||||
#if USE_RESOURCES
|
||||
fResources.DoForEach(FreeResourcesFunc);
|
||||
fResources.MakeEmpty();
|
||||
#endif
|
||||
fDirectories.DoForEach(FreePathFunc);
|
||||
fDirectories.MakeEmpty();
|
||||
fTypes.DoForEach(FreeTypeFunc);
|
||||
fTypes.MakeEmpty();
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
TResourceSet::AddResources(BResources *RESOURCES_ONLY(resources))
|
||||
{
|
||||
#if USE_RESOURCES
|
||||
if (!resources)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
BAutolock lock(&fLock);
|
||||
status_t err = fResources.AddItem(resources) ? B_OK : B_ERROR;
|
||||
if (err != B_OK)
|
||||
delete resources;
|
||||
return err;
|
||||
#else
|
||||
return B_ERROR;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
TResourceSet::AddDirectory(const char *fullPath)
|
||||
{
|
||||
if (!fullPath)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
BPath *path = new BPath(fullPath);
|
||||
status_t err = path->InitCheck();
|
||||
if (err != B_OK) {
|
||||
delete path;
|
||||
return err;
|
||||
}
|
||||
|
||||
BAutolock lock(&fLock);
|
||||
err = fDirectories.AddItem(path) ? B_OK : B_ERROR;
|
||||
if (err != B_OK)
|
||||
delete path;
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
TResourceSet::AddEnvDirectory(const char *in, const char *defaultValue)
|
||||
{
|
||||
BString buf;
|
||||
status_t err = ExpandString(&buf, in);
|
||||
|
||||
if (err != B_OK) {
|
||||
if (defaultValue)
|
||||
return AddDirectory(defaultValue);
|
||||
return err;
|
||||
}
|
||||
|
||||
return AddDirectory(buf.String());
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
TResourceSet::ExpandString(BString *out, const char *in)
|
||||
{
|
||||
const char *start = in;
|
||||
while (*in) {
|
||||
if (*in == '$') {
|
||||
if (start < in)
|
||||
out->Append(start, (int32)(in - start));
|
||||
|
||||
in++;
|
||||
char variableName[1024];
|
||||
size_t i = 0;
|
||||
if (*in == '{') {
|
||||
in++;
|
||||
while (*in && *in != '}' && i < sizeof(variableName) - 1)
|
||||
variableName[i++] = *in++;
|
||||
|
||||
if (*in)
|
||||
in++;
|
||||
|
||||
} else
|
||||
while (isalnum(*in) || *in == '_' && i < sizeof(variableName) - 1)
|
||||
variableName[i++] = *in++;
|
||||
|
||||
start = in;
|
||||
|
||||
variableName[i] = '\0';
|
||||
|
||||
const char *val = getenv(variableName);
|
||||
if (!val) {
|
||||
PRINT(("Error: env var %s not found.\n", &variableName[0]));
|
||||
return B_NAME_NOT_FOUND;
|
||||
}
|
||||
|
||||
status_t err = ExpandString(out, val);
|
||||
if (err != B_OK)
|
||||
return err;
|
||||
|
||||
} else if (*in == '\\') {
|
||||
if (start < in)
|
||||
out->Append(start, (int32)(in - start));
|
||||
in++;
|
||||
start = in;
|
||||
in++;
|
||||
} else
|
||||
in++;
|
||||
}
|
||||
|
||||
if (start < in)
|
||||
out->Append(start, (int32)(in - start));
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
const void *
|
||||
TResourceSet::FindResource(type_code type, int32 id, size_t *outSize)
|
||||
{
|
||||
TypeItem *item = FindItemID(type, id);
|
||||
|
||||
if (outSize)
|
||||
*outSize = item ? item->Size() : 0;
|
||||
|
||||
return item ? item->Data() : NULL;
|
||||
}
|
||||
|
||||
|
||||
const void *
|
||||
TResourceSet::FindResource(type_code type, const char *name, size_t *outSize)
|
||||
{
|
||||
TypeItem *item = FindItemName(type, name);
|
||||
|
||||
if (outSize)
|
||||
*outSize = item ? item->Size() : 0;
|
||||
|
||||
return item ? item->Data() : NULL;
|
||||
}
|
||||
|
||||
|
||||
const BBitmap *
|
||||
TResourceSet::FindBitmap(type_code type, int32 id)
|
||||
{
|
||||
return ReturnBitmapItem(type, FindItemID(type, id));
|
||||
}
|
||||
|
||||
|
||||
const BBitmap *
|
||||
TResourceSet::FindBitmap(type_code type, const char *name)
|
||||
{
|
||||
return ReturnBitmapItem(type, FindItemName(type, name));
|
||||
}
|
||||
|
||||
|
||||
const TStringBlock *
|
||||
TResourceSet::FindStringBlock(type_code type, int32 id)
|
||||
{
|
||||
return ReturnStringBlockItem(FindItemID(type, id));
|
||||
}
|
||||
|
||||
|
||||
const TStringBlock *
|
||||
TResourceSet::FindStringBlock(type_code type, const char *name)
|
||||
{
|
||||
return ReturnStringBlockItem(FindItemName(type, name));
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
TResourceSet::FindString(type_code type, int32 id, uint32 index)
|
||||
{
|
||||
const TStringBlock *stringBlock = FindStringBlock(type, id);
|
||||
if (!stringBlock)
|
||||
return NULL;
|
||||
|
||||
return stringBlock->String(index);
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
TResourceSet::FindString(type_code type, const char *name, uint32 index)
|
||||
{
|
||||
const TStringBlock *stringBlock = FindStringBlock(type, name);
|
||||
if (!stringBlock)
|
||||
return NULL;
|
||||
|
||||
return stringBlock->String(index);
|
||||
}
|
||||
|
||||
|
||||
TypeList *
|
||||
TResourceSet::FindTypeList(type_code type)
|
||||
{
|
||||
BAutolock lock(&fLock);
|
||||
|
||||
int32 count = fTypes.CountItems();
|
||||
for (int32 i = 0; i < count; i++ ) {
|
||||
TypeList *list = (TypeList *)fTypes.ItemAt(i);
|
||||
if (list && list->Type() == type)
|
||||
return list;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
TypeItem *
|
||||
TResourceSet::FindItemID(type_code type, int32 id)
|
||||
{
|
||||
TypeList *list = FindTypeList(type);
|
||||
TypeItem *item = NULL;
|
||||
|
||||
if (list) item = list->FindItemByID(id);
|
||||
|
||||
if (!item)
|
||||
item = LoadResource(type, id, 0, &list);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
TypeItem *
|
||||
TResourceSet::FindItemName(type_code type, const char *name)
|
||||
{
|
||||
TypeList *list = FindTypeList(type);
|
||||
TypeItem *item = NULL;
|
||||
|
||||
if (list)
|
||||
item = list->FindItemByName(name);
|
||||
|
||||
if (!item)
|
||||
item = LoadResource(type, -1, name, &list);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
TypeItem *
|
||||
TResourceSet::LoadResource(type_code type, int32 id, const char *name,
|
||||
TypeList **inOutList)
|
||||
{
|
||||
TypeItem *item = NULL;
|
||||
|
||||
if (name) {
|
||||
BEntry entry;
|
||||
|
||||
// If a named resource, first look in directories.
|
||||
fLock.Lock();
|
||||
int32 count = fDirectories.CountItems();
|
||||
for (int32 i = 0; item == 0 && i < count; i++) {
|
||||
BPath *dir = (BPath *)fDirectories.ItemAt(i);
|
||||
if (dir) {
|
||||
fLock.Unlock();
|
||||
BPath path(dir->Path(), name);
|
||||
if (entry.SetTo(path.Path(), true) == B_OK ) {
|
||||
BFile file(&entry, B_READ_ONLY);
|
||||
if (file.InitCheck() == B_OK ) {
|
||||
item = new TypeItem(id, name, &file);
|
||||
item->SetSourceIsFile(true);
|
||||
}
|
||||
}
|
||||
fLock.Lock();
|
||||
}
|
||||
}
|
||||
fLock.Unlock();
|
||||
}
|
||||
|
||||
#if USE_RESOURCES
|
||||
if (!item) {
|
||||
// Look through resource objects for data.
|
||||
fLock.Lock();
|
||||
int32 count = fResources.CountItems();
|
||||
for (int32 i = 0; item == 0 && i < count; i++ ) {
|
||||
BResources *resource = (BResources *)fResources.ItemAt(i);
|
||||
if (resource) {
|
||||
const void *data = NULL;
|
||||
size_t size = 0;
|
||||
if (id >= 0)
|
||||
data = resource->LoadResource(type, id, &size);
|
||||
else if (name != NULL)
|
||||
data = resource->LoadResource(type, name, &size);
|
||||
|
||||
if (data && size) {
|
||||
item = new TypeItem(id, name, data, size);
|
||||
item->SetSourceIsFile(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
fLock.Unlock();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (item) {
|
||||
TypeList *list = inOutList ? *inOutList : NULL;
|
||||
if (!list) {
|
||||
// Don't currently have a list for this type -- check if there is
|
||||
// already one.
|
||||
list = FindTypeList(type);
|
||||
}
|
||||
|
||||
BAutolock lock(&fLock);
|
||||
|
||||
if (!list) {
|
||||
// Need to make a new list for this type.
|
||||
list = new TypeList(type);
|
||||
fTypes.AddItem(list);
|
||||
}
|
||||
if (inOutList)
|
||||
*inOutList = list;
|
||||
|
||||
list->AddItem(item);
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
BBitmap *
|
||||
TResourceSet::ReturnBitmapItem(type_code, TypeItem *from)
|
||||
{
|
||||
if (!from)
|
||||
return NULL;
|
||||
|
||||
TypeObject *obj = from->Object();
|
||||
BitmapTypeItem *bitmap = dynamic_cast<BitmapTypeItem *>(obj);
|
||||
if (bitmap)
|
||||
return bitmap;
|
||||
|
||||
// Can't change an existing object.
|
||||
if (obj)
|
||||
return NULL;
|
||||
|
||||
// Don't have a bitmap in the item -- we'll try to create one.
|
||||
BMemoryIO stream(from->Data(), from->Size());
|
||||
|
||||
// Try to read as an archived bitmap.
|
||||
stream.Seek(0, SEEK_SET);
|
||||
BMessage archive;
|
||||
if (archive.Unflatten(&stream) == B_OK ) {
|
||||
bitmap = new BitmapTypeItem(&archive);
|
||||
if (bitmap && bitmap->InitCheck() != B_OK) {
|
||||
bitmap->Delete(); // allows us to delete this bitmap...
|
||||
delete bitmap;
|
||||
bitmap = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (bitmap) {
|
||||
BAutolock lock(&fLock);
|
||||
if (from->Object() != NULL) {
|
||||
// Whoops! Someone snuck in under us.
|
||||
bitmap->Delete();
|
||||
delete bitmap;
|
||||
bitmap = dynamic_cast<BitmapTypeItem *>(from->Object());
|
||||
} else
|
||||
from->SetObject(bitmap);
|
||||
}
|
||||
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
|
||||
TStringBlock *
|
||||
TResourceSet::ReturnStringBlockItem(TypeItem *from)
|
||||
{
|
||||
if (!from)
|
||||
return NULL;
|
||||
|
||||
TypeObject *obj = from->Object();
|
||||
StringBlockTypeItem *stringBlock = dynamic_cast<StringBlockTypeItem *>(obj);
|
||||
if (stringBlock)
|
||||
return stringBlock;
|
||||
|
||||
// Can't change an existing object.
|
||||
if (obj)
|
||||
return NULL;
|
||||
|
||||
// Don't have a string block in the item -- we'll create one.
|
||||
if (from->SourceIsFile() ) {
|
||||
BMemoryIO stream(from->Data(), from->Size());
|
||||
stringBlock = new StringBlockTypeItem(&stream);
|
||||
} else
|
||||
stringBlock = new StringBlockTypeItem(from->Data(), from->Size());
|
||||
|
||||
if (stringBlock) {
|
||||
BAutolock lock(&fLock);
|
||||
if (from->Object() != NULL) {
|
||||
// Whoops! Someone snuck in under us.
|
||||
delete stringBlock;
|
||||
stringBlock = dynamic_cast<StringBlockTypeItem*>(from->Object());
|
||||
} else
|
||||
from->SetObject(stringBlock);
|
||||
}
|
||||
|
||||
return stringBlock;
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
namespace TResourcePrivate {
|
||||
|
||||
TResourceSet *gResources = NULL;
|
||||
BLocker gResourceLocker;
|
||||
|
||||
}
|
||||
|
||||
|
||||
TResourceSet *
|
||||
AppResSet()
|
||||
{
|
||||
// If already have it, return immediately.
|
||||
if (gResources)
|
||||
return gResources;
|
||||
|
||||
// Don't have 'em, lock access to make 'em.
|
||||
if (!gResourceLocker.Lock())
|
||||
return NULL;
|
||||
if (gResources) {
|
||||
// Whoops, somebody else already did. Oh well.
|
||||
gResourceLocker.Unlock();
|
||||
return gResources;
|
||||
}
|
||||
|
||||
// Make 'em.
|
||||
gResources = new TResourceSet;
|
||||
gResources->AddResources(BApplication::AppResources());
|
||||
gResourceLocker.Unlock();
|
||||
return gResources;
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
Open Tracker License
|
||||
|
||||
Terms and Conditions
|
||||
|
||||
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice applies to all licensees
|
||||
and shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of Be Incorporated shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings in
|
||||
this Software without prior written authorization from Be Incorporated.
|
||||
|
||||
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
||||
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 _T_RESOURCE_SET_H
|
||||
#define _T_RESOURCE_SET_H
|
||||
|
||||
#include <List.h>
|
||||
#include <Locker.h>
|
||||
#include <SupportDefs.h>
|
||||
|
||||
class BBitmap;
|
||||
class BResources;
|
||||
class BDataIO;
|
||||
class BString;
|
||||
|
||||
namespace TResourcePrivate {
|
||||
class TypeItem;
|
||||
class TypeList;
|
||||
}
|
||||
|
||||
using namespace TResourcePrivate;
|
||||
|
||||
const uint32 B_STRING_BLOCK_TYPE = 'SBLK';
|
||||
|
||||
class TStringBlock {
|
||||
public:
|
||||
TStringBlock(BDataIO *data);
|
||||
TStringBlock(const void *block, size_t size);
|
||||
virtual ~TStringBlock();
|
||||
|
||||
const char *String(size_t index) const;
|
||||
|
||||
private:
|
||||
size_t PreIndex(char *strings, ssize_t len);
|
||||
void MakeIndex(const char *strings, ssize_t len,
|
||||
size_t indexLen, size_t *outIndex);
|
||||
|
||||
size_t fNumEntries;
|
||||
size_t *fIndex;
|
||||
char *fStrings;
|
||||
bool fOwnData;
|
||||
};
|
||||
|
||||
class TResourceSet {
|
||||
public:
|
||||
TResourceSet();
|
||||
virtual ~TResourceSet();
|
||||
|
||||
status_t AddResources(BResources *resources);
|
||||
status_t AddDirectory(const char *fullPath);
|
||||
status_t AddEnvDirectory(const char *envPath,
|
||||
const char *defaultValue = NULL);
|
||||
|
||||
const void *FindResource(type_code type, int32 id,
|
||||
size_t *outSize);
|
||||
const void *FindResource(type_code type, const char *name,
|
||||
size_t *outSize);
|
||||
|
||||
const BBitmap *FindBitmap(type_code type, int32 id);
|
||||
const BBitmap *FindBitmap(type_code type, const char *name);
|
||||
|
||||
const TStringBlock *FindStringBlock(type_code type, int32 id);
|
||||
const TStringBlock *FindStringBlock(type_code type, const char *name);
|
||||
|
||||
const char *FindString(type_code type, int32 id, uint32 index);
|
||||
const char *FindString(type_code type, const char *name, uint32 index);
|
||||
|
||||
private:
|
||||
status_t ExpandString(BString *out, const char *in);
|
||||
TypeList *FindTypeList(type_code type);
|
||||
|
||||
TypeItem *FindItemID(type_code type, int32 id);
|
||||
TypeItem *FindItemName(type_code type, const char *name);
|
||||
|
||||
TypeItem *LoadResource(type_code type, int32 id, const char *name,
|
||||
TypeList **inoutList = NULL);
|
||||
|
||||
BBitmap *ReturnBitmapItem(type_code type, TypeItem *from);
|
||||
TStringBlock *ReturnStringBlockItem(TypeItem *from);
|
||||
|
||||
BLocker fLock; // access control.
|
||||
BList fResources; // containing BResources objects.
|
||||
BList fDirectories; // containing BPath objects.
|
||||
BList fTypes; // containing TypeList objects.
|
||||
};
|
||||
|
||||
TResourceSet *AppResSet();
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
Open Tracker License
|
||||
|
||||
Terms and Conditions
|
||||
|
||||
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice applies to all licensees
|
||||
and shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of Be Incorporated shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings in
|
||||
this Software without prior written authorization from Be Incorporated.
|
||||
|
||||
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
||||
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.
|
||||
*/
|
||||
|
||||
#include <Debug.h>
|
||||
#include <malloc.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <Roster.h>
|
||||
|
||||
#include "ShowHideMenuItem.h"
|
||||
#include "WindowMenuItem.h"
|
||||
#include "tracker_private.h"
|
||||
|
||||
|
||||
const int32 kDesktopWindow = 4;
|
||||
const float kHPad = 10.0f;
|
||||
const float kVPad = 2.0f;
|
||||
|
||||
|
||||
TShowHideMenuItem::TShowHideMenuItem(const char *title, const BList *teams, uint32 action)
|
||||
: BMenuItem(title, NULL),
|
||||
fTeams(teams),
|
||||
fAction(action)
|
||||
{
|
||||
BFont font(be_plain_font);
|
||||
fTitleWidth = ceilf(font.StringWidth(title));
|
||||
font_height fontHeight;
|
||||
font.GetHeight(&fontHeight);
|
||||
fTitleAscent = ceilf(fontHeight.ascent);
|
||||
fTitleDescent = ceilf(fontHeight.descent + fontHeight.leading);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TShowHideMenuItem::GetContentSize(float *width, float *height)
|
||||
{
|
||||
*width = kHPad + fTitleWidth + kHPad;
|
||||
*height = fTitleAscent + fTitleDescent;
|
||||
*height += kVPad * 2;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TShowHideMenuItem::DrawContent()
|
||||
{
|
||||
BRect frame(Frame());
|
||||
float labelHeight = fTitleAscent + fTitleDescent;
|
||||
BPoint drawLoc;
|
||||
drawLoc.x = kHPad;
|
||||
drawLoc.y = ((frame.Height() - labelHeight) / 2);
|
||||
Menu()->MovePenBy(drawLoc.x, drawLoc.y);
|
||||
BMenuItem::DrawContent();
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
TShowHideMenuItem::Invoke(BMessage *)
|
||||
{
|
||||
bool doZoom = false;
|
||||
BRect zoomRect(0, 0, 0, 0);
|
||||
BMenuItem *item = Menu()->Superitem();
|
||||
|
||||
if (item->Menu()->Window() != NULL) {
|
||||
zoomRect = item->Menu()->ConvertToScreen(item->Frame());
|
||||
doZoom = true;
|
||||
}
|
||||
return TeamShowHideCommon(static_cast<int32>(fAction), fTeams, zoomRect, doZoom);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
TShowHideMenuItem::TeamShowHideCommon(int32 action, const BList *teamList,
|
||||
BRect zoomRect, bool doZoom)
|
||||
{
|
||||
if (teamList == NULL)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
int32 count = teamList->CountItems();
|
||||
for (int32 index = 0; index < count; index++) {
|
||||
team_id team = (team_id)teamList->ItemAt(index);
|
||||
|
||||
switch (action) {
|
||||
case B_MINIMIZE_WINDOW:
|
||||
do_minimize_team(zoomRect, team, doZoom && index == 0);
|
||||
break;
|
||||
|
||||
case B_BRING_TO_FRONT:
|
||||
do_bring_to_front_team(zoomRect, team, doZoom && index == 0);
|
||||
break;
|
||||
|
||||
case B_QUIT_REQUESTED:
|
||||
{
|
||||
BMessenger messenger((char *)NULL, team);
|
||||
uint32 command = B_QUIT_REQUESTED;
|
||||
app_info aInfo;
|
||||
be_roster->GetRunningAppInfo(team, &aInfo);
|
||||
|
||||
if (strcasecmp(aInfo.signature, kTrackerSignature) == 0)
|
||||
command = 'Tall';
|
||||
|
||||
messenger.SendMessage(command);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
Open Tracker License
|
||||
|
||||
Terms and Conditions
|
||||
|
||||
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice applies to all licensees
|
||||
and shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of Be Incorporated shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings in
|
||||
this Software without prior written authorization from Be Incorporated.
|
||||
|
||||
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
||||
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.
|
||||
*/
|
||||
|
||||
// window control menu items (Show All, Hide All, Close All)
|
||||
// in WindowMenu
|
||||
|
||||
#ifndef SHOWHIDEMENUITEM_H
|
||||
#define SHOWHIDEMENUITEM_H
|
||||
|
||||
#include <MenuItem.h>
|
||||
|
||||
|
||||
class TShowHideMenuItem : public BMenuItem {
|
||||
public:
|
||||
TShowHideMenuItem(const char *title,
|
||||
const BList *teams,
|
||||
uint32 action);
|
||||
|
||||
static status_t TeamShowHideCommon(int32 action,
|
||||
const BList *teamList,
|
||||
BRect zoomRect = BRect(0, 0, 0, 0),
|
||||
bool doZoom = false);
|
||||
protected:
|
||||
virtual void GetContentSize(float *width, float *height);
|
||||
virtual void DrawContent();
|
||||
virtual status_t Invoke(BMessage *message = NULL);
|
||||
|
||||
private:
|
||||
const BList* fTeams;
|
||||
uint32 fAction;
|
||||
float fTitleWidth;
|
||||
float fTitleAscent;
|
||||
float fTitleDescent;
|
||||
};
|
||||
|
||||
|
||||
#endif /* SHOWHIDEMENUITEM_H */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,208 @@
|
||||
/*
|
||||
Open Tracker License
|
||||
|
||||
Terms and Conditions
|
||||
|
||||
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice applies to all licensees
|
||||
and shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of Be Incorporated shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings in
|
||||
this Software without prior written authorization from Be Incorporated.
|
||||
|
||||
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
||||
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 __STATUS_VIEW__
|
||||
#define __STATUS_VIEW__
|
||||
|
||||
#include <Control.h>
|
||||
#include <Node.h>
|
||||
#include <Query.h>
|
||||
#include <Shelf.h>
|
||||
#include <View.h>
|
||||
|
||||
#include "BarView.h"
|
||||
#include "TimeView.h"
|
||||
|
||||
const float kMaxReplicantHeight = 16.0f;
|
||||
const float kMaxReplicantWidth = 16.0f;
|
||||
const int32 kMinimumReplicantCount = 6;
|
||||
const int32 kIconGap = 2;
|
||||
const int32 kGutter = 1;
|
||||
const int32 kDragRegionWidth = 6;
|
||||
|
||||
// 1 pixel left gutter
|
||||
// space for replicant tray (6 items)
|
||||
// 6 pixel drag region
|
||||
const float kMinimumTrayWidth = kIconGap
|
||||
+ (kMinimumReplicantCount * kIconGap)
|
||||
+ (kMinimumReplicantCount * kMaxReplicantWidth) + kGutter;
|
||||
const float kMinimumTrayHeight = kGutter + kMaxReplicantHeight + kGutter;
|
||||
|
||||
const float kMinimumWindowWidth = kGutter + kMinimumTrayWidth + kDragRegionWidth;
|
||||
|
||||
#ifdef DB_ADDONS
|
||||
struct DeskbarItemInfo {
|
||||
bool isAddOn; // attribute tagged item
|
||||
int32 id; // id given to replicant
|
||||
entry_ref entryRef; // entry_ref to item tagged
|
||||
node_ref nodeRef; // node_ref to boot vol item
|
||||
};
|
||||
#endif
|
||||
|
||||
class TReplicantTray : public BView {
|
||||
public:
|
||||
TReplicantTray(TBarView *bv, bool vertical);
|
||||
virtual ~TReplicantTray();
|
||||
|
||||
virtual void AttachedToWindow();
|
||||
virtual void DetachedFromWindow();
|
||||
virtual void Draw(BRect updateRect);
|
||||
virtual void MouseDown(BPoint point);
|
||||
virtual void MessageReceived(BMessage *);
|
||||
virtual void GetPreferredSize(float *, float *);
|
||||
|
||||
void AdjustPlacement();
|
||||
|
||||
void ShowReplicantMenu(BPoint);
|
||||
|
||||
void SetMultiRow(bool state);
|
||||
bool IsMultiRow() const { return fMultiRowMode; }
|
||||
|
||||
status_t ItemInfo(int32 target, const char **name);
|
||||
status_t ItemInfo(const char *name, int32 *id);
|
||||
status_t ItemInfo(int32 index, const char **name, int32 *id);
|
||||
|
||||
bool IconExists(int32 target, bool byIndex = false);
|
||||
bool IconExists(const char *name);
|
||||
|
||||
int32 IconCount() const;
|
||||
|
||||
status_t AddIcon(BMessage *, int32 *id, const entry_ref * = NULL);
|
||||
|
||||
void RemoveIcon(int32 target, bool byIndex = false);
|
||||
void RemoveIcon(const char *name);
|
||||
|
||||
BRect IconFrame(int32 target, bool byIndex=false);
|
||||
BRect IconFrame(const char *name);
|
||||
|
||||
bool AcceptAddon(BRect frame, BMessage *message);
|
||||
void RealignReplicants(int32 startIndex = -1);
|
||||
|
||||
bool ShowingSeconds(void);
|
||||
bool ShowingMiltime(void);
|
||||
bool ShowingEuroDate(void);
|
||||
bool ShowingFullDate(void);
|
||||
bool CanShowFullDate(void);
|
||||
|
||||
void RememberClockSettings();
|
||||
void DealWithClock(bool);
|
||||
|
||||
#ifdef DB_ADDONS
|
||||
status_t LoadAddOn(BEntry *entry, int32 *id, bool force = false);
|
||||
#endif
|
||||
|
||||
private:
|
||||
BView *ViewAt(int32 *index, int32 *id, int32 target, bool byIndex = false);
|
||||
BView *ViewAt(int32 *index, int32 *id, const char *name);
|
||||
|
||||
void RealReplicantAdjustment(int32 startindex);
|
||||
|
||||
#ifdef DB_ADDONS
|
||||
void InitAddOnSupport();
|
||||
void DeleteAddOnSupport();
|
||||
void RunAddOnQuery(BVolume *volume, const char *predicated);
|
||||
|
||||
bool IsAddOn(entry_ref &ref);
|
||||
DeskbarItemInfo *DeskbarItemFor(node_ref &nodeRef);
|
||||
DeskbarItemInfo *DeskbarItemFor(int32 id);
|
||||
bool NodeExists(node_ref &nodeRef);
|
||||
|
||||
void HandleEntryUpdate(BMessage *);
|
||||
status_t AddItem(int32 id, node_ref nodeRef, BEntry &entry, bool isAddon);
|
||||
|
||||
void UnloadAddOn(node_ref *, dev_t *, bool which, bool removeAll);
|
||||
void RemoveItem(int32 id);
|
||||
|
||||
void MoveItem(entry_ref *, ino_t toDirectory);
|
||||
#endif
|
||||
|
||||
BPoint LocForReplicant(int32 replicantCount, int32 index, float width);
|
||||
BShelf *Shelf() const;
|
||||
|
||||
friend class TReplicantShelf;
|
||||
|
||||
TTimeView *fClock;
|
||||
TBarView *fBarView;
|
||||
TReplicantShelf *fShelf;
|
||||
|
||||
bool fMultiRowMode;
|
||||
|
||||
bool fAlignmentSupport;
|
||||
#ifdef DB_ADDONS
|
||||
BList *fItemList;
|
||||
uint64 fDeskbarSecurityCode;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
enum {
|
||||
kNoDragRegion,
|
||||
kDontDrawDragRegion,
|
||||
kAutoPlaceDragRegion,
|
||||
kDragRegionLeft,
|
||||
kDragRegionRight,
|
||||
kDragRegionTop,
|
||||
kDragRegionBottom
|
||||
};
|
||||
|
||||
class TDragRegion : public BControl {
|
||||
public:
|
||||
TDragRegion(TBarView *, BView *);
|
||||
|
||||
virtual void AttachedToWindow();
|
||||
virtual void GetPreferredSize(float *, float *);
|
||||
virtual void Draw(BRect);
|
||||
virtual void FrameMoved(BPoint);
|
||||
virtual void MouseDown(BPoint );
|
||||
virtual void MouseUp(BPoint );
|
||||
virtual void MouseMoved(BPoint , uint32 , const BMessage *);
|
||||
|
||||
void DrawDragRegion();
|
||||
BRect DragRegion() const;
|
||||
|
||||
bool SwitchModeForRect(BPoint mouse, BRect rect,
|
||||
bool newVertical, bool newLeft, bool newTop, int32 newState);
|
||||
|
||||
int32 DragRegionLocation() const;
|
||||
void SetDragRegionLocation(int32);
|
||||
|
||||
private:
|
||||
TBarView *fBarView;
|
||||
BView *fChild;
|
||||
BPoint fPreviousPosition;
|
||||
int32 fDragLocation;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
Open Tracker License
|
||||
|
||||
Terms and Conditions
|
||||
|
||||
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice applies to all licensees
|
||||
and shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of Be Incorporated shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings in
|
||||
this Software without prior written authorization from Be Incorporated.
|
||||
|
||||
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
||||
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.
|
||||
*/
|
||||
|
||||
#include <Debug.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <InterfaceDefs.h>
|
||||
|
||||
#include "StatusViewShelf.h"
|
||||
#include "StatusView.h"
|
||||
|
||||
TReplicantShelf::TReplicantShelf(TReplicantTray* parent)
|
||||
: BShelf(parent, false, "DeskbarShelf")
|
||||
{
|
||||
fParent = parent;
|
||||
SetAllowsZombies(false);
|
||||
}
|
||||
|
||||
TReplicantShelf::~TReplicantShelf()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
TReplicantShelf::MessageReceived(BMessage* message)
|
||||
{
|
||||
switch(message->what) {
|
||||
case B_DELETE_PROPERTY:
|
||||
{
|
||||
BMessage repspec;
|
||||
int32 index = 0;
|
||||
//
|
||||
// this should only occur via scripting
|
||||
// since we can't use ReplicantDeleted
|
||||
// catch the message and find the id or name specifier
|
||||
// then delete the rep vi the api,
|
||||
//
|
||||
// this will fix the problem of realigning the reps
|
||||
// after a remove when done through scripting
|
||||
//
|
||||
// note: if specified by index its the index not the id!
|
||||
//
|
||||
while (message->FindMessage("specifiers", index++, &repspec) == B_OK) {
|
||||
const char* str;
|
||||
if (repspec.FindString("property", &str) == B_OK) {
|
||||
if (strcmp(str, "Replicant") == 0) {
|
||||
int32 index;
|
||||
if (repspec.FindInt32("index", &index) == B_OK) {
|
||||
int32 id;
|
||||
const char* name;
|
||||
if (fParent->ItemInfo(index, &name, &id) == B_OK)
|
||||
fParent->RemoveIcon(id);
|
||||
break;
|
||||
} else if (repspec.FindString("name", &str) == B_OK) {
|
||||
fParent->RemoveIcon(str);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
BShelf::MessageReceived(message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
TReplicantShelf::CanAcceptReplicantView(BRect frame, BView* view, BMessage* message) const
|
||||
{
|
||||
if (view->ResizingMode() != B_FOLLOW_NONE)
|
||||
view->SetResizingMode(B_FOLLOW_NONE);
|
||||
|
||||
// determine placement and whether the new replicant will 'fit'
|
||||
return fParent->AcceptAddon(frame, message);
|
||||
}
|
||||
|
||||
BPoint
|
||||
TReplicantShelf::AdjustReplicantBy(BRect frame, BMessage *message) const
|
||||
{
|
||||
// added in AcceptAddon, from TReplicantTray
|
||||
BPoint pt;
|
||||
message->FindPoint("_pjp_loc", &pt);
|
||||
message->RemoveName("_pjp_loc");
|
||||
|
||||
pt = pt - frame.LeftTop();
|
||||
|
||||
return pt;
|
||||
}
|
||||
|
||||
//
|
||||
// the virtual BShelf::ReplicantDeleted is called before the
|
||||
// replicant is actually removed from BShelf's internal list
|
||||
// thus, this returns the wrong number of replicants.
|
||||
//
|
||||
void
|
||||
TReplicantShelf::ReplicantDeleted(int32, const BMessage*, const BView*)
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
Open Tracker License
|
||||
|
||||
Terms and Conditions
|
||||
|
||||
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice applies to all licensees
|
||||
and shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of Be Incorporated shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings in
|
||||
this Software without prior written authorization from Be Incorporated.
|
||||
|
||||
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
||||
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.
|
||||
*/
|
||||
|
||||
// overrides BShelf; rejects draggers that won't fit into the shelf
|
||||
// alligns received draggers into a grid
|
||||
|
||||
#ifndef __STATUS_VIEW_SHELF__
|
||||
#define __STATUS_VIEW_SHELF__
|
||||
|
||||
#include <Shelf.h>
|
||||
|
||||
class TReplicantTray;
|
||||
class TReplicantShelf : public BShelf {
|
||||
public:
|
||||
TReplicantShelf(TReplicantTray *view);
|
||||
~TReplicantShelf();
|
||||
|
||||
void MessageReceived(BMessage*);
|
||||
|
||||
protected:
|
||||
bool CanAcceptReplicantView(BRect, BView *, BMessage *) const;
|
||||
BPoint AdjustReplicantBy(BRect, BMessage *) const;
|
||||
void ReplicantDeleted(int32, const BMessage *, const BView *);
|
||||
|
||||
private:
|
||||
TReplicantTray* fParent;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,253 @@
|
||||
/*
|
||||
Open Tracker License
|
||||
|
||||
Terms and Conditions
|
||||
|
||||
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice applies to all licensees
|
||||
and shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of Be Incorporated shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings in
|
||||
this Software without prior written authorization from Be Incorporated.
|
||||
|
||||
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
||||
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
|
||||
|
||||
#include <Box.h>
|
||||
#include <List.h>
|
||||
#include <OS.h>
|
||||
#include <StringView.h>
|
||||
#include <Window.h>
|
||||
|
||||
class TTeamGroup {
|
||||
public:
|
||||
TTeamGroup();
|
||||
TTeamGroup(BList *teams, uint32 flags, char *name, const char *sig);
|
||||
virtual ~TTeamGroup();
|
||||
|
||||
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; }
|
||||
|
||||
|
||||
private:
|
||||
BList *fTeams;
|
||||
uint32 fFlags;
|
||||
char fSig[B_MIME_TYPE_LENGTH];
|
||||
char *fName;
|
||||
BBitmap *fSmallIcon;
|
||||
BBitmap *fLargeIcon;
|
||||
};
|
||||
|
||||
class TIconView;
|
||||
class TBox;
|
||||
class TWindowView;
|
||||
class TSwitcherWindow;
|
||||
struct window_info;
|
||||
|
||||
class TSwitchMgr : public BHandler {
|
||||
public:
|
||||
TSwitchMgr(BPoint where);
|
||||
virtual ~TSwitchMgr();
|
||||
|
||||
virtual void MessageReceived(BMessage *);
|
||||
|
||||
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();
|
||||
|
||||
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);
|
||||
|
||||
TSwitcherWindow *fWindow;
|
||||
sem_id fMainMonitor;
|
||||
bool fBlock;
|
||||
bigtime_t fSkipUntil;
|
||||
BList fGroupList;
|
||||
int32 fCurIndex;
|
||||
int32 fCurWindow;
|
||||
int32 fCurSlot;
|
||||
int32 fWindowID;
|
||||
bigtime_t fLastActivity;
|
||||
};
|
||||
|
||||
class TSwitcherWindow : public BWindow {
|
||||
public:
|
||||
TSwitcherWindow(BRect frame, TSwitchMgr *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);
|
||||
|
||||
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);
|
||||
|
||||
private:
|
||||
|
||||
TSwitchMgr *fMgr;
|
||||
TIconView *fIconView;
|
||||
TBox *fTopView;
|
||||
TWindowView *fWindowView;
|
||||
bool fHairTrigger;
|
||||
};
|
||||
|
||||
class TWindowView : public BView {
|
||||
public:
|
||||
TWindowView(BRect, TSwitchMgr *, TSwitcherWindow *);
|
||||
|
||||
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);
|
||||
|
||||
void ShowIndex(int32 windex);
|
||||
BRect FrameOf(int32 index) const;
|
||||
|
||||
private:
|
||||
|
||||
int32 fCurToken;
|
||||
float fItemHeight;
|
||||
TSwitcherWindow *fSwitcher;
|
||||
TSwitchMgr *fMgr;
|
||||
bool fLocal;
|
||||
};
|
||||
|
||||
class TIconView : public BView {
|
||||
public:
|
||||
TIconView(BRect , TSwitchMgr *, TSwitcherWindow *);
|
||||
~TIconView();
|
||||
|
||||
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);
|
||||
|
||||
private:
|
||||
|
||||
void CacheIcons(TTeamGroup *);
|
||||
void AnimateIcon(BBitmap *startIcon, BBitmap *endIcon);
|
||||
|
||||
bool fAutoScrolling;
|
||||
bool fCapsState;
|
||||
TSwitcherWindow *fSwitcher;
|
||||
TSwitchMgr *fMgr;
|
||||
BBitmap *fOffBitmap;
|
||||
BView *fOffView;
|
||||
BBitmap *fCurSmall;
|
||||
BBitmap *fCurLarge;
|
||||
};
|
||||
|
||||
class TBox : public BBox {
|
||||
public:
|
||||
TBox(BRect bounds, TSwitchMgr *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);
|
||||
|
||||
private:
|
||||
TSwitchMgr *fMgr;
|
||||
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 TIconView *TSwitcherWindow::IconView()
|
||||
{ return fIconView; }
|
||||
|
||||
inline TWindowView *TSwitcherWindow::WindowView()
|
||||
{ return fWindowView; }
|
||||
|
||||
inline void TSwitchMgr::Touch(bool zero)
|
||||
{ fLastActivity = zero ? 0 : system_time(); }
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
Open Tracker License
|
||||
|
||||
Terms and Conditions
|
||||
|
||||
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice applies to all licensees
|
||||
and shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of Be Incorporated shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings in
|
||||
this Software without prior written authorization from Be Incorporated.
|
||||
|
||||
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
||||
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.
|
||||
*/
|
||||
|
||||
#include <Debug.h>
|
||||
#include <string.h>
|
||||
#include <Application.h>
|
||||
#include <Roster.h>
|
||||
|
||||
#include "BarApp.h"
|
||||
#include "BarMenuBar.h"
|
||||
#include "DeskBarUtils.h"
|
||||
#include "TeamMenuItem.h"
|
||||
#include "TeamMenu.h"
|
||||
|
||||
|
||||
TTeamMenu::TTeamMenu()
|
||||
: BMenu("Team Menu")
|
||||
{
|
||||
SetItemMargins(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
SetFont(be_plain_font);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
TTeamMenu::CompareByName( const void *first, const void *second)
|
||||
{
|
||||
return strcasecmp(
|
||||
(*(static_cast<BarTeamInfo * const*>(first )))->name,
|
||||
(*(static_cast<BarTeamInfo * const*>(second)))->name);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TTeamMenu::AttachedToWindow()
|
||||
{
|
||||
BMenuItem *item = NULL;
|
||||
while ((item = RemoveItem((int32)0)) != NULL)
|
||||
delete item;
|
||||
|
||||
BMessenger self(this);
|
||||
BList teamList;
|
||||
TBarApp::Subscribe(self, &teamList);
|
||||
|
||||
TBarView *barview = (dynamic_cast<TBarApp *>(be_app))->BarView();
|
||||
bool dragging = barview && barview->Dragging();
|
||||
|
||||
desk_settings *settings = ((TBarApp *)be_app)->Settings();
|
||||
|
||||
if (settings->sortRunningApps)
|
||||
teamList.SortItems(CompareByName);
|
||||
|
||||
int32 count = teamList.CountItems();
|
||||
for (int32 i = 0; i < count; i++) {
|
||||
BarTeamInfo *barInfo = (BarTeamInfo *)teamList.ItemAt(i);
|
||||
|
||||
if (((barInfo->flags & B_BACKGROUND_APP) == 0)
|
||||
&& (strcasecmp(barInfo->sig, kDeskbarSignature) != 0)) {
|
||||
TTeamMenuItem *item = new TTeamMenuItem(barInfo->teams, barInfo->icon,
|
||||
barInfo->name, barInfo->sig, -1, -1, true, true);
|
||||
|
||||
if ((settings->trackerAlwaysFirst)
|
||||
&& (strcmp(barInfo->sig, kTrackerSignature) == 0))
|
||||
AddItem(item, 0);
|
||||
else
|
||||
AddItem(item);
|
||||
|
||||
if (dragging && item) {
|
||||
bool canhandle = (dynamic_cast<TBarApp *>(be_app))->BarView()->
|
||||
AppCanHandleTypes(item->Signature());
|
||||
if (item->IsEnabled() != canhandle)
|
||||
item->SetEnabled(canhandle);
|
||||
|
||||
BMenu *menu = item->Submenu();
|
||||
if (menu)
|
||||
menu->SetTrackingHook(barview->MenuTrackingHook,
|
||||
barview->GetTrackingHookData());
|
||||
}
|
||||
|
||||
barInfo->teams = NULL;
|
||||
barInfo->icon = NULL;
|
||||
barInfo->name = NULL;
|
||||
barInfo->sig = NULL;
|
||||
}
|
||||
delete barInfo;
|
||||
}
|
||||
|
||||
if (dragging && barview->LockLooper()) {
|
||||
SetTrackingHook(barview->MenuTrackingHook, barview->GetTrackingHookData());
|
||||
barview->DragStart();
|
||||
barview->UnlockLooper();
|
||||
}
|
||||
|
||||
BMenu::AttachedToWindow();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TTeamMenu::DetachedFromWindow()
|
||||
{
|
||||
TBarView *barView = (dynamic_cast<TBarApp *>(be_app))->BarView();
|
||||
if (barView) {
|
||||
BLooper *looper = barView->Looper();
|
||||
if (looper->Lock()) {
|
||||
barView->DragStop();
|
||||
looper->Unlock();
|
||||
}
|
||||
}
|
||||
|
||||
BMenu::DetachedFromWindow();
|
||||
|
||||
BMessenger self(this);
|
||||
TBarApp::Unsubscribe(self);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TTeamMenu::DrawBackground(BRect)
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
Open Tracker License
|
||||
|
||||
Terms and Conditions
|
||||
|
||||
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice applies to all licensees
|
||||
and shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of Be Incorporated shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings in
|
||||
this Software without prior written authorization from Be Incorporated.
|
||||
|
||||
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
||||
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.
|
||||
*/
|
||||
|
||||
// listing of running applications
|
||||
// menu of BarMenuTitle
|
||||
// in mini mode only
|
||||
|
||||
#ifndef TEAMMENU_H
|
||||
#define TEAMMENU_H
|
||||
|
||||
#include <Menu.h>
|
||||
#include "BarMenuBar.h"
|
||||
#include "TeamMenuItem.h"
|
||||
|
||||
class TTeamMenu : public BMenu {
|
||||
public:
|
||||
TTeamMenu();
|
||||
|
||||
void AttachedToWindow();
|
||||
void DetachedFromWindow();
|
||||
void DrawBackground(BRect update);
|
||||
|
||||
private:
|
||||
static int CompareByName( const void *first, const void *second);
|
||||
};
|
||||
|
||||
#endif /* TEAMMENU_H */
|
||||
@@ -0,0 +1,510 @@
|
||||
/*
|
||||
Open Tracker License
|
||||
|
||||
Terms and Conditions
|
||||
|
||||
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice applies to all licensees
|
||||
and shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of Be Incorporated shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings in
|
||||
this Software without prior written authorization from Be Incorporated.
|
||||
|
||||
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
||||
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.
|
||||
*/
|
||||
|
||||
#include <Debug.h>
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <Bitmap.h>
|
||||
#include <Font.h>
|
||||
#include <Region.h>
|
||||
#include <Roster.h>
|
||||
#include <Resources.h>
|
||||
|
||||
#include "BarApp.h"
|
||||
#include "BarMenuBar.h"
|
||||
#include "ExpandoMenuBar.h"
|
||||
#include "ResourceSet.h"
|
||||
#include "ShowHideMenuItem.h"
|
||||
#include "TeamMenu.h"
|
||||
#include "TeamMenuItem.h"
|
||||
#include "WindowMenu.h"
|
||||
#include "WindowMenuItem.h"
|
||||
|
||||
|
||||
const float kHPad = 8.0f;
|
||||
const float kVPad = 1.0f;
|
||||
const float kLabelOffset = 8.0f;
|
||||
const float kSwitchWidth = 12;
|
||||
|
||||
|
||||
TTeamMenuItem::TTeamMenuItem(BList *team, BBitmap *icon, char *name, char *sig,
|
||||
float width, float height, bool drawLabel, bool vertical)
|
||||
: BMenuItem(new TWindowMenu(team, sig))
|
||||
{
|
||||
InitData(team, icon, name, sig, width, height, drawLabel, vertical);
|
||||
}
|
||||
|
||||
|
||||
TTeamMenuItem::TTeamMenuItem(float width,float height,bool vertical)
|
||||
: BMenuItem("", NULL)
|
||||
{
|
||||
InitData(NULL, NULL, strdup(""), strdup(""), width, height, false, vertical);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TTeamMenuItem::InitData(BList *team, BBitmap *icon, char *name, char *sig,
|
||||
float width, float height, bool drawLabel, bool vertical)
|
||||
{
|
||||
fTeam = team;
|
||||
fIcon = icon;
|
||||
fName = name;
|
||||
fSig = sig;
|
||||
SetLabel(name);
|
||||
if (fName == NULL) {
|
||||
char *tmp = (char *)malloc(32);
|
||||
sprintf(tmp, "team %ld", (int32)team->ItemAt(0));
|
||||
fName = tmp;
|
||||
}
|
||||
|
||||
BFont font(be_plain_font);
|
||||
fLabelWidth = ceilf(font.StringWidth(fName));
|
||||
font_height fontHeight;
|
||||
font.GetHeight(&fontHeight);
|
||||
fLabelAscent = ceilf(fontHeight.ascent);
|
||||
fLabelDescent = ceilf(fontHeight.descent + fontHeight.leading);
|
||||
|
||||
fOverrideWidth = width;
|
||||
fOverrideHeight = height;
|
||||
|
||||
fDrawLabel = drawLabel;
|
||||
fVertical = vertical;
|
||||
|
||||
fExpanded = false;
|
||||
}
|
||||
|
||||
|
||||
TTeamMenuItem::~TTeamMenuItem()
|
||||
{
|
||||
delete fTeam;
|
||||
delete fIcon;
|
||||
free(fName);
|
||||
free(fSig);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
TTeamMenuItem::Invoke(BMessage *message)
|
||||
{
|
||||
if ((static_cast<TBarApp *>(be_app))->BarView()->InvokeItem(Signature()))
|
||||
// handles drop on application
|
||||
return B_OK;
|
||||
|
||||
// if the app could not handle the drag message
|
||||
// and we were dragging, then kill the drag
|
||||
// should never get here, disabled item will not invoke
|
||||
TBarView *barview = (static_cast<TBarApp *>(be_app))->BarView();
|
||||
if (barview && barview->Dragging())
|
||||
barview->DragStop();
|
||||
|
||||
// bring to front or minimize shortcuts
|
||||
uint32 mods = modifiers();
|
||||
if (mods & B_CONTROL_KEY)
|
||||
TShowHideMenuItem::TeamShowHideCommon((mods & B_SHIFT_KEY)
|
||||
? B_MINIMIZE_WINDOW : B_BRING_TO_FRONT, Teams());
|
||||
|
||||
return BMenuItem::Invoke(message);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TTeamMenuItem::SetOverrideWidth(float width)
|
||||
{
|
||||
fOverrideWidth = width;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TTeamMenuItem::SetOverrideHeight(float height)
|
||||
{
|
||||
fOverrideHeight = height;
|
||||
}
|
||||
|
||||
|
||||
float
|
||||
TTeamMenuItem::LabelWidth() const
|
||||
{
|
||||
return fLabelWidth;
|
||||
}
|
||||
|
||||
|
||||
BList *
|
||||
TTeamMenuItem::Teams() const
|
||||
{
|
||||
return fTeam;
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
TTeamMenuItem::Signature() const
|
||||
{
|
||||
return fSig;
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
TTeamMenuItem::Name() const
|
||||
{
|
||||
return fName;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TTeamMenuItem::GetContentSize(float *width, float *height)
|
||||
{
|
||||
BRect iconBounds;
|
||||
|
||||
if (fIcon)
|
||||
iconBounds = fIcon->Bounds();
|
||||
else
|
||||
iconBounds = BRect(0,0,15,15);
|
||||
|
||||
BMenuItem::GetContentSize(width, height);
|
||||
|
||||
if (fOverrideWidth != -1.0f)
|
||||
*width = fOverrideWidth;
|
||||
else
|
||||
*width = kHPad + iconBounds.Width() + kLabelOffset + fLabelWidth + kHPad + 20;
|
||||
|
||||
if (fOverrideHeight != -1.0f)
|
||||
*height = fOverrideHeight;
|
||||
else {
|
||||
*height = iconBounds.Height();
|
||||
float labelHeight = fLabelAscent + fLabelDescent;
|
||||
if (labelHeight > *height)
|
||||
*height = labelHeight;
|
||||
*height += (kVPad * 2) + 2;
|
||||
}
|
||||
*height += 2;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TTeamMenuItem::Draw()
|
||||
{
|
||||
BRect frame(Frame());
|
||||
BMenu *menu = Menu();
|
||||
menu->PushState();
|
||||
rgb_color menuColor = ui_color(B_MENU_BACKGROUND_COLOR);
|
||||
|
||||
// if not selected or being tracked on, fill with gray
|
||||
TBarView *barview = (static_cast<TBarApp *>(be_app))->BarView();
|
||||
bool canHandle = !barview->Dragging() || barview->AppCanHandleTypes(Signature());
|
||||
if (!IsSelected() && !menu->IsRedrawAfterSticky() || !canHandle || !IsEnabled()) {
|
||||
frame.InsetBy(1, 1);
|
||||
menu->SetHighColor(menuColor);
|
||||
menu->FillRect(frame);
|
||||
}
|
||||
|
||||
// draw the gray, unselected item, border
|
||||
if (!IsSelected() || !IsEnabled()) {
|
||||
rgb_color shadow = tint_color(menuColor, B_DARKEN_1_TINT);
|
||||
rgb_color light = tint_color(menuColor, B_LIGHTEN_2_TINT);
|
||||
|
||||
frame = Frame();
|
||||
if (!fVertical)
|
||||
frame.top += 1;
|
||||
|
||||
menu->SetHighColor(shadow);
|
||||
if (fVertical)
|
||||
menu->StrokeLine(frame.LeftBottom(), frame.RightBottom());
|
||||
else
|
||||
menu->StrokeLine(frame.LeftBottom() + BPoint(1, 0), frame.RightBottom());
|
||||
|
||||
menu->StrokeLine(frame.RightBottom(), frame.RightTop());
|
||||
|
||||
menu->SetHighColor(light);
|
||||
menu->StrokeLine(frame.RightTop() + BPoint(-1, 0), frame.LeftTop());
|
||||
if (fVertical)
|
||||
menu->StrokeLine(frame.LeftTop(), frame.LeftBottom() + BPoint(0, -1));
|
||||
else
|
||||
menu->StrokeLine(frame.LeftTop(), frame.LeftBottom());
|
||||
}
|
||||
|
||||
// if selected or being tracked on, fill with the hilite gray color
|
||||
if (IsEnabled() && IsSelected() && !menu->IsRedrawAfterSticky() && canHandle) {
|
||||
// fill
|
||||
menu->SetHighColor(tint_color(menuColor, B_HIGHLIGHT_BACKGROUND_TINT));
|
||||
menu->FillRect(frame);
|
||||
|
||||
// these continue the dark grey border on the left or top edge
|
||||
menu->SetHighColor(tint_color(menuColor, B_DARKEN_4_TINT));
|
||||
if (fVertical)
|
||||
// dark line at top
|
||||
menu->StrokeLine(frame.LeftTop(), frame.RightTop());
|
||||
else
|
||||
// dark line on the left
|
||||
menu->StrokeLine(frame.LeftTop(), frame.LeftBottom());
|
||||
} else
|
||||
menu->SetLowColor(menuColor);
|
||||
|
||||
menu->MovePenTo(ContentLocation());
|
||||
DrawContent();
|
||||
menu->PopState();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TTeamMenuItem::DrawContent()
|
||||
{
|
||||
BMenu *menu = Menu();
|
||||
if (fIcon) {
|
||||
menu->SetDrawingMode(B_OP_OVER);
|
||||
BRect frame(Frame());
|
||||
|
||||
if (!fVertical)
|
||||
frame.top += 1;
|
||||
|
||||
BRect iconBounds(fIcon->Bounds());
|
||||
BRect dstRect(iconBounds);
|
||||
float extra = fVertical ? 0.0f : 1.0f;
|
||||
BPoint contLoc = ContentLocation();
|
||||
dstRect.OffsetTo(BPoint(contLoc.x + kHPad, contLoc.y +
|
||||
((frame.Height() - iconBounds.Height()) / 2) + extra));
|
||||
menu->DrawBitmapAsync(fIcon, dstRect);
|
||||
|
||||
menu->SetDrawingMode(B_OP_COPY);
|
||||
|
||||
float labelHeight = fLabelAscent + fLabelDescent;
|
||||
BPoint drawLoc = contLoc + BPoint(kHPad, kVPad);
|
||||
drawLoc.x += iconBounds.Width() + kLabelOffset;
|
||||
drawLoc.y = frame.top + ((frame.Height() - labelHeight) / 2) + 1.0f;
|
||||
menu->MovePenTo(drawLoc);
|
||||
}
|
||||
|
||||
// set the pen to black so that either method will draw in the same color
|
||||
// low color is set in inherited::DrawContent, override makes sure its what we want
|
||||
if (fDrawLabel) {
|
||||
menu->SetHighColor(0,0,0);
|
||||
|
||||
// override the drawing of the content when the item is disabled
|
||||
// the wrong lowcolor is used when the item is disabled since the
|
||||
// text color does not change
|
||||
DrawContentLabel();
|
||||
}
|
||||
|
||||
// Draw the expandable icon.
|
||||
TBarView *barView = (static_cast<TBarApp *>(be_app))->BarView();
|
||||
if (fVertical && static_cast<TBarApp *>(be_app)->Settings()->superExpando
|
||||
&& barView->Expando()) {
|
||||
BRect frame(Frame());
|
||||
BRect rect(0, 0, kSwitchWidth, 10);
|
||||
rect.OffsetTo(BPoint(frame.right - rect.Width(),
|
||||
ContentLocation().y + ((frame.Height() - rect.Height()) / 2)));
|
||||
|
||||
rgb_color outlineColor = {80, 80, 80, 255};
|
||||
rgb_color middleColor = {200, 200, 200, 255};
|
||||
|
||||
menu->SetDrawingMode(B_OP_COPY);
|
||||
|
||||
if (!fExpanded) {
|
||||
menu->BeginLineArray(6);
|
||||
|
||||
menu->AddLine(BPoint(rect.left + 3, rect.top + 1),
|
||||
BPoint(rect.left + 3, rect.bottom - 1), outlineColor);
|
||||
menu->AddLine(BPoint(rect.left + 3, rect.top + 1),
|
||||
BPoint(rect.left + 7, rect.top + 5), outlineColor);
|
||||
menu->AddLine(BPoint(rect.left + 7, rect.top + 5),
|
||||
BPoint(rect.left + 3, rect.bottom - 1), outlineColor);
|
||||
|
||||
menu->AddLine(BPoint(rect.left + 4, rect.top + 3),
|
||||
BPoint(rect.left + 4, rect.bottom - 3), middleColor);
|
||||
menu->AddLine(BPoint(rect.left + 5, rect.top + 4),
|
||||
BPoint(rect.left + 5, rect.bottom - 4), middleColor);
|
||||
menu->AddLine(BPoint(rect.left + 5, rect.top + 5),
|
||||
BPoint(rect.left + 6, rect.top + 5), middleColor);
|
||||
menu->EndLineArray();
|
||||
} else {
|
||||
// expanded state
|
||||
|
||||
menu->BeginLineArray(6);
|
||||
menu->AddLine(BPoint(rect.left + 1, rect.top + 3),
|
||||
BPoint(rect.right - 3, rect.top + 3), outlineColor);
|
||||
menu->AddLine(BPoint(rect.left + 1, rect.top + 3),
|
||||
BPoint(rect.left + 5, rect.top + 7), outlineColor);
|
||||
menu->AddLine(BPoint(rect.left + 5, rect.top + 7),
|
||||
BPoint(rect.right - 3, rect.top + 3), outlineColor);
|
||||
|
||||
menu->AddLine(BPoint(rect.left + 3, rect.top + 4),
|
||||
BPoint(rect.right - 5, rect.top + 4), middleColor);
|
||||
menu->AddLine(BPoint(rect.left + 4, rect.top + 5),
|
||||
BPoint(rect.right - 6, rect.top + 5), middleColor);
|
||||
menu->AddLine(BPoint(rect.left + 5, rect.top + 5),
|
||||
BPoint(rect.left + 5, rect.top + 6), middleColor);
|
||||
menu->EndLineArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TTeamMenuItem::DrawContentLabel()
|
||||
{
|
||||
BMenu *menu = Menu();
|
||||
menu->MovePenBy(0, fLabelAscent);
|
||||
menu->SetDrawingMode(B_OP_COPY);
|
||||
|
||||
float cachedWidth = menu->StringWidth(Label());
|
||||
if (Submenu() && fVertical)
|
||||
cachedWidth += 18;
|
||||
|
||||
const char *label = Label();
|
||||
char *truncLabel = NULL;
|
||||
float max = 0;
|
||||
if (static_cast<TBarApp *>(be_app)->Settings()->superExpando && fVertical)
|
||||
max = menu->MaxContentWidth() - kSwitchWidth;
|
||||
else
|
||||
max = menu->MaxContentWidth();
|
||||
|
||||
if (max > 0) {
|
||||
BPoint penloc = menu->PenLocation();
|
||||
BRect frame = Frame();
|
||||
float offset = penloc.x - frame.left;
|
||||
if (cachedWidth + offset > max) {
|
||||
truncLabel = (char *)malloc(strlen(label) + 4);
|
||||
if (!truncLabel)
|
||||
return;
|
||||
TruncateLabel(max-offset, truncLabel);
|
||||
label = truncLabel;
|
||||
}
|
||||
}
|
||||
|
||||
if (!label)
|
||||
label = Label();
|
||||
|
||||
TBarView *barview = (static_cast<TBarApp *>(be_app))->BarView();
|
||||
bool canHandle = !barview->Dragging() || barview->AppCanHandleTypes(Signature());
|
||||
if (IsSelected() && IsEnabled() && canHandle)
|
||||
menu->SetLowColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR),
|
||||
B_HIGHLIGHT_BACKGROUND_TINT));
|
||||
else
|
||||
menu->SetLowColor(menu->ViewColor());
|
||||
|
||||
menu->DrawString(label);
|
||||
|
||||
if (truncLabel)
|
||||
free(truncLabel);
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
TTeamMenuItem::IsExpanded()
|
||||
{
|
||||
return fExpanded;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TTeamMenuItem::ToggleExpandState(bool resizeWindow)
|
||||
{
|
||||
fExpanded = !fExpanded;
|
||||
|
||||
if (fExpanded) {
|
||||
// Populate Menu() with the stuff from SubMenu().
|
||||
TWindowMenu *sub = (static_cast<TWindowMenu *>(Submenu()));
|
||||
if (sub) {
|
||||
// force the menu to update it's contents.
|
||||
Submenu()->AttachedToWindow();
|
||||
if (sub->CountItems() > 1){
|
||||
TExpandoMenuBar *parent = static_cast<TExpandoMenuBar *>(Menu());
|
||||
int myindex = parent->IndexOf(this) + 1;
|
||||
|
||||
TWindowMenuItem *windowItem = NULL;
|
||||
int childIndex = 0;
|
||||
int totalChildren = sub->CountItems() - 4; // hide, show, close, separator.
|
||||
for (; childIndex < totalChildren; childIndex++) {
|
||||
windowItem = static_cast<TWindowMenuItem *>(sub->RemoveItem((int32)0));
|
||||
parent->AddItem(windowItem, myindex + childIndex);
|
||||
windowItem->ExpandedItem(true);
|
||||
}
|
||||
sub->SetExpanded(true, myindex + childIndex);
|
||||
|
||||
if (resizeWindow)
|
||||
parent->SizeWindow();
|
||||
} else
|
||||
fExpanded = fExpanded;
|
||||
}
|
||||
} else {
|
||||
// Remove the goodies from the Menu() that should be in the SubMenu();
|
||||
TWindowMenu *sub = static_cast<TWindowMenu *>(Submenu());
|
||||
|
||||
if (sub) {
|
||||
TExpandoMenuBar *parent = static_cast<TExpandoMenuBar *>(Menu());
|
||||
|
||||
TWindowMenuItem *windowItem = NULL;
|
||||
int childIndex = parent->IndexOf(this) + 1;
|
||||
while (!parent->SubmenuAt(childIndex) && childIndex < parent->CountItems()) {
|
||||
windowItem = static_cast<TWindowMenuItem *>(parent->RemoveItem(childIndex));
|
||||
sub->AddItem(windowItem, 0);
|
||||
windowItem->ExpandedItem(false);
|
||||
}
|
||||
sub->SetExpanded(false, 0);
|
||||
|
||||
if (resizeWindow)
|
||||
parent->SizeWindow();
|
||||
} else
|
||||
fExpanded = fExpanded;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TWindowMenuItem*
|
||||
TTeamMenuItem::ExpandedWindowItem(int32 id)
|
||||
{
|
||||
if (!fExpanded) // Paranoia
|
||||
return NULL;
|
||||
|
||||
TExpandoMenuBar *parent = static_cast<TExpandoMenuBar *>(Menu());
|
||||
int childIndex = parent->IndexOf(this) + 1;
|
||||
|
||||
while (!parent->SubmenuAt(childIndex) && childIndex < parent->CountItems()) {
|
||||
TWindowMenuItem *item = static_cast<TWindowMenuItem *>(parent->ItemAt(childIndex));
|
||||
if (item->ID() == id)
|
||||
return item;
|
||||
|
||||
childIndex++;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
BRect
|
||||
TTeamMenuItem::ExpanderBounds() const
|
||||
{
|
||||
BRect bounds(Frame());
|
||||
bounds.left = bounds.right - kSwitchWidth;
|
||||
return bounds;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
Open Tracker License
|
||||
|
||||
Terms and Conditions
|
||||
|
||||
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice applies to all licensees
|
||||
and shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of Be Incorporated shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings in
|
||||
this Software without prior written authorization from Be Incorporated.
|
||||
|
||||
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
||||
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 TEAMMENUITEM_H
|
||||
#define TEAMMENUITEM_H
|
||||
|
||||
// Individual team/application listing
|
||||
// item for TeamMenu in mini/vertical mode
|
||||
// item for ExpandoMenuBar in vertical or horizontal expanded mode
|
||||
|
||||
#include <MenuItem.h>
|
||||
|
||||
#include "WindowMenuItem.h"
|
||||
#include "BarMenuBar.h"
|
||||
|
||||
|
||||
class BBitmap;
|
||||
|
||||
|
||||
class TTeamMenuItem : public BMenuItem {
|
||||
public:
|
||||
TTeamMenuItem(BList *team, BBitmap *icon, char *name, char *sig,
|
||||
float width = -1.0f, float height = -1.0f,
|
||||
bool drawLabel = true, bool vertical = true);
|
||||
TTeamMenuItem(float width = -1.0f, float height = -1.0f, bool vertical=true);
|
||||
virtual ~TTeamMenuItem();
|
||||
|
||||
status_t Invoke(BMessage *msg = NULL);
|
||||
|
||||
void SetOverrideWidth(float width);
|
||||
void SetOverrideHeight(float height);
|
||||
|
||||
bool IsExpanded();
|
||||
void ToggleExpandState(bool resizeWindow);
|
||||
BRect ExpanderBounds() const;
|
||||
TWindowMenuItem* ExpandedWindowItem(int32 id);
|
||||
|
||||
float LabelWidth() const;
|
||||
BList *Teams() const;
|
||||
const char *Signature() const;
|
||||
const char *Name() const;
|
||||
|
||||
protected:
|
||||
void GetContentSize(float *width, float *height);
|
||||
void Draw();
|
||||
void DrawContent();
|
||||
void DrawContentLabel();
|
||||
|
||||
private:
|
||||
friend class TExpandoMenuBar;
|
||||
void InitData(BList *team, BBitmap *icon, char *name, char *sig,
|
||||
float width = -1.0f, float height = -1.0f,
|
||||
bool drawLabel = true,bool vertical=true);
|
||||
|
||||
BList *fTeam;
|
||||
BBitmap *fIcon;
|
||||
char *fName;
|
||||
char *fSig;
|
||||
float fLabelWidth;
|
||||
float fLabelAscent;
|
||||
float fLabelDescent;
|
||||
float fOverrideWidth;
|
||||
float fOverrideHeight;
|
||||
|
||||
bool fDrawLabel;
|
||||
bool fVertical;
|
||||
|
||||
bool fExpanded;
|
||||
};
|
||||
|
||||
#endif /* TEAMMENUITEM_H */
|
||||
@@ -0,0 +1,534 @@
|
||||
/*
|
||||
Open Tracker License
|
||||
|
||||
Terms and Conditions
|
||||
|
||||
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice applies to all licensees
|
||||
and shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of Be Incorporated shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings in
|
||||
this Software without prior written authorization from Be Incorporated.
|
||||
|
||||
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
||||
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.
|
||||
*/
|
||||
|
||||
|
||||
#include "TimeView.h"
|
||||
|
||||
#ifdef _SHOW_CALENDAR_MENU_ITEM
|
||||
# include "CalendarMenuItem.h"
|
||||
#endif
|
||||
|
||||
#include <Debug.h>
|
||||
#include <MenuItem.h>
|
||||
#include <PopUpMenu.h>
|
||||
#include <Roster.h>
|
||||
#include <Window.h>
|
||||
#include <Screen.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
static const char * const kMinString = "99:99 AM";
|
||||
|
||||
|
||||
static float
|
||||
FontHeight(BView *target, bool full)
|
||||
{
|
||||
font_height fontInfo;
|
||||
target->GetFontHeight(&fontInfo);
|
||||
float h = fontInfo.ascent + fontInfo.descent;
|
||||
|
||||
if (full)
|
||||
h += fontInfo.leading;
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
|
||||
enum {
|
||||
kMsgShowClock,
|
||||
kMsgChangeClock,
|
||||
kMsgHide
|
||||
};
|
||||
|
||||
|
||||
TTimeView::TTimeView(bool showSeconds, bool milTime, bool fullDate, bool euroDate, bool)
|
||||
: BView(BRect(-100,-100,-90,-90), "_deskbar_tv_",
|
||||
B_FOLLOW_RIGHT | B_FOLLOW_TOP,
|
||||
B_WILL_DRAW | B_PULSE_NEEDED | B_FRAME_EVENTS),
|
||||
fParent(NULL),
|
||||
fShowInterval(true), // ToDo: defaulting this to true until UI is in place
|
||||
fShowSeconds(showSeconds),
|
||||
fMilTime(milTime),
|
||||
fFullDate(fullDate),
|
||||
fCanShowFullDate(false),
|
||||
fEuroDate(euroDate),
|
||||
fOrientation(false)
|
||||
{
|
||||
fShowingDate = false;
|
||||
fTime = fLastTime = time(NULL);
|
||||
fSeconds = fMinute = fHour = 0;
|
||||
fLastTimeStr[0] = 0;
|
||||
fLastDateStr[0] = 0;
|
||||
fNeedToUpdate = true;
|
||||
}
|
||||
|
||||
|
||||
#ifdef AS_REPLICANT
|
||||
TTimeView::TTimeView(BMessage *data)
|
||||
: BView(data)
|
||||
{
|
||||
fTime = fLastTime = time(NULL);
|
||||
data->FindBool("seconds", &fShowSeconds);
|
||||
data->FindBool("miltime", &fMilTime);
|
||||
data->FindBool("fulldate", &fFullDate);
|
||||
data->FindBool("eurodate", &fEuroDate);
|
||||
data->FindBool("interval", &fInterval);
|
||||
fShowingDate = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
TTimeView::~TTimeView()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
#ifdef AS_REPLICANT
|
||||
BArchivable*
|
||||
TTimeView::Instantiate(BMessage *data)
|
||||
{
|
||||
if (!validate_instantiation(data, "TTimeView"))
|
||||
return NULL;
|
||||
|
||||
return new TTimeView(data);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
TTimeView::Archive(BMessage *data, bool deep) const
|
||||
{
|
||||
BView::Archive(data, deep);
|
||||
data->AddBool("seconds", fShowSeconds);
|
||||
data->AddBool("miltime", fMilTime);
|
||||
data->AddBool("fulldate", fFullDate);
|
||||
data->AddBool("eurodate", fEuroDate);
|
||||
data->AddBool("interval", fInterval);
|
||||
data->AddInt32("deskbar:private_align", B_ALIGN_RIGHT);
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void
|
||||
TTimeView::AttachedToWindow()
|
||||
{
|
||||
fTime = time(NULL);
|
||||
|
||||
SetFont(be_plain_font);
|
||||
if (Parent()) {
|
||||
fParent = Parent();
|
||||
SetViewColor(Parent()->ViewColor());
|
||||
} else
|
||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
|
||||
fFontHeight = FontHeight(this, true);
|
||||
ResizeToPreferred();
|
||||
CalculateTextPlacement();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TTimeView::GetPreferredSize(float *width, float *height)
|
||||
{
|
||||
*height = fFontHeight;
|
||||
|
||||
GetCurrentTime();
|
||||
GetCurrentDate();
|
||||
|
||||
if (ShowingDate())
|
||||
*width = 6 + StringWidth(fDateStr);
|
||||
else {
|
||||
*width = 6 + StringWidth(fTimeStr);
|
||||
// Changed this from 10 to 6 so even with interval + seconds, there still
|
||||
// is room for two replicants in the default tray.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TTimeView::ResizeToPreferred()
|
||||
{
|
||||
float width, height;
|
||||
float oldWidth = Bounds().Width(), oldHeight = Bounds().Height();
|
||||
|
||||
GetPreferredSize(&width, &height);
|
||||
if (height != oldHeight || width != oldWidth) {
|
||||
ResizeTo(width, height);
|
||||
MoveBy(oldWidth - width, 0);
|
||||
fNeedToUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TTimeView::FrameMoved(BPoint)
|
||||
{
|
||||
Update();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TTimeView::MessageReceived(BMessage* message)
|
||||
{
|
||||
switch (message->what) {
|
||||
case kMsgFullDate:
|
||||
ShowFullDate(!ShowingFullDate());
|
||||
break;
|
||||
|
||||
case kMsgShowSeconds:
|
||||
ShowSeconds(!ShowingSeconds());
|
||||
break;
|
||||
|
||||
case kMsgMilTime:
|
||||
ShowMilTime(!ShowingMilTime());
|
||||
break;
|
||||
|
||||
case kMsgEuroDate:
|
||||
ShowEuroDate(!ShowingEuroDate());
|
||||
break;
|
||||
|
||||
case kMsgChangeClock:
|
||||
// launch the time prefs app
|
||||
be_roster->Launch("application/x-vnd.Be-TIME");
|
||||
break;
|
||||
|
||||
case 'time':
|
||||
Window()->PostMessage(message, Parent());
|
||||
break;
|
||||
|
||||
default:
|
||||
BView::MessageReceived(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TTimeView::GetCurrentTime()
|
||||
{
|
||||
char tmp[64];
|
||||
tm time = *localtime(&fTime);
|
||||
|
||||
if (fMilTime) {
|
||||
strftime(tmp, 64, fShowSeconds ? "%H:%M:%S" : "%H:%M", &time);
|
||||
} else {
|
||||
if (fShowInterval)
|
||||
strftime(tmp, 64, fShowSeconds ? "%I:%M:%S %p" : "%I:%M %p", &time);
|
||||
else
|
||||
strftime(tmp, 64, fShowSeconds ? "%I:%M:%S" : "%I:%M", &time);
|
||||
}
|
||||
|
||||
// remove leading 0 from time when hour is less than 10
|
||||
const char *str = tmp;
|
||||
if (str[0] == '0')
|
||||
str++;
|
||||
|
||||
strcpy(fTimeStr, str);
|
||||
|
||||
fSeconds = time.tm_sec;
|
||||
fMinute = time.tm_min;
|
||||
fHour = time.tm_hour;
|
||||
}
|
||||
|
||||
|
||||
const char *kShortDateFormat = "%m/%d/%y";
|
||||
const char *kShortEuroDateFormat = "%d/%m/%y";
|
||||
const char *kLongDateFormat = "%a, %B %d, %Y";
|
||||
const char *kLongEuroDateFormat = "%a, %d %B, %Y";
|
||||
|
||||
|
||||
void
|
||||
TTimeView::GetCurrentDate()
|
||||
{
|
||||
char tmp[64];
|
||||
tm time = *localtime(&fTime);
|
||||
|
||||
if (fFullDate && CanShowFullDate())
|
||||
strftime(tmp, 64, fEuroDate ? kLongEuroDateFormat : kLongDateFormat, &time);
|
||||
else
|
||||
strftime(tmp, 64, fEuroDate ? kShortEuroDateFormat : kShortDateFormat, &time);
|
||||
|
||||
// remove leading 0 from date when month is less than 10 (MM/DD/YY)
|
||||
// or remove leading 0 from date when day is less than 10 (DD/MM/YY)
|
||||
const char* str = tmp;
|
||||
if (str[0] == '0')
|
||||
str++;
|
||||
|
||||
strcpy(fDateStr, str);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TTimeView::Draw(BRect /*updateRect*/)
|
||||
{
|
||||
PushState();
|
||||
|
||||
SetHighColor(ViewColor());
|
||||
SetLowColor(ViewColor());
|
||||
FillRect(Bounds());
|
||||
SetHighColor(0, 0, 0, 255);
|
||||
|
||||
if (fShowingDate) {
|
||||
MovePenTo(fDateLocation);
|
||||
DrawString(fDateStr);
|
||||
} else {
|
||||
MovePenTo(fTimeLocation);
|
||||
DrawString(fTimeStr);
|
||||
}
|
||||
|
||||
PopState();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TTimeView::MouseDown(BPoint point)
|
||||
{
|
||||
uint32 buttons;
|
||||
|
||||
Window()->CurrentMessage()->FindInt32("buttons", (int32 *)&buttons);
|
||||
if (buttons == B_SECONDARY_MOUSE_BUTTON) {
|
||||
ShowClockOptions(ConvertToScreen(point));
|
||||
return;
|
||||
}
|
||||
|
||||
// flip to/from showing date or time
|
||||
fShowingDate = !fShowingDate;
|
||||
if (fShowingDate)
|
||||
fLastTime = time(NULL);
|
||||
|
||||
// invalidate last time/date strings and call the pulse
|
||||
// method directly to change the display instantly
|
||||
fLastDateStr[0] = '\0';
|
||||
fLastTimeStr[0] = '\0';
|
||||
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();
|
||||
|
||||
// use the doubleClickSpeed as a treshold
|
||||
bigtime_t doubleClickSpeed;
|
||||
get_click_speed(&doubleClickSpeed);
|
||||
|
||||
while (buttons) {
|
||||
BPoint where;
|
||||
GetMouse(&where, &buttons, false);
|
||||
|
||||
if ((system_time() - startTime) > doubleClickSpeed) {
|
||||
BPopUpMenu *menu = new BPopUpMenu("", false, false);
|
||||
menu->SetFont(be_plain_font);
|
||||
|
||||
menu->AddItem(new CalendarMenuItem());
|
||||
menu->ResizeToPreferred();
|
||||
|
||||
point = where;
|
||||
BScreen screen;
|
||||
where.y = Bounds().bottom + 4;
|
||||
|
||||
// make sure the menu is visible at doesn't hide the date
|
||||
ConvertToScreen(&where);
|
||||
if (where.y + menu->Bounds().Height() > screen.Frame().bottom)
|
||||
where.y -= menu->Bounds().Height() + 2 * Bounds().Height();
|
||||
|
||||
ConvertToScreen(&point);
|
||||
menu->Go(where, true, true, BRect(point.x - 4, point.y - 4,
|
||||
point.x + 4, point.y + 4), true);
|
||||
return;
|
||||
}
|
||||
|
||||
snooze(15000);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TTimeView::Pulse()
|
||||
{
|
||||
time_t curTime = time(NULL);
|
||||
tm ct = *localtime(&curTime);
|
||||
fTime = curTime;
|
||||
|
||||
GetCurrentTime();
|
||||
GetCurrentDate();
|
||||
if ((!fShowingDate && strcmp(fTimeStr, fLastTimeStr) != 0)
|
||||
|| (fShowingDate && strcmp(fDateStr, fLastDateStr) != 0)) {
|
||||
// Update bounds when the size of the strings has changed
|
||||
// For dates, Update() could be called two times in a row,
|
||||
// but that should only happen very rarely
|
||||
if ((!fShowingDate && fLastTimeStr[1] != fTimeStr[1]
|
||||
&& (fLastTimeStr[1] == ':' || fTimeStr[1] == ':'))
|
||||
|| (fShowingDate && strlen(fDateStr) != strlen(fLastDateStr))
|
||||
|| !fLastTimeStr[0])
|
||||
Update();
|
||||
|
||||
strcpy(fLastTimeStr, fTimeStr);
|
||||
strcpy(fLastDateStr, fDateStr);
|
||||
fNeedToUpdate = true;
|
||||
}
|
||||
|
||||
if (fShowingDate && (fLastTime + 5 <= time(NULL))) {
|
||||
fShowingDate = false;
|
||||
Update(); // Needs to happen since size can change here
|
||||
}
|
||||
|
||||
if (fNeedToUpdate) {
|
||||
fSeconds = ct.tm_sec;
|
||||
fMinute = ct.tm_min;
|
||||
fHour = ct.tm_hour;
|
||||
fInterval = ct.tm_hour >= 12;
|
||||
|
||||
Draw(Bounds());
|
||||
fNeedToUpdate = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TTimeView::ShowSeconds(bool on)
|
||||
{
|
||||
fShowSeconds = on;
|
||||
Update();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TTimeView::ShowMilTime(bool on)
|
||||
{
|
||||
fMilTime = on;
|
||||
Update();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TTimeView::ShowDate(bool on)
|
||||
{
|
||||
fShowingDate = on;
|
||||
Update();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TTimeView::ShowFullDate(bool on)
|
||||
{
|
||||
fFullDate = on;
|
||||
Update();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TTimeView::ShowEuroDate(bool on)
|
||||
{
|
||||
fEuroDate = on;
|
||||
Update();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TTimeView::AllowFullDate(bool allow)
|
||||
{
|
||||
fCanShowFullDate = allow;
|
||||
|
||||
if (allow != ShowingFullDate())
|
||||
Update();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TTimeView::Update()
|
||||
{
|
||||
GetCurrentTime();
|
||||
GetCurrentDate();
|
||||
|
||||
ResizeToPreferred();
|
||||
CalculateTextPlacement();
|
||||
|
||||
if (fParent) {
|
||||
fParent->MessageReceived(new BMessage('trfm'));
|
||||
// time string format realign
|
||||
fParent->Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TTimeView::SetOrientation(bool o)
|
||||
{
|
||||
fOrientation = o;
|
||||
CalculateTextPlacement();
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TTimeView::CalculateTextPlacement()
|
||||
{
|
||||
BRect bounds(Bounds());
|
||||
|
||||
if (fOrientation) { // vertical mode
|
||||
fDateLocation.x = bounds.Width()/2 - StringWidth(fDateStr)/2;
|
||||
fTimeLocation.x = bounds.Width()/2 - StringWidth(fTimeStr)/2;
|
||||
} else {
|
||||
fTimeLocation.x = bounds.Width() - StringWidth(fTimeStr) - 5;
|
||||
fDateLocation.x = bounds.Width() - StringWidth(fDateStr) - 5;
|
||||
}
|
||||
// center vertically
|
||||
fDateLocation.y = fTimeLocation.y = bounds.Height()/2 + fFontHeight/2;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TTimeView::ShowClockOptions(BPoint point)
|
||||
{
|
||||
BPopUpMenu *menu = new BPopUpMenu("", false, false);
|
||||
menu->SetFont(be_plain_font);
|
||||
BMenuItem *item;
|
||||
|
||||
item = new BMenuItem("Change Time" B_UTF8_ELLIPSIS, new BMessage(kMsgChangeClock));
|
||||
menu->AddItem(item);
|
||||
|
||||
item = new BMenuItem("Hide Time", new BMessage('time'));
|
||||
menu->AddItem(item);
|
||||
|
||||
menu->SetTargetForItems(this);
|
||||
// Changed to accept screen coord system point;
|
||||
// not constrained to this view now
|
||||
menu->Go(point, true, true, BRect(point.x - 4, point.y - 4,
|
||||
point.x + 4, point.y +4), true);
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
Open Tracker License
|
||||
|
||||
Terms and Conditions
|
||||
|
||||
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice applies to all licensees
|
||||
and shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of Be Incorporated shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings in
|
||||
this Software without prior written authorization from Be Incorporated.
|
||||
|
||||
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
||||
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 TIME_VIEW_H
|
||||
#define TIME_VIEW_H
|
||||
|
||||
|
||||
#include <OS.h>
|
||||
#include <View.h>
|
||||
|
||||
|
||||
const uint32 kMsgShowSeconds = 'ShSc';
|
||||
const uint32 kMsgMilTime = 'MilT';
|
||||
const uint32 kMsgFullDate = 'FDat';
|
||||
const uint32 kMsgEuroDate = 'EDat';
|
||||
|
||||
|
||||
#ifdef AS_REPLICANT
|
||||
class _EXPORT TTimeView;
|
||||
#endif
|
||||
|
||||
class TTimeView : public BView {
|
||||
public:
|
||||
TTimeView(bool showSeconds = false, bool milTime = false, bool fullDate = false,
|
||||
bool euroDate = false, bool showInterval = false);
|
||||
TTimeView(BMessage *data);
|
||||
~TTimeView();
|
||||
|
||||
#ifdef AS_REPLICANT
|
||||
status_t Archive(BMessage *data, bool deep = true) const;
|
||||
static BArchivable *Instantiate(BMessage *data);
|
||||
#endif
|
||||
|
||||
void AttachedToWindow();
|
||||
void Draw(BRect update);
|
||||
void GetPreferredSize(float *width, float *height);
|
||||
void ResizeToPreferred();
|
||||
void FrameMoved(BPoint);
|
||||
void MessageReceived(BMessage*);
|
||||
void MouseDown(BPoint where);
|
||||
void Pulse();
|
||||
|
||||
bool ShowingSeconds() { return fShowSeconds; }
|
||||
void ShowSeconds(bool);
|
||||
bool ShowingMilTime() { return fMilTime; }
|
||||
void ShowMilTime(bool);
|
||||
bool ShowingDate() { return fShowingDate; }
|
||||
void ShowDate(bool);
|
||||
bool ShowingFullDate() { return fFullDate; }
|
||||
void ShowFullDate(bool);
|
||||
bool CanShowFullDate() const { return fCanShowFullDate; }
|
||||
void AllowFullDate(bool);
|
||||
bool ShowingEuroDate() {return fEuroDate; }
|
||||
void ShowEuroDate(bool);
|
||||
|
||||
bool Orientation() const;
|
||||
void SetOrientation(bool o);
|
||||
|
||||
private:
|
||||
friend class TReplicantTray;
|
||||
|
||||
void Update();
|
||||
void GetCurrentTime();
|
||||
void GetCurrentDate();
|
||||
void CalculateTextPlacement();
|
||||
void ShowClockOptions(BPoint);
|
||||
|
||||
BView *fParent;
|
||||
bool fNeedToUpdate;
|
||||
|
||||
time_t fTime;
|
||||
time_t fLastTime;
|
||||
|
||||
char fTimeStr[64];
|
||||
char fLastTimeStr[64];
|
||||
char fDateStr[64];
|
||||
char fLastDateStr[64];
|
||||
|
||||
int fSeconds;
|
||||
int fMinute;
|
||||
int fHour;
|
||||
bool fInterval;
|
||||
|
||||
bool fShowInterval;
|
||||
bool fShowSeconds;
|
||||
bool fMilTime;
|
||||
bool fShowingDate;
|
||||
bool fFullDate;
|
||||
bool fCanShowFullDate;
|
||||
bool fEuroDate;
|
||||
|
||||
float fFontHeight;
|
||||
bool fOrientation; // vertical = true
|
||||
BPoint fTimeLocation;
|
||||
BPoint fDateLocation;
|
||||
};
|
||||
|
||||
|
||||
inline bool
|
||||
TTimeView::Orientation() const
|
||||
{
|
||||
return fOrientation;
|
||||
}
|
||||
|
||||
|
||||
#endif /* TIME_VIEW_H */
|
||||
@@ -0,0 +1,241 @@
|
||||
/*
|
||||
Open Tracker License
|
||||
|
||||
Terms and Conditions
|
||||
|
||||
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice applies to all licensees
|
||||
and shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of Be Incorporated shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings in
|
||||
this Software without prior written authorization from Be Incorporated.
|
||||
|
||||
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
||||
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.
|
||||
*/
|
||||
|
||||
#include <malloc.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <Window.h>
|
||||
|
||||
#include "BarApp.h"
|
||||
#include "BarView.h"
|
||||
#include "ExpandoMenuBar.h"
|
||||
#include "ShowHideMenuItem.h"
|
||||
#include "TeamMenu.h"
|
||||
#include "TeamMenuItem.h"
|
||||
#include "WindowMenuItem.h"
|
||||
#include "WindowMenu.h"
|
||||
|
||||
#include "tracker_private.h"
|
||||
|
||||
|
||||
const int32 kDesktopWindow = 1024;
|
||||
const int32 kMenuWindow = 1025;
|
||||
const uint32 kWindowScreen = 1026;
|
||||
const uint32 kNormalWindow = 0;
|
||||
const int32 kTeamFloater = 4;
|
||||
const int32 kListFloater = 5;
|
||||
const int32 kSystemFloater = 6;
|
||||
|
||||
|
||||
bool
|
||||
TWindowMenu::WindowShouldBeListed(uint32 behavior)
|
||||
{
|
||||
if (behavior == kNormalWindow || behavior == kWindowScreen)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
TWindowMenu::TWindowMenu(const BList *team, const char *signature)
|
||||
: BMenu("Deskbar Team Menu"), fTeam(team),
|
||||
fApplicationSignature(signature), fExpanded(false), fExpandedIndex(0)
|
||||
{
|
||||
SetItemMargins(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TWindowMenu::AttachedToWindow()
|
||||
{
|
||||
SetFont(be_plain_font);
|
||||
|
||||
BMenuItem *item = NULL;
|
||||
while ((item = RemoveItem((int32)0)) != NULL)
|
||||
delete (item);
|
||||
|
||||
int32 miniCount = 0;
|
||||
|
||||
bool dragging = false;
|
||||
TBarView *barview =(static_cast<TBarApp *>(be_app))->BarView();
|
||||
if (barview && barview->LockLooper()) {
|
||||
// 'dragging' mode set in BarView::CacheDragData
|
||||
// invoke in MouseEnter in ExpandoMenuBar
|
||||
dragging = barview->Dragging();
|
||||
if (dragging) {
|
||||
// We don't want to show the menu when dragging, but it's not
|
||||
// possible to remove a submenu once it exists, so we simply hide it
|
||||
// Don't call BMenu::Hide(), it causes the menu to pop up every now
|
||||
// and then.
|
||||
Window()->Hide();
|
||||
// if in expando (horizontal or vertical)
|
||||
if (barview->Expando()) {
|
||||
SetTrackingHook(barview->MenuTrackingHook,
|
||||
barview->GetTrackingHookData());
|
||||
}
|
||||
barview->DragStart();
|
||||
}
|
||||
barview->UnlockLooper();
|
||||
}
|
||||
|
||||
int32 parentMenuItems = 0;
|
||||
|
||||
int32 numTeams = fTeam->CountItems();
|
||||
for (int32 i = 0; i < numTeams; i++) {
|
||||
team_id theTeam = (team_id)fTeam->ItemAt(i);
|
||||
int32 count = 0;
|
||||
int32 *tokens = get_token_list(theTeam, &count);
|
||||
|
||||
for (int32 j = 0; j < count; j++) {
|
||||
window_info *wInfo = get_window_info(tokens[j]);
|
||||
if (wInfo == NULL)
|
||||
continue;
|
||||
|
||||
if (WindowShouldBeListed(wInfo->w_type)
|
||||
&& (wInfo->show_hide_level <= 0 || wInfo->is_mini)) {
|
||||
// Don't add new items if we're expanded. We've already done this,
|
||||
// they've just been moved.
|
||||
int32 numItems = CountItems();
|
||||
int32 addIndex = 0;
|
||||
for (; addIndex < numItems; addIndex++)
|
||||
if (strcasecmp(ItemAt(addIndex)->Label(), wInfo->name) > 0)
|
||||
break;
|
||||
|
||||
if (!fExpanded) {
|
||||
TWindowMenuItem *item = new TWindowMenuItem(wInfo->name, wInfo->id,
|
||||
wInfo->is_mini, ((1 << current_workspace()) & wInfo->workspaces) != 0,
|
||||
dragging);
|
||||
|
||||
// disable app's window dropping for now
|
||||
if (dragging)
|
||||
item->SetEnabled(false);
|
||||
|
||||
AddItem(item, addIndex);
|
||||
} else {
|
||||
TTeamMenuItem *parentItem = static_cast<TTeamMenuItem *>(Superitem());
|
||||
if (parentItem->ExpandedWindowItem(wInfo->id)) {
|
||||
TWindowMenuItem *item = parentItem->ExpandedWindowItem(wInfo->id);
|
||||
if (item == NULL)
|
||||
continue;
|
||||
|
||||
item->SetTo(wInfo->name, wInfo->id, wInfo->is_mini,
|
||||
((1 << current_workspace()) & wInfo->workspaces) != 0, dragging);
|
||||
parentMenuItems++;
|
||||
}
|
||||
}
|
||||
|
||||
if (wInfo->is_mini)
|
||||
miniCount++;
|
||||
}
|
||||
free(wInfo);
|
||||
}
|
||||
free(tokens);
|
||||
}
|
||||
|
||||
int32 itemCount = CountItems() + parentMenuItems;
|
||||
if (itemCount < 1) {
|
||||
TWindowMenuItem *noWindowsItem =
|
||||
new TWindowMenuItem("No Windows", -1, false, false);
|
||||
|
||||
noWindowsItem->SetEnabled(false);
|
||||
|
||||
AddItem(noWindowsItem);
|
||||
|
||||
// if an application has no windows, this feature makes it easy to quit it.
|
||||
// (but we only add this option if the application is not Tracker.)
|
||||
if (fApplicationSignature.Compare(kTrackerSignature) != 0) {
|
||||
AddSeparatorItem();
|
||||
AddItem(new TShowHideMenuItem("Quit Application", fTeam, B_QUIT_REQUESTED));
|
||||
}
|
||||
} else {
|
||||
// if we are in drag mode, then don't add the window controls
|
||||
// to the menu
|
||||
if (!dragging) {
|
||||
TShowHideMenuItem *hide =
|
||||
new TShowHideMenuItem("Hide All", fTeam, B_MINIMIZE_WINDOW);
|
||||
TShowHideMenuItem *show =
|
||||
new TShowHideMenuItem("Show All", fTeam, B_BRING_TO_FRONT);
|
||||
TShowHideMenuItem* close =
|
||||
new TShowHideMenuItem("Close All", fTeam, B_QUIT_REQUESTED);
|
||||
|
||||
if (miniCount == itemCount)
|
||||
hide->SetEnabled(false);
|
||||
else if (miniCount == 0)
|
||||
show->SetEnabled(false);
|
||||
|
||||
if (!parentMenuItems)
|
||||
AddSeparatorItem();
|
||||
AddItem(hide);
|
||||
AddItem(show);
|
||||
AddItem(close);
|
||||
}
|
||||
}
|
||||
|
||||
BMenu::AttachedToWindow();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TWindowMenu::DetachedFromWindow()
|
||||
{
|
||||
// in expando mode the teammenu will not call DragStop,
|
||||
// thus, it needs to be called from here
|
||||
TBarView *barview = (dynamic_cast<TBarApp*>(be_app))->BarView();
|
||||
if (barview && barview->Expando()) {
|
||||
BLooper *looper = barview->Looper();
|
||||
if (looper->Lock()) {
|
||||
Window()->Show(); // We changed the show level in AttachedToWindow(). Undo it.
|
||||
barview->DragStop();
|
||||
looper->Unlock();
|
||||
}
|
||||
}
|
||||
|
||||
BMenu::DetachedFromWindow();
|
||||
}
|
||||
|
||||
|
||||
BPoint
|
||||
TWindowMenu::ScreenLocation()
|
||||
{
|
||||
return BMenu::ScreenLocation();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TWindowMenu::SetExpanded(bool status, int lastIndex)
|
||||
{
|
||||
fExpanded = status;
|
||||
fExpandedIndex = lastIndex;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
Open Tracker License
|
||||
|
||||
Terms and Conditions
|
||||
|
||||
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice applies to all licensees
|
||||
and shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of Be Incorporated shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings in
|
||||
this Software without prior written authorization from Be Incorporated.
|
||||
|
||||
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
||||
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.
|
||||
*/
|
||||
|
||||
// list of windows for a specific application
|
||||
// always submenu for a TeamMenuItem
|
||||
// all DB positions
|
||||
|
||||
#ifndef WINDOWMENU_H
|
||||
#define WINDOWMENU_H
|
||||
|
||||
#include <Menu.h>
|
||||
#include <String.h>
|
||||
|
||||
|
||||
class TWindowMenu : public BMenu {
|
||||
public:
|
||||
TWindowMenu(const BList *team, const char *signature);
|
||||
|
||||
virtual void AttachedToWindow();
|
||||
virtual void DetachedFromWindow();
|
||||
|
||||
BPoint ScreenLocation();
|
||||
void SetExpanded(bool status, int addAtIndex);
|
||||
static bool WindowShouldBeListed(uint32 behavior);
|
||||
|
||||
private:
|
||||
const BList *fTeam;
|
||||
BString fApplicationSignature;
|
||||
bool fExpanded;
|
||||
int fExpandedIndex;
|
||||
};
|
||||
|
||||
#endif /* WINDOWMENU_H */
|
||||
@@ -0,0 +1,268 @@
|
||||
/*
|
||||
Open Tracker License
|
||||
|
||||
Terms and Conditions
|
||||
|
||||
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice applies to all licensees
|
||||
and shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of Be Incorporated shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings in
|
||||
this Software without prior written authorization from Be Incorporated.
|
||||
|
||||
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
||||
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.
|
||||
*/
|
||||
|
||||
#include <Debug.h>
|
||||
#include <stdio.h>
|
||||
#include <Bitmap.h>
|
||||
|
||||
#include "BarApp.h"
|
||||
#include "BarMenuBar.h"
|
||||
#include "ExpandoMenuBar.h"
|
||||
#include "ResourceSet.h"
|
||||
#include "TeamMenu.h"
|
||||
#include "WindowMenu.h"
|
||||
#include "WindowMenuItem.h"
|
||||
#include "icons.h"
|
||||
|
||||
|
||||
const float kHPad = 10.0f;
|
||||
const float kVPad = 2.0f;
|
||||
const float kLabelOffset = 8.0f;
|
||||
const BRect kIconRect(1.0f, 1.0f, 13.0f, 14.0f);
|
||||
|
||||
|
||||
TWindowMenuItem::TWindowMenuItem(const char *title, int32 id,
|
||||
bool mini, bool currentWorkspace, bool dragging)
|
||||
: BMenuItem(title, NULL),
|
||||
fID(id),
|
||||
fMini(mini),
|
||||
fCurrentWorkSpace(currentWorkspace),
|
||||
fDragging(dragging),
|
||||
fExpanded(false),
|
||||
fRequireUpdate(false),
|
||||
fModified(false)
|
||||
{
|
||||
Initialize(title);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TWindowMenuItem::Initialize(const char *title)
|
||||
{
|
||||
if (fMini)
|
||||
fBitmap = fCurrentWorkSpace
|
||||
? AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_WindowHiddenIcon)
|
||||
: AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_WindowHiddenSwitchIcon);
|
||||
else
|
||||
fBitmap = fCurrentWorkSpace
|
||||
? AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_WindowShownIcon)
|
||||
: AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_WindowShownSwitchIcon);
|
||||
|
||||
BFont font(be_plain_font);
|
||||
fTitleWidth = ceilf(font.StringWidth(title));
|
||||
font_height fontHeight;
|
||||
font.GetHeight(&fontHeight);
|
||||
fTitleAscent = ceilf(fontHeight.ascent);
|
||||
fTitleDescent = ceilf(fontHeight.descent + fontHeight.leading);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TWindowMenuItem::SetTo(const char *title, int32 id,
|
||||
bool mini, bool currentWorkspace, bool dragging)
|
||||
{
|
||||
fModified = fCurrentWorkSpace != currentWorkspace || fMini != mini;
|
||||
|
||||
fID = id;
|
||||
fMini = mini;
|
||||
fCurrentWorkSpace = currentWorkspace;
|
||||
fDragging = dragging;
|
||||
fRequireUpdate = false;
|
||||
|
||||
Initialize(title);
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
TWindowMenuItem::ChangedState()
|
||||
{
|
||||
return fModified;
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
TWindowMenuItem::ID()
|
||||
{
|
||||
return fID;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TWindowMenuItem::GetContentSize(float *width, float *height)
|
||||
{
|
||||
if (!fExpanded) {
|
||||
*width = kHPad + fTitleWidth + kHPad;
|
||||
if (fID >= 0)
|
||||
*width += fBitmap->Bounds().Width() + kLabelOffset;
|
||||
} else
|
||||
*width = Frame().Width() - kHPad;
|
||||
|
||||
// ToDo: label width is not correct yet - the text label is
|
||||
// always written completely, if it fits or not!
|
||||
|
||||
*height = (fID >= 0) ? fBitmap->Bounds().Height() : 0.0f;
|
||||
float labelHeight = fTitleAscent + fTitleDescent;
|
||||
*height = (labelHeight > *height) ? labelHeight : *height;
|
||||
*height += kVPad * 2;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TWindowMenuItem::Draw()
|
||||
{
|
||||
if (fExpanded) {
|
||||
rgb_color menuColor = ui_color(B_MENU_BACKGROUND_COLOR);
|
||||
BRect frame(Frame());
|
||||
BMenu *menu = Menu();
|
||||
|
||||
menu->PushState();
|
||||
|
||||
// if not selected or being tracked on, fill with gray
|
||||
TBarView *barview = (static_cast<TBarApp *>(be_app))->BarView();
|
||||
if (!IsSelected() && !menu->IsRedrawAfterSticky() || barview->Dragging() || !IsEnabled()) {
|
||||
menu->SetHighColor(menuColor);
|
||||
menu->FillRect(frame);
|
||||
|
||||
if (fExpanded) {
|
||||
rgb_color shadow = tint_color(menuColor, B_DARKEN_1_TINT);
|
||||
menu->SetHighColor(shadow);
|
||||
frame.right = frame.left + kHPad / 2;
|
||||
menu->FillRect(frame);
|
||||
}
|
||||
}
|
||||
|
||||
if (IsEnabled() && IsSelected() && !menu->IsRedrawAfterSticky()) {
|
||||
// fill
|
||||
menu->SetHighColor(tint_color(menuColor, B_HIGHLIGHT_BACKGROUND_TINT));
|
||||
menu->FillRect(frame);
|
||||
} else
|
||||
menu->SetLowColor(menuColor);
|
||||
|
||||
menu->MovePenTo(ContentLocation());
|
||||
DrawContent();
|
||||
menu->PopState();
|
||||
}
|
||||
BMenuItem::Draw();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TWindowMenuItem::DrawContent()
|
||||
{
|
||||
BMenu *menu = Menu();
|
||||
menu->PushState();
|
||||
|
||||
BRect frame(Frame());
|
||||
BPoint contLoc = ContentLocation() + BPoint(kHPad, kVPad);
|
||||
if (fExpanded)
|
||||
contLoc.x += kHPad;
|
||||
menu->SetDrawingMode(B_OP_COPY);
|
||||
|
||||
if (fID >= 0) {
|
||||
menu->SetDrawingMode(B_OP_OVER);
|
||||
|
||||
float width = fBitmap->Bounds().Width();
|
||||
|
||||
if (width > 16)
|
||||
contLoc.x -= 8;
|
||||
|
||||
menu->MovePenTo(contLoc);
|
||||
menu->DrawBitmapAsync(fBitmap);
|
||||
|
||||
if (width > 16)
|
||||
contLoc.x += 8;
|
||||
|
||||
contLoc.x += kIconRect.Width() + kLabelOffset;
|
||||
|
||||
menu->SetDrawingMode(B_OP_COPY);
|
||||
}
|
||||
contLoc.y = frame.top + ((frame.Height() - fTitleAscent - fTitleDescent) / 2) + 1.0f;
|
||||
menu->PopState();
|
||||
|
||||
menu->MovePenTo(contLoc);
|
||||
// Set the pen color so that the label is always visible.
|
||||
menu->SetHighColor(0, 0, 0);
|
||||
BMenuItem::DrawContent();
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
TWindowMenuItem::Invoke(BMessage *)
|
||||
{
|
||||
if (!fDragging) {
|
||||
if (fID >= 0) {
|
||||
int32 action = (modifiers() & B_CONTROL_KEY)
|
||||
? B_MINIMIZE_WINDOW :B_BRING_TO_FRONT;
|
||||
|
||||
bool doZoom = false;
|
||||
BRect zoomRect(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
BMenuItem *item;
|
||||
if (!fExpanded)
|
||||
item = Menu()->Superitem();
|
||||
else
|
||||
item = this;
|
||||
|
||||
if (item->Menu()->Window() != NULL) {
|
||||
zoomRect = item->Menu()->ConvertToScreen(item->Frame());
|
||||
doZoom = fMini && (action == B_BRING_TO_FRONT) ||
|
||||
!fMini && (action == B_MINIMIZE_WINDOW);
|
||||
}
|
||||
|
||||
do_window_action(fID, action, zoomRect, doZoom);
|
||||
}
|
||||
}
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TWindowMenuItem::ExpandedItem(bool status)
|
||||
{
|
||||
fExpanded = status;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TWindowMenuItem::SetRequireUpdate()
|
||||
{
|
||||
fRequireUpdate = true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
TWindowMenuItem::RequiresUpdate()
|
||||
{
|
||||
return fRequireUpdate;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
Open Tracker License
|
||||
|
||||
Terms and Conditions
|
||||
|
||||
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice applies to all licensees
|
||||
and shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of Be Incorporated shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings in
|
||||
this Software without prior written authorization from Be Incorporated.
|
||||
|
||||
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
||||
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.
|
||||
*/
|
||||
|
||||
// individual windows of an application
|
||||
// item for WindowMenu, sub of TeamMenuItem
|
||||
// all DB positions
|
||||
|
||||
#ifndef WINDOWMENUITEM_H
|
||||
#define WINDOWMENUITEM_H
|
||||
|
||||
#include <MenuItem.h>
|
||||
#include <String.h>
|
||||
|
||||
|
||||
class BBitmap;
|
||||
|
||||
|
||||
class TWindowMenuItem : public BMenuItem {
|
||||
public:
|
||||
TWindowMenuItem(const char *title, int32 id, bool mini,
|
||||
bool currentWorkSpace, bool dragging = false);
|
||||
|
||||
void ExpandedItem(bool state);
|
||||
void SetTo(const char *title, int32 id, bool mini,
|
||||
bool currentWorkSpace, bool dragging = false);
|
||||
int32 ID();
|
||||
void SetRequireUpdate();
|
||||
bool RequiresUpdate();
|
||||
bool ChangedState();
|
||||
|
||||
protected:
|
||||
void Initialize(const char *title);
|
||||
virtual void GetContentSize(float *width, float *height);
|
||||
virtual void DrawContent();
|
||||
virtual status_t Invoke(BMessage *message = NULL);
|
||||
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;
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
** WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING **
|
||||
** **
|
||||
** DANGER, WILL ROBINSON! **
|
||||
** **
|
||||
** The rest of the interfaces contained here are part of BeOS's **
|
||||
** **
|
||||
** >> PRIVATE NOT FOR PUBLIC USE << **
|
||||
** **
|
||||
** implementation. **
|
||||
** **
|
||||
** These interfaces WILL CHANGE in future releases. **
|
||||
** If you use them, your app WILL BREAK at some future time. **
|
||||
** **
|
||||
** (And yes, this does mean that binaries built from OpenTracker will not **
|
||||
** be compatible with some future releases of the OS. When that happens, **
|
||||
** we will provide an updated version of this file to keep compatibility.) **
|
||||
** **
|
||||
** WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING **
|
||||
****************************************************************************/
|
||||
|
||||
// from interface_defs.h
|
||||
struct window_info {
|
||||
team_id team;
|
||||
int32 id; /* window's token */
|
||||
|
||||
int32 thread;
|
||||
int32 client_token;
|
||||
int32 client_port;
|
||||
uint32 workspaces;
|
||||
|
||||
int32 layer;
|
||||
uint32 w_type; /* B_TITLED_WINDOW, etc. */
|
||||
uint32 flags; /* B_WILL_FLOAT, etc. */
|
||||
int32 window_left;
|
||||
int32 window_top;
|
||||
int32 window_right;
|
||||
int32 window_bottom;
|
||||
int32 show_hide_level;
|
||||
bool is_mini;
|
||||
char name[1];
|
||||
};
|
||||
|
||||
// from interface_misc.h
|
||||
enum window_action {
|
||||
B_MINIMIZE_WINDOW,
|
||||
B_BRING_TO_FRONT
|
||||
};
|
||||
|
||||
// from interface_misc.h
|
||||
void do_window_action(int32 window_id, int32 action,
|
||||
BRect zoomRect, bool zoom);
|
||||
window_info *get_window_info(int32 a_token);
|
||||
int32 *get_token_list(team_id app, int32 *count);
|
||||
void do_minimize_team(BRect zoomRect, team_id team, bool zoom);
|
||||
void do_bring_to_front_team(BRect zoomRect, team_id app, bool zoom);
|
||||
|
||||
|
||||
#endif /* WINDOWMENUITEM_H */
|
||||
Binary file not shown.
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
** /src/open/deskbar/icons.h
|
||||
**
|
||||
** Automatically generated by BResourceParser on
|
||||
** Friday, January 26, 2001 at 11:38:39.
|
||||
**
|
||||
*/
|
||||
|
||||
enum {
|
||||
R_LargeNewGroupIcon = 16,
|
||||
R_SmallNewGroupIcon = 17,
|
||||
R_TeamIcon = 18,
|
||||
R_GenericAppIcon = 19,
|
||||
R_WindowShownIcon = 20,
|
||||
R_WindowHiddenIcon = 21,
|
||||
R_ResizeIcon = 22,
|
||||
R_WindowShownSwitchIcon = 23,
|
||||
R_WindowHiddenSwitchIcon = 24
|
||||
};
|
||||
@@ -0,0 +1,191 @@
|
||||
/*
|
||||
** /src/open/deskbar/icons.rdef
|
||||
**
|
||||
** Automatically generated by BResourceParser on
|
||||
** Friday, January 26, 2001 at 11:38:39.
|
||||
**
|
||||
*/
|
||||
|
||||
#include "icons.h"
|
||||
|
||||
resource(R_LargeNewGroupIcon) archive(, 0x00000000) BBitmap {
|
||||
"_frame" = rect { 0.0, 0.0, 31.0, 31.0 },
|
||||
"_cspace" = 4,
|
||||
"_bmflags" = 1,
|
||||
"_rowbytes" = 32,
|
||||
"_data" = array {
|
||||
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
||||
$"FFFFFFFFFFFFFFFFFF0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
||||
$"FFFFFFFFFFFFFFFF00FAFA0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
||||
$"FFFFFFFFFFFFFFFF00FAF8FAFA0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
||||
$"FFFFFFFFFFFF000000FAF8F8F8FAFA0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
||||
$"FFFFFFFFFF00FAFA0000F8F8F8F8F8FAFA00FFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
||||
$"FFFFFFFFFF00FAF8FAFA0000F8F8F8F8F800FFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
||||
$"FFFFFFFFFF00FAF8F8F8FAFA0000F8F8F800FFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
||||
$"FFFFFFFFFF00FAF8F8F8F8F8FAFA00F8F80000FFFFFFFFFFFFFFFFFFFFFFFFFF"
|
||||
$"FFFFFFFFFF001BF8F8F8F8F8F8F8000E0F1C1C0000FFFFFFFFFFFFFFFFFFFFFF"
|
||||
$"FFFFFFFFFF001B0F0F0FF8F8F8F8003F3F0E0F1C1C0000FFFFFFFFFFFFFFFFFF"
|
||||
$"FFFFFFFFFF001B0F3F3F0E0FF8F800003F3F3F0E0F1C1C0000FFFFFFFFFFFFFF"
|
||||
$"FFFFFFFFFF001B0F3F3F3F3F0E0F1C1C00003F3F3F0E0F1A190000FFFFFFFFFF"
|
||||
$"FFFFFFFFFF001B0F3F3F3F3F3F3F0E0F1C1C00003F3F3F0E1A1900FFFFFFFFFF"
|
||||
$"FFFFFFFFFF001B0F3F3F3F3F3F3F3F3F0E0F1C1C00003F3F171900FFFFFFFFFF"
|
||||
$"FFFFFFFFFF001B0F3F3F3F3F3F3F3F3F3F3F0E0F1A190000171900FFFFFFFFFF"
|
||||
$"FFFFFFFFFF001B0F3F3F3F3F3F3F3F3F3F3F3F3F0E1A1900171900FFFFFFFFFF"
|
||||
$"FFFFFFFFFF001B0F3F3F3F3F3F3F3F3F3F3F3F3F3F171900171900FFFFFFFFFF"
|
||||
$"FFFFFFFFFF001B0F3F3F3F3F3F3F3F3F3F3F3F3F3F171900171900FFFFFFFFFF"
|
||||
$"FFFFFFFFFF001B0F3F3F3F3F3F3F3F3F3F3F3F3F3F171900171900FFFFFFFFFF"
|
||||
$"FFFFFFFFFF001B183F3F3F3F3F3F3F3F3F3F3F3F3F171900171900FFFFFFFFFF"
|
||||
$"FFFFFFFFFF001B1C17183F3F3F3F3F3F3F3F3F3F3F171900171900FFFFFFFFFF"
|
||||
$"FFFFFFFFFFFF00001B1C17183F3F3F3F3F3F3F3F3F171900171900FFFFFFFFFF"
|
||||
$"FFFFFFFFFFFFFFFF0000191A17173F3F3F3F3F3F3F171900171900FFFFFFFFFF"
|
||||
$"FFFFFFFFFFFFFFFFFFFF0000191A17173F3F3F3F3F171900171A00FFFFFFFFFF"
|
||||
$"FFFFFFFFFFFFFFFFFFFFFFFF0000191A17173F3F3F1719001A1900FFFFFFFFFF"
|
||||
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFF0000191A17173F171900001900FFFFFFFFFF"
|
||||
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000191A17171A00FF0000FFFFFFFFFF"
|
||||
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000191A1900FFFFFFFFFFFFFFFF"
|
||||
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00001900FFFFFFFFFFFFFFFF"
|
||||
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFFFFFFFFFF"
|
||||
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
||||
}
|
||||
};
|
||||
|
||||
resource(R_SmallNewGroupIcon) archive(, 0x00000000) BBitmap {
|
||||
"_frame" = rect { 0.0, 0.0, 15.0, 15.0 },
|
||||
"_cspace" = 4,
|
||||
"_bmflags" = 1,
|
||||
"_rowbytes" = 16,
|
||||
"_data" = array {
|
||||
$"FFFFFFFF0E0EFFFFFFFFFFFFFFFFFFFFFFFFFF0EFAFA0E0EFFFFFFFFFFFFFFFF"
|
||||
$"FFFF0E0EF8F8FAFA0EFFFFFFFFFFFFFFFFFF0EFAFA0EF8F80EFFFFFFFFFFFFFF"
|
||||
$"FFFF0EF8F8FAFA0E0E0EFFFFFFFFFFFFFFFF0E1818F8F80E3F3F0E0EFFFFFFFF"
|
||||
$"FFFF0E183F18180F0F3F3F0E12FFFFFFFFFF0E183F3F3F18180F0F0E12FFFFFF"
|
||||
$"FFFF0E183F3F3F3F3F18180E12FFFFFFFFFF0E183F3F3F3F3F3F1C0E12FFFFFF"
|
||||
$"FFFF0E0E181C3F3F3F3F1C0E12FFFFFFFFFFFFFF0E0E171C3F3F1C0E12FFFFFF"
|
||||
$"FFFFFFFFFFFF0E0E171C1C0E12FFFFFFFFFFFFFFFFFFFFFF0E0E170E12FFFFFF"
|
||||
$"FFFFFFFFFFFFFFFFFFFF0E0EFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
||||
}
|
||||
};
|
||||
|
||||
resource(R_TeamIcon) archive(, 0x00000000) BBitmap {
|
||||
"_frame" = rect { 0.0, 0.0, 19.0, 15.0 },
|
||||
"_cspace" = 4,
|
||||
"_bmflags" = 1,
|
||||
"_rowbytes" = 20,
|
||||
"_data" = array {
|
||||
$"FFFF0000000000000000000000000000FFFFFFFFFFFF008F8F8F8F8F8F8F8F8F"
|
||||
$"8F00000000FFFFFFFFFF008F8F8F8F8F0000000000D9D90000FFFFFFFFFF008F"
|
||||
$"8F3F8F3F00D9001B00D9D9AA01FFFFFFFFFF008F3F3F3F3F8F8F00001500000A"
|
||||
$"0016FFFFFFFF008F8F3F8F3F3F8F8F8F001B151C1C00FFFFFFFF008F8F3F8F3F"
|
||||
$"8F8F8F8F0015150B1B00FFFFFFFF008F8F8F8F8F8F8F8F8F8F0100001C00FFFF"
|
||||
$"FFFF008F8F8F8F8F8F8F8F8F8F0166001C00FFFFFFFF00000000000000000000"
|
||||
$"000066660000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0066660000FFFFFFFFFFFF"
|
||||
$"FFFFFFFFFF000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF006666"
|
||||
$"8D00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0066668D00FFFFFFFFFFFFFFFFFFFF"
|
||||
$"FFFFFFFF0000AAAA0011FFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000011FFFF"
|
||||
}
|
||||
};
|
||||
|
||||
resource(R_GenericAppIcon) archive(, 0x00000000) BBitmap {
|
||||
"_frame" = rect { 0.0, 0.0, 15.0, 15.0 },
|
||||
"_cspace" = 4,
|
||||
"_bmflags" = 1,
|
||||
"_rowbytes" = 16,
|
||||
"_data" = array {
|
||||
$"FFFFFFFFFFFFFF0000FFFFFFFFFFFFFFFFFFFFFFFFFF00FAFA0000FFFFFFFFFF"
|
||||
$"FFFFFFFFFF00FAFAFAFAFA0000FFFFFFFFFFFFFF001FFAFAFAFA1F5D00FFFFFF"
|
||||
$"FFFFFFFF00F91F1FFA1F5D5D00FFFFFFFFFFFF0000F9F9F91F5D5D5D00FFFFFF"
|
||||
$"FFFF006001F9F9F9F95D5D5D0000FFFFFF00606001F9F9F9F95D5D5D00A30000"
|
||||
$"001F60606001F9F9F95D5D00A31F2D0000861F1F601F0000F95D00A31F2D2D00"
|
||||
$"008686861FD527000000A31F2D2D2E000086868686D52801CACAA3A32D2D2E00"
|
||||
$"0086868686D5D500CAA3A3A32D2D2D000086868686D5D500A3A3A3A32D2D2E01"
|
||||
$"FF00008686D5D5010000A3A32D2E0011FFFFFF000000001111FF000000001111"
|
||||
}
|
||||
};
|
||||
|
||||
resource(R_WindowShownIcon) archive(, 0x00000000) BBitmap {
|
||||
"_frame" = rect { 0.0, 0.0, 15.0, 15.0 },
|
||||
"_cspace" = 4,
|
||||
"_bmflags" = 1,
|
||||
"_rowbytes" = 16,
|
||||
"_data" = array {
|
||||
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0F0F0F0F0F0F0F0F0FFFFFFFFFFFFF"
|
||||
$"FF0FFCFCFCFCFCFCFC00FFFFFFFFFFFFFF0FBDBDBDBDBDBDBD0F0F0F0F0FFFFF"
|
||||
$"FF0F191919191919191919191900FFFFFF0F193F3F3F3F3F3F3F3F3F1900FFFF"
|
||||
$"FF0F193F3F3F3F3F3F3F3F3F1900FFFFFF0F193F3F3F3F3F3F3F3F3F1900FFFF"
|
||||
$"FF0F193F3F3F3F3F3F3F3F3F1900FFFFFF0F193F3F3F3F3F3F3F3F3F1900FFFF"
|
||||
$"FF0F193F3F3F3F3F3F3F3F3F1900FFFFFF0F193F3F3F3F3F3F3F3F3F1900FFFF"
|
||||
$"FF0F193F3F3F3F3F3F3F3F3F1900FFFFFF0F191919191919191919191900FFFF"
|
||||
$"FF00000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
||||
}
|
||||
};
|
||||
|
||||
resource(R_WindowHiddenIcon) archive(, 0x00000000) BBitmap {
|
||||
"_frame" = rect { 0.0, 0.0, 15.0, 15.0 },
|
||||
"_cspace" = 4,
|
||||
"_bmflags" = 1,
|
||||
"_rowbytes" = 16,
|
||||
"_data" = array {
|
||||
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0F0F0F0F0F0F0F0F0FFFFFFFFFFFFF"
|
||||
$"FF0F1313131313131300FFFFFFFFFFFFFF0F131313131313130F0F0F0F0FFFFF"
|
||||
$"FF0F191919191919191919191900FFFFFF0F191919191919191919191900FFFF"
|
||||
$"FF0F191919191919191919191900FFFFFF0F191919191919191919191900FFFF"
|
||||
$"FF0F191919191919191919191900FFFFFF0F191919191919191919191900FFFF"
|
||||
$"FF0F191919191919191919191900FFFFFF0F191919191919191919191900FFFF"
|
||||
$"FF0F191919191919191919191900FFFFFF0F191919191919191919191900FFFF"
|
||||
$"FF00000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
||||
}
|
||||
};
|
||||
|
||||
resource(R_ResizeIcon) archive(, 0x00000000) BBitmap {
|
||||
"_frame" = rect { 0.0, 0.0, 7.0, 7.0 },
|
||||
"_cspace" = 4,
|
||||
"_bmflags" = 1,
|
||||
"_rowbytes" = 8,
|
||||
"_data" = array {
|
||||
$"1B1B1B1B1B1B0C1B1B1B1B1B1B1B1B3F1B1B1B1B1B1B1B1B1B1B1B0C1B1B0C1B"
|
||||
$"1B1B1B1B3F1B1B3F1B1B1B1B1B1B1B1B0C1B1B0C1B1B0C1B1B3F1B1B3F1B1B3F"
|
||||
}
|
||||
};
|
||||
|
||||
resource(R_WindowShownSwitchIcon) archive(, 0x00000000) BBitmap {
|
||||
"_frame" = rect { 0.0, 0.0, 23.0, 15.0 },
|
||||
"_cspace" = 4,
|
||||
"_bmflags" = 1,
|
||||
"_rowbytes" = 24,
|
||||
"_data" = array {
|
||||
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
||||
$"FF0C0C0C0C0C0C0C0C0CFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0CFAFAFAFAFAFA"
|
||||
$"FA00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0CF9F9F9F9F9F9F90C0C0C0C0CFFFF"
|
||||
$"FFFFFFFFFFFFFFFFFF0C191919191919191919191900FFFFFFFFFFFFFFFFFFFF"
|
||||
$"FF0C193F3F3F3F3F3F3F3F3F1900FFFFFFFF0CFF0C0C0CFFFF0C193F3F3F3F3F"
|
||||
$"3F3F3F3F1900FFFFFFFFFFFFFFFFFFFFFF0C193F3F3F3F3F3F3F3F3F1900FFFF"
|
||||
$"FFFFFFFFFFFFFFFFFF0C193F3F3F3F3F3F3F3F3F1900FFFF0CFF0C0C0C0C0CFF"
|
||||
$"FF0C193F3F3F3F3F3F3F3F3F1900FFFFFFFFFFFFFFFFFFFFFF0C193F3F3F3F3F"
|
||||
$"3F3F3F3F1900FFFFFFFFFFFFFFFFFFFFFF0C193F3F3F3F3F3F3F3F3F1900FFFF"
|
||||
$"FF0CFF0C0C0C0CFFFF0C193F3F3F3F3F3F3F3F3F1900FFFFFFFFFFFFFFFFFFFF"
|
||||
$"FF0C191919191919191919191900FFFFFFFFFFFFFFFFFFFFFF00000000000000"
|
||||
$"000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
||||
}
|
||||
};
|
||||
|
||||
resource(R_WindowHiddenSwitchIcon) archive(, 0x00000000) BBitmap {
|
||||
"_frame" = rect { 0.0, 0.0, 23.0, 15.0 },
|
||||
"_cspace" = 4,
|
||||
"_bmflags" = 1,
|
||||
"_rowbytes" = 24,
|
||||
"_data" = array {
|
||||
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
||||
$"FF0C0C0C0C0C0C0C0C0CFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0C101010101010"
|
||||
$"1000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0C101010101010100C0C0C0C0CFFFF"
|
||||
$"FFFFFFFFFFFFFFFFFF0C191919191919191919191900FFFFFFFFFFFFFFFFFFFF"
|
||||
$"FF0C191919191919191919191900FFFFFFFF0CFF0C0C0CFFFF0C191919191919"
|
||||
$"191919191900FFFFFFFFFFFFFFFFFFFFFF0C191919191919191919191900FFFF"
|
||||
$"FFFFFFFFFFFFFFFFFF0C191919191919191919191900FFFF0CFF0C0C0C0C0CFF"
|
||||
$"FF0C191919191919191919191900FFFFFFFFFFFFFFFFFFFFFF0C191919191919"
|
||||
$"191919191900FFFFFFFFFFFFFFFFFFFFFF0C191919191919191919191900FFFF"
|
||||
$"FF0CFF0C0C0C0CFFFF0C191919191919191919191900FFFFFFFFFFFFFFFFFFFF"
|
||||
$"FF0C191919191919191919191900FFFFFFFFFFFFFFFFFFFFFF00000000000000"
|
||||
$"000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
enum {
|
||||
R_BeLogoIcon = 14
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
SubDir OBOS_TOP src apps tracker ;
|
||||
|
||||
UsePrivateHeaders shared ;
|
||||
UsePrivateHeaders tracker ;
|
||||
SubDirHdrs $(OBOS_TOP) src kits tracker ;
|
||||
|
||||
AddResources Tracker : Tracker.rsrc ;
|
||||
|
||||
App Tracker :
|
||||
main.cpp
|
||||
;
|
||||
|
||||
LinkSharedOSLibs Tracker : libbe.so libtracker.so ;
|
||||
Binary file not shown.
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
Open Tracker License
|
||||
|
||||
Terms and Conditions
|
||||
|
||||
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice applies to all licensees
|
||||
and shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of Be Incorporated shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings in
|
||||
this Software without prior written authorization from Be Incorporated.
|
||||
|
||||
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
||||
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.
|
||||
*/
|
||||
|
||||
#include "Tracker.h"
|
||||
|
||||
#if DEBUG
|
||||
//#define LEAK_CHECKING
|
||||
|
||||
#ifdef LEAK_CHECKING
|
||||
#include "LeakChecking.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef PROFILE
|
||||
#include "libprof.h"
|
||||
#endif
|
||||
|
||||
int main(int , char **)
|
||||
{
|
||||
#ifdef PROFILE
|
||||
PROFILE_INIT(1024);
|
||||
#endif
|
||||
|
||||
#ifdef LEAK_CHECKING
|
||||
SetNewLeakChecking(true);
|
||||
SetMallocLeakChecking(true);
|
||||
#endif
|
||||
|
||||
TTracker tracker;
|
||||
tracker.Run();
|
||||
|
||||
#ifdef PROFILE
|
||||
PROFILE_DUMP("/boot/home/Desktop/trackerProfile");
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user