2 * Copyright 2002-2017 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
6 * Axel Dörfler, axeld@pinc-software.de
7 * Jerome Duval, jerome.duval@free.fr
8 * Jonas Sundström, jonas@kirilla.se
9 * John Scipione, jscipione@gmail.com
10 * Brian Hill <supernova@warpmail.net>
14 #include "BackgroundsView.h"
24 #include <ControlLook.h>
28 #include <FindDirectory.h>
29 #include <LayoutBuilder.h>
31 #include <MenuField.h>
32 #include <Messenger.h>
35 #include <PopUpMenu.h>
37 #include <be_apps/Tracker/Background.h>
38 #include <ScreenDefs.h>
40 #include "ImageFilePanel.h"
43 #undef B_TRANSLATION_CONTEXT
44 #define B_TRANSLATION_CONTEXT "Main View"
47 static const uint32 kMsgApplySettings
= 'aply';
48 static const uint32 kMsgRevertSettings
= 'rvrt';
50 static const uint32 kMsgUpdateColor
= 'upcl';
51 static const uint32 kMsgAllWorkspaces
= 'alwk';
52 static const uint32 kMsgCurrentWorkspace
= 'crwk';
53 static const uint32 kMsgDefaultFolder
= 'dffl';
54 static const uint32 kMsgOtherFolder
= 'otfl';
55 static const uint32 kMsgNoImage
= 'noim';
56 static const uint32 kMsgOtherImage
= 'otim';
57 static const uint32 kMsgImageSelected
= 'imsl';
58 static const uint32 kMsgFolderSelected
= 'flsl';
60 static const uint32 kMsgCenterPlacement
= 'cnpl';
61 static const uint32 kMsgManualPlacement
= 'mnpl';
62 static const uint32 kMsgScalePlacement
= 'scpl';
63 static const uint32 kMsgTilePlacement
= 'tlpl';
64 static const uint32 kMsgIconLabelOutline
= 'ilol';
66 static const uint32 kMsgImagePlacement
= 'xypl';
67 static const uint32 kMsgUpdatePreviewPlacement
= 'pvpl';
70 BackgroundsView::BackgroundsView()
72 BBox("BackgroundsView"),
78 fFoundPositionSetting(false)
80 SetBorder(B_NO_BORDER
);
82 BBox
* previewBox
= new BBox("preview");
83 previewBox
->SetLabel(B_TRANSLATE("Preview"));
85 fPreview
= new Preview();
87 fTopLeft
= new FramePart(FRAME_TOP_LEFT
);
88 fTop
= new FramePart(FRAME_TOP
);
89 fTopRight
= new FramePart(FRAME_TOP_RIGHT
);
90 fLeft
= new FramePart(FRAME_LEFT_SIDE
);
91 fRight
= new FramePart(FRAME_RIGHT_SIDE
);
92 fBottomLeft
= new FramePart(FRAME_BOTTOM_LEFT
);
93 fBottom
= new FramePart(FRAME_BOTTOM
);
94 fBottomRight
= new FramePart(FRAME_BOTTOM_RIGHT
);
96 fXPlacementText
= new BTextControl(B_TRANSLATE("X:"), NULL
,
97 new BMessage(kMsgImagePlacement
));
98 fYPlacementText
= new BTextControl(B_TRANSLATE("Y:"), NULL
,
99 new BMessage(kMsgImagePlacement
));
101 fXPlacementText
->TextView()->SetMaxBytes(5);
102 fYPlacementText
->TextView()->SetMaxBytes(5);
104 for (int32 i
= 0; i
< 256; i
++) {
105 if ((i
< '0' || i
> '9') && i
!= '-') {
106 fXPlacementText
->TextView()->DisallowChar(i
);
107 fYPlacementText
->TextView()->DisallowChar(i
);
111 previewBox
->AddChild(BLayoutBuilder::Group
<>()
113 .AddGroup(B_VERTICAL
, 0)
114 .AddGroup(B_HORIZONTAL
, 0)
119 .Add(fTopRight
, 2, 0)
123 .Add(fBottomLeft
, 0, 2)
125 .Add(fBottomRight
, 2, 2)
129 .AddStrut(be_control_look
->DefaultItemSpacing() * 2)
130 .AddGroup(B_HORIZONTAL
)
131 .Add(fXPlacementText
)
132 .Add(fYPlacementText
)
135 .SetInsets(B_USE_DEFAULT_SPACING
)
140 BBox
* rightbox
= new BBox("rightbox");
142 fWorkspaceMenu
= new BPopUpMenu(B_TRANSLATE("pick one"));
143 fWorkspaceMenu
->AddItem(new BMenuItem(B_TRANSLATE("All workspaces"),
144 new BMessage(kMsgAllWorkspaces
)));
146 fWorkspaceMenu
->AddItem(menuItem
= new BMenuItem(
147 B_TRANSLATE("Current workspace"),
148 new BMessage(kMsgCurrentWorkspace
)));
149 menuItem
->SetMarked(true);
150 fLastWorkspaceIndex
=
151 fWorkspaceMenu
->IndexOf(fWorkspaceMenu
->FindMarked());
152 fWorkspaceMenu
->AddSeparatorItem();
153 fWorkspaceMenu
->AddItem(new BMenuItem(B_TRANSLATE("Default folder"),
154 new BMessage(kMsgDefaultFolder
)));
155 fWorkspaceMenu
->AddItem(new BMenuItem(
156 B_TRANSLATE("Other folder" B_UTF8_ELLIPSIS
),
157 new BMessage(kMsgOtherFolder
)));
159 BMenuField
* workspaceMenuField
= new BMenuField("workspaceMenuField",
160 NULL
, fWorkspaceMenu
);
161 workspaceMenuField
->ResizeToPreferred();
162 rightbox
->SetLabel(workspaceMenuField
);
164 fImageMenu
= new BPopUpMenu(B_TRANSLATE("pick one"));
165 fImageMenu
->AddItem(new BGImageMenuItem(B_TRANSLATE("None"), -1,
166 new BMessage(kMsgNoImage
)));
167 fImageMenu
->AddSeparatorItem();
168 fImageMenu
->AddItem(new BMenuItem(B_TRANSLATE("Other" B_UTF8_ELLIPSIS
),
169 new BMessage(kMsgOtherImage
)));
171 BMenuField
* imageMenuField
= new BMenuField("image",
172 B_TRANSLATE("Image:"), fImageMenu
);
173 imageMenuField
->SetAlignment(B_ALIGN_RIGHT
);
175 fPlacementMenu
= new BPopUpMenu(B_TRANSLATE("pick one"));
176 fPlacementMenu
->AddItem(new BMenuItem(B_TRANSLATE("Manual"),
177 new BMessage(kMsgManualPlacement
)));
178 fPlacementMenu
->AddItem(new BMenuItem(B_TRANSLATE("Center"),
179 new BMessage(kMsgCenterPlacement
)));
180 fPlacementMenu
->AddItem(new BMenuItem(B_TRANSLATE("Scale to fit"),
181 new BMessage(kMsgScalePlacement
)));
182 fPlacementMenu
->AddItem(new BMenuItem(B_TRANSLATE("Tile"),
183 new BMessage(kMsgTilePlacement
)));
185 BMenuField
* placementMenuField
= new BMenuField("placement",
186 B_TRANSLATE("Placement:"), fPlacementMenu
);
187 placementMenuField
->SetAlignment(B_ALIGN_RIGHT
);
189 fIconLabelOutline
= new BCheckBox(B_TRANSLATE("Icon label outline"),
190 new BMessage(kMsgIconLabelOutline
));
191 fIconLabelOutline
->SetValue(B_CONTROL_OFF
);
193 fPicker
= new BColorControl(BPoint(0, 0), B_CELLS_32x8
, 8.0, "Picker",
194 new BMessage(kMsgUpdateColor
));
196 rightbox
->AddChild(BLayoutBuilder::Group
<>(B_VERTICAL
)
197 .AddGroup(B_HORIZONTAL
, 0.0f
)
198 .AddGrid(B_USE_DEFAULT_SPACING
, B_USE_SMALL_SPACING
)
199 .Add(imageMenuField
->CreateLabelLayoutItem(), 0, 0)
200 .AddGroup(B_HORIZONTAL
, 0.0f
, 1, 0)
201 .Add(imageMenuField
->CreateMenuBarLayoutItem(), 0.0f
)
204 .Add(placementMenuField
->CreateLabelLayoutItem(), 0, 1)
205 .AddGroup(B_HORIZONTAL
, 0.0f
, 1, 1)
206 .Add(placementMenuField
->CreateMenuBarLayoutItem(), 0.0f
)
209 .Add(fIconLabelOutline
, 1, 2)
215 .SetInsets(B_USE_DEFAULT_SPACING
)
218 fRevert
= new BButton(B_TRANSLATE("Revert"),
219 new BMessage(kMsgRevertSettings
));
220 fApply
= new BButton(B_TRANSLATE("Apply"),
221 new BMessage(kMsgApplySettings
));
223 fRevert
->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT
,
224 B_ALIGN_NO_VERTICAL
));
225 fApply
->SetExplicitAlignment(BAlignment(B_ALIGN_RIGHT
,
226 B_ALIGN_NO_VERTICAL
));
228 BLayoutBuilder::Group
<>(this, B_VERTICAL
, 0)
229 .SetInsets(B_USE_WINDOW_SPACING
)
230 .AddGroup(B_HORIZONTAL
, 0)
231 .AddGroup(B_VERTICAL
, 0)
232 .AddStrut(floorf(rightbox
->TopBorderOffset()
233 - previewBox
->TopBorderOffset()) - 1)
236 .AddStrut(B_USE_DEFAULT_SPACING
)
239 .AddGroup(B_HORIZONTAL
, 0)
242 .SetInsets(0, B_USE_DEFAULT_SPACING
, 0, 0)
245 fApply
->MakeDefault(true);
249 BackgroundsView::~BackgroundsView()
251 // The order matter. The last panel saves the state
258 BackgroundsView::AllAttached()
260 fPlacementMenu
->SetTargetForItems(this);
261 fImageMenu
->SetTargetForItems(this);
262 fWorkspaceMenu
->SetTargetForItems(this);
263 fXPlacementText
->SetTarget(this);
264 fYPlacementText
->SetTarget(this);
265 fIconLabelOutline
->SetTarget(this);
266 fPicker
->SetTarget(this);
267 fApply
->SetTarget(this);
268 fRevert
->SetTarget(this);
272 if (find_directory(B_SYSTEM_DATA_DIRECTORY
, &path
) == B_OK
) {
273 path
.Append("artwork");
274 get_ref_for_path(path
.Path(), &ref
);
277 BMessenger
messenger(this);
278 fPanel
= new ImageFilePanel(B_OPEN_PANEL
, &messenger
, &ref
,
279 B_FILE_NODE
, false, NULL
, new CustomRefFilter(true));
280 fPanel
->SetButtonLabel(B_DEFAULT_BUTTON
, B_TRANSLATE("Select"));
282 fFolderPanel
= new BFilePanel(B_OPEN_PANEL
, &messenger
, NULL
,
283 B_DIRECTORY_NODE
, false, NULL
, new CustomRefFilter(false));
284 fFolderPanel
->SetButtonLabel(B_DEFAULT_BUTTON
, B_TRANSLATE("Select"));
287 _LoadDesktopFolder();
290 if (fSettings
.FindPoint("pos", &point
) == B_OK
) {
291 fFoundPositionSetting
= true;
292 Window()->MoveTo(point
);
295 fApply
->SetEnabled(false);
296 fRevert
->SetEnabled(false);
301 BackgroundsView::MessageReceived(BMessage
* message
)
304 if (message
->WasDropped()) {
307 if (message
->FindData("RGBColor", B_RGB_COLOR_TYPE
,
308 (const void **)&clr
, &out_size
) == B_OK
) {
309 fPicker
->SetValue(*clr
);
316 switch (message
->what
) {
318 case B_REFS_RECEIVED
:
319 RefsReceived(message
);
322 case kMsgUpdatePreviewPlacement
:
324 BString xstring
, ystring
;
325 xstring
<< (int)fPreview
->fPoint
.x
;
326 ystring
<< (int)fPreview
->fPoint
.y
;
327 fXPlacementText
->SetText(xstring
.String());
328 fYPlacementText
->SetText(ystring
.String());
334 case kMsgManualPlacement
:
335 case kMsgTilePlacement
:
336 case kMsgScalePlacement
:
337 case kMsgCenterPlacement
:
342 case kMsgIconLabelOutline
:
346 case kMsgUpdateColor
:
347 case kMsgImagePlacement
:
352 case kMsgCurrentWorkspace
:
353 case kMsgAllWorkspaces
:
354 fImageMenu
->FindItem(kMsgNoImage
)->SetLabel(B_TRANSLATE("None"));
355 fLastWorkspaceIndex
= fWorkspaceMenu
->IndexOf(
356 fWorkspaceMenu
->FindMarked());
357 if (fCurrent
&& fCurrent
->IsDesktop()) {
361 _LoadDesktopFolder();
365 case kMsgDefaultFolder
:
366 fImageMenu
->FindItem(kMsgNoImage
)->SetLabel(B_TRANSLATE("None"));
367 fLastWorkspaceIndex
= fWorkspaceMenu
->IndexOf(
368 fWorkspaceMenu
->FindMarked());
370 _LoadDefaultFolder();
373 case kMsgOtherFolder
:
374 fFolderPanel
->Show();
383 PRINT(("cancel received\n"));
385 message
->FindPointer("source", &pointer
);
386 if (pointer
== fPanel
) {
387 if (fLastImageIndex
>= 0)
388 _FindImageItem(fLastImageIndex
)->SetMarked(true);
390 fImageMenu
->ItemAt(0)->SetMarked(true);
391 } else if (pointer
== fFolderPanel
) {
392 if (fLastWorkspaceIndex
>= 0)
393 fWorkspaceMenu
->ItemAt(fLastWorkspaceIndex
)
399 case kMsgImageSelected
:
401 fLastImageIndex
= ((BGImageMenuItem
*)fImageMenu
->FindMarked())
407 case kMsgFolderSelected
:
408 fImageMenu
->FindItem(kMsgNoImage
)->SetLabel(B_TRANSLATE("Default"));
409 fLastWorkspaceIndex
= fWorkspaceMenu
->IndexOf(
410 fWorkspaceMenu
->FindMarked());
413 _LoadRecentFolder(*fPathList
.ItemAt(fWorkspaceMenu
->IndexOf(
414 fWorkspaceMenu
->FindMarked()) - 6));
417 case kMsgApplySettings
:
421 // Notify the server and Screen preflet
422 thread_id notify_thread
;
423 notify_thread
= spawn_thread(BackgroundsView::_NotifyThread
,
424 "notifyThread", B_NORMAL_PRIORITY
, this);
425 resume_thread(notify_thread
);
429 case kMsgRevertSettings
:
430 _UpdateWithCurrent();
434 BView::MessageReceived(message
);
441 BackgroundsView::_LoadDesktopFolder()
444 if (find_directory(B_DESKTOP_DIRECTORY
, &path
) == B_OK
) {
446 err
= get_ref_for_path(path
.Path(), &fCurrentRef
);
448 printf("error in LoadDesktopSettings\n");
455 BackgroundsView::_LoadDefaultFolder()
458 if (find_directory(B_USER_SETTINGS_DIRECTORY
, &path
) == B_OK
) {
459 BString pathString
= path
.Path();
460 pathString
<< "/Tracker/DefaultFolderTemplate";
462 err
= get_ref_for_path(pathString
.String(), &fCurrentRef
);
464 printf("error in LoadDefaultFolderSettings\n");
471 BackgroundsView::_LoadRecentFolder(BPath path
)
474 err
= get_ref_for_path(path
.Path(), &fCurrentRef
);
476 printf("error in LoadRecentFolder\n");
482 BackgroundsView::_LoadFolder(bool isDesktop
)
489 BNode
node(&fCurrentRef
);
490 if (node
.InitCheck() == B_OK
)
491 fCurrent
= BackgroundImage::GetBackgroundImage(&node
, isDesktop
, this);
493 _UpdateWithCurrent();
498 BackgroundsView::_UpdateWithCurrent(void)
500 if (fCurrent
== NULL
)
503 fPlacementMenu
->FindItem(kMsgScalePlacement
)
504 ->SetEnabled(fCurrent
->IsDesktop());
505 fPlacementMenu
->FindItem(kMsgCenterPlacement
)
506 ->SetEnabled(fCurrent
->IsDesktop());
508 if (fWorkspaceMenu
->IndexOf(fWorkspaceMenu
->FindMarked()) > 5)
509 fImageMenu
->FindItem(kMsgNoImage
)->SetLabel(B_TRANSLATE("Default"));
511 fImageMenu
->FindItem(kMsgNoImage
)->SetLabel(B_TRANSLATE("None"));
513 for (int32 i
= fImageMenu
->CountItems() - 5; i
>= 0; i
--) {
514 fImageMenu
->RemoveItem(2);
517 for (int32 i
= fImageList
.CountItems() - 1; i
>= 0; i
--) {
518 BMessage
* message
= new BMessage(kMsgImageSelected
);
519 _AddItem(new BGImageMenuItem(GetImage(i
)->GetName(), i
, message
));
522 fImageMenu
->SetTargetForItems(this);
524 fCurrentInfo
= fCurrent
->ImageInfoForWorkspace(current_workspace());
527 fImageMenu
->FindItem(kMsgNoImage
)->SetMarked(true);
528 fPlacementMenu
->FindItem(kMsgManualPlacement
)->SetMarked(true);
529 fIconLabelOutline
->SetValue(B_CONTROL_ON
);
531 fIconLabelOutline
->SetValue(fCurrentInfo
->fTextWidgetLabelOutline
532 ? B_CONTROL_ON
: B_CONTROL_OFF
);
534 fLastImageIndex
= fCurrentInfo
->fImageIndex
;
535 _FindImageItem(fLastImageIndex
)->SetMarked(true);
537 if (fLastImageIndex
> -1) {
539 BString xtext
, ytext
;
541 switch (fCurrentInfo
->fMode
) {
542 case BackgroundImage::kCentered
:
543 cmd
= kMsgCenterPlacement
;
545 case BackgroundImage::kScaledToFit
:
546 cmd
= kMsgScalePlacement
;
548 case BackgroundImage::kAtOffset
:
549 cmd
= kMsgManualPlacement
;
550 xtext
<< (int)fCurrentInfo
->fOffset
.x
;
551 ytext
<< (int)fCurrentInfo
->fOffset
.y
;
553 case BackgroundImage::kTiled
:
554 cmd
= kMsgTilePlacement
;
559 fPlacementMenu
->FindItem(cmd
)->SetMarked(true);
561 fXPlacementText
->SetText(xtext
.String());
562 fYPlacementText
->SetText(ytext
.String());
564 fPlacementMenu
->FindItem(kMsgManualPlacement
)->SetMarked(true);
568 rgb_color color
= {255, 255, 255, 255};
569 if (fCurrent
->IsDesktop()) {
570 color
= BScreen().DesktopColor();
571 fPicker
->SetEnabled(true);
573 fPicker
->SetEnabled(false);
575 fPicker
->SetValue(color
);
583 BackgroundsView::_Save()
585 bool textWidgetLabelOutline
586 = fIconLabelOutline
->Value() == B_CONTROL_ON
;
588 BackgroundImage::Mode mode
= _FindPlacementMode();
589 BPoint
offset(atoi(fXPlacementText
->Text()), atoi(fYPlacementText
->Text()));
591 if (!fCurrent
->IsDesktop()) {
592 if (fCurrentInfo
== NULL
) {
593 fCurrentInfo
= new BackgroundImage::BackgroundImageInfo(
594 B_ALL_WORKSPACES
, fLastImageIndex
, mode
, offset
,
595 textWidgetLabelOutline
, 0, 0);
596 fCurrent
->Add(fCurrentInfo
);
598 fCurrentInfo
->fTextWidgetLabelOutline
= textWidgetLabelOutline
;
599 fCurrentInfo
->fMode
= mode
;
600 if (fCurrentInfo
->fMode
== BackgroundImage::kAtOffset
)
601 fCurrentInfo
->fOffset
= offset
;
602 fCurrentInfo
->fImageIndex
= fLastImageIndex
;
605 uint32 workspaceMask
= 1;
606 int32 workspace
= current_workspace();
607 for (; workspace
; workspace
--)
610 if (fCurrentInfo
!= NULL
) {
611 if (fWorkspaceMenu
->FindItem(kMsgCurrentWorkspace
)->IsMarked()) {
612 if (fCurrentInfo
->fWorkspace
& workspaceMask
613 && fCurrentInfo
->fWorkspace
!= workspaceMask
) {
614 fCurrentInfo
->fWorkspace
= fCurrentInfo
->fWorkspace
616 fCurrentInfo
= new BackgroundImage::BackgroundImageInfo(
617 workspaceMask
, fLastImageIndex
, mode
, offset
,
618 textWidgetLabelOutline
, fCurrentInfo
->fImageSet
,
619 fCurrentInfo
->fCacheMode
);
620 fCurrent
->Add(fCurrentInfo
);
621 } else if (fCurrentInfo
->fWorkspace
== workspaceMask
) {
622 fCurrentInfo
->fTextWidgetLabelOutline
623 = textWidgetLabelOutline
;
624 fCurrentInfo
->fMode
= mode
;
625 if (fCurrentInfo
->fMode
== BackgroundImage::kAtOffset
)
626 fCurrentInfo
->fOffset
= offset
;
628 fCurrentInfo
->fImageIndex
= fLastImageIndex
;
631 fCurrent
->RemoveAll();
633 fCurrentInfo
= new BackgroundImage::BackgroundImageInfo(
634 B_ALL_WORKSPACES
, fLastImageIndex
, mode
, offset
,
635 textWidgetLabelOutline
, fCurrent
->GetShowingImageSet(),
636 fCurrentInfo
->fCacheMode
);
637 fCurrent
->Add(fCurrentInfo
);
640 if (fWorkspaceMenu
->FindItem(kMsgCurrentWorkspace
)->IsMarked()) {
641 fCurrentInfo
= new BackgroundImage::BackgroundImageInfo(
642 workspaceMask
, fLastImageIndex
, mode
, offset
,
643 textWidgetLabelOutline
, fCurrent
->GetShowingImageSet(), 0);
645 fCurrent
->RemoveAll();
646 fCurrentInfo
= new BackgroundImage::BackgroundImageInfo(
647 B_ALL_WORKSPACES
, fLastImageIndex
, mode
, offset
,
648 textWidgetLabelOutline
, fCurrent
->GetShowingImageSet(), 0);
650 fCurrent
->Add(fCurrentInfo
);
653 if (!fWorkspaceMenu
->FindItem(kMsgCurrentWorkspace
)->IsMarked()) {
654 for (int32 i
= 0; i
< count_workspaces(); i
++) {
655 BScreen().SetDesktopColor(fPicker
->ValueAsColor(), i
, true);
658 BScreen().SetDesktopColor(fPicker
->ValueAsColor(), true);
661 BNode
node(&fCurrentRef
);
663 status_t status
= fCurrent
->SetBackgroundImage(&node
);
664 if (status
!= B_OK
) {
665 BString
error(strerror(status
));
666 BString
text(B_TRANSLATE("Setting the background image failed:"));
667 text
.Append("\n").Append(error
);
668 BAlert
* alert
= new BAlert(B_TRANSLATE("Set background image error"),
669 text
, B_TRANSLATE("OK"));
670 alert
->SetShortcut(0, B_ESCAPE
);
672 printf("setting background image failed: %s\n", error
.String());
678 BackgroundsView::_NotifyServer()
680 BMessenger
tracker("application/x-vnd.Be-TRAK");
682 if (fCurrent
->IsDesktop()) {
683 tracker
.SendMessage(new BMessage(B_RESTORE_BACKGROUND_IMAGE
));
688 BEntry
currentEntry(&fCurrentRef
);
689 BPath
currentPath(¤tEntry
);
691 = !fWorkspaceMenu
->FindItem(kMsgDefaultFolder
)->IsMarked();
694 BMessage
msg(B_GET_PROPERTY
);
697 // look at the "Poses" in every Tracker window
698 msg
.AddSpecifier("Poses");
699 msg
.AddSpecifier("Window", i
);
702 tracker
.SendMessage(&msg
, &reply
);
704 // break out of the loop when we're at the end of
706 if (reply
.what
== B_MESSAGE_NOT_UNDERSTOOD
707 && reply
.FindInt32("error", &err
) == B_OK
708 && err
== B_BAD_INDEX
)
711 // don't stop for windows that don't understand
712 // a request for "Poses"; they're not displaying
714 if (reply
.what
== B_MESSAGE_NOT_UNDERSTOOD
715 && reply
.FindInt32("error", &err
) == B_OK
716 && err
!= B_BAD_SCRIPT_SYNTAX
)
719 BMessenger trackerWindow
;
720 if (reply
.FindMessenger("result", &trackerWindow
) != B_OK
)
723 if (isCustomFolder
) {
724 // found a window with poses, ask for its path
726 msg
.what
= B_GET_PROPERTY
;
727 msg
.AddSpecifier("Path");
728 msg
.AddSpecifier("Poses");
729 msg
.AddSpecifier("Window", i
);
732 tracker
.SendMessage(&msg
, &reply
);
734 // go on with the next if this din't have a path
735 if (reply
.what
== B_MESSAGE_NOT_UNDERSTOOD
)
739 if (reply
.FindRef("result", &ref
) == B_OK
) {
743 // these are not the paths you're looking for
744 if (currentPath
!= path
)
749 trackerWindow
.SendMessage(B_RESTORE_BACKGROUND_IMAGE
);
756 BackgroundsView::_NotifyScreenPreflet()
758 BMessenger
messenger("application/x-vnd.Haiku-Screen");
759 if (messenger
.IsValid())
760 messenger
.SendMessage(UPDATE_DESKTOP_COLOR_MSG
);
765 BackgroundsView::_NotifyThread(void* data
)
767 BackgroundsView
* view
= (BackgroundsView
*)data
;
769 view
->_NotifyServer();
770 view
->_NotifyScreenPreflet();
776 BackgroundsView::SaveSettings(void)
779 if (find_directory(B_USER_SETTINGS_DIRECTORY
, &path
) == B_OK
) {
780 path
.Append(SETTINGS_FILE
);
781 BFile
file(path
.Path(), B_READ_WRITE
| B_CREATE_FILE
| B_ERASE_FILE
);
783 BPoint point
= Window()->Frame().LeftTop();
784 if (fSettings
.ReplacePoint("pos", point
) != B_OK
)
785 fSettings
.AddPoint("pos", point
);
790 fPanel
->GetPanelDirectory(&ref
);
792 entry
.GetPath(&path
);
793 if (fSettings
.ReplaceString("paneldir", path
.Path()) != B_OK
)
794 fSettings
.AddString("paneldir", path
.Path());
796 fFolderPanel
->GetPanelDirectory(&ref
);
798 entry
.GetPath(&path
);
799 if (fSettings
.ReplaceString("folderpaneldir", path
.Path()) != B_OK
)
800 fSettings
.AddString("folderpaneldir", path
.Path());
802 fSettings
.RemoveName("recentfolder");
803 for (int32 i
= 0; i
< fPathList
.CountItems(); i
++) {
804 fSettings
.AddString("recentfolder", fPathList
.ItemAt(i
)->Path());
807 fSettings
.Flatten(&file
);
813 BackgroundsView::_LoadSettings()
815 fSettings
.MakeEmpty();
818 if (find_directory(B_USER_SETTINGS_DIRECTORY
, &path
) != B_OK
)
821 path
.Append(SETTINGS_FILE
);
822 BFile
file(path
.Path(), B_READ_ONLY
);
823 if (file
.InitCheck() != B_OK
)
826 if (fSettings
.Unflatten(&file
) != B_OK
) {
827 printf("Error unflattening settings file %s\n", path
.Path());
831 PRINT_OBJECT(fSettings
);
834 if (fSettings
.FindString("paneldir", &string
) == B_OK
)
835 fPanel
->SetPanelDirectory(string
.String());
837 if (fSettings
.FindString("folderpaneldir", &string
) == B_OK
)
838 fFolderPanel
->SetPanelDirectory(string
.String());
841 while (fSettings
.FindString("recentfolder", index
, &string
) == B_OK
) {
843 fWorkspaceMenu
->AddSeparatorItem();
845 path
.SetTo(string
.String());
846 int32 i
= _AddPath(path
);
848 s
<< B_TRANSLATE("Folder: ") << path
.Leaf();
849 BMenuItem
* item
= new BMenuItem(s
.String(),
850 new BMessage(kMsgFolderSelected
));
851 fWorkspaceMenu
->AddItem(item
, -i
- 1 + 6);
854 fWorkspaceMenu
->SetTargetForItems(this);
856 PRINT(("Settings Loaded\n"));
861 BackgroundsView::WorkspaceActivated(uint32 oldWorkspaces
, bool active
)
863 _UpdateWithCurrent();
868 BackgroundsView::_UpdatePreview()
870 bool imageEnabled
= !(fImageMenu
->FindItem(kMsgNoImage
)->IsMarked());
871 if (fPlacementMenu
->IsEnabled() ^ imageEnabled
)
872 fPlacementMenu
->SetEnabled(imageEnabled
);
875 = (fPlacementMenu
->FindItem(kMsgManualPlacement
)->IsMarked())
877 if (fXPlacementText
->IsEnabled() ^ textEnabled
)
878 fXPlacementText
->SetEnabled(textEnabled
);
879 if (fYPlacementText
->IsEnabled() ^ textEnabled
)
880 fYPlacementText
->SetEnabled(textEnabled
);
882 if (textEnabled
&& (strcmp(fXPlacementText
->Text(), "") == 0)) {
883 fXPlacementText
->SetText("0");
884 fYPlacementText
->SetText("0");
887 fXPlacementText
->SetText(NULL
);
888 fYPlacementText
->SetText(NULL
);
891 fXPlacementText
->TextView()->MakeSelectable(textEnabled
);
892 fYPlacementText
->TextView()->MakeSelectable(textEnabled
);
893 fXPlacementText
->TextView()->MakeEditable(textEnabled
);
894 fYPlacementText
->TextView()->MakeEditable(textEnabled
);
896 fPreview
->ClearViewBitmap();
898 int32 index
= ((BGImageMenuItem
*)fImageMenu
->FindMarked())->ImageIndex();
900 BBitmap
* bitmap
= GetImage(index
)->GetBitmap();
902 BackgroundImage::BackgroundImageInfo
* info
903 = new BackgroundImage::BackgroundImageInfo(0, index
,
904 _FindPlacementMode(), BPoint(atoi(fXPlacementText
->Text()),
905 atoi(fYPlacementText
->Text())),
906 fIconLabelOutline
->Value() == B_CONTROL_ON
, 0, 0);
907 if (info
->fMode
== BackgroundImage::kAtOffset
) {
908 fPreview
->SetEnabled(true);
909 fPreview
->fPoint
.x
= atoi(fXPlacementText
->Text());
910 fPreview
->fPoint
.y
= atoi(fYPlacementText
->Text());
912 fPreview
->SetEnabled(false);
914 fPreview
->fImageBounds
= BRect(bitmap
->Bounds());
915 fCurrent
->Show(info
, fPreview
);
920 fPreview
->SetEnabled(false);
922 fPreview
->SetViewColor(fPicker
->ValueAsColor());
923 fPreview
->Invalidate();
927 BackgroundImage::Mode
928 BackgroundsView::_FindPlacementMode()
930 BackgroundImage::Mode mode
= BackgroundImage::kAtOffset
;
932 if (fPlacementMenu
->FindItem(kMsgCenterPlacement
)->IsMarked())
933 mode
= BackgroundImage::kCentered
;
934 if (fPlacementMenu
->FindItem(kMsgScalePlacement
)->IsMarked())
935 mode
= BackgroundImage::kScaledToFit
;
936 if (fPlacementMenu
->FindItem(kMsgManualPlacement
)->IsMarked())
937 mode
= BackgroundImage::kAtOffset
;
938 if (fPlacementMenu
->FindItem(kMsgTilePlacement
)->IsMarked())
939 mode
= BackgroundImage::kTiled
;
946 BackgroundsView::_UpdateButtons()
948 bool hasChanged
= false;
949 if (fPicker
->IsEnabled()
950 && fPicker
->ValueAsColor() != BScreen().DesktopColor()) {
952 } else if (fCurrentInfo
) {
953 if ((fIconLabelOutline
->Value() == B_CONTROL_ON
)
954 ^ fCurrentInfo
->fTextWidgetLabelOutline
) {
956 } else if (_FindPlacementMode() != fCurrentInfo
->fMode
) {
958 } else if (fCurrentInfo
->fImageIndex
959 != ((BGImageMenuItem
*)fImageMenu
->FindMarked())->ImageIndex()) {
961 } else if (fCurrent
->IsDesktop()
962 && ((fCurrentInfo
->fWorkspace
!= B_ALL_WORKSPACES
)
963 ^ (fWorkspaceMenu
->FindItem(kMsgCurrentWorkspace
)->IsMarked())))
966 } else if (fCurrentInfo
->fImageIndex
> -1
967 && fCurrentInfo
->fMode
== BackgroundImage::kAtOffset
) {
968 BString oldString
, newString
;
969 oldString
<< (int)fCurrentInfo
->fOffset
.x
;
970 if (oldString
!= BString(fXPlacementText
->Text())) {
974 oldString
<< (int)fCurrentInfo
->fOffset
.y
;
975 if (oldString
!= BString(fYPlacementText
->Text())) {
979 } else if (fImageMenu
->IndexOf(fImageMenu
->FindMarked()) > 0) {
981 } else if (fIconLabelOutline
->Value() == B_CONTROL_OFF
) {
985 fApply
->SetEnabled(hasChanged
);
986 fRevert
->SetEnabled(hasChanged
);
991 BackgroundsView::RefsReceived(BMessage
* message
)
993 if (!message
->HasRef("refs") && message
->HasRef("dir_ref")) {
995 if (message
->FindRef("dir_ref", &dirRef
) == B_OK
)
996 message
->AddRef("refs", &dirRef
);
1001 BMimeType
imageType("image");
1003 find_directory(B_DESKTOP_DIRECTORY
, &desktopPath
);
1005 while (message
->FindRef("refs", i
++, &ref
) == B_OK
) {
1007 BEntry
entry(&ref
, true);
1011 if (node
.IsFile()) {
1013 BMimeType::GuessMimeType(&ref
, &refType
);
1014 if (!imageType
.Contains(&refType
))
1017 BGImageMenuItem
* item
;
1018 int32 index
= AddImage(path
);
1020 item
= _FindImageItem(index
);
1021 fLastImageIndex
= index
;
1023 const char* name
= GetImage(-index
- 1)->GetName();
1024 item
= new BGImageMenuItem(name
, -index
- 1,
1025 new BMessage(kMsgImageSelected
));
1027 item
->SetTarget(this);
1028 fLastImageIndex
= -index
- 1;
1031 // An optional placement may have been sent
1032 int32 placement
= 0;
1033 if (message
->FindInt32("placement", &placement
) == B_OK
) {
1034 BMenuItem
* item
= fPlacementMenu
->FindItem(placement
);
1036 item
->SetMarked(true);
1038 item
->SetMarked(true);
1039 BMessenger(this).SendMessage(kMsgImageSelected
);
1040 } else if (node
.IsDirectory()) {
1041 if (desktopPath
== path
) {
1042 fWorkspaceMenu
->FindItem(kMsgCurrentWorkspace
)->SetMarked(true);
1043 BMessenger(this).SendMessage(kMsgCurrentWorkspace
);
1047 int32 index
= _AddPath(path
);
1049 item
= fWorkspaceMenu
->ItemAt(index
+ 6);
1050 fLastWorkspaceIndex
= index
+ 6;
1052 if (fWorkspaceMenu
->CountItems() <= 5)
1053 fWorkspaceMenu
->AddSeparatorItem();
1055 s
<< B_TRANSLATE("Folder: ") << path
.Leaf();
1056 item
= new BMenuItem(s
.String(),
1057 new BMessage(kMsgFolderSelected
));
1058 fWorkspaceMenu
->AddItem(item
, -index
- 1 + 6);
1059 item
->SetTarget(this);
1060 fLastWorkspaceIndex
= -index
- 1 + 6;
1063 item
->SetMarked(true);
1064 BMessenger(this).SendMessage(kMsgFolderSelected
);
1071 BackgroundsView::_AddPath(BPath path
)
1073 int32 count
= fPathList
.CountItems();
1075 for (; index
< count
; index
++) {
1076 BPath
* p
= fPathList
.ItemAt(index
);
1077 int c
= BString(p
->Path()).ICompare(path
.Path());
1084 fPathList
.AddItem(new BPath(path
), index
);
1090 BackgroundsView::AddImage(BPath path
)
1092 int32 count
= fImageList
.CountItems();
1094 for (; index
< count
; index
++) {
1095 Image
* image
= fImageList
.ItemAt(index
);
1096 if (image
->GetPath() == path
)
1100 fImageList
.AddItem(new Image(path
));
1106 BackgroundsView::GetImage(int32 imageIndex
)
1108 return fImageList
.ItemAt(imageIndex
);
1113 BackgroundsView::_FindImageItem(const int32 imageIndex
)
1116 return (BGImageMenuItem
*)fImageMenu
->ItemAt(0);
1118 int32 count
= fImageMenu
->CountItems() - 2;
1120 for (; index
< count
; index
++) {
1121 BGImageMenuItem
* image
= (BGImageMenuItem
*)fImageMenu
->ItemAt(index
);
1122 if (image
->ImageIndex() == imageIndex
)
1130 BackgroundsView::_AddItem(BGImageMenuItem
* item
)
1132 int32 count
= fImageMenu
->CountItems() - 2;
1134 if (count
< index
) {
1135 fImageMenu
->AddItem(new BSeparatorItem(), 1);
1136 count
= fImageMenu
->CountItems() - 2;
1139 for (; index
< count
; index
++) {
1140 BGImageMenuItem
* image
= (BGImageMenuItem
*)fImageMenu
->ItemAt(index
);
1141 int c
= (BString(image
->Label()).ICompare(BString(item
->Label())));
1145 return fImageMenu
->AddItem(item
, index
);
1150 BackgroundsView::_SetDesktop(bool isDesktop
)
1152 fTopLeft
->SetDesktop(isDesktop
);
1153 fTop
->SetDesktop(isDesktop
);
1154 fTopRight
->SetDesktop(isDesktop
);
1155 fLeft
->SetDesktop(isDesktop
);
1156 fRight
->SetDesktop(isDesktop
);
1157 fBottomLeft
->SetDesktop(isDesktop
);
1158 fBottom
->SetDesktop(isDesktop
);
1159 fBottomRight
->SetDesktop(isDesktop
);
1166 BackgroundsView::FoundPositionSetting()
1168 return fFoundPositionSetting
;
1177 BControl("PreView", NULL
, NULL
, B_WILL_DRAW
| B_SUBPIXEL_PRECISE
)
1179 float aspectRatio
= BScreen().Frame().Width() / BScreen().Frame().Height();
1180 float previewWidth
= 120.0f
* std::max(1.0f
, be_plain_font
->Size() / 12.0f
);
1181 float previewHeight
= ceil(previewWidth
/ aspectRatio
);
1183 ResizeTo(previewWidth
, previewHeight
);
1184 SetExplicitMinSize(BSize(previewWidth
, previewHeight
));
1185 SetExplicitMaxSize(BSize(previewWidth
, previewHeight
));
1190 Preview::AttachedToWindow()
1192 rgb_color color
= ViewColor();
1193 BControl::AttachedToWindow();
1194 SetViewColor(color
);
1199 Preview::MouseDown(BPoint point
)
1201 if (IsEnabled() && Bounds().Contains(point
)) {
1203 GetMouse(&point
, &buttons
);
1204 if (buttons
& B_PRIMARY_MOUSE_BUTTON
) {
1207 BScreen().GetMode(&fMode
);
1208 fXRatio
= Bounds().Width() / fMode
.virtual_width
;
1209 fYRatio
= Bounds().Height() / fMode
.virtual_height
;
1210 SetMouseEventMask(B_POINTER_EVENTS
,
1211 B_LOCK_WINDOW_FOCUS
| B_NO_POINTER_HISTORY
);
1213 BCursor
grabbingCursor(B_CURSOR_ID_GRABBING
);
1214 SetViewCursor(&grabbingCursor
);
1221 Preview::MouseUp(BPoint point
)
1225 BCursor
grabCursor(B_CURSOR_ID_GRAB
);
1226 SetViewCursor(&grabCursor
);
1232 Preview::MouseMoved(BPoint point
, uint32 transit
, const BMessage
* message
)
1234 if (!IsTracking()) {
1235 BCursor
cursor(IsEnabled()
1236 ? B_CURSOR_ID_GRAB
: B_CURSOR_ID_SYSTEM_DEFAULT
);
1237 SetViewCursor(&cursor
);
1240 x
= fPoint
.x
+ (point
.x
- fOldPoint
.x
) / fXRatio
;
1241 y
= fPoint
.y
+ (point
.y
- fOldPoint
.y
) / fYRatio
;
1242 bool min
, max
, mustSend
= false;
1243 min
= (x
> -fImageBounds
.Width());
1244 max
= (x
< fMode
.virtual_width
);
1246 fOldPoint
.x
= point
.x
;
1250 if (!min
&& fPoint
.x
> -fImageBounds
.Width()) {
1251 fPoint
.x
= -fImageBounds
.Width();
1252 fOldPoint
.x
= point
.x
- (x
- fPoint
.x
) * fXRatio
;
1255 if (!max
&& fPoint
.x
< fMode
.virtual_width
) {
1256 fPoint
.x
= fMode
.virtual_width
;
1257 fOldPoint
.x
= point
.x
- (x
- fPoint
.x
) * fXRatio
;
1262 min
= (y
> -fImageBounds
.Height());
1263 max
= (y
< fMode
.virtual_height
);
1265 fOldPoint
.y
= point
.y
;
1269 if (!min
&& fPoint
.y
> -fImageBounds
.Height()) {
1270 fPoint
.y
= -fImageBounds
.Height();
1271 fOldPoint
.y
= point
.y
- (y
- fPoint
.y
) * fYRatio
;
1274 if (!max
&& fPoint
.y
< fMode
.virtual_height
) {
1275 fPoint
.y
= fMode
.virtual_height
;
1276 fOldPoint
.y
= point
.y
- (y
- fPoint
.y
) * fYRatio
;
1282 BMessenger
messenger(Parent());
1283 messenger
.SendMessage(kMsgUpdatePreviewPlacement
);
1287 BControl::MouseMoved(point
, transit
, message
);
1294 BGImageMenuItem::BGImageMenuItem(const char* label
, int32 imageIndex
,
1295 BMessage
* message
, char shortcut
, uint32 modifiers
)
1296 : BMenuItem(label
, message
, shortcut
, modifiers
),
1297 fImageIndex(imageIndex
)
1305 FramePart::FramePart(int32 part
)
1307 BView(NULL
, B_WILL_DRAW
| B_FRAME_EVENTS
),
1311 _SetSizeAndAlignment();
1316 FramePart::Draw(BRect rect
)
1318 rgb_color color
= HighColor();
1319 SetDrawingMode(B_OP_COPY
);
1320 SetHighColor(Parent()->ViewColor());
1323 switch (fFramePart
) {
1324 case FRAME_TOP_LEFT
:
1326 SetHighColor(160, 160, 160);
1327 FillRoundRect(BRect(0, 0, 8, 8), 3, 3);
1328 SetHighColor(96, 96, 96);
1329 StrokeRoundRect(BRect(0, 0, 8, 8), 3, 3);
1333 SetHighColor(160, 160, 160);
1334 FillRect(BRect(0, 1, rect
.right
, 3));
1335 SetHighColor(96, 96, 96);
1336 StrokeLine(BPoint(0, 0), BPoint(rect
.right
, 0));
1337 SetHighColor(0, 0, 0);
1338 StrokeLine(BPoint(0, 4), BPoint(rect
.right
, 4));
1341 case FRAME_TOP_RIGHT
:
1343 SetHighColor(160, 160, 160);
1344 FillRoundRect(BRect(-4, 0, 4, 8), 3, 3);
1345 SetHighColor(96, 96, 96);
1346 StrokeRoundRect(BRect(-4, 0, 4, 8), 3, 3);
1349 case FRAME_LEFT_SIDE
:
1350 SetHighColor(160, 160, 160);
1351 FillRect(BRect(1, 0, 3, rect
.bottom
));
1352 SetHighColor(96, 96, 96);
1353 StrokeLine(BPoint(0, 0), BPoint(0, rect
.bottom
));
1354 SetHighColor(0, 0, 0);
1355 StrokeLine(BPoint(4, 0), BPoint(4, rect
.bottom
));
1358 case FRAME_RIGHT_SIDE
:
1359 SetHighColor(160, 160, 160);
1360 FillRect(BRect(1, 0, 3, rect
.bottom
));
1361 SetHighColor(0, 0, 0);
1362 StrokeLine(BPoint(0, 0), BPoint(0, rect
.bottom
));
1363 SetHighColor(96, 96, 96);
1364 StrokeLine(BPoint(4, 0), BPoint(4, rect
.bottom
));
1367 case FRAME_BOTTOM_LEFT
:
1369 SetHighColor(160, 160, 160);
1370 FillRoundRect(BRect(0, -4, 8, 4), 3, 3);
1371 SetHighColor(96, 96, 96);
1372 StrokeRoundRect(BRect(0, -4, 8, 4), 3, 3);
1376 SetHighColor(160, 160, 160);
1377 FillRect(BRect(0, 1, rect
.right
, 3));
1378 SetHighColor(0, 0, 0);
1379 StrokeLine(BPoint(0, 0), BPoint(rect
.right
, 0));
1380 SetHighColor(96, 96, 96);
1381 StrokeLine(BPoint(0, 4), BPoint(rect
.right
, 4));
1382 SetHighColor(228, 0, 0);
1383 StrokeLine(BPoint(5, 2), BPoint(7, 2));
1386 case FRAME_BOTTOM_RIGHT
:
1388 SetHighColor(160, 160, 160);
1389 FillRoundRect(BRect(-4, -4, 4, 4), 3, 3);
1390 SetHighColor(96, 96, 96);
1391 StrokeRoundRect(BRect(-4, -4, 4, 4), 3, 3);
1398 switch (fFramePart
) {
1399 case FRAME_TOP_LEFT
:
1400 SetHighColor(152, 152, 152);
1401 StrokeLine(BPoint(0, 0), BPoint(0, 12));
1402 StrokeLine(BPoint(0, 0), BPoint(4, 0));
1403 StrokeLine(BPoint(3, 12), BPoint(3, 12));
1404 SetHighColor(255, 203, 0);
1405 FillRect(BRect(1, 1, 3, 9));
1406 SetHighColor(240, 240, 240);
1407 StrokeLine(BPoint(1, 12), BPoint(1, 10));
1408 StrokeLine(BPoint(2, 10), BPoint(3, 10));
1409 SetHighColor(200, 200, 200);
1410 StrokeLine(BPoint(2, 12), BPoint(2, 11));
1411 StrokeLine(BPoint(3, 11), BPoint(3, 11));
1415 FillRect(BRect(54, 0, rect
.right
, 8));
1416 SetHighColor(255, 203, 0);
1417 FillRect(BRect(0, 1, 52, 9));
1418 SetHighColor(152, 152, 152);
1419 StrokeLine(BPoint(0, 0), BPoint(53, 0));
1420 StrokeLine(BPoint(53, 1), BPoint(53, 9));
1421 StrokeLine(BPoint(54, 9), BPoint(rect
.right
, 9));
1422 SetHighColor(240, 240, 240);
1423 StrokeLine(BPoint(0, 10), BPoint(rect
.right
, 10));
1424 SetHighColor(200, 200, 200);
1425 StrokeLine(BPoint(0, 11), BPoint(rect
.right
, 11));
1426 SetHighColor(152, 152, 152);
1427 StrokeLine(BPoint(0, 12), BPoint(rect
.right
, 12));
1430 case FRAME_TOP_RIGHT
:
1431 FillRect(BRect(0, 0, 3, 8));
1432 SetHighColor(152, 152, 152);
1433 StrokeLine(BPoint(0, 12), BPoint(0, 12));
1434 StrokeLine(BPoint(0, 9), BPoint(3, 9));
1435 StrokeLine(BPoint(3, 12), BPoint(3, 9));
1436 SetHighColor(240, 240, 240);
1437 StrokeLine(BPoint(0, 10), BPoint(2, 10));
1438 StrokeLine(BPoint(1, 12), BPoint(1, 12));
1439 SetHighColor(200, 200, 200);
1440 StrokeLine(BPoint(2, 12), BPoint(2, 12));
1441 StrokeLine(BPoint(0, 11), BPoint(2, 11));
1444 case FRAME_LEFT_SIDE
:
1445 case FRAME_RIGHT_SIDE
:
1446 SetHighColor(152, 152, 152);
1447 StrokeLine(BPoint(0, 0), BPoint(0, rect
.bottom
));
1448 SetHighColor(240, 240, 240);
1449 StrokeLine(BPoint(1, 0), BPoint(1, rect
.bottom
));
1450 SetHighColor(200, 200, 200);
1451 StrokeLine(BPoint(2, 0), BPoint(2, rect
.bottom
));
1452 SetHighColor(152, 152, 152);
1453 StrokeLine(BPoint(3, 0), BPoint(3, rect
.bottom
));
1456 case FRAME_BOTTOM_LEFT
:
1457 SetHighColor(152, 152, 152);
1458 StrokeLine(BPoint(0, 0), BPoint(0, 3));
1459 StrokeLine(BPoint(0, 3), BPoint(3, 3));
1460 StrokeLine(BPoint(3, 0), BPoint(3, 0));
1461 SetHighColor(240, 240, 240);
1462 StrokeLine(BPoint(1, 0), BPoint(1, 2));
1463 StrokeLine(BPoint(3, 1), BPoint(3, 1));
1464 SetHighColor(200, 200, 200);
1465 StrokeLine(BPoint(2, 0), BPoint(2, 2));
1466 StrokeLine(BPoint(3, 2), BPoint(3, 2));
1470 SetHighColor(152, 152, 152);
1471 StrokeLine(BPoint(0, 0), BPoint(rect
.right
, 0));
1472 SetHighColor(240, 240, 240);
1473 StrokeLine(BPoint(0, 1), BPoint(rect
.right
, 1));
1474 SetHighColor(200, 200, 200);
1475 StrokeLine(BPoint(0, 2), BPoint(rect
.right
, 2));
1476 SetHighColor(152, 152, 152);
1477 StrokeLine(BPoint(0, 3), BPoint(rect
.right
, 3));
1480 case FRAME_BOTTOM_RIGHT
:
1481 SetHighColor(152, 152, 152);
1482 StrokeLine(BPoint(0, 0), BPoint(0, 0));
1483 SetHighColor(240, 240, 240);
1484 StrokeLine(BPoint(1, 0), BPoint(1, 1));
1485 StrokeLine(BPoint(0, 1), BPoint(0, 1));
1486 SetHighColor(200, 200, 200);
1487 StrokeLine(BPoint(2, 0), BPoint(2, 2));
1488 StrokeLine(BPoint(0, 2), BPoint(1, 2));
1489 SetHighColor(152, 152, 152);
1490 StrokeLine(BPoint(3, 0), BPoint(3, 3));
1491 StrokeLine(BPoint(0, 3), BPoint(2, 3));
1499 SetHighColor(color
);
1504 FramePart::SetDesktop(bool isDesktop
)
1506 fIsDesktop
= isDesktop
;
1508 _SetSizeAndAlignment();
1514 FramePart::_SetSizeAndAlignment()
1517 switch (fFramePart
) {
1518 case FRAME_TOP_LEFT
:
1519 SetExplicitMinSize(BSize(4, 4));
1520 SetExplicitMaxSize(BSize(4, 4));
1524 SetExplicitMinSize(BSize(1, 4));
1525 SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED
, 4));
1528 case FRAME_TOP_RIGHT
:
1529 SetExplicitMinSize(BSize(4, 4));
1530 SetExplicitMaxSize(BSize(4, 4));
1533 case FRAME_LEFT_SIDE
:
1534 SetExplicitMinSize(BSize(4, 1));
1535 SetExplicitMaxSize(BSize(4, B_SIZE_UNLIMITED
));
1538 case FRAME_RIGHT_SIDE
:
1539 SetExplicitMinSize(BSize(4, 1));
1540 SetExplicitMaxSize(BSize(4, B_SIZE_UNLIMITED
));
1543 case FRAME_BOTTOM_LEFT
:
1544 SetExplicitMinSize(BSize(4, 4));
1545 SetExplicitMaxSize(BSize(4, 4));
1549 SetExplicitMinSize(BSize(1, 4));
1550 SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED
, 4));
1553 case FRAME_BOTTOM_RIGHT
:
1554 SetExplicitMaxSize(BSize(4, 4));
1555 SetExplicitMinSize(BSize(4, 4));
1562 switch (fFramePart
) {
1563 case FRAME_TOP_LEFT
:
1564 SetExplicitMinSize(BSize(3, 12));
1565 SetExplicitMaxSize(BSize(3, 12));
1569 SetExplicitMinSize(BSize(1, 12));
1570 SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED
, 12));
1573 case FRAME_TOP_RIGHT
:
1574 SetExplicitMinSize(BSize(3, 12));
1575 SetExplicitMaxSize(BSize(3, 12));
1578 case FRAME_LEFT_SIDE
:
1579 SetExplicitMinSize(BSize(3, 1));
1580 SetExplicitMaxSize(BSize(3, B_SIZE_UNLIMITED
));
1583 case FRAME_RIGHT_SIDE
:
1584 SetExplicitMinSize(BSize(3, 1));
1585 SetExplicitMaxSize(BSize(3, B_SIZE_UNLIMITED
));
1588 case FRAME_BOTTOM_LEFT
:
1589 SetExplicitMinSize(BSize(3, 3));
1590 SetExplicitMaxSize(BSize(3, 3));
1594 SetExplicitMinSize(BSize(1, 3));
1595 SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED
, 3));
1598 case FRAME_BOTTOM_RIGHT
:
1599 SetExplicitMaxSize(BSize(3, 3));
1600 SetExplicitMinSize(BSize(3, 3));
1608 switch (fFramePart
) {
1609 case FRAME_TOP_LEFT
:
1610 SetExplicitAlignment(BAlignment(B_ALIGN_RIGHT
, B_ALIGN_BOTTOM
));
1614 SetExplicitAlignment(BAlignment(B_ALIGN_CENTER
, B_ALIGN_BOTTOM
));
1617 case FRAME_TOP_RIGHT
:
1618 SetExplicitAlignment(BAlignment(B_ALIGN_LEFT
, B_ALIGN_BOTTOM
));
1621 case FRAME_LEFT_SIDE
:
1622 SetExplicitAlignment(BAlignment(B_ALIGN_RIGHT
, B_ALIGN_MIDDLE
));
1625 case FRAME_RIGHT_SIDE
:
1626 SetExplicitAlignment(BAlignment(B_ALIGN_LEFT
, B_ALIGN_MIDDLE
));
1629 case FRAME_BOTTOM_LEFT
:
1630 SetExplicitAlignment(BAlignment(B_ALIGN_RIGHT
, B_ALIGN_TOP
));
1634 SetExplicitAlignment(BAlignment(B_ALIGN_CENTER
, B_ALIGN_TOP
));
1637 case FRAME_BOTTOM_RIGHT
:
1638 SetExplicitAlignment(BAlignment(B_ALIGN_LEFT
, B_ALIGN_TOP
));