-
diff --git a/src/apps/deskbar/BarApp.cpp b/src/apps/deskbar/BarApp.cpp
index 2647068..6cc209a 100644
a
|
b
|
All rights reserved.
|
60 | 60 | #include "PublicCommands.h" |
61 | 61 | #include "ResourceSet.h" |
62 | 62 | #include "Switcher.h" |
63 | | #include "TeamMenu.h" |
64 | | #include "WindowMenuItem.h" |
65 | 63 | |
66 | 64 | |
67 | 65 | BLocker TBarApp::sSubscriberLock; |
… |
… |
BList TBarApp::sSubscribers;
|
72 | 70 | const uint32 kShowBeMenu = 'BeMn'; |
73 | 71 | const uint32 kShowTeamMenu = 'TmMn'; |
74 | 72 | |
75 | | const BRect kIconSize(0.0f, 0.0f, 15.0f, 15.0f); |
76 | 73 | |
| 74 | const BRect kIconRect(0.0f, 0.0f, 15.0f, 15.0f); |
77 | 75 | static const color_space kIconFormat = B_RGBA32; |
78 | 76 | |
79 | 77 | |
… |
… |
TBarApp::SaveSettings()
|
190 | 188 | storedSettings.AddFloat("width", fSettings.width); |
191 | 189 | storedSettings.AddBool("showTime", fSettings.showTime); |
192 | 190 | storedSettings.AddPoint("switcherLoc", fSettings.switcherLoc); |
193 | | storedSettings.AddInt32("recentAppsCount", |
194 | | fSettings.recentAppsCount); |
195 | | storedSettings.AddInt32("recentDocsCount", |
196 | | fSettings.recentDocsCount); |
197 | | storedSettings.AddBool("timeShowSeconds", |
198 | | fSettings.timeShowSeconds); |
| 191 | storedSettings.AddInt32("recentAppsCount", fSettings.recentAppsCount); |
| 192 | storedSettings.AddInt32("recentDocsCount", fSettings.recentDocsCount); |
| 193 | storedSettings.AddBool("timeShowSeconds", fSettings.timeShowSeconds); |
199 | 194 | storedSettings.AddInt32("recentFoldersCount", |
200 | 195 | fSettings.recentFoldersCount); |
201 | 196 | storedSettings.AddBool("alwaysOnTop", fSettings.alwaysOnTop); |
202 | 197 | storedSettings.AddBool("timeFullDate", fSettings.timeFullDate); |
203 | 198 | storedSettings.AddBool("trackerAlwaysFirst", |
204 | 199 | fSettings.trackerAlwaysFirst); |
205 | | storedSettings.AddBool("sortRunningApps", |
206 | | fSettings.sortRunningApps); |
207 | | storedSettings.AddBool("superExpando", |
208 | | fSettings.superExpando); |
209 | | storedSettings.AddBool("expandNewTeams", |
210 | | fSettings.expandNewTeams); |
211 | | storedSettings.AddBool("autoRaise", |
212 | | fSettings.autoRaise); |
| 200 | storedSettings.AddBool("sortRunningApps", fSettings.sortRunningApps); |
| 201 | storedSettings.AddBool("superExpando", fSettings.superExpando); |
| 202 | storedSettings.AddBool("expandNewTeams", fSettings.expandNewTeams); |
| 203 | storedSettings.AddBool("autoRaise", fSettings.autoRaise); |
213 | 204 | storedSettings.AddBool("recentAppsEnabled", |
214 | 205 | fSettings.recentAppsEnabled); |
215 | 206 | storedSettings.AddBool("recentDocsEnabled", |
… |
… |
TBarApp::InitSettings()
|
291 | 282 | &settings.trackerAlwaysFirst); |
292 | 283 | storedSettings.FindBool("sortRunningApps", |
293 | 284 | &settings.sortRunningApps); |
294 | | storedSettings.FindBool("superExpando", |
295 | | &settings.superExpando); |
296 | | storedSettings.FindBool("expandNewTeams", |
297 | | &settings.expandNewTeams); |
298 | | storedSettings.FindBool("autoRaise", |
299 | | &settings.autoRaise); |
| 285 | storedSettings.FindBool("superExpando", &settings.superExpando); |
| 286 | storedSettings.FindBool("expandNewTeams", &settings.expandNewTeams); |
| 287 | storedSettings.FindBool("autoRaise", &settings.autoRaise); |
300 | 288 | storedSettings.FindBool("recentAppsEnabled", |
301 | 289 | &settings.recentAppsEnabled); |
302 | 290 | storedSettings.FindBool("recentDocsEnabled", |
… |
… |
TBarApp::InitSettings()
|
313 | 301 | void |
314 | 302 | TBarApp::MessageReceived(BMessage* message) |
315 | 303 | { |
316 | | int32 count; |
317 | | bool enabled; |
318 | 304 | switch (message->what) { |
319 | 305 | case 'gloc': |
320 | 306 | case 'sloc': |
… |
… |
TBarApp::MessageReceived(BMessage* message)
|
353 | 339 | break; |
354 | 340 | |
355 | 341 | case kUpdateRecentCounts: |
| 342 | int32 count; |
| 343 | bool enabled; |
| 344 | |
356 | 345 | if (message->FindInt32("applications", &count) == B_OK) |
357 | 346 | fSettings.recentAppsCount = count; |
358 | 347 | if (message->FindBool("applicationsEnabled", &enabled) == B_OK) |
… |
… |
TBarApp::MessageReceived(BMessage* message)
|
423 | 412 | { |
424 | 413 | fSettings.autoRaise = !fSettings.autoRaise; |
425 | 414 | |
426 | | TBarView* barView = static_cast<TBarApp*>(be_app)->BarView(); |
427 | 415 | fBarWindow->Lock(); |
428 | | barView->UpdateAutoRaise(); |
| 416 | BarView()->UpdateAutoRaise(); |
429 | 417 | fBarWindow->Unlock(); |
430 | 418 | break; |
431 | 419 | } |
… |
… |
TBarApp::MessageReceived(BMessage* message)
|
434 | 422 | { |
435 | 423 | fSettings.trackerAlwaysFirst = !fSettings.trackerAlwaysFirst; |
436 | 424 | |
437 | | TBarView* barView = static_cast<TBarApp*>(be_app)->BarView(); |
438 | 425 | fBarWindow->Lock(); |
439 | | barView->UpdatePlacement(); |
| 426 | BarView()->UpdatePlacement(); |
440 | 427 | fBarWindow->Unlock(); |
441 | 428 | break; |
442 | 429 | } |
… |
… |
TBarApp::MessageReceived(BMessage* message)
|
445 | 432 | { |
446 | 433 | fSettings.sortRunningApps = !fSettings.sortRunningApps; |
447 | 434 | |
448 | | TBarView* barView = static_cast<TBarApp*>(be_app)->BarView(); |
449 | 435 | fBarWindow->Lock(); |
450 | | barView->UpdatePlacement(); |
| 436 | BarView()->UpdatePlacement(); |
451 | 437 | fBarWindow->Unlock(); |
452 | 438 | break; |
453 | 439 | } |
… |
… |
TBarApp::MessageReceived(BMessage* message)
|
464 | 450 | { |
465 | 451 | fSettings.superExpando = !fSettings.superExpando; |
466 | 452 | |
467 | | TBarView* barView = static_cast<TBarApp*>(be_app)->BarView(); |
468 | 453 | fBarWindow->Lock(); |
469 | | barView->UpdatePlacement(); |
| 454 | BarView()->UpdatePlacement(); |
470 | 455 | fBarWindow->Unlock(); |
471 | 456 | break; |
472 | 457 | } |
… |
… |
TBarApp::MessageReceived(BMessage* message)
|
475 | 460 | { |
476 | 461 | fSettings.expandNewTeams = !fSettings.expandNewTeams; |
477 | 462 | |
478 | | TBarView* barView = static_cast<TBarApp*>(be_app)->BarView(); |
479 | 463 | fBarWindow->Lock(); |
480 | | barView->UpdatePlacement(); |
| 464 | BarView()->UpdatePlacement(); |
481 | 465 | fBarWindow->Unlock(); |
482 | 466 | break; |
483 | 467 | } |
… |
… |
TBarApp::AddTeam(team_id team, uint32 flags, const char* sig, entry_ref* ref)
|
636 | 620 | BAppFileInfo appMime(&file); |
637 | 621 | |
638 | 622 | BarTeamInfo* barInfo = new BarTeamInfo(new BList(), flags, strdup(sig), |
639 | | new BBitmap(kIconSize, kIconFormat), strdup(ref->name)); |
| 623 | new BBitmap(kIconRect, kIconFormat), strdup(ref->name)); |
640 | 624 | |
641 | 625 | barInfo->teams->AddItem((void*)team); |
642 | 626 | if (appMime.GetIcon(barInfo->icon, B_MINI_ICON) != B_OK) |
-
diff --git a/src/apps/deskbar/BarApp.h b/src/apps/deskbar/BarApp.h
index 6f15838..c3fd47b 100644
a
|
b
|
class TBarApp : public BApplication {
|
141 | 141 | static void Unsubscribe(const BMessenger &subscriber); |
142 | 142 | |
143 | 143 | private: |
144 | | void AddTeam(team_id team, uint32 flags, const char *sig, entry_ref *); |
| 144 | void AddTeam(team_id team, uint32 flags, const char *sig, entry_ref*); |
145 | 145 | void RemoveTeam(team_id); |
146 | 146 | |
147 | 147 | void InitSettings(); |
-
diff --git a/src/apps/deskbar/BarMenuBar.cpp b/src/apps/deskbar/BarMenuBar.cpp
index b246eb3..da27803 100644
a
|
b
|
init_tracking_hook(BMenuItem* item, bool (*hookFunction)(BMenu*, void*),
|
180 | 180 | |
181 | 181 | BMenu* windowMenu = item->Submenu(); |
182 | 182 | if (windowMenu) |
183 | | // have a menu, set the tracking hook |
| 183 | // have a menu, set the tracking hook |
184 | 184 | windowMenu->SetTrackingHook(hookFunction, state); |
185 | 185 | } |
186 | 186 | |
… |
… |
TBarMenuBar::InitTrackingHook(bool (*hookFunction)(BMenu*, void*),
|
192 | 192 | BPoint loc; |
193 | 193 | uint32 buttons; |
194 | 194 | GetMouse(&loc, &buttons); |
195 | | // set the hook functions for the two menus |
196 | | // will always have the be menu |
197 | | // may have the app menu as well (mini mode) |
| 195 | // set the hook functions for the two menus |
| 196 | // will always have the be menu |
| 197 | // may have the app menu as well (mini mode) |
198 | 198 | if (fBeMenuItem->Frame().Contains(loc) || both) |
199 | 199 | init_tracking_hook(fBeMenuItem, hookFunction, state); |
200 | 200 | |
-
diff --git a/src/apps/deskbar/BarMenuBar.h b/src/apps/deskbar/BarMenuBar.h
index ef21df1..620eb77 100644
a
|
b
|
class TBarMenuBar : public BMenuBar {
|
63 | 63 | |
64 | 64 | void InitTrackingHook(bool (* hookfunction)(BMenu*, void*), void* state, |
65 | 65 | bool both = false); |
66 | | |
| 66 | |
67 | 67 | private: |
68 | 68 | TBarView* fBarView; |
69 | 69 | TBarMenuTitle* fBeMenuItem; |
-
diff --git a/src/apps/deskbar/BarMenuTitle.cpp b/src/apps/deskbar/BarMenuTitle.cpp
index df8b0d2..9c9195c 100644
a
|
b
|
TBarMenuTitle::DrawContent()
|
123 | 123 | dstRect.OffsetBy(rintf(((frame.Width() - dstRect.Width()) / 2) |
124 | 124 | - 1.0f), rintf(((frame.Height() - dstRect.Height()) / 2) |
125 | 125 | - 0.0f)); |
126 | | |
| 126 | |
127 | 127 | menu->DrawBitmapAsync(fIcon, dstRect); |
128 | 128 | } |
129 | 129 | return; |
… |
… |
TBarMenuTitle::Invoke(BMessage* message)
|
204 | 204 | looper->Unlock(); |
205 | 205 | } |
206 | 206 | } |
207 | | |
| 207 | |
208 | 208 | return BMenuItem::Invoke(message); |
209 | 209 | } |
210 | 210 | |
-
diff --git a/src/apps/deskbar/BarMenuTitle.h b/src/apps/deskbar/BarMenuTitle.h
index be7aa99..9324aa1 100644
a
|
b
|
class BMenu;
|
46 | 46 | |
47 | 47 | class TBarMenuTitle : public BMenuItem { |
48 | 48 | public: |
49 | | TBarMenuTitle(float width,float height, const BBitmap* icon, |
50 | | BMenu* menu, bool inexpando = false); |
| 49 | TBarMenuTitle(float width, float height, const BBitmap* icon, |
| 50 | BMenu* menu, bool inexpando = false); |
51 | 51 | virtual ~TBarMenuTitle(); |
52 | 52 | |
53 | 53 | void SetWidthHeight(float width, float height); |
54 | 54 | void Draw(); |
55 | 55 | |
56 | 56 | status_t Invoke(BMessage* message); |
57 | | |
| 57 | |
58 | 58 | protected: |
59 | 59 | void DrawContent(); |
60 | 60 | void GetContentSize(float* width, float* height); |
-
diff --git a/src/apps/deskbar/BarView.cpp b/src/apps/deskbar/BarView.cpp
index 53dfeec..649bc3d 100644
a
|
b
|
TBarView::PlaceBeMenu()
|
206 | 206 | fBarMenuBar = NULL; |
207 | 207 | } |
208 | 208 | |
209 | | // top or bottom expando mode has Be menu built in for tracking |
210 | | // only for vertical mini or expanded |
211 | | // mini mode will have team menu added as part of BarMenuBar |
| 209 | // top or bottom expando mode has Be menu built in for tracking |
| 210 | // only for vertical mini or expanded |
| 211 | // mini mode will have team menu added as part of BarMenuBar |
212 | 212 | if (fVertical && !fBarMenuBar) { |
213 | 213 | // create the Be menu |
214 | 214 | BRect mbarFrame(Bounds()); |
… |
… |
TBarView::PlaceBeMenu()
|
217 | 217 | AddChild(fBarMenuBar); |
218 | 218 | } |
219 | 219 | |
220 | | // if there isn't a bemenu at this point, |
221 | | // DB should be in top/bottom mode, else error |
| 220 | // if there isn't a bemenu at this point, |
| 221 | // DB should be in top/bottom mode, else error |
222 | 222 | if (!fBarMenuBar) |
223 | 223 | return; |
224 | 224 | |
… |
… |
TBarView::SaveSettings()
|
404 | 404 | settings->state = (uint32)State(); |
405 | 405 | settings->width = 0; |
406 | 406 | settings->showTime = ShowingClock(); |
407 | | |
| 407 | |
408 | 408 | fReplicantTray->RememberClockSettings(); |
409 | | settings->alwaysOnTop = (Window()->Feel() & B_FLOATING_ALL_WINDOW_FEEL) |
410 | | != 0; |
| 409 | settings->alwaysOnTop |
| 410 | = (Window()->Feel() & B_FLOATING_ALL_WINDOW_FEEL) != 0; |
411 | 411 | } |
412 | 412 | |
413 | 413 | |
… |
… |
TBarView::UpdateAutoRaise()
|
424 | 424 | void |
425 | 425 | TBarView::UpdatePlacement() |
426 | 426 | { |
427 | | ChangeState(fState, fVertical, fLeft, fTop); |
| 427 | ChangeState(fState, fVertical, fLeft, fTop); |
428 | 428 | } |
429 | 429 | |
430 | 430 | |
… |
… |
TBarView::ChangeState(int32 state, bool vertical, bool left, bool top)
|
455 | 455 | BString* signature = NULL; |
456 | 456 | if (fVertical && Expando() |
457 | 457 | && static_cast<TBarApp*>(be_app)->Settings()->superExpando) { |
458 | | // Get a list of the signatures of expanded apps. Can't use |
| 458 | // Get a list of the signatures of expanded apps. Can't use |
459 | 459 | // team_id because there can be more than one team per application |
460 | 460 | if (fVertical && Expando() && vertical && fExpando) { |
461 | 461 | for (int index = 0; index < fExpando->CountItems(); index++) { |
… |
… |
TBarView::ChangeState(int32 state, bool vertical, bool left, bool top)
|
469 | 469 | } |
470 | 470 | } |
471 | 471 | |
472 | | PlaceApplicationBar(screenFrame); |
473 | | SizeWindow(screenFrame); |
474 | | PositionWindow(screenFrame); |
475 | | Window()->UpdateIfNeeded(); |
| 472 | PlaceApplicationBar(screenFrame); |
| 473 | SizeWindow(screenFrame); |
| 474 | PositionWindow(screenFrame); |
| 475 | Window()->UpdateIfNeeded(); |
476 | 476 | |
477 | 477 | // Re-expand those apps. |
478 | 478 | if (expandedItems.CountItems() > 0) { |
… |
… |
TBarView::ChangeState(int32 state, bool vertical, bool left, bool top)
|
505 | 505 | } |
506 | 506 | |
507 | 507 | |
508 | | // window placement functions |
| 508 | // window placement functions |
509 | 509 | |
510 | 510 | bool |
511 | 511 | TBarView::Vertical() const |
… |
… |
void
|
586 | 586 | TBarView::CacheDragData(const BMessage* incoming) |
587 | 587 | { |
588 | 588 | if (!incoming) |
589 | | return; |
| 589 | return; |
590 | 590 | |
591 | 591 | if (Dragging() && SpringLoadedFolderCompareMessages(incoming, fDragMessage)) |
592 | 592 | return; |
… |
… |
init_tracking_hook(BMenuItem* item,
|
614 | 614 | |
615 | 615 | status_t |
616 | 616 | TBarView::DragStart() |
617 | | { |
| 617 | { |
618 | 618 | if (!Dragging()) |
619 | 619 | return B_OK; |
620 | 620 | |
… |
… |
TBarView::DragStart()
|
634 | 634 | if (item == fLastDragItem) |
635 | 635 | return B_OK; |
636 | 636 | |
637 | | fLastDragItem = item; |
638 | | } |
| 637 | fLastDragItem = item; |
| 638 | } |
639 | 639 | } |
640 | 640 | |
641 | 641 | return B_OK; |
-
diff --git a/src/apps/deskbar/BarWindow.cpp b/src/apps/deskbar/BarWindow.cpp
index 26b02b7..44f6963 100644
a
|
b
|
All rights reserved.
|
58 | 58 | #include <MessagePrivate.h> |
59 | 59 | |
60 | 60 | |
61 | | // This is a very ugly hack to be able to call the private BMenuBar::StartMenuBar() |
62 | | // method from the TBarWindow::ShowBeMenu() method. |
| 61 | // This is a very ugly hack to be able to call the private |
| 62 | // BMenuBar::StartMenuBar() method from the TBarWindow::ShowBeMenu() method. |
63 | 63 | // Don't do this at home -- but why the hell is this method private? |
64 | 64 | #if __MWERKS__ |
65 | 65 | #define BMenuBar_StartMenuBar_Hack StartMenuBar__8BMenuBarFlbbP5BRect |
… |
… |
TBarWindow::ShowBeMenu()
|
312 | 312 | if (menuBar == NULL) |
313 | 313 | return; |
314 | 314 | |
315 | | BMenuBar_StartMenuBar_Hack(menuBar,0,true,true,NULL); |
| 315 | BMenuBar_StartMenuBar_Hack(menuBar, 0, true, true, NULL); |
316 | 316 | } |
317 | 317 | |
318 | 318 | |
… |
… |
TBarWindow::ShowTeamMenu()
|
326 | 326 | if (KeyMenuBar() == NULL) |
327 | 327 | return; |
328 | 328 | |
329 | | BMenuBar_StartMenuBar_Hack(KeyMenuBar(),index,true,true,NULL); |
| 329 | BMenuBar_StartMenuBar_Hack(KeyMenuBar(), index, true, true, NULL); |
330 | 330 | } |
331 | 331 | |
332 | 332 | |
333 | | /** determines the actual location of the window */ |
| 333 | // determines the actual location of the window |
334 | 334 | |
335 | 335 | deskbar_location |
336 | 336 | TBarWindow::DeskbarLocation() const |
… |
… |
TBarWindow::_IsFocusMessage(BMessage* message)
|
632 | 632 | |
633 | 633 | return true; |
634 | 634 | } |
| 635 | |
-
diff --git a/src/apps/deskbar/BeMenu.h b/src/apps/deskbar/BeMenu.h
index 276275d..3862dba 100644
a
|
b
|
All rights reserved.
|
42 | 42 | class TBarView; |
43 | 43 | |
44 | 44 | enum recent_type { |
45 | | kRecentDocuments = 0, |
| 45 | kRecentDocuments = 0, |
46 | 46 | kRecentApplications, |
47 | 47 | kRecentFolders, |
48 | 48 | kRecentAppDocuments |
… |
… |
class TBeMenu : public BNavMenu {
|
118 | 118 | |
119 | 119 | bool AddStandardBeMenuItems(); |
120 | 120 | |
121 | | private: |
122 | | virtual bool StartBuildingItemList(); |
| 121 | private: |
| 122 | virtual bool StartBuildingItemList(); |
123 | 123 | virtual void DoneBuildingItemList(); |
124 | | virtual bool AddNextItem(); |
125 | | virtual void ClearMenuBuildingState(); |
| 124 | virtual bool AddNextItem(); |
| 125 | virtual void ClearMenuBuildingState(); |
126 | 126 | |
127 | | // to keep track of the menu building state |
| 127 | // to keep track of the menu building state |
128 | 128 | State fAddState; |
129 | | TBarView *fBarView; |
| 129 | TBarView* fBarView; |
130 | 130 | }; |
131 | 131 | |
132 | 132 | #endif /* _BE_MENU_H_ */ |
-
diff --git a/src/apps/deskbar/CalendarMenuWindow.cpp b/src/apps/deskbar/CalendarMenuWindow.cpp
index 7cdbb61..c7af6d1 100644
a
|
b
|
using BPrivate::B_WEEK_START_SUNDAY;
|
24 | 24 | using BPrivate::B_WEEK_START_MONDAY; |
25 | 25 | |
26 | 26 | |
27 | | // #pragma mark -- FlatButton |
| 27 | // #pragma mark -- FlatButton |
28 | 28 | |
29 | 29 | |
30 | 30 | class FlatButton : public BButton { |
… |
… |
FlatButton::Draw(BRect updateRect)
|
66 | 66 | } |
67 | 67 | |
68 | 68 | |
69 | | // #pragma mark -- CalendarMenuWindow |
| 69 | // #pragma mark -- CalendarMenuWindow |
70 | 70 | |
71 | 71 | |
72 | 72 | enum { |
-
diff --git a/src/apps/deskbar/CalendarMenuWindow.h b/src/apps/deskbar/CalendarMenuWindow.h
index 57b627e..27d6e1a 100644
a
|
b
|
public:
|
25 | 25 | CalendarMenuWindow(BPoint where); |
26 | 26 | virtual ~CalendarMenuWindow(); |
27 | 27 | |
28 | | virtual void Show(); |
29 | | virtual void WindowActivated(bool active); |
30 | | virtual void MessageReceived(BMessage* message); |
| 28 | virtual void Show(); |
| 29 | virtual void WindowActivated(bool active); |
| 30 | virtual void MessageReceived(BMessage* message); |
31 | 31 | |
32 | 32 | private: |
33 | 33 | void _UpdateUI(const BDate& date); |
-
diff --git a/src/apps/deskbar/DeskBarUtils.cpp b/src/apps/deskbar/DeskBarUtils.cpp
index 151fd60..74f18af 100644
a
|
b
|
AddRefsToBeMenu(const BMessage* m, entry_ref* subdirectory)
|
60 | 60 | int32 count = 0; |
61 | 61 | uint32 type = 0; |
62 | 62 | entry_ref ref; |
63 | | |
| 63 | |
64 | 64 | m->GetInfo("refs", &type, &count); |
65 | 65 | if (count <= 0) |
66 | 66 | return; |
67 | | |
| 67 | |
68 | 68 | BPath path; |
69 | 69 | BSymLink link; |
70 | 70 | BDirectory dir; |
… |
… |
AddRefsToBeMenu(const BMessage* m, entry_ref* subdirectory)
|
72 | 72 | ref = *subdirectory; |
73 | 73 | BEntry entry(&ref); |
74 | 74 | if (entry.Exists()) { |
75 | | // if the ref is a file |
76 | | // get the parent and convert it to a ref |
| 75 | // if the ref is a file get the parent and convert it to a ref |
77 | 76 | if (entry.IsFile()) { |
78 | 77 | BEntry parent; |
79 | 78 | entry.GetParent(&parent); |
… |
… |
AddRefsToBeMenu(const BMessage* m, entry_ref* subdirectory)
|
81 | 80 | } |
82 | 81 | } else |
83 | 82 | return; |
84 | | |
| 83 | |
85 | 84 | dir.SetTo(&ref); |
86 | 85 | } else { |
87 | 86 | if (find_directory(B_USER_DESKBAR_DIRECTORY, &path) == B_OK) |
… |
… |
AddRefsToBeMenu(const BMessage* m, entry_ref* subdirectory)
|
89 | 88 | else |
90 | 89 | return; |
91 | 90 | } |
92 | | |
| 91 | |
93 | 92 | for (long i = 0; i < count; i++) { |
94 | 93 | if (m->FindRef("refs", i, &ref) == B_NO_ERROR) { |
95 | | |
96 | 94 | BEntry entry(&ref); |
97 | 95 | entry.GetPath(&path); |
98 | | |
| 96 | |
99 | 97 | dir.CreateSymLink(ref.name, path.Path(), &link); |
100 | 98 | } |
101 | 99 | } |
-
diff --git a/src/apps/deskbar/ExpandoMenuBar.cpp b/src/apps/deskbar/ExpandoMenuBar.cpp
index 0fd4483..b83560c 100644
a
|
b
|
TExpandoMenuBar::AttachedToWindow()
|
118 | 118 | R_BeLogoIcon); |
119 | 119 | if (logoBitmap != NULL) |
120 | 120 | fBeMenuWidth = logoBitmap->Bounds().Width() + 16; |
121 | | fBeMenuItem = new TBarMenuTitle(fBeMenuWidth, Frame().Height(), |
122 | | logoBitmap, beMenu, true); |
| 121 | fBeMenuItem = new TBarMenuTitle(fBeMenuWidth, Frame().Height(), |
| 122 | logoBitmap, beMenu, true); |
123 | 123 | AddItem(fBeMenuItem); |
124 | 124 | |
125 | 125 | fSeparatorItem = new TTeamMenuItem(kSepItemWidth, height, fVertical); |
… |
… |
TExpandoMenuBar::RemoveTeam(team_id team, bool partial)
|
584 | 584 | RemoveItem(i); |
585 | 585 | |
586 | 586 | if (fVertical) { |
587 | | // instead of resizing the window here and there in the |
588 | | // code the resize method will be centered in one place |
589 | | // thus, the same behavior (good or bad) will be used |
590 | | // whereever window sizing is done |
| 587 | // instead of resizing the window here and there in the |
| 588 | // code the resize method will be centered in one place |
| 589 | // thus, the same behavior (good or bad) will be used |
| 590 | // whereever window sizing is done |
591 | 591 | fBarView->SizeWindow(BScreen(Window()).Frame()); |
592 | 592 | } else |
593 | 593 | CheckItemSizes(-1); |
… |
… |
TExpandoMenuBar::CheckItemSizes(int32 delta)
|
613 | 613 | |
614 | 614 | if (!fBarView->Vertical()) { |
615 | 615 | // in this case there are 2 extra items: |
616 | | // The Be Menu |
617 | | // The little separator item |
| 616 | // - The Be Menu |
| 617 | // - The little separator item |
618 | 618 | fullWidth = fullWidth - (sMinimumWindowWidth * 2) |
619 | 619 | + (fBeMenuWidth + kSepItemWidth); |
620 | 620 | width -= (fBeMenuWidth + kSepItemWidth); |
… |
… |
void
|
713 | 713 | TExpandoMenuBar::CheckForSizeOverrun() |
714 | 714 | { |
715 | 715 | BRect screenFrame = (BScreen(Window())).Frame(); |
716 | | if (fVertical) |
717 | | fIsScrolling = Window()->Frame().bottom > screenFrame.bottom; |
718 | | else |
719 | | fIsScrolling = false; |
| 716 | |
| 717 | fIsScrolling = fVertical ? Window()->Frame().bottom > screenFrame.bottom |
| 718 | : false; |
720 | 719 | } |
721 | 720 | |
722 | 721 | |
… |
… |
TExpandoMenuBar::monitor_team_windows(void* arg)
|
744 | 743 | // Set all WindowMenuItems to require an update. |
745 | 744 | TWindowMenuItem* item = NULL; |
746 | 745 | for (int32 i = 0; i < totalItems; i++) { |
747 | | if (!teamMenu->SubmenuAt(i)){ |
| 746 | if (!teamMenu->SubmenuAt(i)) { |
748 | 747 | item = static_cast<TWindowMenuItem*>(teamMenu->ItemAt(i)); |
749 | 748 | item->SetRequireUpdate(); |
750 | 749 | } |
… |
… |
TExpandoMenuBar::monitor_team_windows(void* arg)
|
814 | 813 | |
815 | 814 | // Remove any remaining items which require an update. |
816 | 815 | for (int32 i = 0; i < totalItems; i++) { |
817 | | if (!teamMenu->SubmenuAt(i)){ |
| 816 | if (!teamMenu->SubmenuAt(i)) { |
818 | 817 | item = static_cast<TWindowMenuItem*>(teamMenu->ItemAt(i)); |
819 | 818 | if (item && item->RequiresUpdate()) { |
820 | 819 | item = static_cast<TWindowMenuItem*> |
-
diff --git a/src/apps/deskbar/ExpandoMenuBar.h b/src/apps/deskbar/ExpandoMenuBar.h
index 928555c..0a2719b 100644
a
|
b
|
All rights reserved.
|
34 | 34 | #ifndef EXPANDO_MENU_BAR_H |
35 | 35 | #define EXPANDO_MENU_BAR_H |
36 | 36 | |
37 | | // application list |
38 | | // top level at window |
39 | | // in expanded mode horizontal and vertical |
| 37 | // application list |
| 38 | // top level at window |
| 39 | // in expanded mode horizontal and vertical |
40 | 40 | |
41 | 41 | |
42 | 42 | #include <MenuBar.h> |
-
diff --git a/src/apps/deskbar/PreferencesWindow.cpp b/src/apps/deskbar/PreferencesWindow.cpp
index aecbba7..bb378f1 100644
a
|
b
|
PreferencesWindow::PreferencesWindow(BRect frame)
|
35 | 35 | // Controls |
36 | 36 | fMenuRecentDocuments = new BCheckBox(B_TRANSLATE("Recent documents:"), |
37 | 37 | new BMessage(kUpdateRecentCounts)); |
38 | | fMenuRecentApplications = new BCheckBox( |
39 | | B_TRANSLATE("Recent applications:"), |
| 38 | fMenuRecentApplications = new BCheckBox(B_TRANSLATE("Recent applications:"), |
40 | 39 | new BMessage(kUpdateRecentCounts)); |
41 | 40 | fMenuRecentFolders = new BCheckBox(B_TRANSLATE("Recent folders:"), |
42 | 41 | new BMessage(kUpdateRecentCounts)); |
… |
… |
PreferencesWindow::PreferencesWindow(BRect frame)
|
52 | 51 | new BMessage(kSortRunningApps)); |
53 | 52 | fAppsSortTrackerFirst = new BCheckBox(B_TRANSLATE("Tracker always first"), |
54 | 53 | new BMessage(kTrackerFirst)); |
55 | | fAppsShowExpanders = new BCheckBox( |
56 | | B_TRANSLATE("Show application expander"), |
| 54 | fAppsShowExpanders = new BCheckBox(B_TRANSLATE("Show application expander"), |
57 | 55 | new BMessage(kSuperExpando)); |
58 | 56 | fAppsExpandNew = new BCheckBox(B_TRANSLATE("Expand new applications"), |
59 | 57 | new BMessage(kExpandNewTeams)); |
… |
… |
PreferencesWindow::PreferencesWindow(BRect frame)
|
83 | 81 | |
84 | 82 | // Values |
85 | 83 | TBarApp* barApp = static_cast<TBarApp*>(be_app); |
86 | | desk_settings* appSettings = barApp->Settings();; |
| 84 | desk_settings* appSettings = barApp->Settings(); |
87 | 85 | |
88 | 86 | fAppsSort->SetValue(appSettings->sortRunningApps); |
89 | 87 | fAppsSortTrackerFirst->SetValue(appSettings->trackerAlwaysFirst); |
-
diff --git a/src/apps/deskbar/PreferencesWindow.h b/src/apps/deskbar/PreferencesWindow.h
index 9bacafd..a45005c 100644
a
|
b
|
public:
|
28 | 28 | PreferencesWindow(BRect frame); |
29 | 29 | ~PreferencesWindow(); |
30 | 30 | |
31 | | virtual void MessageReceived(BMessage* message); |
32 | | virtual void WindowActivated(bool active); |
| 31 | virtual void MessageReceived(BMessage* message); |
| 32 | virtual void WindowActivated(bool active); |
33 | 33 | |
34 | 34 | private: |
35 | 35 | void _UpdateRecentCounts(); |
-
diff --git a/src/apps/deskbar/ResourceSet.cpp b/src/apps/deskbar/ResourceSet.cpp
index 6bbb33b..d1d0dbf 100644
a
|
b
|
namespace TResourcePrivate {
|
70 | 70 | : fDeleteOK(false) |
71 | 71 | { |
72 | 72 | } |
73 | | |
| 73 | |
74 | 74 | virtual ~TypeObject() |
75 | 75 | { |
76 | 76 | if (!fDeleteOK) |
77 | 77 | debugger("deleting object owned by BResourceSet"); |
78 | 78 | } |
79 | | |
| 79 | |
80 | 80 | void Delete() |
81 | 81 | { |
82 | 82 | fDeleteOK = true; |
83 | 83 | } |
84 | | |
| 84 | |
85 | 85 | private: |
86 | 86 | TypeObject(const TypeObject &); |
87 | 87 | TypeObject &operator=(const TypeObject &); |
88 | 88 | bool operator==(const TypeObject &); |
89 | 89 | bool operator!=(const TypeObject &); |
90 | | |
| 90 | |
91 | 91 | bool fDeleteOK; |
92 | 92 | }; |
93 | | |
| 93 | |
94 | 94 | class BitmapTypeItem : public BBitmap, public TypeObject { |
95 | 95 | public: |
96 | 96 | BitmapTypeItem(BRect bounds, uint32 flags, color_space depth, |
… |
… |
namespace TResourcePrivate {
|
99 | 99 | : BBitmap(bounds, flags, depth, bytesPerRow, screenID) |
100 | 100 | { |
101 | 101 | } |
102 | | |
| 102 | |
103 | 103 | BitmapTypeItem(const BBitmap* source, bool accepts_views = false, |
104 | 104 | bool need_contiguous = false) |
105 | 105 | : BBitmap(source, accepts_views, need_contiguous) |
106 | 106 | { |
107 | 107 | } |
108 | | |
| 108 | |
109 | 109 | BitmapTypeItem(BMessage* data) |
110 | 110 | : BBitmap(data) |
111 | 111 | { |
112 | 112 | } |
113 | | |
| 113 | |
114 | 114 | virtual ~BitmapTypeItem() |
115 | 115 | { |
116 | 116 | } |
117 | 117 | }; |
118 | | |
| 118 | |
119 | 119 | class StringBlockTypeItem : public TStringBlock, public TypeObject { |
120 | 120 | public: |
121 | 121 | StringBlockTypeItem(BDataIO* data) |
122 | 122 | : TStringBlock(data) |
123 | 123 | { |
124 | 124 | } |
125 | | |
| 125 | |
126 | 126 | StringBlockTypeItem(const void* block, size_t size) |
127 | 127 | : TStringBlock(block, size) |
128 | 128 | { |
129 | 129 | } |
130 | | |
| 130 | |
131 | 131 | virtual ~StringBlockTypeItem() |
132 | 132 | { |
133 | 133 | } |
134 | 134 | }; |
135 | | |
| 135 | |
136 | 136 | class TypeItem { |
137 | 137 | public: |
138 | 138 | TypeItem(int32 id, const char* name, const void* data, size_t size) |
… |
… |
namespace TResourcePrivate {
|
141 | 141 | fOwnData(false), fSourceIsFile(false) |
142 | 142 | { |
143 | 143 | } |
144 | | |
| 144 | |
145 | 145 | TypeItem(int32 id, const char* name, BFile* file) |
146 | 146 | : fID(id), |
147 | 147 | fName(name), |
… |
… |
namespace TResourcePrivate {
|
162 | 162 | } |
163 | 163 | } |
164 | 164 | } |
165 | | |
| 165 | |
166 | 166 | virtual ~TypeItem() |
167 | 167 | { |
168 | 168 | if (fOwnData) { |
… |
… |
namespace TResourcePrivate {
|
172 | 172 | } |
173 | 173 | SetObject(NULL); |
174 | 174 | } |
175 | | |
| 175 | |
176 | 176 | int32 ID() const |
177 | | { return fID; } |
| 177 | { |
| 178 | return fID; |
| 179 | } |
178 | 180 | |
179 | 181 | const char* Name() const |
180 | | { return fName.String(); } |
| 182 | { |
| 183 | return fName.String(); |
| 184 | } |
181 | 185 | |
182 | 186 | const void* Data() const |
183 | | { return fData; } |
| 187 | { |
| 188 | return fData; |
| 189 | } |
184 | 190 | |
185 | 191 | size_t Size() const |
186 | | { return fSize; } |
187 | | |
| 192 | { |
| 193 | return fSize; |
| 194 | } |
| 195 | |
188 | 196 | void SetObject(TypeObject* object) |
189 | 197 | { |
190 | 198 | if (object == fObject) |
… |
… |
namespace TResourcePrivate {
|
195 | 203 | } |
196 | 204 | |
197 | 205 | TypeObject* Object() const |
198 | | { return fObject; } |
199 | | |
| 206 | { |
| 207 | return fObject; |
| 208 | } |
| 209 | |
200 | 210 | void SetSourceIsFile(bool state) |
201 | | { fSourceIsFile = state; } |
| 211 | { |
| 212 | fSourceIsFile = state; |
| 213 | } |
202 | 214 | |
203 | 215 | bool SourceIsFile() const |
204 | | { return fSourceIsFile; } |
205 | | |
| 216 | { |
| 217 | return fSourceIsFile; |
| 218 | } |
| 219 | |
206 | 220 | private: |
207 | 221 | int32 fID; |
208 | 222 | BString fName; |
… |
… |
namespace TResourcePrivate {
|
225 | 239 | : fType(type) |
226 | 240 | { |
227 | 241 | } |
228 | | |
| 242 | |
229 | 243 | virtual ~TypeList() |
230 | 244 | { |
231 | 245 | fItems.DoForEach(FreeTypeItemFunc); |
232 | 246 | fItems.MakeEmpty(); |
233 | 247 | } |
234 | | |
| 248 | |
235 | 249 | type_code Type() const |
236 | | { return fType; } |
237 | | |
| 250 | { |
| 251 | return fType; |
| 252 | } |
| 253 | |
238 | 254 | TypeItem* FindItemByID(int32 id) |
239 | 255 | { |
240 | 256 | for (int32 i = 0; i < fItems.CountItems(); i++ ) { |
… |
… |
namespace TResourcePrivate {
|
254 | 270 | } |
255 | 271 | return NULL; |
256 | 272 | } |
257 | | |
| 273 | |
258 | 274 | void AddItem(TypeItem* item) |
259 | 275 | { |
260 | 276 | fItems.AddItem(item); |
261 | 277 | } |
262 | | |
| 278 | |
263 | 279 | private: |
264 | 280 | type_code fType; |
265 | 281 | BList fItems; |
266 | 282 | }; |
267 | | |
268 | 283 | } |
269 | 284 | |
270 | 285 | using namespace TResourcePrivate; |
… |
… |
TStringBlock::TStringBlock(BDataIO* data)
|
288 | 303 | } |
289 | 304 | if (amount > 0) |
290 | 305 | pos += amount; |
291 | | |
| 306 | |
292 | 307 | fNumEntries = PreIndex(fStrings, amount); |
293 | 308 | fIndex = (size_t*)malloc(sizeof(size_t) * fNumEntries); |
294 | 309 | MakeIndex(fStrings, amount, fNumEntries, fIndex); |
… |
… |
TStringBlock::TStringBlock(const void* block, size_t size)
|
304 | 319 | { |
305 | 320 | fIndex = (size_t*)const_cast<void*>(block); |
306 | 321 | fStrings = (char*)const_cast<void*>(block); |
307 | | |
| 322 | |
308 | 323 | // Figure out how many entries there are. |
309 | 324 | size_t last_off = 0; |
310 | 325 | while (fIndex[fNumEntries] > last_off && fIndex[fNumEntries] < size ) { |
… |
… |
size_t
|
339 | 354 | TStringBlock::PreIndex(char* strings, ssize_t len) |
340 | 355 | { |
341 | 356 | size_t count = 0; |
342 | | |
343 | 357 | char* orig = strings; |
344 | 358 | char* end = strings + len; |
345 | 359 | bool in_cr = false; |
346 | 360 | bool first = true; |
347 | 361 | bool skipping = false; |
| 362 | |
348 | 363 | while (orig < end) { |
349 | 364 | if (*orig == '\n' || *orig == '\r' || *orig == 0) { |
350 | 365 | if (!in_cr && *orig == '\r') |
… |
… |
TStringBlock::PreIndex(char* strings, ssize_t len)
|
371 | 386 | case '\\': |
372 | 387 | *strings = '\\'; |
373 | 388 | break; |
374 | | |
| 389 | |
375 | 390 | case '\n': |
376 | 391 | *strings = '\n'; |
377 | 392 | break; |
378 | | |
| 393 | |
379 | 394 | case '\r': |
380 | 395 | *strings = '\r'; |
381 | 396 | break; |
382 | | |
| 397 | |
383 | 398 | case '\t': |
384 | 399 | *strings = '\t'; |
385 | 400 | break; |
386 | | |
| 401 | |
387 | 402 | default: |
388 | 403 | *strings = *orig; |
389 | 404 | break; |
… |
… |
TStringBlock::PreIndex(char* strings, ssize_t len)
|
394 | 409 | orig++; |
395 | 410 | strings++; |
396 | 411 | } |
397 | | |
398 | 412 | return count; |
399 | 413 | } |
400 | 414 | |
… |
… |
TStringBlock::MakeIndex(const char* strings, ssize_t len,
|
405 | 419 | { |
406 | 420 | *resultingIndex++ = 0; |
407 | 421 | indexLength--; |
408 | | |
| 422 | |
409 | 423 | ssize_t pos = 0; |
410 | 424 | while (pos < len && indexLength > 0) { |
411 | 425 | if (strings[pos] == 0 ) { |
… |
… |
TResourceSet::AddResources(BResources* RESOURCES_ONLY(resources))
|
475 | 489 | #if USE_RESOURCES |
476 | 490 | if (!resources) |
477 | 491 | return B_BAD_VALUE; |
478 | | |
| 492 | |
479 | 493 | BAutolock lock(&fLock); |
480 | 494 | status_t err = fResources.AddItem(resources) ? B_OK : B_ERROR; |
481 | 495 | if (err != B_OK) |
… |
… |
TResourceSet::AddDirectory(const char* fullPath)
|
499 | 513 | delete path; |
500 | 514 | return err; |
501 | 515 | } |
502 | | |
| 516 | |
503 | 517 | BAutolock lock(&fLock); |
504 | 518 | err = fDirectories.AddItem(path) ? B_OK : B_ERROR; |
505 | 519 | if (err != B_OK) |
… |
… |
TResourceSet::AddEnvDirectory(const char* in, const char* defaultValue)
|
514 | 528 | { |
515 | 529 | BString buf; |
516 | 530 | status_t err = ExpandString(&buf, in); |
517 | | |
| 531 | |
518 | 532 | if (err != B_OK) { |
519 | 533 | if (defaultValue) |
520 | 534 | return AddDirectory(defaultValue); |
521 | 535 | return err; |
522 | 536 | } |
523 | | |
| 537 | |
524 | 538 | return AddDirectory(buf.String()); |
525 | 539 | } |
526 | 540 | |
… |
… |
status_t
|
529 | 543 | TResourceSet::ExpandString(BString* out, const char* in) |
530 | 544 | { |
531 | 545 | const char* start = in; |
| 546 | |
532 | 547 | while (*in) { |
533 | 548 | if (*in == '$') { |
534 | 549 | if (start < in) |
535 | 550 | out->Append(start, (int32)(in - start)); |
536 | | |
| 551 | |
537 | 552 | in++; |
538 | 553 | char variableName[1024]; |
539 | 554 | size_t i = 0; |
… |
… |
TResourceSet::ExpandString(BString* out, const char* in)
|
549 | 564 | while ((isalnum(*in) || *in == '_') && i |
550 | 565 | < sizeof(variableName) - 1) |
551 | 566 | variableName[i++] = *in++; |
552 | | |
| 567 | |
553 | 568 | start = in; |
554 | | |
555 | 569 | variableName[i] = '\0'; |
556 | | |
| 570 | |
557 | 571 | const char* val = getenv(variableName); |
558 | 572 | if (!val) { |
559 | 573 | PRINT(("Error: env var %s not found.\n", &variableName[0])); |
560 | 574 | return B_NAME_NOT_FOUND; |
561 | 575 | } |
562 | | |
| 576 | |
563 | 577 | status_t err = ExpandString(out, val); |
564 | 578 | if (err != B_OK) |
565 | 579 | return err; |
566 | | |
| 580 | |
567 | 581 | } else if (*in == '\\') { |
568 | 582 | if (start < in) |
569 | 583 | out->Append(start, (int32)(in - start)); |
… |
… |
TResourceSet::ExpandString(BString* out, const char* in)
|
576 | 590 | |
577 | 591 | if (start < in) |
578 | 592 | out->Append(start, (int32)(in - start)); |
579 | | |
| 593 | |
580 | 594 | return B_OK; |
581 | 595 | } |
582 | 596 | |
… |
… |
const void*
|
585 | 599 | TResourceSet::FindResource(type_code type, int32 id, size_t* outSize) |
586 | 600 | { |
587 | 601 | TypeItem* item = FindItemID(type, id); |
588 | | |
| 602 | |
589 | 603 | if (outSize) |
590 | 604 | *outSize = item ? item->Size() : 0; |
591 | 605 | |
… |
… |
const void*
|
597 | 611 | TResourceSet::FindResource(type_code type, const char* name, size_t* outSize) |
598 | 612 | { |
599 | 613 | TypeItem* item = FindItemName(type, name); |
600 | | |
| 614 | |
601 | 615 | if (outSize) |
602 | 616 | *outSize = item ? item->Size() : 0; |
603 | 617 | |
… |
… |
TResourceSet::FindStringBlock(type_code type, const char* name)
|
632 | 646 | return ReturnStringBlockItem(FindItemName(type, name)); |
633 | 647 | } |
634 | 648 | |
635 | | |
| 649 | |
636 | 650 | const char* |
637 | 651 | TResourceSet::FindString(type_code type, int32 id, uint32 index) |
638 | 652 | { |
639 | 653 | const TStringBlock* stringBlock = FindStringBlock(type, id); |
| 654 | |
640 | 655 | if (!stringBlock) |
641 | 656 | return NULL; |
642 | 657 | |
… |
… |
const char*
|
648 | 663 | TResourceSet::FindString(type_code type, const char* name, uint32 index) |
649 | 664 | { |
650 | 665 | const TStringBlock* stringBlock = FindStringBlock(type, name); |
| 666 | |
651 | 667 | if (!stringBlock) |
652 | 668 | return NULL; |
653 | 669 | |
654 | 670 | return stringBlock->String(index); |
655 | 671 | } |
656 | 672 | |
657 | | |
| 673 | |
658 | 674 | TypeList* |
659 | 675 | TResourceSet::FindTypeList(type_code type) |
660 | 676 | { |
661 | 677 | BAutolock lock(&fLock); |
662 | | |
| 678 | |
663 | 679 | int32 count = fTypes.CountItems(); |
664 | 680 | for (int32 i = 0; i < count; i++ ) { |
665 | 681 | TypeList* list = (TypeList*)fTypes.ItemAt(i); |
666 | 682 | if (list && list->Type() == type) |
667 | 683 | return list; |
668 | 684 | } |
669 | | |
| 685 | |
670 | 686 | return NULL; |
671 | 687 | } |
672 | 688 | |
… |
… |
TResourceSet::FindItemID(type_code type, int32 id)
|
676 | 692 | { |
677 | 693 | TypeList* list = FindTypeList(type); |
678 | 694 | TypeItem* item = NULL; |
679 | | |
680 | | if (list) item = list->FindItemByID(id); |
681 | | |
| 695 | |
| 696 | if (list) |
| 697 | item = list->FindItemByID(id); |
| 698 | |
682 | 699 | if (!item) |
683 | 700 | item = LoadResource(type, id, 0, &list); |
684 | | |
| 701 | |
685 | 702 | return item; |
686 | 703 | } |
687 | 704 | |
… |
… |
TResourceSet::FindItemName(type_code type, const char* name)
|
691 | 708 | { |
692 | 709 | TypeList* list = FindTypeList(type); |
693 | 710 | TypeItem* item = NULL; |
694 | | |
| 711 | |
695 | 712 | if (list) |
696 | 713 | item = list->FindItemByName(name); |
697 | | |
| 714 | |
698 | 715 | if (!item) |
699 | 716 | item = LoadResource(type, -1, name, &list); |
700 | | |
| 717 | |
701 | 718 | return item; |
702 | 719 | } |
703 | 720 | |
… |
… |
TResourceSet::LoadResource(type_code type, int32 id, const char* name,
|
707 | 724 | TypeList** inOutList) |
708 | 725 | { |
709 | 726 | TypeItem* item = NULL; |
710 | | |
| 727 | |
711 | 728 | if (name) { |
712 | 729 | BEntry entry; |
713 | | |
| 730 | |
714 | 731 | // If a named resource, first look in directories. |
715 | 732 | fLock.Lock(); |
716 | 733 | int32 count = fDirectories.CountItems(); |
… |
… |
TResourceSet::LoadResource(type_code type, int32 id, const char* name,
|
731 | 748 | } |
732 | 749 | fLock.Unlock(); |
733 | 750 | } |
734 | | |
| 751 | |
735 | 752 | #if USE_RESOURCES |
736 | 753 | if (!item) { |
737 | 754 | // Look through resource objects for data. |
… |
… |
TResourceSet::LoadResource(type_code type, int32 id, const char* name,
|
746 | 763 | data = resource->LoadResource(type, id, &size); |
747 | 764 | else if (name != NULL) |
748 | 765 | data = resource->LoadResource(type, name, &size); |
749 | | |
| 766 | |
750 | 767 | if (data && size) { |
751 | 768 | item = new TypeItem(id, name, data, size); |
752 | 769 | item->SetSourceIsFile(false); |
… |
… |
TResourceSet::ReturnBitmapItem(type_code, TypeItem* from)
|
803 | 820 | // Try to read as an archived bitmap. |
804 | 821 | stream.Seek(0, SEEK_SET); |
805 | 822 | BMessage archive; |
806 | | if (archive.Unflatten(&stream) == B_OK ) { |
| 823 | if (archive.Unflatten(&stream) == B_OK) { |
807 | 824 | bitmap = new BitmapTypeItem(&archive); |
808 | 825 | if (bitmap && bitmap->InitCheck() != B_OK) { |
809 | | bitmap->Delete(); // allows us to delete this bitmap... |
| 826 | // allows us to delete this bitmap... |
| 827 | bitmap->Delete(); |
810 | 828 | delete bitmap; |
811 | 829 | bitmap = NULL; |
812 | 830 | } |
… |
… |
TResourceSet::ReturnBitmapItem(type_code, TypeItem* from)
|
815 | 833 | if (bitmap) { |
816 | 834 | BAutolock lock(&fLock); |
817 | 835 | if (from->Object() != NULL) { |
818 | | // Whoops! Someone snuck in under us. |
| 836 | // Whoops! Someone snuck in under us. |
819 | 837 | bitmap->Delete(); |
820 | 838 | delete bitmap; |
821 | 839 | bitmap = dynamic_cast<BitmapTypeItem*>(from->Object()); |
822 | | } else |
| 840 | } else |
823 | 841 | from->SetObject(bitmap); |
824 | 842 | } |
825 | 843 | |
… |
… |
TResourceSet::ReturnStringBlockItem(TypeItem* from)
|
832 | 850 | { |
833 | 851 | if (!from) |
834 | 852 | return NULL; |
835 | | |
| 853 | |
836 | 854 | TypeObject* obj = from->Object(); |
837 | 855 | StringBlockTypeItem* stringBlock = dynamic_cast<StringBlockTypeItem*>(obj); |
838 | 856 | if (stringBlock) |
839 | 857 | return stringBlock; |
840 | | |
| 858 | |
841 | 859 | // Can't change an existing object. |
842 | 860 | if (obj) |
843 | 861 | return NULL; |
844 | | |
| 862 | |
845 | 863 | // Don't have a string block in the item -- we'll create one. |
846 | 864 | if (from->SourceIsFile() ) { |
847 | 865 | BMemoryIO stream(from->Data(), from->Size()); |
848 | 866 | stringBlock = new StringBlockTypeItem(&stream); |
849 | 867 | } else |
850 | 868 | stringBlock = new StringBlockTypeItem(from->Data(), from->Size()); |
851 | | |
| 869 | |
852 | 870 | if (stringBlock) { |
853 | 871 | BAutolock lock(&fLock); |
854 | 872 | if (from->Object() != NULL) { |
855 | | // Whoops! Someone snuck in under us. |
| 873 | // Whoops! Someone snuck in under us. |
856 | 874 | delete stringBlock; |
857 | 875 | stringBlock = dynamic_cast<StringBlockTypeItem*>(from->Object()); |
858 | 876 | } else |
859 | 877 | from->SetObject(stringBlock); |
860 | 878 | } |
861 | | |
| 879 | |
862 | 880 | return stringBlock; |
863 | 881 | } |
864 | 882 | |
… |
… |
TResourceSet::ReturnStringBlockItem(TypeItem* from)
|
867 | 885 | |
868 | 886 | |
869 | 887 | namespace TResourcePrivate { |
870 | | |
871 | 888 | TResourceSet* gResources = NULL; |
872 | 889 | BLocker gResourceLocker; |
873 | | |
874 | 890 | } |
875 | 891 | |
876 | 892 | |
… |
… |
AppResSet()
|
880 | 896 | // If already have it, return immediately. |
881 | 897 | if (gResources) |
882 | 898 | return gResources; |
883 | | |
| 899 | |
884 | 900 | // Don't have 'em, lock access to make 'em. |
885 | 901 | if (!gResourceLocker.Lock()) |
886 | 902 | return NULL; |
… |
… |
AppResSet()
|
889 | 905 | gResourceLocker.Unlock(); |
890 | 906 | return gResources; |
891 | 907 | } |
892 | | |
| 908 | |
893 | 909 | // Make 'em. |
894 | 910 | gResources = new TResourceSet; |
895 | 911 | gResources->AddResources(BApplication::AppResources()); |
-
diff --git a/src/apps/deskbar/ResourceSet.h b/src/apps/deskbar/ResourceSet.h
index 5975304..919d3d6 100644
a
|
b
|
public:
|
57 | 57 | TStringBlock(BDataIO* data); |
58 | 58 | TStringBlock(const void* block, size_t size); |
59 | 59 | virtual ~TStringBlock(); |
60 | | |
| 60 | |
61 | 61 | const char* String(size_t index) const; |
62 | 62 | |
63 | 63 | private: |
64 | 64 | size_t PreIndex(char* strings, ssize_t len); |
65 | | void MakeIndex(const char* strings, ssize_t len, |
66 | | size_t indexLen, size_t* outIndex); |
67 | | |
| 65 | void MakeIndex(const char* strings, ssize_t len, size_t indexLen, |
| 66 | size_t* outIndex); |
| 67 | |
68 | 68 | size_t fNumEntries; |
69 | 69 | size_t* fIndex; |
70 | 70 | char* fStrings; |
… |
… |
public:
|
81 | 81 | status_t AddEnvDirectory(const char* envPath, |
82 | 82 | const char* defaultValue = NULL); |
83 | 83 | |
84 | | const void* FindResource(type_code type, int32 id, |
85 | | size_t* outSize); |
86 | | const void* FindResource(type_code type, const char* name, |
87 | | size_t* outSize); |
88 | | |
| 84 | const void* FindResource(type_code type, int32 id, size_t* outSize); |
| 85 | const void* FindResource(type_code type, const char* name, size_t* outSize); |
| 86 | |
89 | 87 | const BBitmap* FindBitmap(type_code type, int32 id); |
90 | 88 | const BBitmap* FindBitmap(type_code type, const char* name); |
91 | | |
| 89 | |
92 | 90 | const TStringBlock* FindStringBlock(type_code type, int32 id); |
93 | 91 | const TStringBlock* FindStringBlock(type_code type, const char* name); |
94 | | |
| 92 | |
95 | 93 | const char* FindString(type_code type, int32 id, uint32 index); |
96 | 94 | const char* FindString(type_code type, const char* name, uint32 index); |
97 | | |
| 95 | |
98 | 96 | private: |
99 | 97 | status_t ExpandString(BString* out, const char* in); |
100 | 98 | TypeList* FindTypeList(type_code type); |
101 | | |
| 99 | |
102 | 100 | TypeItem* FindItemID(type_code type, int32 id); |
103 | 101 | TypeItem* FindItemName(type_code type, const char* name); |
104 | | |
| 102 | |
105 | 103 | TypeItem* LoadResource(type_code type, int32 id, const char* name, |
106 | 104 | TypeList** inoutList = NULL); |
107 | | |
| 105 | |
108 | 106 | BBitmap* ReturnBitmapItem(type_code type, TypeItem* from); |
109 | 107 | TStringBlock* ReturnStringBlockItem(TypeItem* from); |
110 | | |
| 108 | |
111 | 109 | BLocker fLock; // access control. |
112 | 110 | BList fResources; // containing BResources objects. |
113 | 111 | BList fDirectories; // containing BPath objects. |
-
diff --git a/src/apps/deskbar/StatusView.cpp b/src/apps/deskbar/StatusView.cpp
index a504101..e067a77 100644
a
|
b
|
All rights reserved.
|
74 | 74 | using std::max; |
75 | 75 | |
76 | 76 | #ifdef DB_ADDONS |
77 | | // Add-on support |
| 77 | // Add-on support |
78 | 78 | // |
79 | | // Item - internal item list (node, eref, etc) |
80 | | // Icon - physical replicant handed to the DeskbarClass class |
81 | | // AddOn - attribute based add-on |
| 79 | // Item - internal item list (node, eref, etc) |
| 80 | // Icon - physical replicant handed to the DeskbarClass class |
| 81 | // AddOn - attribute based add-on |
82 | 82 | |
83 | 83 | const char* const kInstantiateItemCFunctionName = "instantiate_deskbar_item"; |
84 | 84 | const char* const kInstantiateEntryCFunctionName = "instantiate_deskbar_entry"; |
… |
… |
TReplicantTray::DealWithClock(bool showClock)
|
240 | 240 | } |
241 | 241 | |
242 | 242 | |
243 | | /*! |
244 | | Width is set to a minimum of kMinimumReplicantCount by kMaxReplicantWidth |
| 243 | /*! Width is set to a minimum of kMinimumReplicantCount by kMaxReplicantWidth |
245 | 244 | if not in multirowmode and greater than kMinimumReplicantCount |
246 | 245 | the width should be calculated based on the actual |
247 | 246 | replicant widths |
… |
… |
TReplicantTray::GetPreferredSize(float* preferredWidth, float* preferredHeight)
|
255 | 254 | if (fShelf->CountReplicants() > 0) |
256 | 255 | height = fRightBottomReplicant.bottom; |
257 | 256 | |
258 | | // the height will be uniform for the number of rows |
259 | | // necessary to show all the reps + any gutters |
260 | | // necessary for spacing |
| 257 | // the height will be uniform for the number of rows necessary to show |
| 258 | // all the reps + any gutters necessary for spacing |
261 | 259 | int32 rowCount = (int32)(height / kMaxReplicantHeight); |
262 | 260 | height = kGutter + (rowCount * kMaxReplicantHeight) |
263 | 261 | + ((rowCount - 1) * kIconGap) + kGutter; |
264 | 262 | height = max(kMinimumTrayHeight, height); |
265 | 263 | width = fMinimumTrayWidth; |
266 | 264 | } else { |
267 | | // if last replicant overruns clock then |
268 | | // resize to accomodate |
| 265 | // if last replicant overruns clock then resize to accomodate |
269 | 266 | if (fShelf->CountReplicants() > 0) { |
270 | 267 | if (fBarView->ShowingClock() |
271 | 268 | && fRightBottomReplicant.right + 6 >= fClock->Frame().left) { |
… |
… |
TReplicantTray::GetPreferredSize(float* preferredWidth, float* preferredHeight)
|
274 | 271 | } else |
275 | 272 | width = fRightBottomReplicant.right + 3; |
276 | 273 | } |
| 274 | |
277 | 275 | // this view has a fixed minimum width |
278 | 276 | width = max(fMinimumTrayWidth, width); |
279 | 277 | } |
280 | 278 | |
281 | 279 | *preferredWidth = width; |
282 | | // add 2 for the border |
| 280 | // add 1 for the border |
283 | 281 | *preferredHeight = height + 1; |
284 | 282 | } |
285 | 283 | |
… |
… |
TReplicantTray::ShowReplicantMenu(BPoint point)
|
350 | 348 | BPopUpMenu* menu = new BPopUpMenu("", false, false); |
351 | 349 | menu->SetFont(be_plain_font); |
352 | 350 | |
353 | | // If the clock is visible, show the extended menu |
354 | | // otheriwse, show "Show Time". |
| 351 | // If clock is visible show the extended menu, otherwise show "Show Time" |
355 | 352 | |
356 | 353 | if (fBarView->ShowingClock()) |
357 | 354 | fClock->ShowClockOptions(ConvertToScreen(point)); |
… |
… |
TReplicantTray::MouseDown(BPoint where)
|
375 | 372 | DumpList(fItemList); |
376 | 373 | #endif |
377 | 374 | |
378 | | uint32 buttons; |
| 375 | uint32 buttons; |
379 | 376 | |
380 | 377 | Window()->CurrentMessage()->FindInt32("buttons", (int32*)&buttons); |
381 | 378 | if (buttons == B_SECONDARY_MOUSE_BUTTON) { |
… |
… |
TReplicantTray::InitAddOnSupport()
|
412 | 409 | { |
413 | 410 | // list to maintain refs to each rep added/deleted |
414 | 411 | fItemList = new BList(); |
415 | | |
416 | 412 | bool haveKey = false; |
417 | | BPath path; |
| 413 | BPath path; |
| 414 | |
418 | 415 | if (find_directory(B_USER_SETTINGS_DIRECTORY, &path, true) == B_OK) { |
419 | 416 | path.Append(kDeskbarSecurityCodeFile); |
420 | 417 | |
421 | 418 | BFile file(path.Path(),B_READ_ONLY); |
422 | 419 | if (file.InitCheck() == B_OK |
423 | | && file.Read(&fDeskbarSecurityCode, sizeof(fDeskbarSecurityCode)) |
| 420 | && file.Read(&fDeskbarSecurityCode, sizeof(fDeskbarSecurityCode)) |
424 | 421 | == sizeof(fDeskbarSecurityCode)) |
425 | 422 | haveKey = true; |
426 | 423 | } |
… |
… |
TReplicantTray::InitAddOnSupport()
|
443 | 440 | } |
444 | 441 | } |
445 | 442 | |
446 | | // for each volume currently mounted |
447 | | // index the volume with our indices |
| 443 | // for each volume currently mounted index the volume with our indices |
448 | 444 | BVolumeRoster roster; |
449 | 445 | BVolume volume; |
450 | 446 | while (roster.GetNextVolume(&volume) == B_OK) { |
… |
… |
TReplicantTray::RunAddOnQuery(BVolume* volume, const char* predicate)
|
488 | 484 | || fs_stat_index(volume->Device(), kStatusPredicate, &info) != 0) |
489 | 485 | return; |
490 | 486 | |
491 | | // run a new query on a specific volume |
492 | | // make it live |
| 487 | // run a new query on a specific volume and make it live |
493 | 488 | BQuery query; |
494 | 489 | query.SetVolume(volume); |
495 | 490 | query.SetPredicate(predicate); |
… |
… |
TReplicantTray::NodeExists(node_ref& nodeRef)
|
557 | 552 | } |
558 | 553 | |
559 | 554 | |
560 | | /*! This handles B_NODE_MONITOR & B_QUERY_UPDATE messages received |
| 555 | /*! This handles B_NODE_MONITOR & B_QUERY_UPDATE messages received |
561 | 556 | for the registered add-ons. |
562 | 557 | */ |
563 | 558 | void |
… |
… |
TReplicantTray::HandleEntryUpdate(BMessage* message)
|
697 | 692 | } |
698 | 693 | |
699 | 694 | |
700 | | /*! |
701 | | The add-ons must support the exported C function API |
| 695 | /*! The add-ons must support the exported C function API |
702 | 696 | if they do, they will be loaded and added to deskbar |
703 | 697 | primary function is the Instantiate function |
704 | 698 | */ |
… |
… |
TReplicantTray::IconCount() const
|
989 | 983 | } |
990 | 984 | |
991 | 985 | |
992 | | /*! Message must contain an archivable view for later rehydration. |
| 986 | /*! Message must contain an archivable view for later rehydration. |
993 | 987 | This function takes over ownership of the provided message on success |
994 | 988 | only. |
995 | 989 | Returns the current replicant ID. |
… |
… |
TReplicantTray::AddIcon(BMessage* archive, int32* id, const entry_ref* addOn)
|
1003 | 997 | // find entry_ref |
1004 | 998 | |
1005 | 999 | entry_ref ref; |
1006 | | if (addOn) { |
1007 | | // Use it if we got it |
1008 | | ref = *addOn; |
1009 | | } else { |
| 1000 | if (addOn) |
| 1001 | ref = *addOn; // Use it if we got it |
| 1002 | else { |
1010 | 1003 | const char* signature; |
| 1004 | |
1011 | 1005 | status_t status = archive->FindString("add_on", &signature); |
1012 | 1006 | if (status == B_OK) { |
1013 | 1007 | BRoster roster; |
… |
… |
TReplicantTray::AddIcon(BMessage* archive, int32* id, const entry_ref* addOn)
|
1028 | 1022 | return status; |
1029 | 1023 | |
1030 | 1024 | BEntry entry(&ref, true); |
1031 | | // ToDo: this resolves an eventual link for the item |
1032 | | // being added - this is okay for now, but in multi-user |
1033 | | // environments, one might want to have links that |
1034 | | // carry the be:deskbar_item_status attribute |
| 1025 | // TODO: this resolves an eventual link for the item being added - this is |
| 1026 | // okay for now, but in multi-user environments, one might want to have |
| 1027 | // links that carry the be:deskbar_item_status attribute |
1035 | 1028 | status = entry.InitCheck(); |
1036 | 1029 | if (status != B_OK) |
1037 | 1030 | return status; |
… |
… |
TReplicantTray::AddIcon(BMessage* archive, int32* id, const entry_ref* addOn)
|
1041 | 1034 | archive->what = 0; |
1042 | 1035 | |
1043 | 1036 | BRect originalBounds = archive->FindRect("_frame"); |
1044 | | // this is a work-around for buggy replicants that change their |
1045 | | // size in AttachedToWindow() (such as "SVM") |
| 1037 | // this is a work-around for buggy replicants that change their size in |
| 1038 | // AttachedToWindow() (such as "SVM") |
1046 | 1039 | |
1047 | | // !! check for name collisions? |
| 1040 | // TODO: check for name collisions? |
1048 | 1041 | status = fShelf->AddReplicant(archive, BPoint(1, 1)); |
1049 | 1042 | if (status != B_OK) |
1050 | 1043 | return status; |
… |
… |
TReplicantTray::AddIcon(BMessage* archive, int32* id, const entry_ref* addOn)
|
1070 | 1063 | // add the item to the add-on list |
1071 | 1064 | |
1072 | 1065 | AddItem(*id, nodeRef, entry, addOn != NULL); |
1073 | | return B_OK; |
| 1066 | return B_OK; |
1074 | 1067 | } |
1075 | 1068 | |
1076 | 1069 | |
… |
… |
TReplicantTray::RealReplicantAdjustment(int32 startIndex)
|
1129 | 1122 | float width, height; |
1130 | 1123 | GetPreferredSize(&width, &height); |
1131 | 1124 | if (oldWidth != width || oldHeight != height) { |
1132 | | // resize view to accomodate the replicants |
1133 | | // redraw as necessary |
| 1125 | // resize view to accomodate the replicants, redraw as necessary |
1134 | 1126 | AdjustPlacement(); |
1135 | 1127 | } |
1136 | 1128 | } |
… |
… |
TReplicantTray::ViewAt(int32* index, int32* id, int32 target, bool byIndex)
|
1165 | 1157 | } |
1166 | 1158 | } |
1167 | 1159 | } |
1168 | | |
1169 | 1160 | return NULL; |
1170 | 1161 | } |
1171 | 1162 | |
… |
… |
TReplicantTray::ViewAt(int32* index, int32* id, const char* name)
|
1189 | 1180 | return view; |
1190 | 1181 | } |
1191 | 1182 | } |
1192 | | |
1193 | 1183 | return NULL; |
1194 | 1184 | } |
1195 | 1185 | |
… |
… |
TReplicantTray::SetMultiRow(bool state)
|
1353 | 1343 | // #pragma mark - |
1354 | 1344 | |
1355 | 1345 | |
1356 | | /*! Draggable region that is asynchronous so that dragging does not block |
| 1346 | /*! Draggable region that is asynchronous so that dragging does not block |
1357 | 1347 | other activities. |
1358 | 1348 | */ |
1359 | 1349 | TDragRegion::TDragRegion(TBarView* parent, BView* child) |
… |
… |
TDragRegion::MouseDown(BPoint thePoint)
|
1544 | 1534 | BRect dragRegion(DragRegion()); |
1545 | 1535 | |
1546 | 1536 | dragRegion.InsetBy(-2.0f, -2.0f); |
1547 | | // DragRegion() is designed for drawing, not clicking |
| 1537 | // DragRegion() is designed for drawing, not clicking |
1548 | 1538 | |
1549 | 1539 | if (!dragRegion.Contains(thePoint)) |
1550 | 1540 | return; |
… |
… |
TDragRegion::SwitchModeForRect(BPoint mouse, BRect rect,
|
1584 | 1574 | bool newVertical, bool newLeft, bool newTop, int32 newState) |
1585 | 1575 | { |
1586 | 1576 | if (!rect.Contains(mouse)) |
1587 | | // not our rect |
1588 | | return false; |
| 1577 | return false; // not our rect |
1589 | 1578 | |
1590 | | if (newVertical == fBarView->Vertical() |
1591 | | && newLeft == fBarView->Left() |
1592 | | && newTop == fBarView->Top() |
1593 | | && newState == fBarView->State()) |
1594 | | // already in the correct mode |
1595 | | return true; |
| 1579 | if (newVertical == fBarView->Vertical() && newLeft == fBarView->Left() |
| 1580 | && newTop == fBarView->Top() && newState == fBarView->State()) |
| 1581 | return true; // already in the correct mode |
1596 | 1582 | |
1597 | 1583 | fBarView->ChangeState(newState, newVertical, newLeft, newTop); |
1598 | 1584 | return true; |
-
diff --git a/src/apps/deskbar/StatusView.h b/src/apps/deskbar/StatusView.h
index aeef04b..057d06c 100644
a
|
b
|
const int32 kIconGap = 2;
|
51 | 51 | const int32 kGutter = 1; |
52 | 52 | const int32 kDragRegionWidth = 6; |
53 | 53 | |
54 | | // 1 pixel left gutter |
55 | | // space for replicant tray (6 items) |
56 | | // 6 pixel drag region |
57 | | const float kMinimumTrayWidth = kIconGap |
58 | | + (kMinimumReplicantCount * kIconGap) |
59 | | + (kMinimumReplicantCount * kMaxReplicantWidth) + kGutter; |
| 54 | // 1 pixel left gutter |
| 55 | // space for replicant tray (6 items) |
| 56 | // 6 pixel drag region |
| 57 | const float kMinimumTrayWidth = kIconGap + (kMinimumReplicantCount * kIconGap) |
| 58 | + (kMinimumReplicantCount * kMaxReplicantWidth) + kGutter; |
60 | 59 | const float kMinimumTrayHeight = kGutter + kMaxReplicantHeight + kGutter; |
61 | 60 | |
62 | 61 | extern float sMinimumWindowWidth; |
-
diff --git a/src/apps/deskbar/StatusViewShelf.cpp b/src/apps/deskbar/StatusViewShelf.cpp
index c879036..0212015 100644
a
|
b
|
TReplicantShelf::MessageReceived(BMessage* message)
|
77 | 77 | while (message->FindMessage("specifiers", index++, &repspec) |
78 | 78 | == B_OK) { |
79 | 79 | const char* str; |
| 80 | |
80 | 81 | if (repspec.FindString("property", &str) == B_OK) { |
81 | 82 | if (strcmp(str, "Replicant") == 0) { |
82 | 83 | int32 index; |
-
diff --git a/src/apps/deskbar/StatusViewShelf.h b/src/apps/deskbar/StatusViewShelf.h
index 4db46fb..d7e3c92 100644
a
|
b
|
public:
|
50 | 50 | |
51 | 51 | protected: |
52 | 52 | bool CanAcceptReplicantView(BRect, BView*, BMessage*) const; |
53 | | BPoint AdjustReplicantBy(BRect, BMessage*) const; |
| 53 | BPoint AdjustReplicantBy(BRect, BMessage*) const; |
54 | 54 | void ReplicantDeleted(int32, const BMessage*, const BView*); |
55 | 55 | |
56 | 56 | private: |
-
diff --git a/src/apps/deskbar/Switcher.cpp b/src/apps/deskbar/Switcher.cpp
index 86df52d..3b43252 100644
a
|
b
|
All rights reserved.
|
56 | 56 | |
57 | 57 | |
58 | 58 | #define _ALLOW_STICKY_ 0 |
59 | | // allows you to press 's' to keep the switcher window on screen |
| 59 | // allows you to press 's' to keep the switcher window on screen |
60 | 60 | |
61 | 61 | |
62 | 62 | static const color_space kIconFormat = B_RGBA32; |
… |
… |
public:
|
99 | 99 | TSwitchManager* manager); |
100 | 100 | virtual ~TSwitcherWindow(); |
101 | 101 | |
102 | | virtual bool QuitRequested(); |
103 | | virtual void MessageReceived(BMessage* message); |
104 | | virtual void Show(); |
105 | | virtual void Hide(); |
106 | | virtual void WindowActivated(bool state); |
| 102 | virtual bool QuitRequested(); |
| 103 | virtual void MessageReceived(BMessage* message); |
| 104 | virtual void Show(); |
| 105 | virtual void Hide(); |
| 106 | virtual void WindowActivated(bool state); |
107 | 107 | |
108 | 108 | void DoKey(uint32 key, uint32 modifiers); |
109 | 109 | TIconView* IconView(); |
… |
… |
public:
|
133 | 133 | void UpdateGroup(int32 groupIndex, int32 windowIndex); |
134 | 134 | |
135 | 135 | virtual void AttachedToWindow(); |
136 | | virtual void Draw(BRect update); |
137 | | virtual void Pulse(); |
138 | | virtual void GetPreferredSize(float* w, float* h); |
| 136 | virtual void Draw(BRect update); |
| 137 | virtual void Pulse(); |
| 138 | virtual void GetPreferredSize(float* w, float* h); |
139 | 139 | void ScrollTo(float x, float y) |
140 | 140 | { ScrollTo(BPoint(x,y)); } |
141 | | virtual void ScrollTo(BPoint where); |
| 141 | virtual void ScrollTo(BPoint where); |
142 | 142 | |
143 | 143 | void ShowIndex(int32 windex); |
144 | 144 | BRect FrameOf(int32 index) const; |
… |
… |
public:
|
161 | 161 | void Hiding(); |
162 | 162 | |
163 | 163 | virtual void KeyDown(const char* bytes, int32 numBytes); |
164 | | virtual void Pulse(); |
165 | | virtual void MouseDown(BPoint point); |
166 | | virtual void Draw(BRect updateRect); |
| 164 | virtual void Pulse(); |
| 165 | virtual void MouseDown(BPoint point); |
| 166 | virtual void Draw(BRect updateRect); |
167 | 167 | |
168 | 168 | void ScrollTo(float x, float y) |
169 | 169 | { ScrollTo(BPoint(x,y)); } |
170 | | virtual void ScrollTo(BPoint where); |
| 170 | virtual void ScrollTo(BPoint where); |
171 | 171 | void Update(int32 previous, int32 current, |
172 | 172 | int32 previousSlot, int32 currentSlot, |
173 | 173 | bool forward); |
… |
… |
public:
|
199 | 199 | |
200 | 200 | virtual void Draw(BRect update); |
201 | 201 | virtual void AllAttached(); |
202 | | virtual void DrawIconScrollers(bool force); |
203 | | virtual void DrawWindowScrollers(bool force); |
204 | | virtual void MouseDown(BPoint where); |
| 202 | virtual void DrawIconScrollers(bool force); |
| 203 | virtual void DrawWindowScrollers(bool force); |
| 204 | virtual void MouseDown(BPoint where); |
205 | 205 | |
206 | 206 | private: |
207 | 207 | TSwitchManager* fManager; |
… |
… |
LowBitIndex(uint32 value)
|
252 | 252 | inline bool |
253 | 253 | IsVisibleInCurrentWorkspace(const window_info* windowInfo) |
254 | 254 | { |
255 | | /* |
256 | | The window list is always ordered from the top |
257 | | front visible window (the first on the list), going down through all |
258 | | the other visible windows, then all the hidden or non workspace |
259 | | visible window at the end. |
260 | | |
261 | | layer > 2 : normal visible window. |
262 | | layer == 2 : reserved for the desktop window (visible also). |
263 | | layer < 2 : hidden (0) and non workspace visible window (1) |
264 | | */ |
| 255 | // The window list is always ordered from the top |
| 256 | // front visible window (the first on the list), going down through all |
| 257 | // the other visible windows, then all the hidden or non workspace |
| 258 | // visible window at the end. |
| 259 | // |
| 260 | // layer > 2 : normal visible window. |
| 261 | // layer == 2 : reserved for the desktop window (visible also). |
| 262 | // layer < 2 : hidden (0) and non workspace visible window (1) |
265 | 263 | return windowInfo->layer > 2; |
266 | 264 | } |
267 | 265 | |
… |
… |
IsWindowOK(const window_info* windowInfo)
|
284 | 282 | // show_hide >= 1 means that the window is hidden. |
285 | 283 | // |
286 | 284 | // If the window is both minimized and hidden, then you get : |
287 | | // TWindow->is_mini = false; |
288 | | // TWindow->was_mini = true; |
289 | | // TWindow->show_hide >= 1; |
| 285 | // TWindow->is_mini = false; |
| 286 | // TWindow->was_mini = true; |
| 287 | // TWindow->show_hide >= 1; |
290 | 288 | |
291 | 289 | if (windowInfo->feel != _STD_W_TYPE_) |
292 | 290 | return false; |
… |
… |
SmartStrcmp(const char* s1, const char* s2)
|
333 | 331 | continue; |
334 | 332 | } |
335 | 333 | if (*s1 != *s2) |
336 | | return 1; // they differ |
| 334 | return 1; // they differ |
337 | 335 | s1++; |
338 | 336 | s2++; |
339 | 337 | } |
340 | 338 | |
341 | 339 | // if one of the strings ended before the other |
342 | | // ??? could process trailing spaces & underscores! |
| 340 | // TODO: could process trailing spaces and underscores |
343 | 341 | if (*s1) |
344 | 342 | return 1; |
345 | 343 | if (*s2) |
… |
… |
TSwitchManager::TSwitchManager(BPoint point)
|
448 | 446 | TBarApp::Subscribe(BMessenger(this), &tmpList); |
449 | 447 | |
450 | 448 | for (int32 i = 0; ; i++) { |
451 | | BarTeamInfo *barTeamInfo = (BarTeamInfo *)tmpList.ItemAt(i); |
| 449 | BarTeamInfo* barTeamInfo = (BarTeamInfo*)tmpList.ItemAt(i); |
452 | 450 | if (!barTeamInfo) |
453 | 451 | break; |
454 | 452 | |
… |
… |
TSwitchManager::MessageReceived(BMessage* message)
|
485 | 483 | int i = 0; |
486 | 484 | TTeamGroup* tinfo; |
487 | 485 | message->FindInt32("team", &teamID); |
| 486 | |
488 | 487 | while ((tinfo = (TTeamGroup*)fGroupList.ItemAt(i)) != NULL) { |
489 | 488 | if (tinfo->TeamList()->HasItem((void*)teamID)) { |
490 | 489 | fGroupList.RemoveItem(i); |
… |
… |
TSwitchManager::MessageReceived(BMessage* message)
|
519 | 518 | delete teams; |
520 | 519 | break; |
521 | 520 | } |
| 521 | |
522 | 522 | delete smallIcon; |
| 523 | |
523 | 524 | if (message->FindString("sig", &signature) != B_OK) { |
524 | 525 | delete teams; |
525 | 526 | break; |
526 | 527 | } |
| 528 | |
527 | 529 | if (message->FindInt32("flags", (int32*)&flags) != B_OK) { |
528 | 530 | delete teams; |
529 | 531 | break; |
530 | 532 | } |
| 533 | |
531 | 534 | if (message->FindString("name", &name) != B_OK) { |
532 | 535 | delete teams; |
533 | 536 | break; |
… |
… |
TSwitchManager::MessageReceived(BMessage* message)
|
548 | 551 | const char* signature = message->FindString("sig"); |
549 | 552 | team_id team = message->FindInt32("team"); |
550 | 553 | |
551 | | int32 numItems = fGroupList.CountItems(); |
552 | | for (int32 i = 0; i < numItems; i++) { |
| 554 | for (int32 i = 0; i < fGroupList.CountItems(); i++) { |
553 | 555 | TTeamGroup* tinfo = (TTeamGroup*)fGroupList.ItemAt(i); |
554 | 556 | if (strcasecmp(tinfo->Signature(), signature) == 0) { |
555 | 557 | if (!(tinfo->TeamList()->HasItem((void*)team))) |
… |
… |
TSwitchManager::MessageReceived(BMessage* message)
|
564 | 566 | { |
565 | 567 | team_id team = message->FindInt32("team"); |
566 | 568 | |
567 | | int32 numItems = fGroupList.CountItems(); |
568 | | for (int32 i = 0; i < numItems; i++) { |
| 569 | for (int32 i = 0; i < fGroupList.CountItems(); i++) { |
569 | 570 | TTeamGroup* tinfo = (TTeamGroup*)fGroupList.ItemAt(i); |
570 | 571 | if (tinfo->TeamList()->HasItem((void*)team)) { |
571 | 572 | tinfo->TeamList()->RemoveItem((void*)team); |
… |
… |
TSwitchManager::MessageReceived(BMessage* message)
|
586 | 587 | // starts differentiating initial key_downs from KeyDowns generated |
587 | 588 | // by auto-repeat. Until then the fSkipUntil stuff helps, but it |
588 | 589 | // isn't perfect. |
589 | | |
590 | 590 | if (time < fSkipUntil) |
591 | 591 | break; |
592 | 592 | |
… |
… |
TSwitchManager::_SortApps()
|
622 | 622 | team_id* teams; |
623 | 623 | int32 count; |
624 | 624 | if (BPrivate::get_application_order(current_workspace(), &teams, &count) |
625 | | != B_OK) |
| 625 | != B_OK) |
626 | 626 | return; |
627 | 627 | |
628 | 628 | BList groups; |
… |
… |
TSwitchManager::MainEntry(BMessage* message)
|
658 | 658 | { |
659 | 659 | bigtime_t now = system_time(); |
660 | 660 | bigtime_t timeout = now + 180000; |
661 | | // The delay above was arrived at by trial and error and |
662 | | // has a good "feel" |
| 661 | // The delay above was arrived at by trial and error and has a good "feel" |
663 | 662 | |
664 | 663 | app_info appInfo; |
665 | 664 | be_roster->GetActiveAppInfo(&appInfo); |
… |
… |
TSwitchManager::MainEntry(BMessage* message)
|
695 | 694 | QuickSwitch(message); |
696 | 695 | return; |
697 | 696 | } |
698 | | snooze(20000); |
699 | | // Must be a multiple of the delay used above |
| 697 | snooze(20000); // Must be a multiple of the delay used above |
700 | 698 | } |
701 | 699 | |
702 | 700 | Process((modifierKeys & B_SHIFT_KEY) == 0, key == 0x11); |
… |
… |
TSwitchManager::_FindNextValidApp(bool forward)
|
887 | 885 | if (fCurrentIndex < 0) |
888 | 886 | fCurrentIndex = max - 1; |
889 | 887 | } |
| 888 | |
890 | 889 | if (fCurrentIndex == startIndex) { |
891 | 890 | // we've gone completely through the list without finding |
892 | 891 | // a good app. Oh well. |
… |
… |
TSwitchManager::ActivateApp(bool forceShow, bool allowWorkspaceSwitch)
|
932 | 931 | |
933 | 932 | int32 currentWorkspace = current_workspace(); |
934 | 933 | TTeamGroup* teamGroup = (TTeamGroup*)fGroupList.ItemAt(fCurrentIndex); |
| 934 | |
935 | 935 | // Let's handle the easy case first: There's only 1 team in the group |
936 | 936 | if (teamGroup->TeamList()->CountItems() == 1) { |
937 | 937 | bool result; |
… |
… |
TSwitchManager::ActivateApp(bool forceShow, bool allowWorkspaceSwitch)
|
990 | 990 | if (tokens == NULL) { |
991 | 991 | ASSERT(windowInfo); |
992 | 992 | free(windowInfo); |
993 | | return true; // weird error, so don't try to recover |
| 993 | return true; // weird error, so don't try to recover |
994 | 994 | } |
995 | 995 | |
996 | 996 | BList windowsToActivate; |
… |
… |
TSwitchManager::QuitApp()
|
1042 | 1042 | |
1043 | 1043 | TTeamGroup* teamGroup; |
1044 | 1044 | int32 count = 0; |
| 1045 | |
1045 | 1046 | for (int32 i = fCurrentIndex + 1; i < fGroupList.CountItems(); i++) { |
1046 | 1047 | teamGroup = (TTeamGroup*)fGroupList.ItemAt(i); |
1047 | 1048 | |
… |
… |
TBox::Draw(BRect update)
|
1382 | 1383 | BeginLineArray(50); |
1383 | 1384 | |
1384 | 1385 | // The main frame around the icon view |
1385 | | AddLine(box.LeftTop(), BPoint(center-kWedge, box.top), veryDarkGray); |
1386 | | AddLine(BPoint(center+kWedge, box.top), box.RightTop(), veryDarkGray); |
| 1386 | AddLine(box.LeftTop(), BPoint(center - kWedge, box.top), veryDarkGray); |
| 1387 | AddLine(BPoint(center + kWedge, box.top), box.RightTop(), veryDarkGray); |
1387 | 1388 | |
1388 | | AddLine(box.LeftBottom(), BPoint(center-kWedge, box.bottom), veryDarkGray); |
1389 | | AddLine(BPoint(center+kWedge, box.bottom), box.RightBottom(), veryDarkGray); |
| 1389 | AddLine(box.LeftBottom(), BPoint(center - kWedge, box.bottom), |
| 1390 | veryDarkGray); |
| 1391 | AddLine(BPoint(center + kWedge, box.bottom), box.RightBottom(), |
| 1392 | veryDarkGray); |
1390 | 1393 | AddLine(box.LeftBottom() + BPoint(1, 1), |
1391 | | BPoint(center-kWedge, box.bottom + 1), white); |
1392 | | AddLine(BPoint(center+kWedge, box.bottom) + BPoint(0, 1), |
| 1394 | BPoint(center - kWedge, box.bottom + 1), white); |
| 1395 | AddLine(BPoint(center + kWedge, box.bottom) + BPoint(0, 1), |
1393 | 1396 | box.RightBottom() + BPoint(1, 1), white); |
1394 | 1397 | |
1395 | 1398 | AddLine(box.LeftTop(), box.LeftBottom(), veryDarkGray); |
1396 | 1399 | AddLine(box.RightTop(), box.RightBottom(), veryDarkGray); |
1397 | | AddLine(box.RightTop() + BPoint(1, 1), |
1398 | | box.RightBottom() + BPoint(1, 1), white); |
| 1400 | AddLine(box.RightTop() + BPoint(1, 1), box.RightBottom() + BPoint(1, 1), |
| 1401 | white); |
1399 | 1402 | |
1400 | 1403 | // downward pointing area at top of frame |
1401 | 1404 | BPoint point(center - kWedge, box.top); |
1402 | 1405 | AddLine(point, point + BPoint(kWedge, kWedge), veryDarkGray); |
1403 | | AddLine(point + BPoint(kWedge, kWedge), |
1404 | | BPoint(center+kWedge, point.y), veryDarkGray); |
| 1406 | AddLine(point + BPoint(kWedge, kWedge), BPoint(center + kWedge, point.y), |
| 1407 | veryDarkGray); |
1405 | 1408 | |
1406 | | AddLine(point + BPoint(1, 0), |
1407 | | point + BPoint(1, 0) + BPoint(kWedge - 1, kWedge - 1), white); |
| 1409 | AddLine(point + BPoint(1, 0), point + BPoint(1, 0) |
| 1410 | + BPoint(kWedge - 1, kWedge - 1), white); |
1408 | 1411 | |
1409 | 1412 | AddLine(point + BPoint(2, -1) + BPoint(kWedge - 1, kWedge - 1), |
1410 | | BPoint(center+kWedge-1, point.y), darkGray); |
| 1413 | BPoint(center + kWedge - 1, point.y), darkGray); |
1411 | 1414 | |
1412 | 1415 | BPoint topPoint = point; |
1413 | 1416 | |
… |
… |
TBox::Draw(BRect update)
|
1416 | 1419 | point.x = center - kWedge; |
1417 | 1420 | AddLine(point, point + BPoint(kWedge, -kWedge), veryDarkGray); |
1418 | 1421 | AddLine(point + BPoint(kWedge, -kWedge), |
1419 | | BPoint(center+kWedge, point.y), veryDarkGray); |
| 1422 | BPoint(center + kWedge, point.y), veryDarkGray); |
1420 | 1423 | |
1421 | 1424 | AddLine(point + BPoint(1, 0), |
1422 | 1425 | point + BPoint(1, 0) + BPoint(kWedge - 1, -(kWedge - 1)), white); |
… |
… |
TBox::DrawIconScrollers(bool force)
|
1467 | 1470 | } |
1468 | 1471 | |
1469 | 1472 | int32 maxIndex = fManager->GroupList()->CountItems() - 1; |
1470 | | // last_frame is in fIconView coordinate space |
| 1473 | // last_frame is in fIconView coordinate space |
1471 | 1474 | BRect lastFrame = fIconView->FrameOf(maxIndex); |
1472 | 1475 | |
1473 | 1476 | if (lastFrame.right > rect.right) { |
… |
… |
TIconView::CacheIcons(TTeamGroup* teamGroup)
|
1893 | 1896 | void |
1894 | 1897 | TIconView::AnimateIcon(BBitmap* startIcon, BBitmap* endIcon) |
1895 | 1898 | { |
1896 | | BRect centerRect(kCenterSlot*kSlotSize, 0, |
| 1899 | BRect centerRect(kCenterSlot * kSlotSize, 0, |
1897 | 1900 | (kCenterSlot + 1) * kSlotSize - 1, kSlotSize - 1); |
1898 | 1901 | BRect startIconBounds = startIcon->Bounds(); |
1899 | 1902 | BRect bounds = Bounds(); |
… |
… |
int32
|
2054 | 2057 | TIconView::SlotOf(int32 index) const |
2055 | 2058 | { |
2056 | 2059 | BRect rect = FrameOf(index); |
| 2060 | |
2057 | 2061 | return (int32)(rect.left / kSlotSize) - kCenterSlot; |
2058 | 2062 | } |
2059 | 2063 | |
… |
… |
TIconView::FrameOf(int32 index) const
|
2063 | 2067 | { |
2064 | 2068 | BList* list = fManager->GroupList(); |
2065 | 2069 | int32 visible = kCenterSlot - 1; |
2066 | | // first few slots in view are empty |
| 2070 | // first few slots in view are empty |
2067 | 2071 | |
2068 | 2072 | TTeamGroup* teamGroup; |
2069 | 2073 | for (int32 i = 0; i <= index; i++) { |
… |
… |
TWindowView::Draw(BRect update)
|
2274 | 2278 | int32 groupIndex = fManager->CurrentIndex(); |
2275 | 2279 | TTeamGroup* teamGroup |
2276 | 2280 | = (TTeamGroup*)fManager->GroupList()->ItemAt(groupIndex); |
| 2281 | |
2277 | 2282 | if (teamGroup == NULL) |
2278 | 2283 | return; |
2279 | 2284 | |
-
diff --git a/src/apps/deskbar/Switcher.h b/src/apps/deskbar/Switcher.h
index 9f319ea..51ca86f 100644
a
|
b
|
public:
|
53 | 53 | TSwitchManager(BPoint where); |
54 | 54 | virtual ~TSwitchManager(); |
55 | 55 | |
56 | | virtual void MessageReceived(BMessage* message); |
| 56 | virtual void MessageReceived(BMessage* message); |
57 | 57 | |
58 | 58 | void Stop(bool doAction, uint32 modifiers); |
59 | 59 | void Unblock(); |
-
diff --git a/src/apps/deskbar/TeamMenu.h b/src/apps/deskbar/TeamMenu.h
index b3b0487..b8563f4 100644
a
|
b
|
names are registered trademarks or trademarks of their respective holders.
|
32 | 32 | All rights reserved. |
33 | 33 | */ |
34 | 34 | |
35 | | // listing of running applications |
36 | | // menu of BarMenuTitle |
37 | | // in mini mode only |
| 35 | // listing of running applications |
| 36 | // menu of BarMenuTitle |
| 37 | // in mini mode only |
38 | 38 | |
39 | 39 | #ifndef TEAMMENU_H |
40 | 40 | #define TEAMMENU_H |
-
diff --git a/src/apps/deskbar/TeamMenuItem.cpp b/src/apps/deskbar/TeamMenuItem.cpp
index cbd669f..6885c4e 100644
a
|
b
|
TTeamMenuItem::TTeamMenuItem(BList* team, BBitmap* icon, char* name, char* sig,
|
71 | 71 | } |
72 | 72 | |
73 | 73 | |
74 | | TTeamMenuItem::TTeamMenuItem(float width,float height,bool vertical) |
| 74 | TTeamMenuItem::TTeamMenuItem(float width, float height, bool vertical) |
75 | 75 | : BMenuItem("", NULL) |
76 | 76 | { |
77 | 77 | InitData(NULL, NULL, strdup(""), strdup(""), width, height, false, vertical); |
… |
… |
TTeamMenuItem::Draw()
|
233 | 233 | BMenu* menu = Menu(); |
234 | 234 | menu->PushState(); |
235 | 235 | rgb_color menuColor = menu->LowColor(); |
236 | | |
237 | 236 | TBarView* barview = (static_cast<TBarApp*>(be_app))->BarView(); |
| 237 | |
238 | 238 | bool canHandle = !barview->Dragging() |
239 | 239 | || barview->AppCanHandleTypes(Signature()); |
240 | 240 | |
… |
… |
TTeamMenuItem::Draw()
|
314 | 314 | |
315 | 315 | // these continue the dark grey border on the left or top edge |
316 | 316 | menu->SetHighColor(tint_color(menuColor, B_DARKEN_4_TINT)); |
317 | | if (fVertical) |
| 317 | if (fVertical) { |
318 | 318 | // dark line at top |
319 | 319 | menu->StrokeLine(frame.LeftTop(), frame.RightTop()); |
320 | | else |
| 320 | } else { |
321 | 321 | // dark line on the left |
322 | 322 | menu->StrokeLine(frame.LeftTop(), frame.LeftBottom()); |
| 323 | } |
323 | 324 | } else |
324 | 325 | menu->SetLowColor(menuColor); |
325 | 326 | |
… |
… |
TTeamMenuItem::DrawContent()
|
337 | 338 | if (fIcon->ColorSpace() == B_RGBA32) { |
338 | 339 | menu->SetDrawingMode(B_OP_ALPHA); |
339 | 340 | menu->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY); |
340 | | } else { |
| 341 | } else |
341 | 342 | menu->SetDrawingMode(B_OP_OVER); |
342 | | } |
343 | | BRect frame(Frame()); |
344 | 343 | |
| 344 | BRect frame(Frame()); |
345 | 345 | BRect iconBounds(fIcon->Bounds()); |
346 | 346 | BRect dstRect(iconBounds); |
347 | 347 | float extra = fVertical ? 0.0f : 1.0f; |
348 | 348 | BPoint contLoc = ContentLocation(); |
| 349 | |
349 | 350 | dstRect.OffsetTo(BPoint(contLoc.x + kHPad, contLoc.y + |
350 | 351 | ((frame.Height() - iconBounds.Height()) / 2) + extra)); |
351 | 352 | menu->DrawBitmapAsync(fIcon, dstRect); |
… |
… |
TTeamMenuItem::DrawContent()
|
357 | 358 | menu->MovePenTo(drawLoc); |
358 | 359 | } |
359 | 360 | |
360 | | // set the pen to black so that either method will draw in the same color |
361 | | // low color is set in inherited::DrawContent, override makes sure its |
362 | | // what we want |
| 361 | // set the pen to black so that either method will draw in the same color |
| 362 | // low color is set in inherited::DrawContent, override makes sure its |
| 363 | // what we want |
363 | 364 | if (fDrawLabel) { |
364 | 365 | menu->SetDrawingMode(B_OP_OVER); |
365 | 366 | menu->SetHighColor(0, 0, 0); |
366 | 367 | |
367 | | // override the drawing of the content when the item is disabled |
368 | | // the wrong lowcolor is used when the item is disabled since the |
369 | | // text color does not change |
| 368 | // override the drawing of the content when the item is disabled |
| 369 | // the wrong lowcolor is used when the item is disabled since the |
| 370 | // text color does not change |
370 | 371 | DrawContentLabel(); |
371 | 372 | } |
372 | 373 | |
… |
… |
TTeamMenuItem::DrawContent()
|
387 | 388 | } else { |
388 | 389 | rgb_color outlineColor = {80, 80, 80, 255}; |
389 | 390 | rgb_color middleColor = {200, 200, 200, 255}; |
390 | | |
| 391 | |
391 | 392 | menu->SetDrawingMode(B_OP_OVER); |
392 | | |
| 393 | |
393 | 394 | if (!fExpanded) { |
394 | 395 | menu->BeginLineArray(6); |
395 | | |
| 396 | |
396 | 397 | menu->AddLine(BPoint(rect.left + 3, rect.top + 1), |
397 | 398 | BPoint(rect.left + 3, rect.bottom - 1), outlineColor); |
398 | 399 | menu->AddLine(BPoint(rect.left + 3, rect.top + 1), |
399 | 400 | BPoint(rect.left + 7, rect.top + 5), outlineColor); |
400 | 401 | menu->AddLine(BPoint(rect.left + 7, rect.top + 5), |
401 | 402 | BPoint(rect.left + 3, rect.bottom - 1), outlineColor); |
402 | | |
| 403 | |
403 | 404 | menu->AddLine(BPoint(rect.left + 4, rect.top + 3), |
404 | 405 | BPoint(rect.left + 4, rect.bottom - 3), middleColor); |
405 | 406 | menu->AddLine(BPoint(rect.left + 5, rect.top + 4), |
… |
… |
TTeamMenuItem::DrawContent()
|
409 | 410 | menu->EndLineArray(); |
410 | 411 | } else { |
411 | 412 | // expanded state |
412 | | |
| 413 | |
413 | 414 | menu->BeginLineArray(6); |
414 | 415 | menu->AddLine(BPoint(rect.left + 1, rect.top + 3), |
415 | 416 | BPoint(rect.right - 3, rect.top + 3), outlineColor); |
… |
… |
TTeamMenuItem::DrawContent()
|
417 | 418 | BPoint(rect.left + 5, rect.top + 7), outlineColor); |
418 | 419 | menu->AddLine(BPoint(rect.left + 5, rect.top + 7), |
419 | 420 | BPoint(rect.right - 3, rect.top + 3), outlineColor); |
420 | | |
| 421 | |
421 | 422 | menu->AddLine(BPoint(rect.left + 3, rect.top + 4), |
422 | 423 | BPoint(rect.right - 5, rect.top + 4), middleColor); |
423 | 424 | menu->AddLine(BPoint(rect.left + 4, rect.top + 5), |
… |
… |
TTeamMenuItem::DrawContentLabel()
|
444 | 445 | const char* label = Label(); |
445 | 446 | char* truncLabel = NULL; |
446 | 447 | float max = 0; |
| 448 | |
447 | 449 | if (static_cast<TBarApp*>(be_app)->Settings()->superExpando && fVertical) |
448 | 450 | max = menu->MaxContentWidth() - kSwitchWidth; |
449 | 451 | else |
… |
… |
void
|
491 | 493 | TTeamMenuItem::ToggleExpandState(bool resizeWindow) |
492 | 494 | { |
493 | 495 | fExpanded = !fExpanded; |
494 | | |
| 496 | |
495 | 497 | if (fExpanded) { |
496 | 498 | // Populate Menu() with the stuff from SubMenu(). |
497 | 499 | TWindowMenu* sub = (static_cast<TWindowMenu*>(Submenu())); |
… |
… |
TTeamMenuItem::ToggleExpandState(bool resizeWindow)
|
503 | 505 | if (locked) |
504 | 506 | sub->UnlockLooper(); |
505 | 507 | |
506 | | if (sub->CountItems() > 1){ |
| 508 | if (sub->CountItems() > 1) { |
507 | 509 | TExpandoMenuBar* parent = static_cast<TExpandoMenuBar*>(Menu()); |
508 | 510 | int myindex = parent->IndexOf(this) + 1; |
509 | 511 | |
… |
… |
TTeamMenuItem::ToggleExpandState(bool resizeWindow)
|
553 | 555 | TWindowMenuItem* |
554 | 556 | TTeamMenuItem::ExpandedWindowItem(int32 id) |
555 | 557 | { |
556 | | if (!fExpanded) // Paranoia |
| 558 | if (!fExpanded) { |
| 559 | // Paranoia |
557 | 560 | return NULL; |
| 561 | } |
558 | 562 | |
559 | 563 | TExpandoMenuBar* parent = static_cast<TExpandoMenuBar*>(Menu()); |
560 | 564 | int childIndex = parent->IndexOf(this) + 1; |
-
diff --git a/src/apps/deskbar/TimeView.cpp b/src/apps/deskbar/TimeView.cpp
index 16c4982..2e338b6 100644
a
|
b
|
TTimeView::GetPreferredSize(float* width, float* height)
|
154 | 154 | |
155 | 155 | GetCurrentTime(); |
156 | 156 | |
157 | | // TODO: SetOrientation never gets called, fix that |
158 | | // When in vertical mode, we want to limit the width so that it can't |
159 | | // overlap the bevels in the parent view. |
| 157 | // TODO: SetOrientation never gets called, fix that when in vertical mode, |
| 158 | // we want to limit the width so that it can't overlap the bevels in the |
| 159 | // parent view. |
160 | 160 | *width = fOrientation ? |
161 | 161 | min_c(fMaxWidth - kHMargin, kHMargin + StringWidth(fTimeStr)) |
162 | 162 | : kHMargin + StringWidth(fTimeStr); |
… |
… |
TTimeView::MessageReceived(BMessage* message)
|
217 | 217 | |
218 | 218 | default: |
219 | 219 | BView::MessageReceived(message); |
| 220 | break; |
220 | 221 | } |
221 | 222 | } |
222 | 223 | |
… |
… |
TTimeView::GetCurrentDate()
|
262 | 263 | |
263 | 264 | fLocale.FormatDate(tmp, 64, fTime, B_FULL_DATE_FORMAT); |
264 | 265 | |
265 | | // remove leading 0 from date when month is less than 10 (MM/DD/YY) |
266 | | // or remove leading 0 from date when day is less than 10 (DD/MM/YY) |
| 266 | // remove leading 0 from date when month is less than 10 (MM/DD/YY) |
| 267 | // or remove leading 0 from date when day is less than 10 (DD/MM/YY) |
267 | 268 | const char* str = tmp; |
268 | 269 | if (str[0] == '0') |
269 | 270 | str++; |
… |
… |
TTimeView::Pulse()
|
325 | 326 | // For dates, Update() could be called two times in a row, |
326 | 327 | // but that should only happen very rarely |
327 | 328 | if ((fLastTimeStr[1] != fTimeStr[1] |
328 | | && (fLastTimeStr[1] == ':' || fTimeStr[1] == ':')) |
| 329 | && (fLastTimeStr[1] == ':' || fTimeStr[1] == ':')) |
329 | 330 | || !fLastTimeStr[0]) |
330 | 331 | Update(); |
331 | 332 | |
… |
… |
TTimeView::Update()
|
361 | 362 | GetCurrentTime(); |
362 | 363 | GetCurrentDate(); |
363 | 364 | |
364 | | |
365 | 365 | SetToolTip(fDateStr); |
366 | 366 | |
367 | 367 | ResizeToPreferred(); |
… |
… |
TTimeView::Update()
|
370 | 370 | if (fParent) { |
371 | 371 | BMessage reformat('Trfm'); |
372 | 372 | fParent->MessageReceived(&reformat); |
373 | | // time string format realign |
| 373 | // time string format realign |
374 | 374 | fParent->Invalidate(); |
375 | 375 | } |
376 | 376 | } |
-
diff --git a/src/apps/deskbar/TimeView.h b/src/apps/deskbar/TimeView.h
index 6034fb0..a8f1e48 100644
a
|
b
|
class TTimeView : public BView {
|
73 | 73 | void MouseDown(BPoint where); |
74 | 74 | void Pulse(); |
75 | 75 | |
76 | | bool ShowingSeconds() { return fShowSeconds; } |
| 76 | bool ShowingSeconds() { return fShowSeconds; } |
77 | 77 | void ShowSeconds(bool); |
78 | 78 | void ShowCalendar(BPoint where); |
79 | 79 | |
… |
… |
class TTimeView : public BView {
|
110 | 110 | |
111 | 111 | float fMaxWidth; |
112 | 112 | float fHeight; |
113 | | bool fOrientation; // vertical = true |
| 113 | bool fOrientation; // vertical = true |
114 | 114 | BPoint fTimeLocation; |
115 | 115 | BPoint fDateLocation; |
116 | 116 | |
-
diff --git a/src/apps/deskbar/WindowMenu.cpp b/src/apps/deskbar/WindowMenu.cpp
index 895b890..7f9eb9c 100644
a
|
b
|
void
|
88 | 88 | TWindowMenu::AttachedToWindow() |
89 | 89 | { |
90 | 90 | SetFont(be_plain_font); |
91 | | |
92 | 91 | RemoveItems(0, CountItems(), true); |
93 | | |
94 | 92 | int32 miniCount = 0; |
95 | 93 | |
96 | 94 | bool dragging = false; |
97 | 95 | TBarView* barview =(static_cast<TBarApp*>(be_app))->BarView(); |
98 | 96 | if (barview && barview->LockLooper()) { |
99 | | // 'dragging' mode set in BarView::CacheDragData |
100 | | // invoke in MouseEnter in ExpandoMenuBar |
| 97 | // 'dragging' mode set in BarView::CacheDragData |
| 98 | // invoke in MouseEnter in ExpandoMenuBar |
101 | 99 | dragging = barview->Dragging(); |
102 | 100 | if (dragging) { |
103 | 101 | // We don't want to show the menu when dragging, but it's not |
… |
… |
TWindowMenu::AttachedToWindow()
|
105 | 103 | // Don't call BMenu::Hide(), it causes the menu to pop up every now |
106 | 104 | // and then. |
107 | 105 | Window()->Hide(); |
108 | | // if in expando (horizontal or vertical) |
| 106 | // if in expando (horizontal or vertical) |
109 | 107 | if (barview->Expando()) { |
110 | 108 | SetTrackingHook(barview->MenuTrackingHook, |
111 | 109 | barview->GetTrackingHookData()); |
… |
… |
TWindowMenu::AttachedToWindow()
|
192 | 190 | fTeam, B_QUIT_REQUESTED)); |
193 | 191 | } |
194 | 192 | } else { |
195 | | // if we are in drag mode, then don't add the window controls |
196 | | // to the menu |
| 193 | // if we are in drag mode, then don't add the window controls |
| 194 | // to the menu |
197 | 195 | if (!dragging) { |
198 | 196 | TShowHideMenuItem* hide = |
199 | 197 | new TShowHideMenuItem(B_TRANSLATE("Hide all"), fTeam, |
… |
… |
TWindowMenu::DetachedFromWindow()
|
230 | 228 | TBarView* barview = (dynamic_cast<TBarApp*>(be_app))->BarView(); |
231 | 229 | if (barview && barview->Expando() && barview->Dragging() |
232 | 230 | && barview->LockLooper()) { |
233 | | // We changed the show level in AttachedToWindow(). Undo it. |
| 231 | // We changed the show level in AttachedToWindow(). Undo it. |
234 | 232 | Window()->Show(); |
235 | 233 | barview->DragStop(); |
236 | 234 | barview->UnlockLooper(); |
-
diff --git a/src/apps/deskbar/WindowMenuItem.cpp b/src/apps/deskbar/WindowMenuItem.cpp
index ddf94f4..5865466 100644
a
|
b
|
All rights reserved.
|
48 | 48 | #include "WindowMenu.h" |
49 | 49 | |
50 | 50 | |
51 | | const float kHPad = 10.0f; |
52 | | const float kVPad = 2.0f; |
53 | | const float kLabelOffset = 8.0f; |
54 | | const BRect kIconRect(1.0f, 1.0f, 13.0f, 14.0f); |
| 51 | const float kHPad = 10.0f; |
| 52 | const float kVPad = 2.0f; |
| 53 | const float kLabelOffset = 8.0f; |
| 54 | const BRect kIconRect(1.0f, 1.0f, 13.0f, 14.0f); |
55 | 55 | |
56 | 56 | |
57 | 57 | TWindowMenuItem::TWindowMenuItem(const char* title, int32 id, bool mini, |
… |
… |
TWindowMenuItem::Draw()
|
204 | 204 | |
205 | 205 | menu->PushState(); |
206 | 206 | |
207 | | // if not selected or being tracked on, fill with gray |
| 207 | // if not selected or being tracked on, fill with gray |
208 | 208 | TBarView* barview = (static_cast<TBarApp*>(be_app))->BarView(); |
209 | 209 | if ((!IsSelected() && !menu->IsRedrawAfterSticky()) |
210 | 210 | || barview->Dragging() || !IsEnabled()) { |
… |
… |
TWindowMenuItem::DrawContent()
|
241 | 241 | |
242 | 242 | BRect frame(Frame()); |
243 | 243 | BPoint contLoc = ContentLocation() + BPoint(kHPad, kVPad); |
244 | | // if (fExpanded) |
245 | | // contLoc.x += kHPad; |
| 244 | //if (fExpanded) |
| 245 | // contLoc.x += kHPad; |
246 | 246 | |
247 | 247 | if (fID >= 0) { |
248 | 248 | menu->SetDrawingMode(B_OP_OVER); |
-
diff --git a/src/apps/deskbar/WindowMenuItem.h b/src/apps/deskbar/WindowMenuItem.h
index bfe14da..e889488 100644
a
|
b
|
public:
|
69 | 69 | |
70 | 70 | protected: |
71 | 71 | void Initialize(const char* title); |
72 | | virtual void GetContentSize(float* width, float* height); |
| 72 | virtual void GetContentSize(float* width, float* height); |
73 | 73 | virtual void DrawContent(); |
74 | 74 | virtual status_t Invoke(BMessage* message = NULL); |
75 | 75 | virtual void Draw(); |
… |
… |
private:
|
91 | 91 | |
92 | 92 | |
93 | 93 | #endif /* WINDOWMENUITEM_H */ |
| 94 | |