141281cf3SAxel Dörfler /* 241281cf3SAxel Dörfler Open Tracker License 341281cf3SAxel Dörfler 441281cf3SAxel Dörfler Terms and Conditions 541281cf3SAxel Dörfler 641281cf3SAxel Dörfler Copyright (c) 1991-2000, Be Incorporated. All rights reserved. 741281cf3SAxel Dörfler 841281cf3SAxel Dörfler Permission is hereby granted, free of charge, to any person obtaining a copy of 941281cf3SAxel Dörfler this software and associated documentation files (the "Software"), to deal in 1041281cf3SAxel Dörfler the Software without restriction, including without limitation the rights to 1141281cf3SAxel Dörfler use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 1241281cf3SAxel Dörfler of the Software, and to permit persons to whom the Software is furnished to do 1341281cf3SAxel Dörfler so, subject to the following conditions: 1441281cf3SAxel Dörfler 1541281cf3SAxel Dörfler The above copyright notice and this permission notice applies to all licensees 1641281cf3SAxel Dörfler and shall be included in all copies or substantial portions of the Software. 1741281cf3SAxel Dörfler 1841281cf3SAxel Dörfler THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1941281cf3SAxel Dörfler IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY, 2041281cf3SAxel Dörfler FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 2141281cf3SAxel Dörfler BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 2241281cf3SAxel Dörfler AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION 2341281cf3SAxel Dörfler WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 2441281cf3SAxel Dörfler 2541281cf3SAxel Dörfler Except as contained in this notice, the name of Be Incorporated shall not be 2641281cf3SAxel Dörfler used in advertising or otherwise to promote the sale, use or other dealings in 2741281cf3SAxel Dörfler this Software without prior written authorization from Be Incorporated. 2841281cf3SAxel Dörfler 291ad8c760SFredrik Holmqvist Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered 301ad8c760SFredrik Holmqvist trademarks of Be Incorporated in the United States and other countries. Other 311ad8c760SFredrik Holmqvist brand product names are registered trademarks or trademarks of their respective 321ad8c760SFredrik Holmqvist holders. 3341281cf3SAxel Dörfler All rights reserved. 3441281cf3SAxel Dörfler */ 3541281cf3SAxel Dörfler 3641281cf3SAxel Dörfler #include <Debug.h> 3741281cf3SAxel Dörfler 3841281cf3SAxel Dörfler #include <errno.h> 3941281cf3SAxel Dörfler #include <stdio.h> 4041281cf3SAxel Dörfler #include <string.h> 4141281cf3SAxel Dörfler #include <time.h> 4241281cf3SAxel Dörfler #include <unistd.h> 4341281cf3SAxel Dörfler #include <algorithm> 4441281cf3SAxel Dörfler 4541281cf3SAxel Dörfler #include <fs_index.h> 4641281cf3SAxel Dörfler #include <fs_info.h> 4741281cf3SAxel Dörfler 4841281cf3SAxel Dörfler #include <Application.h> 4941281cf3SAxel Dörfler #include <Beep.h> 50cb6afcb1SStephan Aßmus #include <Bitmap.h> 51ae7a6e3aSAdrien Destugues #include <Catalog.h> 52cb6afcb1SStephan Aßmus #include <ControlLook.h> 5341281cf3SAxel Dörfler #include <Directory.h> 5441281cf3SAxel Dörfler #include <FindDirectory.h> 55ae7a6e3aSAdrien Destugues #include <Locale.h> 5641281cf3SAxel Dörfler #include <MenuItem.h> 5741281cf3SAxel Dörfler #include <NodeInfo.h> 5841281cf3SAxel Dörfler #include <NodeMonitor.h> 5941281cf3SAxel Dörfler #include <Path.h> 6041281cf3SAxel Dörfler #include <PopUpMenu.h> 6141281cf3SAxel Dörfler #include <Roster.h> 6241281cf3SAxel Dörfler #include <Screen.h> 6341281cf3SAxel Dörfler #include <Volume.h> 6441281cf3SAxel Dörfler #include <VolumeRoster.h> 6541281cf3SAxel Dörfler #include <Window.h> 6641281cf3SAxel Dörfler 67cb6afcb1SStephan Aßmus #include "icons_logo.h" 68cb6afcb1SStephan Aßmus #include "BarApp.h" 69323b6546SOliver Tappe #include "DeskbarUtils.h" 70cb6afcb1SStephan Aßmus #include "ResourceSet.h" 7141281cf3SAxel Dörfler #include "StatusView.h" 7241281cf3SAxel Dörfler #include "StatusViewShelf.h" 7341281cf3SAxel Dörfler #include "TimeView.h" 7441281cf3SAxel Dörfler 756d01b66dSAxel Dörfler using std::max; 7641281cf3SAxel Dörfler 7741281cf3SAxel Dörfler #ifdef DB_ADDONS 7841281cf3SAxel Dörfler // Add-on support 7941281cf3SAxel Dörfler // 8041281cf3SAxel Dörfler // Item - internal item list (node, eref, etc) 8141281cf3SAxel Dörfler // Icon - physical replicant handed to the DeskbarClass class 8241281cf3SAxel Dörfler // AddOn - attribute based add-on 8341281cf3SAxel Dörfler 8441281cf3SAxel Dörfler const char* const kInstantiateItemCFunctionName = "instantiate_deskbar_item"; 8541281cf3SAxel Dörfler const char* const kInstantiateEntryCFunctionName = "instantiate_deskbar_entry"; 863e6ff860SRene Gollent const char* const kReplicantSettingsFile = "Deskbar_replicants"; 87c0ad1c91SRene Gollent const char* const kReplicantPathField = "replicant_path"; 8841281cf3SAxel Dörfler 89cb6afcb1SStephan Aßmus float sMinimumWindowWidth = kGutter + kMinimumTrayWidth + kDragRegionWidth; 90cb6afcb1SStephan Aßmus 9141281cf3SAxel Dörfler 9241281cf3SAxel Dörfler static void 9341281cf3SAxel Dörfler DumpItem(DeskbarItemInfo* item) 9441281cf3SAxel Dörfler { 9541281cf3SAxel Dörfler printf("is addon: %i, id: %li\n", item->isAddOn, item->id); 9666eba86fSAxel Dörfler printf("entry_ref: %ld, %Ld, %s\n", item->entryRef.device, 9766eba86fSAxel Dörfler item->entryRef.directory, item->entryRef.name); 9841281cf3SAxel Dörfler printf("node_ref: %ld, %Ld\n", item->nodeRef.device, item->nodeRef.node); 9941281cf3SAxel Dörfler } 10041281cf3SAxel Dörfler 10141281cf3SAxel Dörfler 10241281cf3SAxel Dörfler static void 10341281cf3SAxel Dörfler DumpList(BList* itemlist) 10441281cf3SAxel Dörfler { 10541281cf3SAxel Dörfler int32 count = itemlist->CountItems() - 1; 10641281cf3SAxel Dörfler if (count < 0) { 10741281cf3SAxel Dörfler printf("no items in list\n"); 10841281cf3SAxel Dörfler return; 10941281cf3SAxel Dörfler } 11041281cf3SAxel Dörfler for (int32 i = count; i >= 0; i--) { 11141281cf3SAxel Dörfler DeskbarItemInfo* item = (DeskbarItemInfo*)itemlist->ItemAt(i); 11241281cf3SAxel Dörfler if (!item) 11341281cf3SAxel Dörfler continue; 11441281cf3SAxel Dörfler 11541281cf3SAxel Dörfler DumpItem(item); 11641281cf3SAxel Dörfler } 11741281cf3SAxel Dörfler } 11841281cf3SAxel Dörfler #endif /* DB_ADDONS */ 11941281cf3SAxel Dörfler 12041281cf3SAxel Dörfler 121546208a5SOliver Tappe #undef B_TRANSLATION_CONTEXT 122546208a5SOliver Tappe #define B_TRANSLATION_CONTEXT "Tray" 123ae7a6e3aSAdrien Destugues 1247da06231SAxel Dörfler // don't change the name of this view to anything other than "Status"! 1257da06231SAxel Dörfler 12641281cf3SAxel Dörfler TReplicantTray::TReplicantTray(TBarView* parent, bool vertical) 1270d2ac94cSJohn Scipione : 128*9ac6fee1SJohn Scipione BView(BRect(0, 0, 1, 1), "Status", B_FOLLOW_LEFT | B_FOLLOW_TOP, 1290d2ac94cSJohn Scipione B_WILL_DRAW | B_FRAME_EVENTS), 130573f748cSJohn Scipione fTime(NULL), 13141281cf3SAxel Dörfler fBarView(parent), 13241281cf3SAxel Dörfler fShelf(new TReplicantShelf(this)), 13341281cf3SAxel Dörfler fMultiRowMode(vertical), 134cb6afcb1SStephan Aßmus fMinimumTrayWidth(kMinimumTrayWidth), 13541281cf3SAxel Dörfler fAlignmentSupport(false) 13641281cf3SAxel Dörfler { 137cb6afcb1SStephan Aßmus // init the minimum window width according to the logo. 138cb6afcb1SStephan Aßmus const BBitmap* logoBitmap = AppResSet()->FindBitmap(B_MESSAGE_TYPE, 1399e8a970bSJonas Sundström R_LeafLogoBitmap); 140cb6afcb1SStephan Aßmus if (logoBitmap != NULL) { 141cb6afcb1SStephan Aßmus sMinimumWindowWidth = max_c(sMinimumWindowWidth, 142cb6afcb1SStephan Aßmus 2 * (logoBitmap->Bounds().Width() + 8)); 143cb6afcb1SStephan Aßmus fMinimumTrayWidth = sMinimumWindowWidth - kGutter - kDragRegionWidth; 144cb6afcb1SStephan Aßmus } 145573f748cSJohn Scipione 1463cf2d117SJohn Scipione BFormattingConventions conventions; 1473cf2d117SJohn Scipione BLocale::Default()->GetFormattingConventions(&conventions); 1483cf2d117SJohn Scipione bool use24HourClock = conventions.Use24HourClock(); 1493cf2d117SJohn Scipione desk_settings* settings = ((TBarApp*)be_app)->Settings(); 1503cf2d117SJohn Scipione 151573f748cSJohn Scipione // Create the time view 152573f748cSJohn Scipione fTime = new TTimeView(fMinimumTrayWidth, kMaxReplicantHeight - 1.0, 153f5be13ecSJohn Scipione use24HourClock, settings->showSeconds, settings->showDayOfWeek); 15441281cf3SAxel Dörfler } 15541281cf3SAxel Dörfler 15641281cf3SAxel Dörfler 15741281cf3SAxel Dörfler TReplicantTray::~TReplicantTray() 15841281cf3SAxel Dörfler { 15941281cf3SAxel Dörfler delete fShelf; 160573f748cSJohn Scipione delete fTime; 16141281cf3SAxel Dörfler } 16241281cf3SAxel Dörfler 16341281cf3SAxel Dörfler 16441281cf3SAxel Dörfler void 16541281cf3SAxel Dörfler TReplicantTray::AttachedToWindow() 16641281cf3SAxel Dörfler { 16741281cf3SAxel Dörfler BView::AttachedToWindow(); 16841281cf3SAxel Dörfler 169cb6afcb1SStephan Aßmus if (be_control_look != NULL) { 170cb6afcb1SStephan Aßmus SetViewColor(Parent()->ViewColor()); 171cb6afcb1SStephan Aßmus } else { 17266eba86fSAxel Dörfler SetViewColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), 17366eba86fSAxel Dörfler B_DARKEN_1_TINT)); 174cb6afcb1SStephan Aßmus } 17541281cf3SAxel Dörfler SetDrawingMode(B_OP_COPY); 17666eba86fSAxel Dörfler 17741281cf3SAxel Dörfler Window()->SetPulseRate(1000000); 17841281cf3SAxel Dörfler 179573f748cSJohn Scipione AddChild(fTime); 180573f748cSJohn Scipione fTime->MoveTo(Bounds().right - fTime->Bounds().Width() - 1, 2); 181573f748cSJohn Scipione if (!((TBarApp*)be_app)->Settings()->showTime) { 182573f748cSJohn Scipione fTime->Hide(); 183573f748cSJohn Scipione RealignReplicants(); 184573f748cSJohn Scipione AdjustPlacement(); 185573f748cSJohn Scipione } 186ae7a6e3aSAdrien Destugues 18741281cf3SAxel Dörfler #ifdef DB_ADDONS 18841281cf3SAxel Dörfler // load addons and rehydrate archives 1893a6add49SAxel Dörfler #if !defined(HAIKU_TARGET_PLATFORM_LIBBE_TEST) 19041281cf3SAxel Dörfler InitAddOnSupport(); 19141281cf3SAxel Dörfler #endif 1929c910f9eSStephan Aßmus #endif 19341281cf3SAxel Dörfler ResizeToPreferred(); 19441281cf3SAxel Dörfler } 19541281cf3SAxel Dörfler 19641281cf3SAxel Dörfler 19741281cf3SAxel Dörfler void 19841281cf3SAxel Dörfler TReplicantTray::DetachedFromWindow() 19941281cf3SAxel Dörfler { 20041281cf3SAxel Dörfler #ifdef DB_ADDONS 20141281cf3SAxel Dörfler // clean up add-on support 202465b54cdSAxel Dörfler #if !defined(HAIKU_TARGET_PLATFORM_LIBBE_TEST) 20341281cf3SAxel Dörfler DeleteAddOnSupport(); 20441281cf3SAxel Dörfler #endif 205465b54cdSAxel Dörfler #endif 20641281cf3SAxel Dörfler BView::DetachedFromWindow(); 20741281cf3SAxel Dörfler } 20841281cf3SAxel Dörfler 20941281cf3SAxel Dörfler 2101ad8c760SFredrik Holmqvist /*! Width is set to a minimum of kMinimumReplicantCount by kMaxReplicantWidth 21166eba86fSAxel Dörfler if not in multirowmode and greater than kMinimumReplicantCount 2122ce9bab8SJohn Scipione the width should be calculated based on the actual replicant widths 21341281cf3SAxel Dörfler */ 21441281cf3SAxel Dörfler void 21541281cf3SAxel Dörfler TReplicantTray::GetPreferredSize(float* preferredWidth, float* preferredHeight) 21641281cf3SAxel Dörfler { 21741281cf3SAxel Dörfler float width = 0, height = kMinimumTrayHeight; 21841281cf3SAxel Dörfler 21941281cf3SAxel Dörfler if (fMultiRowMode) { 2207da06231SAxel Dörfler if (fShelf->CountReplicants() > 0) 2217da06231SAxel Dörfler height = fRightBottomReplicant.bottom; 22241281cf3SAxel Dörfler 2231ad8c760SFredrik Holmqvist // the height will be uniform for the number of rows necessary to show 2241ad8c760SFredrik Holmqvist // all the reps + any gutters necessary for spacing 22541281cf3SAxel Dörfler int32 rowCount = (int32)(height / kMaxReplicantHeight); 22641281cf3SAxel Dörfler height = kGutter + (rowCount * kMaxReplicantHeight) 22741281cf3SAxel Dörfler + ((rowCount - 1) * kIconGap) + kGutter; 22841281cf3SAxel Dörfler height = max(kMinimumTrayHeight, height); 229cb6afcb1SStephan Aßmus width = fMinimumTrayWidth; 23041281cf3SAxel Dörfler } else { 2311ad8c760SFredrik Holmqvist // if last replicant overruns clock then resize to accomodate 2327da06231SAxel Dörfler if (fShelf->CountReplicants() > 0) { 233573f748cSJohn Scipione if (!fTime->IsHidden() && fTime->Frame().left 234573f748cSJohn Scipione < fRightBottomReplicant.right + 6) { 23566eba86fSAxel Dörfler width = fRightBottomReplicant.right + 6 236573f748cSJohn Scipione + fTime->Frame().Width(); 23741281cf3SAxel Dörfler } else 2387da06231SAxel Dörfler width = fRightBottomReplicant.right + 3; 23941281cf3SAxel Dörfler } 2401ad8c760SFredrik Holmqvist 24141281cf3SAxel Dörfler // this view has a fixed minimum width 242cb6afcb1SStephan Aßmus width = max(fMinimumTrayWidth, width); 2432ce9bab8SJohn Scipione height = kGutter + static_cast<TBarApp*>(be_app)->IconSize() + kGutter; 24441281cf3SAxel Dörfler } 24541281cf3SAxel Dörfler 24641281cf3SAxel Dörfler *preferredWidth = width; 2471ad8c760SFredrik Holmqvist // add 1 for the border 24841281cf3SAxel Dörfler *preferredHeight = height + 1; 24941281cf3SAxel Dörfler } 25041281cf3SAxel Dörfler 25141281cf3SAxel Dörfler 25241281cf3SAxel Dörfler void 25341281cf3SAxel Dörfler TReplicantTray::AdjustPlacement() 25441281cf3SAxel Dörfler { 25541281cf3SAxel Dörfler // called when an add-on has been added or removed 25641281cf3SAxel Dörfler // need to resize the parent of this accordingly 257a5210ab1SAxel Dörfler 25841281cf3SAxel Dörfler BRect bounds = Bounds(); 25941281cf3SAxel Dörfler float width, height; 26041281cf3SAxel Dörfler GetPreferredSize(&width, &height); 26141281cf3SAxel Dörfler 26241281cf3SAxel Dörfler if (width == bounds.Width() && height == bounds.Height()) { 26341281cf3SAxel Dörfler // no need to change anything 26441281cf3SAxel Dörfler return; 26541281cf3SAxel Dörfler } 26641281cf3SAxel Dörfler 26741281cf3SAxel Dörfler Parent()->ResizeToPreferred(); 26841281cf3SAxel Dörfler fBarView->UpdatePlacement(); 26941281cf3SAxel Dörfler Parent()->Invalidate(); 27041281cf3SAxel Dörfler Invalidate(); 27141281cf3SAxel Dörfler } 27241281cf3SAxel Dörfler 27341281cf3SAxel Dörfler 27441281cf3SAxel Dörfler void 27541281cf3SAxel Dörfler TReplicantTray::MessageReceived(BMessage* message) 27641281cf3SAxel Dörfler { 27741281cf3SAxel Dörfler switch (message->what) { 27830a55802SJohn Scipione case B_LOCALE_CHANGED: 279573f748cSJohn Scipione { 280573f748cSJohn Scipione if (fTime == NULL) 281573f748cSJohn Scipione return; 282573f748cSJohn Scipione 28330a55802SJohn Scipione // Locale may have updated 12/24 hour clock 284573f748cSJohn Scipione BFormattingConventions conventions; 285573f748cSJohn Scipione BLocale::Default()->GetFormattingConventions(&conventions); 28630a55802SJohn Scipione fTime->SetUse24HourClock(conventions.Use24HourClock()); 28730a55802SJohn Scipione 28841281cf3SAxel Dörfler // time string reformat -> realign 28941281cf3SAxel Dörfler RealignReplicants(); 29041281cf3SAxel Dörfler AdjustPlacement(); 29141281cf3SAxel Dörfler break; 292573f748cSJohn Scipione } 293573f748cSJohn Scipione 29430a55802SJohn Scipione case kShowHideTime: 29530a55802SJohn Scipione // from context menu in clock and in this view 29630a55802SJohn Scipione ShowHideTime(); 29730a55802SJohn Scipione break; 29830a55802SJohn Scipione 2993cf2d117SJohn Scipione case kShowSeconds: 300573f748cSJohn Scipione if (fTime == NULL) 301573f748cSJohn Scipione return; 302573f748cSJohn Scipione 3033cf2d117SJohn Scipione fTime->SetShowSeconds(!fTime->ShowSeconds()); 304573f748cSJohn Scipione 3053cf2d117SJohn Scipione // time string reformat -> realign 3063cf2d117SJohn Scipione RealignReplicants(); 3073cf2d117SJohn Scipione AdjustPlacement(); 308573f748cSJohn Scipione break; 3093cf2d117SJohn Scipione 3103cf2d117SJohn Scipione case kShowDayOfWeek: 3113cf2d117SJohn Scipione if (fTime == NULL) 3123cf2d117SJohn Scipione return; 3133cf2d117SJohn Scipione 3143cf2d117SJohn Scipione fTime->SetShowDayOfWeek(!fTime->ShowDayOfWeek()); 3153cf2d117SJohn Scipione 3163cf2d117SJohn Scipione // time string reformat -> realign 3173cf2d117SJohn Scipione RealignReplicants(); 3183cf2d117SJohn Scipione AdjustPlacement(); 3193cf2d117SJohn Scipione break; 3203cf2d117SJohn Scipione 32141281cf3SAxel Dörfler #ifdef DB_ADDONS 32241281cf3SAxel Dörfler case B_NODE_MONITOR: 32341281cf3SAxel Dörfler HandleEntryUpdate(message); 32441281cf3SAxel Dörfler break; 32541281cf3SAxel Dörfler #endif 32641281cf3SAxel Dörfler 32741281cf3SAxel Dörfler default: 32841281cf3SAxel Dörfler BView::MessageReceived(message); 32941281cf3SAxel Dörfler break; 33041281cf3SAxel Dörfler } 33141281cf3SAxel Dörfler } 33241281cf3SAxel Dörfler 33341281cf3SAxel Dörfler 33441281cf3SAxel Dörfler void 33541281cf3SAxel Dörfler TReplicantTray::MouseDown(BPoint where) 33641281cf3SAxel Dörfler { 33741281cf3SAxel Dörfler #ifdef DB_ADDONS 33841281cf3SAxel Dörfler if (modifiers() & B_CONTROL_KEY) 33941281cf3SAxel Dörfler DumpList(fItemList); 34041281cf3SAxel Dörfler #endif 34141281cf3SAxel Dörfler 34241281cf3SAxel Dörfler uint32 buttons; 34341281cf3SAxel Dörfler 34441281cf3SAxel Dörfler Window()->CurrentMessage()->FindInt32("buttons", (int32*)&buttons); 34541281cf3SAxel Dörfler if (buttons == B_SECONDARY_MOUSE_BUTTON) { 34641281cf3SAxel Dörfler ShowReplicantMenu(where); 34741281cf3SAxel Dörfler } else { 34841281cf3SAxel Dörfler BPoint save = where; 34941281cf3SAxel Dörfler bigtime_t doubleClickSpeed; 35041281cf3SAxel Dörfler bigtime_t start = system_time(); 35141281cf3SAxel Dörfler uint32 buttons; 35241281cf3SAxel Dörfler 35341281cf3SAxel Dörfler get_click_speed(&doubleClickSpeed); 35441281cf3SAxel Dörfler 35541281cf3SAxel Dörfler do { 35641281cf3SAxel Dörfler if (fabs(where.x - save.x) > 4 || fabs(where.y - save.y) > 4) 35741281cf3SAxel Dörfler // user moved out of bounds of click area 35841281cf3SAxel Dörfler break; 35941281cf3SAxel Dörfler 36041281cf3SAxel Dörfler if ((system_time() - start) > (2 * doubleClickSpeed)) { 36141281cf3SAxel Dörfler ShowReplicantMenu(where); 36241281cf3SAxel Dörfler break; 36341281cf3SAxel Dörfler } 36441281cf3SAxel Dörfler 36541281cf3SAxel Dörfler snooze(50000); 36641281cf3SAxel Dörfler GetMouse(&where, &buttons); 36741281cf3SAxel Dörfler } while (buttons); 36841281cf3SAxel Dörfler } 36941281cf3SAxel Dörfler BView::MouseDown(where); 37041281cf3SAxel Dörfler } 37141281cf3SAxel Dörfler 3723cf2d117SJohn Scipione 3733cf2d117SJohn Scipione void 3743cf2d117SJohn Scipione TReplicantTray::ShowReplicantMenu(BPoint point) 3753cf2d117SJohn Scipione { 3763cf2d117SJohn Scipione BPopUpMenu* menu = new BPopUpMenu("", false, false); 3773cf2d117SJohn Scipione menu->SetFont(be_plain_font); 3783cf2d117SJohn Scipione 3793cf2d117SJohn Scipione // If clock is visible show the extended menu, otherwise show "Show time" 3803cf2d117SJohn Scipione 3813cf2d117SJohn Scipione if (!fTime->IsHidden()) 3823cf2d117SJohn Scipione fTime->ShowTimeOptions(ConvertToScreen(point)); 3833cf2d117SJohn Scipione else { 3843cf2d117SJohn Scipione BMenuItem* item = new BMenuItem(B_TRANSLATE("Show time"), 3853cf2d117SJohn Scipione new BMessage(kShowHideTime)); 3863cf2d117SJohn Scipione menu->AddItem(item); 3873cf2d117SJohn Scipione menu->SetTargetForItems(this); 3883cf2d117SJohn Scipione BPoint where = ConvertToScreen(point); 3893cf2d117SJohn Scipione menu->Go(where, true, true, BRect(where - BPoint(4, 4), 3903cf2d117SJohn Scipione where + BPoint(4, 4)), true); 3913cf2d117SJohn Scipione } 3923cf2d117SJohn Scipione } 3933cf2d117SJohn Scipione 3943cf2d117SJohn Scipione 3953cf2d117SJohn Scipione void 3963cf2d117SJohn Scipione TReplicantTray::SetMultiRow(bool state) 3973cf2d117SJohn Scipione { 3983cf2d117SJohn Scipione fMultiRowMode = state; 3993cf2d117SJohn Scipione } 4003cf2d117SJohn Scipione 4013cf2d117SJohn Scipione 4023cf2d117SJohn Scipione void 4033cf2d117SJohn Scipione TReplicantTray::ShowHideTime() 4043cf2d117SJohn Scipione { 4053cf2d117SJohn Scipione if (fTime == NULL) 4063cf2d117SJohn Scipione return; 4073cf2d117SJohn Scipione 4083cf2d117SJohn Scipione if (fTime->IsHidden()) 4093cf2d117SJohn Scipione fTime->Show(); 4103cf2d117SJohn Scipione else 4113cf2d117SJohn Scipione fTime->Hide(); 4123cf2d117SJohn Scipione 4133cf2d117SJohn Scipione RealignReplicants(); 4143cf2d117SJohn Scipione AdjustPlacement(); 4153cf2d117SJohn Scipione } 4163cf2d117SJohn Scipione 4173cf2d117SJohn Scipione 41841281cf3SAxel Dörfler #ifdef DB_ADDONS 41941281cf3SAxel Dörfler 4203cf2d117SJohn Scipione 42141281cf3SAxel Dörfler void 42241281cf3SAxel Dörfler TReplicantTray::InitAddOnSupport() 42341281cf3SAxel Dörfler { 42441281cf3SAxel Dörfler // list to maintain refs to each rep added/deleted 42541281cf3SAxel Dörfler fItemList = new BList(); 42641281cf3SAxel Dörfler BPath path; 4271ad8c760SFredrik Holmqvist 42841281cf3SAxel Dörfler if (find_directory(B_USER_SETTINGS_DIRECTORY, &path, true) == B_OK) { 4293e6ff860SRene Gollent path.Append(kReplicantSettingsFile); 43041281cf3SAxel Dörfler 43141281cf3SAxel Dörfler BFile file(path.Path(), B_READ_ONLY); 4323e6ff860SRene Gollent if (file.InitCheck() == B_OK) { 4333e6ff860SRene Gollent status_t result; 4343e6ff860SRene Gollent BEntry entry; 4353e6ff860SRene Gollent int32 id; 436c0ad1c91SRene Gollent BString path; 4373e6ff860SRene Gollent if (fAddOnSettings.Unflatten(&file) == B_OK) { 438c0ad1c91SRene Gollent for (int32 i = 0; fAddOnSettings.FindString(kReplicantPathField, 439c0ad1c91SRene Gollent i, &path) == B_OK; i++) { 440c0ad1c91SRene Gollent if (entry.SetTo(path.String()) == B_OK && entry.Exists()) { 4413e6ff860SRene Gollent result = LoadAddOn(&entry, &id, false); 4423e6ff860SRene Gollent } else 4433e6ff860SRene Gollent result = B_ENTRY_NOT_FOUND; 44441281cf3SAxel Dörfler 4453e6ff860SRene Gollent if (result != B_OK) { 446c0ad1c91SRene Gollent fAddOnSettings.RemoveData(kReplicantPathField, i); 4473e6ff860SRene Gollent --i; 44841281cf3SAxel Dörfler } 44941281cf3SAxel Dörfler } 45041281cf3SAxel Dörfler } 4513e6ff860SRene Gollent } 4523e6ff860SRene Gollent } 45341281cf3SAxel Dörfler } 45441281cf3SAxel Dörfler 45541281cf3SAxel Dörfler 45641281cf3SAxel Dörfler void 45741281cf3SAxel Dörfler TReplicantTray::DeleteAddOnSupport() 45841281cf3SAxel Dörfler { 4597625ce51SRene Gollent _SaveSettings(); 4603e6ff860SRene Gollent 46141281cf3SAxel Dörfler for (int32 i = fItemList->CountItems(); i-- > 0 ;) { 46241281cf3SAxel Dörfler DeskbarItemInfo* item = (DeskbarItemInfo*)fItemList->RemoveItem(i); 46341281cf3SAxel Dörfler if (item) { 46441281cf3SAxel Dörfler if (item->isAddOn) 46541281cf3SAxel Dörfler watch_node(&(item->nodeRef), B_STOP_WATCHING, this, Window()); 46641281cf3SAxel Dörfler 46741281cf3SAxel Dörfler delete item; 46841281cf3SAxel Dörfler } 46941281cf3SAxel Dörfler } 47041281cf3SAxel Dörfler delete fItemList; 47141281cf3SAxel Dörfler 47241281cf3SAxel Dörfler // stop the volume mount/unmount watch 47341281cf3SAxel Dörfler stop_watching(this, Window()); 47441281cf3SAxel Dörfler } 47541281cf3SAxel Dörfler 47641281cf3SAxel Dörfler 47741281cf3SAxel Dörfler DeskbarItemInfo* 47841281cf3SAxel Dörfler TReplicantTray::DeskbarItemFor(node_ref& nodeRef) 47941281cf3SAxel Dörfler { 48041281cf3SAxel Dörfler for (int32 i = fItemList->CountItems(); i-- > 0 ;) { 48166eba86fSAxel Dörfler DeskbarItemInfo* item = (DeskbarItemInfo*)fItemList->ItemAt(i); 48241281cf3SAxel Dörfler if (item == NULL) 48341281cf3SAxel Dörfler continue; 48441281cf3SAxel Dörfler 48541281cf3SAxel Dörfler if (item->nodeRef == nodeRef) 48641281cf3SAxel Dörfler return item; 48741281cf3SAxel Dörfler } 48841281cf3SAxel Dörfler 48941281cf3SAxel Dörfler return NULL; 49041281cf3SAxel Dörfler } 49141281cf3SAxel Dörfler 49241281cf3SAxel Dörfler 49341281cf3SAxel Dörfler DeskbarItemInfo* 49441281cf3SAxel Dörfler TReplicantTray::DeskbarItemFor(int32 id) 49541281cf3SAxel Dörfler { 49641281cf3SAxel Dörfler for (int32 i = fItemList->CountItems(); i-- > 0 ;) { 49766eba86fSAxel Dörfler DeskbarItemInfo* item = (DeskbarItemInfo*)fItemList->ItemAt(i); 49841281cf3SAxel Dörfler if (item == NULL) 49941281cf3SAxel Dörfler continue; 50041281cf3SAxel Dörfler 50141281cf3SAxel Dörfler if (item->id == id) 50241281cf3SAxel Dörfler return item; 50341281cf3SAxel Dörfler } 50441281cf3SAxel Dörfler 50541281cf3SAxel Dörfler return NULL; 50641281cf3SAxel Dörfler } 50741281cf3SAxel Dörfler 50841281cf3SAxel Dörfler 50941281cf3SAxel Dörfler bool 51041281cf3SAxel Dörfler TReplicantTray::NodeExists(node_ref& nodeRef) 51141281cf3SAxel Dörfler { 51241281cf3SAxel Dörfler return DeskbarItemFor(nodeRef) != NULL; 51341281cf3SAxel Dörfler } 51441281cf3SAxel Dörfler 51541281cf3SAxel Dörfler 51666eba86fSAxel Dörfler /*! This handles B_NODE_MONITOR & B_QUERY_UPDATE messages received 51766eba86fSAxel Dörfler for the registered add-ons. 51841281cf3SAxel Dörfler */ 51941281cf3SAxel Dörfler void 52041281cf3SAxel Dörfler TReplicantTray::HandleEntryUpdate(BMessage* message) 52141281cf3SAxel Dörfler { 52241281cf3SAxel Dörfler int32 opcode; 52341281cf3SAxel Dörfler if (message->FindInt32("opcode", &opcode) != B_OK) 52441281cf3SAxel Dörfler return; 52541281cf3SAxel Dörfler 52641281cf3SAxel Dörfler BPath path; 52741281cf3SAxel Dörfler switch (opcode) { 52841281cf3SAxel Dörfler case B_ENTRY_MOVED: 52941281cf3SAxel Dörfler { 53041281cf3SAxel Dörfler entry_ref ref; 53141281cf3SAxel Dörfler ino_t todirectory; 53241281cf3SAxel Dörfler ino_t node; 53341281cf3SAxel Dörfler const char* name; 53441281cf3SAxel Dörfler if (message->FindString("name", &name) == B_OK 53571bd3ba5SJonas Sundström && message->FindInt64("from directory", &(ref.directory)) 53671bd3ba5SJonas Sundström == B_OK 53741281cf3SAxel Dörfler && message->FindInt64("to directory", &todirectory) == B_OK 53841281cf3SAxel Dörfler && message->FindInt32("device", &(ref.device)) == B_OK 53941281cf3SAxel Dörfler && message->FindInt64("node", &node) == B_OK ) { 54041281cf3SAxel Dörfler 54141281cf3SAxel Dörfler if (!name) 54241281cf3SAxel Dörfler break; 54341281cf3SAxel Dörfler 54441281cf3SAxel Dörfler ref.set_name(name); 54541281cf3SAxel Dörfler // change the directory reference to 54641281cf3SAxel Dörfler // the new directory 54741281cf3SAxel Dörfler MoveItem(&ref, todirectory); 54841281cf3SAxel Dörfler } 54941281cf3SAxel Dörfler break; 55066eba86fSAxel Dörfler } 55141281cf3SAxel Dörfler 55241281cf3SAxel Dörfler case B_ENTRY_REMOVED: 55341281cf3SAxel Dörfler { 55441281cf3SAxel Dörfler // entry was rm'd from the device 55541281cf3SAxel Dörfler node_ref nodeRef; 55641281cf3SAxel Dörfler if (message->FindInt32("device", &(nodeRef.device)) == B_OK 55741281cf3SAxel Dörfler && message->FindInt64("node", &(nodeRef.node)) == B_OK) { 55841281cf3SAxel Dörfler DeskbarItemInfo* item = DeskbarItemFor(nodeRef); 55941281cf3SAxel Dörfler if (item == NULL) 56041281cf3SAxel Dörfler break; 56141281cf3SAxel Dörfler 56241281cf3SAxel Dörfler // If there is a team running where the add-on comes from, 56341281cf3SAxel Dörfler // we don't want to remove the icon yet. 56441281cf3SAxel Dörfler if (be_roster->IsRunning(&item->entryRef)) 56541281cf3SAxel Dörfler break; 56641281cf3SAxel Dörfler 56741281cf3SAxel Dörfler UnloadAddOn(&nodeRef, NULL, true, false); 56841281cf3SAxel Dörfler } 56941281cf3SAxel Dörfler break; 57066eba86fSAxel Dörfler } 57141281cf3SAxel Dörfler } 57266eba86fSAxel Dörfler } 57341281cf3SAxel Dörfler 57441281cf3SAxel Dörfler 5751ad8c760SFredrik Holmqvist /*! The add-ons must support the exported C function API 57666eba86fSAxel Dörfler if they do, they will be loaded and added to deskbar 57766eba86fSAxel Dörfler primary function is the Instantiate function 5787da06231SAxel Dörfler */ 57941281cf3SAxel Dörfler status_t 5803e6ff860SRene Gollent TReplicantTray::LoadAddOn(BEntry* entry, int32* id, bool addToSettings) 58141281cf3SAxel Dörfler { 58241281cf3SAxel Dörfler if (!entry) 58341281cf3SAxel Dörfler return B_ERROR; 58441281cf3SAxel Dörfler 58541281cf3SAxel Dörfler node_ref nodeRef; 58641281cf3SAxel Dörfler entry->GetNodeRef(&nodeRef); 58741281cf3SAxel Dörfler // no duplicates 58841281cf3SAxel Dörfler if (NodeExists(nodeRef)) 58941281cf3SAxel Dörfler return B_ERROR; 59041281cf3SAxel Dörfler 59141281cf3SAxel Dörfler BNode node(entry); 59241281cf3SAxel Dörfler BPath path; 59366eba86fSAxel Dörfler status_t status = entry->GetPath(&path); 59466eba86fSAxel Dörfler if (status < B_OK) 59566eba86fSAxel Dörfler return status; 59641281cf3SAxel Dörfler 59741281cf3SAxel Dörfler // load the add-on 59841281cf3SAxel Dörfler image_id image = load_add_on(path.Path()); 59966eba86fSAxel Dörfler if (image < B_OK) 60066eba86fSAxel Dörfler return image; 60141281cf3SAxel Dörfler 60241281cf3SAxel Dörfler // get the view loading function symbol 60341281cf3SAxel Dörfler // we first look for a symbol that takes an image_id 60441281cf3SAxel Dörfler // and entry_ref pointer, if not found, go with normal 60541281cf3SAxel Dörfler // instantiate function 60641281cf3SAxel Dörfler BView* (*entryFunction)(image_id, const entry_ref*); 60741281cf3SAxel Dörfler BView* (*itemFunction)(void); 60841281cf3SAxel Dörfler BView* view = NULL; 60941281cf3SAxel Dörfler 61041281cf3SAxel Dörfler entry_ref ref; 61141281cf3SAxel Dörfler entry->GetRef(&ref); 61241281cf3SAxel Dörfler 61341281cf3SAxel Dörfler if (get_image_symbol(image, kInstantiateEntryCFunctionName, 61466eba86fSAxel Dörfler B_SYMBOL_TYPE_TEXT, (void**)&entryFunction) >= B_OK) { 61541281cf3SAxel Dörfler view = (*entryFunction)(image, &ref); 61641281cf3SAxel Dörfler } else if (get_image_symbol(image, kInstantiateItemCFunctionName, 61766eba86fSAxel Dörfler B_SYMBOL_TYPE_TEXT, (void**)&itemFunction) >= B_OK) { 61841281cf3SAxel Dörfler view = (*itemFunction)(); 61941281cf3SAxel Dörfler } else { 62041281cf3SAxel Dörfler unload_add_on(image); 62141281cf3SAxel Dörfler return B_ERROR; 62241281cf3SAxel Dörfler } 62341281cf3SAxel Dörfler 62466eba86fSAxel Dörfler if (view == NULL || IconExists(view->Name())) { 62541281cf3SAxel Dörfler delete view; 62641281cf3SAxel Dörfler unload_add_on(image); 62741281cf3SAxel Dörfler return B_ERROR; 62841281cf3SAxel Dörfler } 62941281cf3SAxel Dörfler 63041281cf3SAxel Dörfler BMessage* data = new BMessage; 63141281cf3SAxel Dörfler view->Archive(data); 63241281cf3SAxel Dörfler delete view; 63341281cf3SAxel Dörfler 63441281cf3SAxel Dörfler AddIcon(data, id, &ref); 63541281cf3SAxel Dörfler // add the rep; adds info to list 63641281cf3SAxel Dörfler 6373e6ff860SRene Gollent if (addToSettings) { 638c0ad1c91SRene Gollent fAddOnSettings.AddString(kReplicantPathField, path.Path()); 6397625ce51SRene Gollent _SaveSettings(); 6403e6ff860SRene Gollent } 64141281cf3SAxel Dörfler 64241281cf3SAxel Dörfler return B_OK; 64341281cf3SAxel Dörfler } 64441281cf3SAxel Dörfler 64541281cf3SAxel Dörfler 64641281cf3SAxel Dörfler status_t 64741281cf3SAxel Dörfler TReplicantTray::AddItem(int32 id, node_ref nodeRef, BEntry& entry, bool isAddOn) 64841281cf3SAxel Dörfler { 64941281cf3SAxel Dörfler DeskbarItemInfo* item = new DeskbarItemInfo; 65041281cf3SAxel Dörfler if (item == NULL) 65141281cf3SAxel Dörfler return B_NO_MEMORY; 65241281cf3SAxel Dörfler 65341281cf3SAxel Dörfler item->id = id; 65441281cf3SAxel Dörfler item->isAddOn = isAddOn; 65541281cf3SAxel Dörfler 65641281cf3SAxel Dörfler if (entry.GetRef(&item->entryRef) < B_OK) { 65741281cf3SAxel Dörfler item->entryRef.device = -1; 65841281cf3SAxel Dörfler item->entryRef.directory = -1; 65941281cf3SAxel Dörfler item->entryRef.name = NULL; 66041281cf3SAxel Dörfler } 66141281cf3SAxel Dörfler item->nodeRef = nodeRef; 66241281cf3SAxel Dörfler 66341281cf3SAxel Dörfler fItemList->AddItem(item); 66441281cf3SAxel Dörfler 66541281cf3SAxel Dörfler if (isAddOn) 66641281cf3SAxel Dörfler watch_node(&nodeRef, B_WATCH_NAME | B_WATCH_ATTR, this, Window()); 66741281cf3SAxel Dörfler 66841281cf3SAxel Dörfler return B_OK; 66941281cf3SAxel Dörfler } 67041281cf3SAxel Dörfler 67141281cf3SAxel Dörfler 67241281cf3SAxel Dörfler /** from entry_removed message, when attribute removed 67341281cf3SAxel Dörfler * or when a device is unmounted (use removeall, by device) 67441281cf3SAxel Dörfler */ 67541281cf3SAxel Dörfler 67641281cf3SAxel Dörfler void 67741281cf3SAxel Dörfler TReplicantTray::UnloadAddOn(node_ref* nodeRef, dev_t* device, 67841281cf3SAxel Dörfler bool which, bool removeAll) 67941281cf3SAxel Dörfler { 68041281cf3SAxel Dörfler for (int32 i = fItemList->CountItems(); i-- > 0 ;) { 68141281cf3SAxel Dörfler DeskbarItemInfo* item = (DeskbarItemInfo*)fItemList->ItemAt(i); 68241281cf3SAxel Dörfler if (!item) 68341281cf3SAxel Dörfler continue; 68441281cf3SAxel Dörfler 68541281cf3SAxel Dörfler if ((which && nodeRef && item->nodeRef == *nodeRef) 68641281cf3SAxel Dörfler || (device && item->nodeRef.device == *device)) { 68741281cf3SAxel Dörfler 68841281cf3SAxel Dörfler if (device && be_roster->IsRunning(&item->entryRef)) 68941281cf3SAxel Dörfler continue; 69041281cf3SAxel Dörfler 69141281cf3SAxel Dörfler RemoveIcon(item->id); 69241281cf3SAxel Dörfler 69341281cf3SAxel Dörfler if (!removeAll) 69441281cf3SAxel Dörfler break; 69541281cf3SAxel Dörfler } 69641281cf3SAxel Dörfler } 69741281cf3SAxel Dörfler } 69841281cf3SAxel Dörfler 69941281cf3SAxel Dörfler 70041281cf3SAxel Dörfler void 70141281cf3SAxel Dörfler TReplicantTray::RemoveItem(int32 id) 70241281cf3SAxel Dörfler { 70341281cf3SAxel Dörfler DeskbarItemInfo* item = DeskbarItemFor(id); 70441281cf3SAxel Dörfler if (item == NULL) 70541281cf3SAxel Dörfler return; 70641281cf3SAxel Dörfler 70741281cf3SAxel Dörfler // attribute was added via Deskbar API (AddItem(entry_ref*, int32*) 70841281cf3SAxel Dörfler if (item->isAddOn) { 7097625ce51SRene Gollent BPath path(&item->entryRef); 7107625ce51SRene Gollent BString storedPath; 7117625ce51SRene Gollent for (int32 i = 0; 7128aab28f1SRene Gollent fAddOnSettings.FindString(kReplicantPathField, i, &storedPath) 7137625ce51SRene Gollent == B_OK; i++) { 7147625ce51SRene Gollent if (storedPath == path.Path()) { 7158aab28f1SRene Gollent fAddOnSettings.RemoveData(kReplicantPathField, i); 7167625ce51SRene Gollent break; 7177625ce51SRene Gollent } 7187625ce51SRene Gollent } 7197625ce51SRene Gollent _SaveSettings(); 7207625ce51SRene Gollent 72141281cf3SAxel Dörfler BNode node(&item->entryRef); 72241281cf3SAxel Dörfler watch_node(&item->nodeRef, B_STOP_WATCHING, this, Window()); 72341281cf3SAxel Dörfler } 72441281cf3SAxel Dörfler 72541281cf3SAxel Dörfler fItemList->RemoveItem(item); 72641281cf3SAxel Dörfler delete item; 72741281cf3SAxel Dörfler } 72841281cf3SAxel Dörfler 72941281cf3SAxel Dörfler 73041281cf3SAxel Dörfler /** ENTRY_MOVED message, moving only occurs on a device 73141281cf3SAxel Dörfler * copying will occur (ENTRY_CREATED) between devices 73241281cf3SAxel Dörfler */ 73341281cf3SAxel Dörfler 73441281cf3SAxel Dörfler void 73541281cf3SAxel Dörfler TReplicantTray::MoveItem(entry_ref* ref, ino_t toDirectory) 73641281cf3SAxel Dörfler { 73741281cf3SAxel Dörfler if (!ref) 73841281cf3SAxel Dörfler return; 73941281cf3SAxel Dörfler 74041281cf3SAxel Dörfler // scan for a matching entry_ref and update it 74141281cf3SAxel Dörfler // 74241281cf3SAxel Dörfler // don't need to change node info as it does not change 74341281cf3SAxel Dörfler 74441281cf3SAxel Dörfler for (int32 i = fItemList->CountItems(); i-- > 0 ;) { 74541281cf3SAxel Dörfler DeskbarItemInfo* item = (DeskbarItemInfo*)fItemList->ItemAt(i); 74641281cf3SAxel Dörfler if (!item) 74741281cf3SAxel Dörfler continue; 74841281cf3SAxel Dörfler 74941281cf3SAxel Dörfler if (!strcmp(item->entryRef.name, ref->name) 75041281cf3SAxel Dörfler && item->entryRef.device == ref->device 75141281cf3SAxel Dörfler && item->entryRef.directory == ref->directory) { 75241281cf3SAxel Dörfler item->entryRef.directory = toDirectory; 75341281cf3SAxel Dörfler break; 75441281cf3SAxel Dörfler } 75541281cf3SAxel Dörfler } 75641281cf3SAxel Dörfler } 75741281cf3SAxel Dörfler 75841281cf3SAxel Dörfler #endif // add-on support 75941281cf3SAxel Dörfler 76041281cf3SAxel Dörfler // external add-on API routines 76141281cf3SAxel Dörfler // called using the new BDeskbar class 76241281cf3SAxel Dörfler 76341281cf3SAxel Dörfler // existence of icon/replicant by name or ID 76441281cf3SAxel Dörfler // returns opposite 76541281cf3SAxel Dörfler // note: name and id are semi-private limiting 76641281cf3SAxel Dörfler // the ability of non-host apps to remove 76741281cf3SAxel Dörfler // icons without a little bit of work 76841281cf3SAxel Dörfler 76941281cf3SAxel Dörfler /** for a specific id 77041281cf3SAxel Dörfler * return the name of the replicant (name of view) 77141281cf3SAxel Dörfler */ 77241281cf3SAxel Dörfler 77341281cf3SAxel Dörfler status_t 77441281cf3SAxel Dörfler TReplicantTray::ItemInfo(int32 id, const char** name) 77541281cf3SAxel Dörfler { 77641281cf3SAxel Dörfler if (id < 0) 77741281cf3SAxel Dörfler return B_ERROR; 77841281cf3SAxel Dörfler 77941281cf3SAxel Dörfler int32 index, temp; 78041281cf3SAxel Dörfler BView* view = ViewAt(&index, &temp, id, false); 78141281cf3SAxel Dörfler if (view) { 78241281cf3SAxel Dörfler *name = view->Name(); 78341281cf3SAxel Dörfler return B_OK; 78441281cf3SAxel Dörfler } 78541281cf3SAxel Dörfler 78641281cf3SAxel Dörfler return B_ERROR; 78741281cf3SAxel Dörfler } 78841281cf3SAxel Dörfler 78941281cf3SAxel Dörfler 7907da06231SAxel Dörfler /** for a specific name 7917da06231SAxel Dörfler * return the id (internal to Deskbar) 7927da06231SAxel Dörfler */ 7937da06231SAxel Dörfler 79441281cf3SAxel Dörfler status_t 79541281cf3SAxel Dörfler TReplicantTray::ItemInfo(const char* name, int32* id) 79641281cf3SAxel Dörfler { 79741281cf3SAxel Dörfler if (!name || strlen(name) <= 0) 79841281cf3SAxel Dörfler return B_ERROR; 79941281cf3SAxel Dörfler 80041281cf3SAxel Dörfler int32 index; 80141281cf3SAxel Dörfler BView* view = ViewAt(&index, id, name); 80241281cf3SAxel Dörfler if (view) 80341281cf3SAxel Dörfler return B_OK; 80441281cf3SAxel Dörfler 80541281cf3SAxel Dörfler return B_ERROR; 80641281cf3SAxel Dörfler } 80741281cf3SAxel Dörfler 80841281cf3SAxel Dörfler 8097da06231SAxel Dörfler /** at a specific index 8107da06231SAxel Dörfler * return both the name and the id of the replicant 8117da06231SAxel Dörfler */ 8127da06231SAxel Dörfler 81341281cf3SAxel Dörfler status_t 81441281cf3SAxel Dörfler TReplicantTray::ItemInfo(int32 index, const char** name, int32* id) 81541281cf3SAxel Dörfler { 81641281cf3SAxel Dörfler if (index < 0) 81741281cf3SAxel Dörfler return B_ERROR; 81841281cf3SAxel Dörfler 81941281cf3SAxel Dörfler BView* view; 82041281cf3SAxel Dörfler fShelf->ReplicantAt(index, &view, (uint32*)id, NULL); 82141281cf3SAxel Dörfler if (view) { 82241281cf3SAxel Dörfler *name = view->Name(); 82341281cf3SAxel Dörfler return B_OK; 82441281cf3SAxel Dörfler } 82541281cf3SAxel Dörfler 82641281cf3SAxel Dörfler return B_ERROR; 82741281cf3SAxel Dörfler } 82841281cf3SAxel Dörfler 82941281cf3SAxel Dörfler 8307da06231SAxel Dörfler /** replicant exists, by id/index */ 8317da06231SAxel Dörfler 83241281cf3SAxel Dörfler bool 83341281cf3SAxel Dörfler TReplicantTray::IconExists(int32 target, bool byIndex) 83441281cf3SAxel Dörfler { 83541281cf3SAxel Dörfler int32 index, id; 83641281cf3SAxel Dörfler BView* view = ViewAt(&index, &id, target, byIndex); 83741281cf3SAxel Dörfler 83841281cf3SAxel Dörfler return view && index >= 0; 83941281cf3SAxel Dörfler } 84041281cf3SAxel Dörfler 84141281cf3SAxel Dörfler 8427da06231SAxel Dörfler /** replicant exists, by name */ 8437da06231SAxel Dörfler 84441281cf3SAxel Dörfler bool 84541281cf3SAxel Dörfler TReplicantTray::IconExists(const char* name) 84641281cf3SAxel Dörfler { 84741281cf3SAxel Dörfler if (!name || strlen(name) == 0) 84841281cf3SAxel Dörfler return false; 84941281cf3SAxel Dörfler 85041281cf3SAxel Dörfler int32 index, id; 85141281cf3SAxel Dörfler BView* view = ViewAt(&index, &id, name); 85241281cf3SAxel Dörfler 85341281cf3SAxel Dörfler return view && index >= 0; 85441281cf3SAxel Dörfler } 85541281cf3SAxel Dörfler 85641281cf3SAxel Dörfler 85741281cf3SAxel Dörfler int32 85841281cf3SAxel Dörfler TReplicantTray::IconCount() const 85941281cf3SAxel Dörfler { 86041281cf3SAxel Dörfler return fShelf->CountReplicants(); 86141281cf3SAxel Dörfler } 86241281cf3SAxel Dörfler 86341281cf3SAxel Dörfler 864ced3755cSAxel Dörfler /*! Message must contain an archivable view for later rehydration. 865ced3755cSAxel Dörfler This function takes over ownership of the provided message on success 866ced3755cSAxel Dörfler only. 867ced3755cSAxel Dörfler Returns the current replicant ID. 8687da06231SAxel Dörfler */ 86941281cf3SAxel Dörfler status_t 870ced3755cSAxel Dörfler TReplicantTray::AddIcon(BMessage* archive, int32* id, const entry_ref* addOn) 87141281cf3SAxel Dörfler { 872ced3755cSAxel Dörfler if (archive == NULL || id == NULL) 87341281cf3SAxel Dörfler return B_ERROR; 87441281cf3SAxel Dörfler 8759c50f36eSAxel Dörfler // find entry_ref 8769c50f36eSAxel Dörfler 8779c50f36eSAxel Dörfler entry_ref ref; 8789c50f36eSAxel Dörfler if (addOn) { 8799c50f36eSAxel Dörfler // Use it if we got it 8809c50f36eSAxel Dörfler ref = *addOn; 8819c50f36eSAxel Dörfler } else { 8829c50f36eSAxel Dörfler const char* signature; 8831ad8c760SFredrik Holmqvist 884ced3755cSAxel Dörfler status_t status = archive->FindString("add_on", &signature); 8859c50f36eSAxel Dörfler if (status == B_OK) { 8869c50f36eSAxel Dörfler BRoster roster; 8879c50f36eSAxel Dörfler status = roster.FindApp(signature, &ref); 8889c50f36eSAxel Dörfler } 8899c50f36eSAxel Dörfler if (status < B_OK) 8909c50f36eSAxel Dörfler return status; 8919c50f36eSAxel Dörfler } 8929c50f36eSAxel Dörfler 8939c50f36eSAxel Dörfler BFile file; 8949c50f36eSAxel Dörfler status_t status = file.SetTo(&ref, B_READ_ONLY); 8959c50f36eSAxel Dörfler if (status < B_OK) 8969c50f36eSAxel Dörfler return status; 8979c50f36eSAxel Dörfler 8989c50f36eSAxel Dörfler node_ref nodeRef; 8999c50f36eSAxel Dörfler status = file.GetNodeRef(&nodeRef); 9009c50f36eSAxel Dörfler if (status < B_OK) 9019c50f36eSAxel Dörfler return status; 9029c50f36eSAxel Dörfler 9039c50f36eSAxel Dörfler BEntry entry(&ref, true); 9041ad8c760SFredrik Holmqvist // TODO: this resolves an eventual link for the item being added - this 9051ad8c760SFredrik Holmqvist // is okay for now, but in multi-user environments, one might want to 9061ad8c760SFredrik Holmqvist // have links that carry the be:deskbar_item_status attribute 9079c50f36eSAxel Dörfler status = entry.InitCheck(); 9089c50f36eSAxel Dörfler if (status != B_OK) 9099c50f36eSAxel Dörfler return status; 9109c50f36eSAxel Dörfler 91141281cf3SAxel Dörfler *id = 999; 912ced3755cSAxel Dörfler if (archive->what == B_ARCHIVED_OBJECT) 913ced3755cSAxel Dörfler archive->what = 0; 91441281cf3SAxel Dörfler 915ced3755cSAxel Dörfler BRect originalBounds = archive->FindRect("_frame"); 9161ad8c760SFredrik Holmqvist // this is a work-around for buggy replicants that change their size in 9171ad8c760SFredrik Holmqvist // AttachedToWindow() (such as "SVM") 918a5210ab1SAxel Dörfler 9191ad8c760SFredrik Holmqvist // TODO: check for name collisions? 920ced3755cSAxel Dörfler status = fShelf->AddReplicant(archive, BPoint(1, 1)); 9219c50f36eSAxel Dörfler if (status != B_OK) 9229c50f36eSAxel Dörfler return status; 92341281cf3SAxel Dörfler 924a5210ab1SAxel Dörfler int32 count = fShelf->CountReplicants(); 925a5210ab1SAxel Dörfler BView* view; 926a5210ab1SAxel Dörfler fShelf->ReplicantAt(count - 1, &view, (uint32*)id, NULL); 927a5210ab1SAxel Dörfler 928a5210ab1SAxel Dörfler if (originalBounds != view->Bounds()) { 929a5210ab1SAxel Dörfler // The replicant changed its size when added to the window, so we need 93071bd3ba5SJonas Sundström // to recompute all over again (it's already done once via 93171bd3ba5SJonas Sundström // BShelf::AddReplicant() and TReplicantShelf::CanAcceptReplicantView()) 932a5210ab1SAxel Dörfler RealignReplicants(); 933a5210ab1SAxel Dörfler } 934a5210ab1SAxel Dörfler 93541281cf3SAxel Dörfler float oldWidth = Bounds().Width(); 93641281cf3SAxel Dörfler float oldHeight = Bounds().Height(); 93741281cf3SAxel Dörfler float width, height; 93841281cf3SAxel Dörfler GetPreferredSize(&width, &height); 93941281cf3SAxel Dörfler if (oldWidth != width || oldHeight != height) 94041281cf3SAxel Dörfler AdjustPlacement(); 94141281cf3SAxel Dörfler 94241281cf3SAxel Dörfler // add the item to the add-on list 94341281cf3SAxel Dörfler 94441281cf3SAxel Dörfler AddItem(*id, nodeRef, entry, addOn != NULL); 94541281cf3SAxel Dörfler return B_OK; 94641281cf3SAxel Dörfler } 94741281cf3SAxel Dörfler 94841281cf3SAxel Dörfler 94941281cf3SAxel Dörfler void 95041281cf3SAxel Dörfler TReplicantTray::RemoveIcon(int32 target, bool byIndex) 95141281cf3SAxel Dörfler { 95241281cf3SAxel Dörfler if (target < 0) 95341281cf3SAxel Dörfler return; 95441281cf3SAxel Dörfler 95541281cf3SAxel Dörfler int32 index, id; 95641281cf3SAxel Dörfler BView* view = ViewAt(&index, &id, target, byIndex); 95741281cf3SAxel Dörfler if (view && index >= 0) { 9587da06231SAxel Dörfler // remove the reference from the item list & the shelf 95941281cf3SAxel Dörfler RemoveItem(id); 96041281cf3SAxel Dörfler fShelf->DeleteReplicant(index); 9617da06231SAxel Dörfler 96241281cf3SAxel Dörfler // force a placement update, !! need to fix BShelf 96341281cf3SAxel Dörfler RealReplicantAdjustment(index); 96441281cf3SAxel Dörfler } 96541281cf3SAxel Dörfler } 96641281cf3SAxel Dörfler 96741281cf3SAxel Dörfler 96841281cf3SAxel Dörfler void 96941281cf3SAxel Dörfler TReplicantTray::RemoveIcon(const char* name) 97041281cf3SAxel Dörfler { 97141281cf3SAxel Dörfler if (!name || strlen(name) <= 0) 97241281cf3SAxel Dörfler return; 97341281cf3SAxel Dörfler 97441281cf3SAxel Dörfler int32 id, index; 97541281cf3SAxel Dörfler BView* view = ViewAt(&index, &id, name); 97641281cf3SAxel Dörfler if (view && index >= 0) { 9777da06231SAxel Dörfler // remove the reference from the item list & shelf 97841281cf3SAxel Dörfler RemoveItem(id); 97941281cf3SAxel Dörfler fShelf->DeleteReplicant(index); 9807da06231SAxel Dörfler 98141281cf3SAxel Dörfler // force a placement update, !! need to fix BShelf 98241281cf3SAxel Dörfler RealReplicantAdjustment(index); 98341281cf3SAxel Dörfler } 98441281cf3SAxel Dörfler } 98541281cf3SAxel Dörfler 98641281cf3SAxel Dörfler 98741281cf3SAxel Dörfler void 9887da06231SAxel Dörfler TReplicantTray::RealReplicantAdjustment(int32 startIndex) 98941281cf3SAxel Dörfler { 9907da06231SAxel Dörfler if (startIndex < 0) 99141281cf3SAxel Dörfler return; 9927da06231SAxel Dörfler 9937da06231SAxel Dörfler if (startIndex == fLastReplicant) 9947da06231SAxel Dörfler startIndex = 0; 9957da06231SAxel Dörfler 99641281cf3SAxel Dörfler // reset the locations of all replicants after the one deleted 9977da06231SAxel Dörfler RealignReplicants(startIndex); 99841281cf3SAxel Dörfler 99941281cf3SAxel Dörfler float oldWidth = Bounds().Width(); 100041281cf3SAxel Dörfler float oldHeight = Bounds().Height(); 100141281cf3SAxel Dörfler float width, height; 100241281cf3SAxel Dörfler GetPreferredSize(&width, &height); 100341281cf3SAxel Dörfler if (oldWidth != width || oldHeight != height) { 10041ad8c760SFredrik Holmqvist // resize view to accomodate the replicants, redraw as necessary 100541281cf3SAxel Dörfler AdjustPlacement(); 100641281cf3SAxel Dörfler } 100741281cf3SAxel Dörfler } 100841281cf3SAxel Dörfler 100941281cf3SAxel Dörfler 10107da06231SAxel Dörfler /** looking for a replicant by id/index 10117da06231SAxel Dörfler * return the view and index 10127da06231SAxel Dörfler */ 10137da06231SAxel Dörfler 101441281cf3SAxel Dörfler BView* 101541281cf3SAxel Dörfler TReplicantTray::ViewAt(int32* index, int32* id, int32 target, bool byIndex) 101641281cf3SAxel Dörfler { 101741281cf3SAxel Dörfler *index = -1; 101841281cf3SAxel Dörfler 101941281cf3SAxel Dörfler BView* view; 102041281cf3SAxel Dörfler if (byIndex) { 102141281cf3SAxel Dörfler if (fShelf->ReplicantAt(target, &view, (uint32*)id)) { 102241281cf3SAxel Dörfler if (view) { 102341281cf3SAxel Dörfler *index = target; 102441281cf3SAxel Dörfler return view; 102541281cf3SAxel Dörfler } 102641281cf3SAxel Dörfler } 102741281cf3SAxel Dörfler } else { 102841281cf3SAxel Dörfler int32 count = fShelf->CountReplicants() - 1; 102941281cf3SAxel Dörfler int32 localid; 103041281cf3SAxel Dörfler for (int32 repIndex = count ; repIndex >= 0 ; repIndex--) { 103141281cf3SAxel Dörfler fShelf->ReplicantAt(repIndex, &view, (uint32*)&localid); 103241281cf3SAxel Dörfler if (localid == target && view) { 103341281cf3SAxel Dörfler *index = repIndex; 103441281cf3SAxel Dörfler *id = localid; 103541281cf3SAxel Dörfler return view; 103641281cf3SAxel Dörfler } 103741281cf3SAxel Dörfler } 103841281cf3SAxel Dörfler } 103941281cf3SAxel Dörfler return NULL; 104041281cf3SAxel Dörfler } 104141281cf3SAxel Dörfler 104241281cf3SAxel Dörfler 10437da06231SAxel Dörfler /** looking for a replicant with a view by name 10447da06231SAxel Dörfler * return the view, index and the id of the replicant 10457da06231SAxel Dörfler */ 10467da06231SAxel Dörfler 104741281cf3SAxel Dörfler BView* 104841281cf3SAxel Dörfler TReplicantTray::ViewAt(int32* index, int32* id, const char* name) 104941281cf3SAxel Dörfler { 105041281cf3SAxel Dörfler *index = -1; 105141281cf3SAxel Dörfler *id = -1; 105241281cf3SAxel Dörfler 105341281cf3SAxel Dörfler BView* view; 105441281cf3SAxel Dörfler int32 count = fShelf->CountReplicants()-1; 105541281cf3SAxel Dörfler for (int32 repIndex = count ; repIndex >= 0 ; repIndex--) { 105641281cf3SAxel Dörfler fShelf->ReplicantAt(repIndex, &view, (uint32*)id); 105741281cf3SAxel Dörfler if (view && view->Name() && strcmp(name, view->Name()) == 0) { 105841281cf3SAxel Dörfler *index = repIndex; 105941281cf3SAxel Dörfler return view; 106041281cf3SAxel Dörfler } 106141281cf3SAxel Dörfler } 106241281cf3SAxel Dörfler return NULL; 106341281cf3SAxel Dörfler } 106441281cf3SAxel Dörfler 106541281cf3SAxel Dörfler 10667da06231SAxel Dörfler /** Shelf will call to determine where and if 10677da06231SAxel Dörfler * the replicant is to be added 10687da06231SAxel Dörfler */ 10697da06231SAxel Dörfler 107041281cf3SAxel Dörfler bool 107141281cf3SAxel Dörfler TReplicantTray::AcceptAddon(BRect replicantFrame, BMessage* message) 107241281cf3SAxel Dörfler { 107341281cf3SAxel Dörfler if (!message) 107441281cf3SAxel Dörfler return false; 107541281cf3SAxel Dörfler 107641281cf3SAxel Dörfler if (replicantFrame.Height() > kMaxReplicantHeight) 107741281cf3SAxel Dörfler return false; 107841281cf3SAxel Dörfler 107941281cf3SAxel Dörfler alignment align = B_ALIGN_LEFT; 108041281cf3SAxel Dörfler if (fAlignmentSupport && message->HasBool("deskbar:dynamic_align")) { 108141281cf3SAxel Dörfler if (!fBarView->Vertical()) 108241281cf3SAxel Dörfler align = B_ALIGN_RIGHT; 108341281cf3SAxel Dörfler else 108441281cf3SAxel Dörfler align = fBarView->Left() ? B_ALIGN_LEFT : B_ALIGN_RIGHT; 108541281cf3SAxel Dörfler } else if (message->HasInt32("deskbar:align")) 108641281cf3SAxel Dörfler message->FindInt32("deskbar:align", (int32*)&align); 108741281cf3SAxel Dörfler 108841281cf3SAxel Dörfler if (message->HasInt32("deskbar:private_align")) 108941281cf3SAxel Dörfler message->FindInt32("deskbar:private_align", (int32*)&align); 109041281cf3SAxel Dörfler else 109141281cf3SAxel Dörfler align = B_ALIGN_LEFT; 109241281cf3SAxel Dörfler 10937da06231SAxel Dörfler BPoint loc = LocationForReplicant(fShelf->CountReplicants(), 10947da06231SAxel Dörfler replicantFrame.Width()); 109541281cf3SAxel Dörfler 109641281cf3SAxel Dörfler message->AddPoint("_pjp_loc", loc); 109741281cf3SAxel Dörfler return true; 109841281cf3SAxel Dörfler } 109941281cf3SAxel Dörfler 110041281cf3SAxel Dörfler 110141281cf3SAxel Dörfler /** based on the previous (index - 1) replicant in the list 110241281cf3SAxel Dörfler * calculate where the left point should be for this 110341281cf3SAxel Dörfler * replicant. replicant will flow to the right on its own 110441281cf3SAxel Dörfler */ 110541281cf3SAxel Dörfler 110641281cf3SAxel Dörfler BPoint 11077da06231SAxel Dörfler TReplicantTray::LocationForReplicant(int32 index, float width) 110841281cf3SAxel Dörfler { 110941281cf3SAxel Dörfler BPoint loc(kIconGap + 1, kGutter + 1); 111041281cf3SAxel Dörfler 11117da06231SAxel Dörfler if (fMultiRowMode) { 11127da06231SAxel Dörfler // try to find free space in every row 11137da06231SAxel Dörfler for (int32 row = 0; ; loc.y += kMaxReplicantHeight + kIconGap, row++) { 11147da06231SAxel Dörfler // determine free space in this row 11152ce9bab8SJohn Scipione BRect rect(loc.x, loc.y, loc.x + fMinimumTrayWidth - kIconGap 11162ce9bab8SJohn Scipione - 2.0, loc.y + kMaxReplicantHeight); 1117573f748cSJohn Scipione if (row == 0 && !fTime->IsHidden()) 1118573f748cSJohn Scipione rect.right -= fTime->Frame().Width() + kIconGap; 11197da06231SAxel Dörfler 11207da06231SAxel Dörfler for (int32 i = 0; i < index; i++) { 11217da06231SAxel Dörfler BView* view = NULL; 11227da06231SAxel Dörfler fShelf->ReplicantAt(i, &view); 11237da06231SAxel Dörfler if (view == NULL || view->Frame().top != rect.top) 11247da06231SAxel Dörfler continue; 11257da06231SAxel Dörfler 11267da06231SAxel Dörfler rect.left = view->Frame().right + kIconGap + 1; 11277da06231SAxel Dörfler } 11287da06231SAxel Dörfler 11297da06231SAxel Dörfler if (rect.Width() >= width) { 11307da06231SAxel Dörfler // the icon fits in this row 11317da06231SAxel Dörfler loc = rect.LeftTop(); 11327da06231SAxel Dörfler break; 11337da06231SAxel Dörfler } 11347da06231SAxel Dörfler } 11357da06231SAxel Dörfler } else { 113641281cf3SAxel Dörfler if (index > 0) { 113741281cf3SAxel Dörfler // get the last replicant added for placement reference 113841281cf3SAxel Dörfler BView* view = NULL; 11397da06231SAxel Dörfler fShelf->ReplicantAt(index - 1, &view); 114041281cf3SAxel Dörfler if (view) { 114141281cf3SAxel Dörfler // push this rep placement past the last one 114241281cf3SAxel Dörfler loc.x = view->Frame().right + kIconGap + 1; 114341281cf3SAxel Dörfler loc.y = view->Frame().top; 114441281cf3SAxel Dörfler } 114541281cf3SAxel Dörfler } 11467da06231SAxel Dörfler } 114741281cf3SAxel Dörfler 114871bd3ba5SJonas Sundström if ((loc.y == fRightBottomReplicant.top && loc.x 114971bd3ba5SJonas Sundström > fRightBottomReplicant.left) || loc.y > fRightBottomReplicant.top) { 115071bd3ba5SJonas Sundström fRightBottomReplicant.Set(loc.x, loc.y, loc.x + width, loc.y 115171bd3ba5SJonas Sundström + kMaxReplicantHeight); 11527da06231SAxel Dörfler fLastReplicant = index; 115341281cf3SAxel Dörfler } 11547da06231SAxel Dörfler 115541281cf3SAxel Dörfler return loc; 115641281cf3SAxel Dörfler } 115741281cf3SAxel Dörfler 115841281cf3SAxel Dörfler 115941281cf3SAxel Dörfler BRect 116041281cf3SAxel Dörfler TReplicantTray::IconFrame(int32 target, bool byIndex) 116141281cf3SAxel Dörfler { 116241281cf3SAxel Dörfler int32 index, id; 116341281cf3SAxel Dörfler BView* view = ViewAt(&index, &id, target, byIndex); 116441281cf3SAxel Dörfler if (view) 116541281cf3SAxel Dörfler return view->Frame(); 116641281cf3SAxel Dörfler 116741281cf3SAxel Dörfler return BRect(0, 0, 0, 0); 116841281cf3SAxel Dörfler } 116941281cf3SAxel Dörfler 117041281cf3SAxel Dörfler 117141281cf3SAxel Dörfler BRect 117241281cf3SAxel Dörfler TReplicantTray::IconFrame(const char* name) 117341281cf3SAxel Dörfler { 117441281cf3SAxel Dörfler if (!name) 117541281cf3SAxel Dörfler return BRect(0, 0, 0, 0); 117641281cf3SAxel Dörfler 117741281cf3SAxel Dörfler int32 id, index; 117841281cf3SAxel Dörfler BView* view = ViewAt(&index, &id, name); 117941281cf3SAxel Dörfler if (view) 118041281cf3SAxel Dörfler return view->Frame(); 118141281cf3SAxel Dörfler 118241281cf3SAxel Dörfler return BRect(0, 0, 0, 0); 118341281cf3SAxel Dörfler } 118441281cf3SAxel Dörfler 118541281cf3SAxel Dörfler 11867da06231SAxel Dörfler /** Scan from the startIndex and reset the location 11877da06231SAxel Dörfler * as defined in LocationForReplicant() 118841281cf3SAxel Dörfler */ 118941281cf3SAxel Dörfler 119041281cf3SAxel Dörfler void 119141281cf3SAxel Dörfler TReplicantTray::RealignReplicants(int32 startIndex) 119241281cf3SAxel Dörfler { 119341281cf3SAxel Dörfler if (startIndex < 0) 119441281cf3SAxel Dörfler startIndex = 0; 119541281cf3SAxel Dörfler 119641281cf3SAxel Dörfler int32 count = fShelf->CountReplicants(); 119741281cf3SAxel Dörfler if (count <= 0) 119841281cf3SAxel Dörfler return; 119941281cf3SAxel Dörfler 12007da06231SAxel Dörfler if (startIndex == 0) 12017da06231SAxel Dörfler fRightBottomReplicant.Set(0, 0, 0, 0); 12027da06231SAxel Dörfler 120341281cf3SAxel Dörfler BView* view = NULL; 120441281cf3SAxel Dörfler for (int32 i = startIndex ; i < count ; i++) { 120541281cf3SAxel Dörfler fShelf->ReplicantAt(i, &view); 12060bec7100SStefano Ceccherini if (view != NULL) { 12077da06231SAxel Dörfler BPoint loc = LocationForReplicant(i, view->Frame().Width()); 12080bec7100SStefano Ceccherini if (view->Frame().LeftTop() != loc) 120941281cf3SAxel Dörfler view->MoveTo(loc); 121041281cf3SAxel Dörfler } 121141281cf3SAxel Dörfler } 121241281cf3SAxel Dörfler } 121341281cf3SAxel Dörfler 121441281cf3SAxel Dörfler 12158aab28f1SRene Gollent status_t 12167625ce51SRene Gollent TReplicantTray::_SaveSettings() 12177625ce51SRene Gollent { 12187625ce51SRene Gollent status_t result; 12197625ce51SRene Gollent BPath path; 12207625ce51SRene Gollent if ((result = find_directory(B_USER_SETTINGS_DIRECTORY, &path, true)) 12217625ce51SRene Gollent == B_OK) { 12227625ce51SRene Gollent path.Append(kReplicantSettingsFile); 12237625ce51SRene Gollent 12247625ce51SRene Gollent BFile file(path.Path(), B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE); 12257625ce51SRene Gollent if ((result = file.InitCheck()) == B_OK) 12267625ce51SRene Gollent result = fAddOnSettings.Flatten(&file); 12277625ce51SRene Gollent } 12287625ce51SRene Gollent 12297625ce51SRene Gollent return result; 12307625ce51SRene Gollent } 12317625ce51SRene Gollent 12327625ce51SRene Gollent 12333cf2d117SJohn Scipione void 12343cf2d117SJohn Scipione TReplicantTray::SaveTimeSettings() 12353cf2d117SJohn Scipione { 12363cf2d117SJohn Scipione if (fTime == NULL) 12373cf2d117SJohn Scipione return; 12383cf2d117SJohn Scipione 12393cf2d117SJohn Scipione desk_settings* settings = ((TBarApp*)be_app)->Settings(); 12403cf2d117SJohn Scipione settings->showTime = !fTime->IsHidden(); 12413cf2d117SJohn Scipione settings->showSeconds = fTime->ShowSeconds(); 12423cf2d117SJohn Scipione settings->showDayOfWeek = fTime->ShowDayOfWeek(); 12433cf2d117SJohn Scipione } 12443cf2d117SJohn Scipione 12453cf2d117SJohn Scipione 124641281cf3SAxel Dörfler // #pragma mark - 124741281cf3SAxel Dörfler 124841281cf3SAxel Dörfler 1249ca9acc20SAxel Dörfler /*! Draggable region that is asynchronous so that dragging does not block 1250ca9acc20SAxel Dörfler other activities. 12517da06231SAxel Dörfler */ 125241281cf3SAxel Dörfler TDragRegion::TDragRegion(TBarView* parent, BView* child) 1253ca9acc20SAxel Dörfler : 1254ca9acc20SAxel Dörfler BControl(BRect(0, 0, 0, 0), "", "", NULL, B_FOLLOW_NONE, 125541281cf3SAxel Dörfler B_WILL_DRAW | B_FRAME_EVENTS), 125641281cf3SAxel Dörfler fBarView(parent), 125741281cf3SAxel Dörfler fChild(child), 125841281cf3SAxel Dörfler fDragLocation(kAutoPlaceDragRegion) 125941281cf3SAxel Dörfler { 126041281cf3SAxel Dörfler } 126141281cf3SAxel Dörfler 126241281cf3SAxel Dörfler 126341281cf3SAxel Dörfler void 126441281cf3SAxel Dörfler TDragRegion::AttachedToWindow() 126541281cf3SAxel Dörfler { 126641281cf3SAxel Dörfler BView::AttachedToWindow(); 1267cb6afcb1SStephan Aßmus if (be_control_look != NULL) 1268cb6afcb1SStephan Aßmus SetViewColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), 1.1)); 1269cb6afcb1SStephan Aßmus else 127041281cf3SAxel Dörfler SetViewColor(ui_color(B_MENU_BACKGROUND_COLOR)); 127141281cf3SAxel Dörfler ResizeToPreferred(); 127241281cf3SAxel Dörfler } 127341281cf3SAxel Dörfler 127441281cf3SAxel Dörfler 127541281cf3SAxel Dörfler void 127641281cf3SAxel Dörfler TDragRegion::GetPreferredSize(float* width, float* height) 127741281cf3SAxel Dörfler { 127841281cf3SAxel Dörfler fChild->ResizeToPreferred(); 127941281cf3SAxel Dörfler *width = fChild->Bounds().Width(); 128041281cf3SAxel Dörfler *height = fChild->Bounds().Height(); 128141281cf3SAxel Dörfler 128241281cf3SAxel Dörfler if (fDragLocation != kNoDragRegion) 128341281cf3SAxel Dörfler *width += 7; 128441281cf3SAxel Dörfler else 128541281cf3SAxel Dörfler *width += 6; 128641281cf3SAxel Dörfler 128741281cf3SAxel Dörfler *height += 3; 128841281cf3SAxel Dörfler } 128941281cf3SAxel Dörfler 129041281cf3SAxel Dörfler 129141281cf3SAxel Dörfler void 129241281cf3SAxel Dörfler TDragRegion::FrameMoved(BPoint) 129341281cf3SAxel Dörfler { 1294ca9acc20SAxel Dörfler if (fBarView->Left() && fBarView->Vertical() 1295ca9acc20SAxel Dörfler && fDragLocation != kNoDragRegion) 129641281cf3SAxel Dörfler fChild->MoveTo(5, 2); 129741281cf3SAxel Dörfler else 129841281cf3SAxel Dörfler fChild->MoveTo(2, 2); 129941281cf3SAxel Dörfler } 130041281cf3SAxel Dörfler 130141281cf3SAxel Dörfler 130241281cf3SAxel Dörfler void 130341281cf3SAxel Dörfler TDragRegion::Draw(BRect) 130441281cf3SAxel Dörfler { 1305eaa9af99SStephan Aßmus rgb_color menuColor = ViewColor(); 130641281cf3SAxel Dörfler rgb_color hilite = tint_color(menuColor, B_DARKEN_1_TINT); 1307cb6afcb1SStephan Aßmus rgb_color ldark = tint_color(menuColor, 1.02); 1308cb6afcb1SStephan Aßmus rgb_color dark = tint_color(menuColor, B_DARKEN_2_TINT); 130941281cf3SAxel Dörfler rgb_color vvdark = tint_color(menuColor, B_DARKEN_4_TINT); 131041281cf3SAxel Dörfler rgb_color light = tint_color(menuColor, B_LIGHTEN_2_TINT); 131141281cf3SAxel Dörfler 131241281cf3SAxel Dörfler BRect frame(Bounds()); 131341281cf3SAxel Dörfler BeginLineArray(4); 131441281cf3SAxel Dörfler 1315cb6afcb1SStephan Aßmus if (be_control_look != NULL) { 1316cb6afcb1SStephan Aßmus if (fBarView->Vertical()) { 1317cb6afcb1SStephan Aßmus AddLine(frame.LeftTop(), frame.RightTop(), dark); 1318cb6afcb1SStephan Aßmus AddLine(BPoint(frame.left, frame.top + 1), 1319cb6afcb1SStephan Aßmus BPoint(frame.right, frame.top + 1), ldark); 1320cb6afcb1SStephan Aßmus AddLine(frame.LeftBottom(), frame.RightBottom(), hilite); 1321cb6afcb1SStephan Aßmus } else if (fBarView->AcrossTop() || fBarView->AcrossBottom()) { 1322cb6afcb1SStephan Aßmus AddLine(frame.LeftTop(), 1323cb6afcb1SStephan Aßmus BPoint(frame.left, frame.bottom), dark); 1324cb6afcb1SStephan Aßmus AddLine(BPoint(frame.left + 1, frame.top + 1), 1325cb6afcb1SStephan Aßmus BPoint(frame.right - 1, frame.top + 1), light); 1326cb6afcb1SStephan Aßmus AddLine(BPoint(frame.right, frame.top + 2), 1327cb6afcb1SStephan Aßmus BPoint(frame.right, frame.bottom), hilite); 1328cb6afcb1SStephan Aßmus AddLine(BPoint(frame.left + 1, frame.bottom), 1329cb6afcb1SStephan Aßmus BPoint(frame.right - 1, frame.bottom), hilite); 1330cb6afcb1SStephan Aßmus } 1331cb6afcb1SStephan Aßmus } else { 133241281cf3SAxel Dörfler if (fBarView->Vertical()) { 133341281cf3SAxel Dörfler AddLine(frame.LeftTop(), frame.RightTop(), light); 133441281cf3SAxel Dörfler AddLine(frame.LeftTop(), frame.LeftBottom(), light); 133541281cf3SAxel Dörfler AddLine(frame.RightBottom(), frame.RightTop(), hilite); 133641281cf3SAxel Dörfler } else if (fBarView->AcrossTop()) { 1337cb6afcb1SStephan Aßmus AddLine(BPoint(frame.left, frame.top + 1), 1338cb6afcb1SStephan Aßmus BPoint(frame.right - 1, frame.top + 1), light); 133941281cf3SAxel Dörfler AddLine(frame.RightTop(), frame.RightBottom(), vvdark); 1340cb6afcb1SStephan Aßmus AddLine(BPoint(frame.right - 1, frame.top + 2), 1341cb6afcb1SStephan Aßmus BPoint(frame.right - 1, frame.bottom - 1), hilite); 1342cb6afcb1SStephan Aßmus AddLine(frame.LeftBottom(), 1343cb6afcb1SStephan Aßmus BPoint(frame.right - 1, frame.bottom), hilite); 134441281cf3SAxel Dörfler } else if (fBarView->AcrossBottom()) { 1345cb6afcb1SStephan Aßmus AddLine(BPoint(frame.left, frame.top + 1), 1346cb6afcb1SStephan Aßmus BPoint(frame.right - 1, frame.top + 1), light); 134741281cf3SAxel Dörfler AddLine(frame.LeftBottom(), frame.RightBottom(), hilite); 134841281cf3SAxel Dörfler AddLine(frame.RightTop(), frame.RightBottom(), vvdark); 1349cb6afcb1SStephan Aßmus AddLine(BPoint(frame.right - 1, frame.top + 1), 1350cb6afcb1SStephan Aßmus BPoint(frame.right - 1, frame.bottom - 1), hilite); 1351cb6afcb1SStephan Aßmus } 135241281cf3SAxel Dörfler } 135341281cf3SAxel Dörfler 135441281cf3SAxel Dörfler EndLineArray(); 135541281cf3SAxel Dörfler 135641281cf3SAxel Dörfler if (fDragLocation != kDontDrawDragRegion || fDragLocation != kNoDragRegion) 135741281cf3SAxel Dörfler DrawDragRegion(); 135841281cf3SAxel Dörfler } 135941281cf3SAxel Dörfler 136041281cf3SAxel Dörfler 136141281cf3SAxel Dörfler void 136241281cf3SAxel Dörfler TDragRegion::DrawDragRegion() 136341281cf3SAxel Dörfler { 136441281cf3SAxel Dörfler BRect dragRegion(DragRegion()); 136541281cf3SAxel Dörfler 1366cb6afcb1SStephan Aßmus rgb_color menuColor = ViewColor(); 1367cb6afcb1SStephan Aßmus rgb_color menuHilite = menuColor; 136841281cf3SAxel Dörfler if (IsTracking()) { 1369cb6afcb1SStephan Aßmus // Draw drag region highlighted if tracking mouse 1370cb6afcb1SStephan Aßmus menuHilite = tint_color(menuColor, B_HIGHLIGHT_BACKGROUND_TINT); 137141281cf3SAxel Dörfler SetHighColor(menuHilite); 137241281cf3SAxel Dörfler FillRect(dragRegion); 137341281cf3SAxel Dörfler } 1374cb6afcb1SStephan Aßmus rgb_color vdark = tint_color(menuHilite, B_DARKEN_3_TINT); 1375cb6afcb1SStephan Aßmus rgb_color light = tint_color(menuHilite, B_LIGHTEN_2_TINT); 1376cb6afcb1SStephan Aßmus 1377cb6afcb1SStephan Aßmus BeginLineArray(dragRegion.IntegerHeight()); 1378cb6afcb1SStephan Aßmus BPoint pt; 1379cb6afcb1SStephan Aßmus pt.x = floorf((dragRegion.left + dragRegion.right) / 2 + 0.5) - 1; 1380cb6afcb1SStephan Aßmus pt.y = dragRegion.top + 2; 1381cb6afcb1SStephan Aßmus 138241281cf3SAxel Dörfler while (pt.y + 1 <= dragRegion.bottom) { 138341281cf3SAxel Dörfler AddLine(pt, pt, vdark); 138441281cf3SAxel Dörfler AddLine(pt + BPoint(1, 1), pt + BPoint(1, 1), light); 138541281cf3SAxel Dörfler 138641281cf3SAxel Dörfler pt.y += 3; 138741281cf3SAxel Dörfler } 138841281cf3SAxel Dörfler EndLineArray(); 138941281cf3SAxel Dörfler } 139041281cf3SAxel Dörfler 139141281cf3SAxel Dörfler 139241281cf3SAxel Dörfler BRect 139341281cf3SAxel Dörfler TDragRegion::DragRegion() const 139441281cf3SAxel Dörfler { 1395cb6afcb1SStephan Aßmus float kTopBottomInset = 2; 1396cb6afcb1SStephan Aßmus float kLeftRightInset = 1; 1397cb6afcb1SStephan Aßmus float kDragWidth = 3; 1398cb6afcb1SStephan Aßmus if (be_control_look != NULL) { 1399cb6afcb1SStephan Aßmus kTopBottomInset = 1; 1400cb6afcb1SStephan Aßmus kLeftRightInset = 0; 1401cb6afcb1SStephan Aßmus kDragWidth = 4; 1402cb6afcb1SStephan Aßmus } 1403cb6afcb1SStephan Aßmus 140441281cf3SAxel Dörfler BRect dragRegion(Bounds()); 1405cb6afcb1SStephan Aßmus dragRegion.top += kTopBottomInset; 1406cb6afcb1SStephan Aßmus dragRegion.bottom -= kTopBottomInset; 140741281cf3SAxel Dörfler 140841281cf3SAxel Dörfler bool placeOnLeft = false; 140941281cf3SAxel Dörfler if (fDragLocation == kAutoPlaceDragRegion) { 141041281cf3SAxel Dörfler if (fBarView->Vertical() && fBarView->Left()) 141141281cf3SAxel Dörfler placeOnLeft = true; 141241281cf3SAxel Dörfler else 141341281cf3SAxel Dörfler placeOnLeft = false; 141441281cf3SAxel Dörfler } else if (fDragLocation == kDragRegionLeft) 141541281cf3SAxel Dörfler placeOnLeft = true; 141641281cf3SAxel Dörfler else if (fDragLocation == kDragRegionRight) 141741281cf3SAxel Dörfler placeOnLeft = false; 141841281cf3SAxel Dörfler 141941281cf3SAxel Dörfler if (placeOnLeft) { 1420cb6afcb1SStephan Aßmus dragRegion.left += kLeftRightInset; 1421cb6afcb1SStephan Aßmus dragRegion.right = dragRegion.left + kDragWidth; 142241281cf3SAxel Dörfler } else { 1423cb6afcb1SStephan Aßmus dragRegion.right -= kLeftRightInset; 1424cb6afcb1SStephan Aßmus dragRegion.left = dragRegion.right - kDragWidth; 142541281cf3SAxel Dörfler } 142641281cf3SAxel Dörfler 142741281cf3SAxel Dörfler return dragRegion; 142841281cf3SAxel Dörfler } 142941281cf3SAxel Dörfler 143041281cf3SAxel Dörfler 143141281cf3SAxel Dörfler void 143241281cf3SAxel Dörfler TDragRegion::MouseDown(BPoint thePoint) 143341281cf3SAxel Dörfler { 143441281cf3SAxel Dörfler ulong buttons; 143541281cf3SAxel Dörfler BPoint where; 143641281cf3SAxel Dörfler BRect dragRegion(DragRegion()); 143741281cf3SAxel Dörfler 14387da06231SAxel Dörfler dragRegion.InsetBy(-2.0f, -2.0f); 14397da06231SAxel Dörfler // DragRegion() is designed for drawing, not clicking 144041281cf3SAxel Dörfler 144141281cf3SAxel Dörfler if (!dragRegion.Contains(thePoint)) 144241281cf3SAxel Dörfler return; 144341281cf3SAxel Dörfler 144441281cf3SAxel Dörfler while (true) { 144541281cf3SAxel Dörfler GetMouse(&where, &buttons); 144641281cf3SAxel Dörfler if (!buttons) 144741281cf3SAxel Dörfler break; 144841281cf3SAxel Dörfler 144941281cf3SAxel Dörfler if ((Window()->Flags() & B_ASYNCHRONOUS_CONTROLS) != 0) { 145041281cf3SAxel Dörfler fPreviousPosition = thePoint; 145141281cf3SAxel Dörfler SetTracking(true); 145241281cf3SAxel Dörfler SetMouseEventMask(B_POINTER_EVENTS, 145341281cf3SAxel Dörfler B_NO_POINTER_HISTORY | B_LOCK_WINDOW_FOCUS); 145441281cf3SAxel Dörfler Invalidate(DragRegion()); 145541281cf3SAxel Dörfler break; 145641281cf3SAxel Dörfler } 145741281cf3SAxel Dörfler 145841281cf3SAxel Dörfler snooze(25000); 145941281cf3SAxel Dörfler } 146041281cf3SAxel Dörfler } 146141281cf3SAxel Dörfler 146241281cf3SAxel Dörfler 146341281cf3SAxel Dörfler void 146441281cf3SAxel Dörfler TDragRegion::MouseUp(BPoint pt) 146541281cf3SAxel Dörfler { 146641281cf3SAxel Dörfler if (IsTracking()) { 146741281cf3SAxel Dörfler SetTracking(false); 146841281cf3SAxel Dörfler Invalidate(DragRegion()); 146941281cf3SAxel Dörfler } else 147041281cf3SAxel Dörfler BControl::MouseUp(pt); 147141281cf3SAxel Dörfler } 147241281cf3SAxel Dörfler 147341281cf3SAxel Dörfler 147441281cf3SAxel Dörfler bool 147541281cf3SAxel Dörfler TDragRegion::SwitchModeForRect(BPoint mouse, BRect rect, 147641281cf3SAxel Dörfler bool newVertical, bool newLeft, bool newTop, int32 newState) 147741281cf3SAxel Dörfler { 14781ad8c760SFredrik Holmqvist if (!rect.Contains(mouse)) { 147941281cf3SAxel Dörfler // not our rect 148041281cf3SAxel Dörfler return false; 14811ad8c760SFredrik Holmqvist } 148241281cf3SAxel Dörfler 14831ad8c760SFredrik Holmqvist if (newVertical == fBarView->Vertical() && newLeft == fBarView->Left() 14841ad8c760SFredrik Holmqvist && newTop == fBarView->Top() && newState == fBarView->State()) { 148541281cf3SAxel Dörfler // already in the correct mode 148641281cf3SAxel Dörfler return true; 14871ad8c760SFredrik Holmqvist } 148841281cf3SAxel Dörfler 148941281cf3SAxel Dörfler fBarView->ChangeState(newState, newVertical, newLeft, newTop); 149041281cf3SAxel Dörfler return true; 149141281cf3SAxel Dörfler } 149241281cf3SAxel Dörfler 149341281cf3SAxel Dörfler 149441281cf3SAxel Dörfler void 149541281cf3SAxel Dörfler TDragRegion::MouseMoved(BPoint where, uint32 code, const BMessage* message) 149641281cf3SAxel Dörfler { 149741281cf3SAxel Dörfler if (IsTracking()) { 149841281cf3SAxel Dörfler BScreen screen; 149941281cf3SAxel Dörfler BRect frame = screen.Frame(); 150041281cf3SAxel Dörfler 150141281cf3SAxel Dörfler float hDivider = frame.Width() / 6; 150271bd3ba5SJonas Sundström hDivider = (hDivider < sMinimumWindowWidth + 10.0f) 150371bd3ba5SJonas Sundström ? sMinimumWindowWidth + 10.0f : hDivider; 150441281cf3SAxel Dörfler float miniDivider = frame.top + kMiniHeight + 10.0f; 150541281cf3SAxel Dörfler float vDivider = frame.Height() / 2; 150641281cf3SAxel Dörfler #ifdef FULL_MODE 150741281cf3SAxel Dörfler float thirdScreen = frame.Height() / 3; 150841281cf3SAxel Dörfler #endif 150971bd3ba5SJonas Sundström BRect topLeft(frame.left, frame.top, frame.left + hDivider, 151071bd3ba5SJonas Sundström miniDivider); 151171bd3ba5SJonas Sundström BRect topMiddle(frame.left + hDivider, frame.top, frame.right 151271bd3ba5SJonas Sundström - hDivider, vDivider); 151371bd3ba5SJonas Sundström BRect topRight(frame.right - hDivider, frame.top, frame.right, 151471bd3ba5SJonas Sundström miniDivider); 151541281cf3SAxel Dörfler 151641281cf3SAxel Dörfler #ifdef FULL_MODE 151741281cf3SAxel Dörfler vDivider = miniDivider + thirdScreen; 151841281cf3SAxel Dörfler #endif 151971bd3ba5SJonas Sundström BRect middleLeft(frame.left, miniDivider, frame.left + hDivider, 152071bd3ba5SJonas Sundström vDivider); 152171bd3ba5SJonas Sundström BRect middleRight(frame.right - hDivider, miniDivider, frame.right, 152271bd3ba5SJonas Sundström vDivider); 152341281cf3SAxel Dörfler 152441281cf3SAxel Dörfler #ifdef FULL_MODE 152571bd3ba5SJonas Sundström BRect leftSide(frame.left, vDivider, frame.left + hDivider, 152671bd3ba5SJonas Sundström frame.bottom - thirdScreen); 152771bd3ba5SJonas Sundström BRect rightSide(frame.right - hDivider, vDivider, frame.right, 152871bd3ba5SJonas Sundström frame.bottom - thirdScreen); 152941281cf3SAxel Dörfler 153041281cf3SAxel Dörfler vDivider = frame.bottom - thirdScreen; 153141281cf3SAxel Dörfler #endif 153271bd3ba5SJonas Sundström BRect bottomLeft(frame.left, vDivider, frame.left + hDivider, 153371bd3ba5SJonas Sundström frame.bottom); 153471bd3ba5SJonas Sundström BRect bottomMiddle(frame.left + hDivider, vDivider, frame.right 153571bd3ba5SJonas Sundström - hDivider, frame.bottom); 153671bd3ba5SJonas Sundström BRect bottomRight(frame.right - hDivider, vDivider, frame.right, 153771bd3ba5SJonas Sundström frame.bottom); 153841281cf3SAxel Dörfler 153941281cf3SAxel Dörfler if (where != fPreviousPosition) { 154041281cf3SAxel Dörfler fPreviousPosition = where; 154141281cf3SAxel Dörfler ConvertToScreen(&where); 154241281cf3SAxel Dörfler 154341281cf3SAxel Dörfler // use short circuit evaluation for convenience 154441281cf3SAxel Dörfler if (SwitchModeForRect(where, topLeft, true, true, true, kMiniState) 154571bd3ba5SJonas Sundström || SwitchModeForRect(where, topMiddle, false, true, true, 154671bd3ba5SJonas Sundström kExpandoState) 154771bd3ba5SJonas Sundström || SwitchModeForRect(where, topRight, true, false, true, 154871bd3ba5SJonas Sundström kMiniState) 154971bd3ba5SJonas Sundström || SwitchModeForRect(where, middleLeft, true, true, true, 155071bd3ba5SJonas Sundström kExpandoState) 155171bd3ba5SJonas Sundström || SwitchModeForRect(where, middleRight, true, false, true, 155271bd3ba5SJonas Sundström kExpandoState) 155341281cf3SAxel Dörfler 155441281cf3SAxel Dörfler #ifdef FULL_MODE 155571bd3ba5SJonas Sundström || SwitchModeForRect(where, leftSide, true, true, true, 155671bd3ba5SJonas Sundström kFullState) 155771bd3ba5SJonas Sundström || SwitchModeForRect(where, rightSide, true, false, true, 155871bd3ba5SJonas Sundström kFullState) 155941281cf3SAxel Dörfler #endif 156071bd3ba5SJonas Sundström || SwitchModeForRect(where, bottomLeft, true, true, false, 156171bd3ba5SJonas Sundström kMiniState) 156271bd3ba5SJonas Sundström || SwitchModeForRect(where, bottomMiddle, false, true, false, 156371bd3ba5SJonas Sundström kExpandoState) 156471bd3ba5SJonas Sundström || SwitchModeForRect(where, bottomRight, true, false, false, 156571bd3ba5SJonas Sundström kMiniState)) 156641281cf3SAxel Dörfler ; 156741281cf3SAxel Dörfler } 156841281cf3SAxel Dörfler } else 156941281cf3SAxel Dörfler BControl::MouseMoved(where, code, message); 157041281cf3SAxel Dörfler } 157141281cf3SAxel Dörfler 157241281cf3SAxel Dörfler 157341281cf3SAxel Dörfler int32 157441281cf3SAxel Dörfler TDragRegion::DragRegionLocation() const 157541281cf3SAxel Dörfler { 157641281cf3SAxel Dörfler return fDragLocation; 157741281cf3SAxel Dörfler } 157841281cf3SAxel Dörfler 157941281cf3SAxel Dörfler 158041281cf3SAxel Dörfler void 158141281cf3SAxel Dörfler TDragRegion::SetDragRegionLocation(int32 location) 158241281cf3SAxel Dörfler { 158341281cf3SAxel Dörfler if (location == fDragLocation) 158441281cf3SAxel Dörfler return; 158541281cf3SAxel Dörfler 158641281cf3SAxel Dörfler fDragLocation = location; 158741281cf3SAxel Dörfler Invalidate(); 158841281cf3SAxel Dörfler } 1589