From dca191e9b75fa7c5d70177042a7bc29983e93836 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Sundstr=C3=B6m?= Date: Thu, 5 Nov 2009 23:39:57 +0000 Subject: [PATCH] Partial clean-up. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33910 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../backgrounds/BackgroundImage.cpp | 133 +++++++------ src/preferences/backgrounds/BackgroundImage.h | 52 ++--- src/preferences/backgrounds/Backgrounds.cpp | 11 +- .../backgrounds/BackgroundsView.cpp | 74 +++---- src/preferences/backgrounds/BackgroundsView.h | 182 ++++++++++-------- .../backgrounds/ImageFilePanel.cpp | 81 ++++---- src/preferences/backgrounds/ImageFilePanel.h | 53 ++--- src/preferences/backgrounds/Jamfile | 1 - 8 files changed, 316 insertions(+), 271 deletions(-) diff --git a/src/preferences/backgrounds/BackgroundImage.cpp b/src/preferences/backgrounds/BackgroundImage.cpp index 800639118d..353fa2b01e 100644 --- a/src/preferences/backgrounds/BackgroundImage.cpp +++ b/src/preferences/backgrounds/BackgroundImage.cpp @@ -35,8 +35,14 @@ All rights reserved. // Classes used for setting up and managing background images // +#include "BackgroundImage.h" + +#include +#include + #include #include +#include #include #include #include @@ -47,43 +53,37 @@ All rights reserved. #include #include -#include -#include - -#include "BackgroundImage.h" #include "BackgroundsView.h" -#include - -const char *kBackgroundImageInfo = "be:bgndimginfo"; -const char *kBackgroundImageInfoOffset = "be:bgndimginfooffset"; -//const char *kBackgroundImageInfoTextOutline = "be:bgndimginfotextoutline"; -const char *kBackgroundImageInfoTextOutline = "be:bgndimginfoerasetext"; +const char* kBackgroundImageInfo = "be:bgndimginfo"; +const char* kBackgroundImageInfoOffset = "be:bgndimginfooffset"; +// const char* kBackgroundImageInfoTextOutline = "be:bgndimginfotextoutline"; +const char* kBackgroundImageInfoTextOutline = "be:bgndimginfoerasetext"; // NOTE: the attribute keeps the old name for backwards compatibility, // just in case some users spend time configuring a few windows with // this feature on or off... -const char *kBackgroundImageInfoMode = "be:bgndimginfomode"; -const char *kBackgroundImageInfoWorkspaces = "be:bgndimginfoworkspaces"; -const char *kBackgroundImageInfoPath = "be:bgndimginfopath"; -const char *kBackgroundImageInfoSet = "be:bgndimginfoset"; -const char *kBackgroundImageInfoCacheMode = "be:bgndimginfocachemode"; -const char *kBackgroundImageSetPeriod = "be:bgndimgsetperiod"; -const char *kBackgroundImageRandomChange = "be:bgndimgrandomchange"; -const char *kBackgroundImageCacheMode = "be:bgndimgcachemode"; +const char* kBackgroundImageInfoMode = "be:bgndimginfomode"; +const char* kBackgroundImageInfoWorkspaces = "be:bgndimginfoworkspaces"; +const char* kBackgroundImageInfoPath = "be:bgndimginfopath"; +const char* kBackgroundImageInfoSet = "be:bgndimginfoset"; +const char* kBackgroundImageInfoCacheMode = "be:bgndimginfocachemode"; +const char* kBackgroundImageSetPeriod = "be:bgndimgsetperiod"; +const char* kBackgroundImageRandomChange = "be:bgndimgrandomchange"; +const char* kBackgroundImageCacheMode = "be:bgndimgcachemode"; -BackgroundImage * -BackgroundImage::GetBackgroundImage(const BNode *node, bool isDesktop, +BackgroundImage* +BackgroundImage::GetBackgroundImage(const BNode* node, bool isDesktop, BackgroundsView* view) { - BackgroundImage *result = new BackgroundImage(node, isDesktop, view); + BackgroundImage* result = new BackgroundImage(node, isDesktop, view); attr_info info; if (node->GetAttrInfo(kBackgroundImageInfo, &info) != B_OK) return result; BMessage container; - char *buffer = new char [info.size]; + char* buffer = new char [info.size]; status_t error = node->ReadAttr(kBackgroundImageInfo, info.type, 0, buffer, (size_t)info.size); @@ -103,13 +103,14 @@ BackgroundImage::GetBackgroundImage(const BNode *node, bool isDesktop, uint32 maxImageSet = 0; if (isDesktop) { - container.FindInt32(kBackgroundImageSetPeriod, (int32 *)&imageSetPeriod); - container.FindInt32(kBackgroundImageCacheMode, (int32 *)&globalCacheMode); + container.FindInt32(kBackgroundImageSetPeriod, (int32*)&imageSetPeriod); + container.FindInt32(kBackgroundImageCacheMode, + (int32*)&globalCacheMode); container.FindBool(kBackgroundImageRandomChange, &randomChange); } for (int32 index = 0; ; index++) { - const char *path; + const char* path; uint32 workspaces = B_ALL_WORKSPACES; Mode mode = kTiled; bool textWidgetLabelOutline = false; @@ -118,7 +119,8 @@ BackgroundImage::GetBackgroundImage(const BNode *node, bool isDesktop, uint32 cacheMode = 0; int32 imageIndex = -1; - if (container.FindString(kBackgroundImageInfoPath, index, &path) == B_OK) { + if (container.FindString(kBackgroundImageInfoPath, index, &path) + == B_OK) { if (strcmp(path, "")) { BPath bpath(path); imageIndex = view->AddImage(bpath); @@ -130,24 +132,24 @@ BackgroundImage::GetBackgroundImage(const BNode *node, bool isDesktop, break; container.FindInt32(kBackgroundImageInfoWorkspaces, index, - (int32 *)&workspaces); - container.FindInt32(kBackgroundImageInfoMode, index, (int32 *)&mode); + (int32*)&workspaces); + container.FindInt32(kBackgroundImageInfoMode, index, (int32*)&mode); container.FindBool(kBackgroundImageInfoTextOutline, index, &textWidgetLabelOutline); container.FindPoint(kBackgroundImageInfoOffset, index, &offset); if (isDesktop) { container.FindInt32(kBackgroundImageInfoSet, index, - (int32 *)&imageSet); + (int32*)&imageSet); container.FindInt32(kBackgroundImageInfoCacheMode, index, - (int32 *)&cacheMode); + (int32*)&cacheMode); } - BackgroundImage::BackgroundImageInfo *imageInfo = new + BackgroundImage::BackgroundImageInfo* imageInfo = new BackgroundImage::BackgroundImageInfo(workspaces, imageIndex, mode, offset, textWidgetLabelOutline, imageSet, cacheMode); - //imageInfo->UnloadBitmap(globalCacheMode); + // imageInfo->UnloadBitmap(globalCacheMode); if (imageSet > maxImageSet) maxImageSet = imageSet; @@ -191,7 +193,8 @@ BackgroundImage::BackgroundImageInfo::~BackgroundImageInfo() // #pragma mark - -BackgroundImage::BackgroundImage(const BNode *node, bool desktop, BackgroundsView* view) +BackgroundImage::BackgroundImage(const BNode* node, bool desktop, + BackgroundsView* view) : fIsDesktop(desktop), fDefinedByNode(*node), @@ -214,14 +217,14 @@ BackgroundImage::~BackgroundImage() void -BackgroundImage::Add(BackgroundImageInfo *info) +BackgroundImage::Add(BackgroundImageInfo* info) { fBitmapForWorkspaceList.AddItem(info); } void -BackgroundImage::Remove(BackgroundImageInfo *info) +BackgroundImage::Remove(BackgroundImageInfo* info) { fBitmapForWorkspaceList.RemoveItem(info); } @@ -231,7 +234,7 @@ void BackgroundImage::RemoveAll() { for (int32 index = 0; index < fBitmapForWorkspaceList.CountItems();) { - BackgroundImageInfo *info = fBitmapForWorkspaceList.ItemAt(index); + BackgroundImageInfo* info = fBitmapForWorkspaceList.ItemAt(index); if (info->fImageSet != fShowingImageSet) index++; else @@ -241,24 +244,26 @@ BackgroundImage::RemoveAll() void -BackgroundImage::Show(BView *view, int32 workspace) +BackgroundImage::Show(BView* view, int32 workspace) { fView = view; - BackgroundImageInfo *info = ImageInfoForWorkspace(workspace); + BackgroundImageInfo* info = ImageInfoForWorkspace(workspace); if (info) { - /*BPoseView *poseView = dynamic_cast(fView); + /*BPoseView* poseView = dynamic_cast(fView); if (poseView) - poseView->SetEraseWidgetTextBackground(info->fTextWidgetLabelOutline);*/ + poseView + ->SetEraseWidgetTextBackground(info->fTextWidgetLabelOutline);*/ Show(info, fView); } } void -BackgroundImage::Show(BackgroundImageInfo *info, BView *view) +BackgroundImage::Show(BackgroundImageInfo* info, BView* view) { - BBitmap *bitmap = fBackgroundsView->GetImage(info->fImageIndex)->GetBitmap(); + BBitmap* bitmap + = fBackgroundsView->GetImage(info->fImageIndex)->GetBitmap(); if (!bitmap) return; @@ -287,7 +292,8 @@ BackgroundImage::Show(BackgroundImageInfo *info, BView *view) if (fIsDesktop) { destinationBitmapBounds.OffsetBy( (viewBounds.Width() - destinationBitmapBounds.Width()) / 2, - (viewBounds.Height() - destinationBitmapBounds.Height()) / 2); + (viewBounds.Height() - destinationBitmapBounds.Height()) + / 2); break; } // else fall thru @@ -304,7 +310,8 @@ BackgroundImage::Show(BackgroundImageInfo *info, BView *view) break; } case kTiled: - // Original Backgrounds Preferences center the tiled paper but the Tracker don't do that + // Original Backgrounds Preferences center the tiled paper + // but Tracker doesn't do that //if (fIsDesktop) { destinationBitmapBounds.OffsetBy( (viewBounds.Width() - destinationBitmapBounds.Width()) / 2, @@ -333,7 +340,7 @@ BackgroundImage::Remove() if (fShowingBitmap) { fView->ClearViewBitmap(); fView->Invalidate(); - /*BPoseView *poseView = dynamic_cast(fView); + /*BPoseView* poseView = dynamic_cast(fView); // make sure text widgets draw the default way, erasing their background if (poseView) poseView->SetEraseWidgetTextBackground(true);*/ @@ -342,7 +349,7 @@ BackgroundImage::Remove() } -BackgroundImage::BackgroundImageInfo * +BackgroundImage::BackgroundImageInfo* BackgroundImage::ImageInfoForWorkspace(int32 workspace) const { uint32 workspaceMask = 1; @@ -355,9 +362,9 @@ BackgroundImage::ImageInfoForWorkspace(int32 workspace) const // do a simple lookup for the most likely candidate bitmap - // pick the imageInfo that is only defined for this workspace over one // that supports multiple workspaces - BackgroundImageInfo *result = NULL; + BackgroundImageInfo* result = NULL; for (int32 index = 0; index < count; index++) { - BackgroundImageInfo *info = fBitmapForWorkspaceList.ItemAt(index); + BackgroundImageInfo* info = fBitmapForWorkspaceList.ItemAt(index); if (info->fImageSet != fShowingImageSet) continue; @@ -375,7 +382,7 @@ BackgroundImage::ImageInfoForWorkspace(int32 workspace) const void -BackgroundImage::WorkspaceActivated(BView *view, int32 workspace, bool state) +BackgroundImage::WorkspaceActivated(BView* view, int32 workspace, bool state) { if (!fIsDesktop) { // we only care for desktop bitmaps @@ -387,12 +394,12 @@ BackgroundImage::WorkspaceActivated(BView *view, int32 workspace, bool state) return; } - BackgroundImageInfo *info = ImageInfoForWorkspace(workspace); + BackgroundImageInfo* info = ImageInfoForWorkspace(workspace); if (info != fShowingBitmap) { if (info) Show(info, view); else { - /*if (BPoseView *poseView = dynamic_cast(view)) + /*if (BPoseView* poseView = dynamic_cast(view)) poseView->SetEraseWidgetTextBackground(true);*/ view->ClearViewBitmap(); view->Invalidate(); @@ -416,28 +423,29 @@ BackgroundImage::ScreenChanged(BRect, color_space) (viewBounds.Width() - bitmapBounds.Width()) / 2, (viewBounds.Height() - bitmapBounds.Height()) / 2); - fView->SetViewBitmap(fShowingBitmap->fBitmap, bitmapBounds, destinationBitmapBounds, - B_FOLLOW_NONE, 0); + fView->SetViewBitmap(fShowingBitmap->fBitmap, bitmapBounds, + destinationBitmapBounds, B_FOLLOW_NONE, 0); fView->Invalidate(); }*/ } status_t -BackgroundImage::SetBackgroundImage(BNode *node) +BackgroundImage::SetBackgroundImage(BNode* node) { status_t err; BMessage container; int32 count = fBitmapForWorkspaceList.CountItems(); for (int32 index = 0; index < count; index++) { - BackgroundImageInfo *info = fBitmapForWorkspaceList.ItemAt(index); + BackgroundImageInfo* info = fBitmapForWorkspaceList.ItemAt(index); container.AddBool(kBackgroundImageInfoTextOutline, info->fTextWidgetLabelOutline); if (fBackgroundsView->GetImage(info->fImageIndex) != NULL) { container.AddString(kBackgroundImageInfoPath, - fBackgroundsView->GetImage(info->fImageIndex)->GetPath().Path()); + fBackgroundsView + ->GetImage(info->fImageIndex)->GetPath().Path()); } else container.AddString(kBackgroundImageInfoPath, ""); @@ -473,16 +481,16 @@ BackgroundImage::SetBackgroundImage(BNode *node) } -/*BackgroundImage * -BackgroundImage::Refresh(BackgroundImage *oldBackgroundImage, - const BNode *fromNode, bool desktop, BPoseView *poseView) +/*BackgroundImage* +BackgroundImage::Refresh(BackgroundImage* oldBackgroundImage, + const BNode* fromNode, bool desktop, BPoseView* poseView) { if (oldBackgroundImage) { oldBackgroundImage->Remove(); delete oldBackgroundImage; } - BackgroundImage *result = GetBackgroundImage(fromNode, desktop); + BackgroundImage* result = GetBackgroundImage(fromNode, desktop); if (result && poseView->ViewMode() != kListMode) result->Show(poseView, current_workspace()); return result; @@ -490,12 +498,12 @@ BackgroundImage::Refresh(BackgroundImage *oldBackgroundImage, void -BackgroundImage::ChangeImageSet(BPoseView *poseView) +BackgroundImage::ChangeImageSet(BPoseView* poseView) { if (fRandomChange) { if (fImageSetCount > 1) { uint32 oldShowingImageSet = fShowingImageSet; - while(oldShowingImageSet == fShowingImageSet) + while (oldShowingImageSet == fShowingImageSet) fShowingImageSet = random()%fImageSetCount; } else fShowingImageSet = 0; @@ -535,3 +543,4 @@ Image::GetBitmap() return fBitmap; } + diff --git a/src/preferences/backgrounds/BackgroundImage.h b/src/preferences/backgrounds/BackgroundImage.h index 8a7b119acc..c42787795b 100644 --- a/src/preferences/backgrounds/BackgroundImage.h +++ b/src/preferences/backgrounds/BackgroundImage.h @@ -38,13 +38,14 @@ All rights reserved. #ifndef __BACKGROUND_IMAGE__ #define __BACKGROUND_IMAGE__ -#include "String.h" -#include "ObjectList.h" #include #include #include +#include "ObjectList.h" +#include "String.h" + class BView; class BBitmap; @@ -53,14 +54,14 @@ class BackgroundImage; class Image; class BackgroundsView; -extern const char *kBackgroundImageInfo; -extern const char *kBackgroundImageInfoOffset; -extern const char *kBackgroundImageInfoEraseText; -extern const char *kBackgroundImageInfoMode; -extern const char *kBackgroundImageInfoWorkspaces; -extern const char *kBackgroundImageInfoPath; -extern const char *kBackgroundImageInfoSet; -extern const char *kBackgroundImageInfoSetPeriod; +extern const char* kBackgroundImageInfo; +extern const char* kBackgroundImageInfoOffset; +extern const char* kBackgroundImageInfoEraseText; +extern const char* kBackgroundImageInfoMode; +extern const char* kBackgroundImageInfoWorkspaces; +extern const char* kBackgroundImageInfoPath; +extern const char* kBackgroundImageInfoSet; +extern const char* kBackgroundImageInfoSetPeriod; const uint32 kRestoreBackgroundImage = 'Tbgr'; const uint32 kChangeBackgroundImage = 'Cbgr'; @@ -99,50 +100,50 @@ public: uint32 fCacheMode; // image cache strategy (0 cache , 1 no cache) }; - static BackgroundImage *GetBackgroundImage(const BNode *node, + static BackgroundImage* GetBackgroundImage(const BNode* node, bool isDesktop, BackgroundsView* view); // create a BackgroundImage object by reading it from a node virtual ~BackgroundImage(); - void Show(BView *view, int32 workspace); + void Show(BView* view, int32 workspace); // display the right background for a given workspace void Remove(); // remove the background from it's current view - void WorkspaceActivated(BView *view, int32 workspace, bool state); + void WorkspaceActivated(BView* view, int32 workspace, bool state); // respond to a workspace change void ScreenChanged(BRect rect, color_space space); // respond to a screen size change - /*static BackgroundImage *Refresh(BackgroundImage *oldBackgroundImage, - const BNode *fromNode, bool desktop, BPoseView *poseView); + /*static BackgroundImage* Refresh(BackgroundImage* oldBackgroundImage, + const BNode* fromNode, bool desktop, BPoseView* poseView); // respond to a background image setting change - void ChangeImageSet(BPoseView *poseView); + void ChangeImageSet(BPoseView* poseView); // change to the next imageSet if any, no refresh*/ - BackgroundImageInfo *ImageInfoForWorkspace(int32) const; + BackgroundImageInfo* ImageInfoForWorkspace(int32) const; bool IsDesktop() { return fIsDesktop;} - status_t SetBackgroundImage(BNode *node); + status_t SetBackgroundImage(BNode* node); - void Show(BackgroundImageInfo *, BView *view); + void Show(BackgroundImageInfo*, BView* view); uint32 GetShowingImageSet() { return fShowingImageSet; } - void Add(BackgroundImageInfo *); - void Remove(BackgroundImageInfo *); + void Add(BackgroundImageInfo*); + void Remove(BackgroundImageInfo*); void RemoveAll(); private: - BackgroundImage(const BNode *node, bool isDesktop, BackgroundsView* view); + BackgroundImage(const BNode* node, bool isDesktop, BackgroundsView* view); // no public constructor, GetBackgroundImage factory function is // used instead bool fIsDesktop; BNode fDefinedByNode; - BView *fView; + BView* fView; BackgroundsView* fBackgroundsView; - BackgroundImageInfo *fShowingBitmap; + BackgroundImageInfo* fShowingBitmap; BObjectList fBitmapForWorkspaceList; @@ -164,9 +165,10 @@ public: BBitmap* GetBitmap(); BPath GetPath() {return fPath;} private: - BBitmap *fBitmap; + BBitmap* fBitmap; BPath fPath; BString name; }; #endif + diff --git a/src/preferences/backgrounds/Backgrounds.cpp b/src/preferences/backgrounds/Backgrounds.cpp index 87b394dada..94b1b7887e 100644 --- a/src/preferences/backgrounds/Backgrounds.cpp +++ b/src/preferences/backgrounds/Backgrounds.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008, Haiku, Inc. All Rights Reserved. + * Copyright 2002-2009, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -8,15 +8,15 @@ */ -#include "BackgroundsView.h" - #include #include #include #include +#include "BackgroundsView.h" -static const char *kSignature = "application/x-vnd.Haiku-Backgrounds"; + +static const char* kSignature = "application/x-vnd.Haiku-Backgrounds"; class BackgroundsWindow : public BWindow { @@ -29,7 +29,7 @@ class BackgroundsWindow : public BWindow { virtual bool QuitRequested(); virtual void WorkspaceActivated(int32 oldWorkspaces, bool active); - BackgroundsView *fBackgroundsView; + BackgroundsView* fBackgroundsView; }; @@ -61,6 +61,7 @@ BackgroundsApplication::RefsReceived(BMessage* message) fWindow->RefsReceived(message); } + // #pragma mark - diff --git a/src/preferences/backgrounds/BackgroundsView.cpp b/src/preferences/backgrounds/BackgroundsView.cpp index 983b6396b1..3a7a2c67d8 100644 --- a/src/preferences/backgrounds/BackgroundsView.cpp +++ b/src/preferences/backgrounds/BackgroundsView.cpp @@ -10,7 +10,6 @@ #include "BackgroundsView.h" -#include "ImageFilePanel.h" #include #include @@ -28,6 +27,8 @@ #include +#include "ImageFilePanel.h" + static const uint32 kMsgApplySettings = 'aply'; static const uint32 kMsgRevertSettings = 'rvrt'; @@ -162,7 +163,7 @@ BackgroundsView::BackgroundsView() fPreview->AddChild(view); - BBox *rightbox = new BBox("rightbox"); + BBox* rightbox = new BBox("rightbox"); fWorkspaceMenu = new BPopUpMenu("pick one"); fWorkspaceMenu->AddItem(new BMenuItem("All Workspaces", @@ -178,7 +179,7 @@ BackgroundsView::BackgroundsView() fWorkspaceMenu->AddItem(new BMenuItem("Other folder" B_UTF8_ELLIPSIS, new BMessage(kMsgOtherFolder))); - BMenuField *workspaceMenuField = new BMenuField(BRect(0, 0, 130, 18), + BMenuField* workspaceMenuField = new BMenuField(BRect(0, 0, 130, 18), "workspaceMenuField", NULL, fWorkspaceMenu, true); workspaceMenuField->ResizeToPreferred(); rightbox->SetLabel(workspaceMenuField); @@ -190,7 +191,7 @@ BackgroundsView::BackgroundsView() fImageMenu->AddItem(new BMenuItem("Other" B_UTF8_ELLIPSIS, new BMessage(kMsgOtherImage))); - BMenuField *imageMenuField = new BMenuField(NULL, fImageMenu); + BMenuField* imageMenuField = new BMenuField(NULL, fImageMenu); imageMenuField->SetAlignment(B_ALIGN_RIGHT); imageMenuField->ResizeToPreferred(); @@ -204,7 +205,7 @@ BackgroundsView::BackgroundsView() fPlacementMenu->AddItem(new BMenuItem("Tile", new BMessage(kMsgTilePlacement))); - BMenuField *placementMenuField = new BMenuField(NULL, fPlacementMenu); + BMenuField* placementMenuField = new BMenuField(NULL, fPlacementMenu); placementMenuField->SetAlignment(B_ALIGN_RIGHT); fIconLabelOutline = new BCheckBox("Icon label outline", @@ -319,7 +320,7 @@ BackgroundsView::AllAttached() void -BackgroundsView::MessageReceived(BMessage *msg) +BackgroundsView::MessageReceived(BMessage* msg) { switch (msg->what) { case B_SIMPLE_DATA: @@ -527,7 +528,7 @@ BackgroundsView::UpdateWithCurrent(void) } for (int32 i = fImageList.CountItems() - 1; i >= 0; i--) { - BMessage *message = new BMessage(kMsgImageSelected); + BMessage* message = new BMessage(kMsgImageSelected); AddItem(new BGImageMenuItem(GetImage(i)->GetName(), i, message)); } @@ -594,8 +595,8 @@ BackgroundsView::UpdateWithCurrent(void) void BackgroundsView::Save() { - bool textWidgetLabelOutline = - fIconLabelOutline->Value() == B_CONTROL_ON; + bool textWidgetLabelOutline + = fIconLabelOutline->Value() == B_CONTROL_ON; BackgroundImage::Mode mode = FindPlacementMode(); BPoint offset(atoi(fXPlacementText->Text()), atoi(fYPlacementText->Text())); @@ -631,8 +632,8 @@ BackgroundsView::Save() fCurrentInfo->fCacheMode); fCurrent->Add(fCurrentInfo); } else if (fCurrentInfo->fWorkspace == workspaceMask) { - fCurrentInfo->fTextWidgetLabelOutline = - textWidgetLabelOutline; + fCurrentInfo->fTextWidgetLabelOutline + = textWidgetLabelOutline; fCurrentInfo->fMode = mode; if (fCurrentInfo->fMode == BackgroundImage::kAtOffset) fCurrentInfo->fOffset = offset; @@ -759,9 +760,9 @@ BackgroundsView::NotifyServer() int32 -BackgroundsView::NotifyThread(void *data) +BackgroundsView::NotifyThread(void* data) { - BackgroundsView *view = (BackgroundsView*)data; + BackgroundsView* view = (BackgroundsView*)data; view->NotifyServer(); return B_OK; @@ -842,7 +843,7 @@ BackgroundsView::LoadSettings() int32 i = AddPath(path); BString s; s << "Folder: " << path.Leaf(); - BMenuItem *item = new BMenuItem(s.String(), + BMenuItem* item = new BMenuItem(s.String(), new BMessage(kMsgFolderSelected)); fWorkspaceMenu->AddItem(item, -i - 1 + 6); index++; @@ -893,10 +894,10 @@ BackgroundsView::UpdatePreview() int32 index = ((BGImageMenuItem*)fImageMenu->FindMarked())->ImageIndex(); if (index >= 0) { - BBitmap *bitmap = GetImage(index)->GetBitmap(); + BBitmap* bitmap = GetImage(index)->GetBitmap(); if (bitmap) { - BackgroundImage::BackgroundImageInfo *info = - new BackgroundImage::BackgroundImageInfo(0, index, + BackgroundImage::BackgroundImageInfo* info + = new BackgroundImage::BackgroundImageInfo(0, index, FindPlacementMode(), BPoint(atoi(fXPlacementText->Text()), atoi(fYPlacementText->Text())), fIconLabelOutline->Value() == B_CONTROL_ON, 0, 0); @@ -944,20 +945,21 @@ BackgroundsView::UpdateButtons() && fPicker->ValueAsColor() != BScreen().DesktopColor()) { hasChanged = true; } else if (fCurrentInfo) { - if ((fIconLabelOutline->Value() == B_CONTROL_ON) ^ - fCurrentInfo->fTextWidgetLabelOutline) { + if ((fIconLabelOutline->Value() == B_CONTROL_ON) + ^ fCurrentInfo->fTextWidgetLabelOutline) { hasChanged = true; } else if (FindPlacementMode() != fCurrentInfo->fMode) { hasChanged = true; - } else if (fCurrentInfo->fImageIndex != - ((BGImageMenuItem*)fImageMenu->FindMarked())->ImageIndex()) { + } else if (fCurrentInfo->fImageIndex + != ((BGImageMenuItem*)fImageMenu->FindMarked())->ImageIndex()) { hasChanged = true; } else if (fCurrent->IsDesktop() && ((fCurrentInfo->fWorkspace != B_ALL_WORKSPACES) - ^ (fWorkspaceMenu->FindItem(kMsgCurrentWorkspace)->IsMarked()))) { + ^ (fWorkspaceMenu->FindItem(kMsgCurrentWorkspace)->IsMarked()))) + { hasChanged = true; - } else if (fCurrentInfo->fImageIndex > -1 && - fCurrentInfo->fMode == BackgroundImage::kAtOffset) { + } else if (fCurrentInfo->fImageIndex > -1 + && fCurrentInfo->fMode == BackgroundImage::kAtOffset) { BString oldString, newString; oldString << (int)fCurrentInfo->fOffset.x; if (oldString != BString(fXPlacementText->Text())) { @@ -981,7 +983,7 @@ BackgroundsView::UpdateButtons() void -BackgroundsView::RefsReceived(BMessage *msg) +BackgroundsView::RefsReceived(BMessage* msg) { if (!msg->HasRef("refs") && msg->HasRef("dir_ref")) { entry_ref dirRef; @@ -1007,7 +1009,7 @@ BackgroundsView::RefsReceived(BMessage *msg) if (!imageType.Contains(&refType)) continue; - BGImageMenuItem *item; + BGImageMenuItem* item; int32 index = AddImage(path); if (index >= 0) { item = FindImageItem(index); @@ -1036,7 +1038,7 @@ BackgroundsView::RefsReceived(BMessage *msg) BMessenger(this).SendMessage(kMsgCurrentWorkspace); break; } - BMenuItem *item; + BMenuItem* item; int32 index = AddPath(path); if (index >= 0) { item = fWorkspaceMenu->ItemAt(index + 6); @@ -1066,7 +1068,7 @@ BackgroundsView::AddPath(BPath path) int32 count = fPathList.CountItems(); int32 index = 0; for (; index < count; index++) { - BPath *p = fPathList.ItemAt(index); + BPath* p = fPathList.ItemAt(index); int c = BString(p->Path()).ICompare(path.Path()); if (c == 0) return index; @@ -1085,7 +1087,7 @@ BackgroundsView::AddImage(BPath path) int32 count = fImageList.CountItems(); int32 index = 0; for (; index < count; index++) { - Image *image = fImageList.ItemAt(index); + Image* image = fImageList.ItemAt(index); if (image->GetPath() == path) return index; } @@ -1106,12 +1108,12 @@ BGImageMenuItem* BackgroundsView::FindImageItem(const int32 imageIndex) { if (imageIndex < 0) - return (BGImageMenuItem *)fImageMenu->ItemAt(0); + return (BGImageMenuItem*)fImageMenu->ItemAt(0); int32 count = fImageMenu->CountItems() - 2; int32 index = 2; for (; index < count; index++) { - BGImageMenuItem *image = (BGImageMenuItem *)fImageMenu->ItemAt(index); + BGImageMenuItem* image = (BGImageMenuItem*)fImageMenu->ItemAt(index); if (image->ImageIndex() == imageIndex) return image; } @@ -1120,7 +1122,7 @@ BackgroundsView::FindImageItem(const int32 imageIndex) bool -BackgroundsView::AddItem(BGImageMenuItem *item) +BackgroundsView::AddItem(BGImageMenuItem* item) { int32 count = fImageMenu->CountItems() - 2; int32 index = 2; @@ -1130,7 +1132,7 @@ BackgroundsView::AddItem(BGImageMenuItem *item) } for (; index < count; index++) { - BGImageMenuItem* image = (BGImageMenuItem *)fImageMenu->ItemAt(index); + BGImageMenuItem* image = (BGImageMenuItem*)fImageMenu->ItemAt(index); int c = (BString(image->Label()).ICompare(BString(item->Label()))); if (c > 0) break; @@ -1217,7 +1219,7 @@ PreView::MouseUp(BPoint point) void -PreView::MouseMoved(BPoint point, uint32 transit, const BMessage *message) +PreView::MouseMoved(BPoint point, uint32 transit, const BMessage* message) { if (IsEnabled()) SetViewCursor(&fMoveHandCursor); @@ -1279,8 +1281,8 @@ PreView::MouseMoved(BPoint point, uint32 transit, const BMessage *message) // #pragma mark - -BGImageMenuItem::BGImageMenuItem(const char *label, int32 imageIndex, - BMessage *message, char shortcut, uint32 modifiers) +BGImageMenuItem::BGImageMenuItem(const char* label, int32 imageIndex, + BMessage* message, char shortcut, uint32 modifiers) : BMenuItem(label, message, shortcut, modifiers), fImageIndex(imageIndex) { diff --git a/src/preferences/backgrounds/BackgroundsView.h b/src/preferences/backgrounds/BackgroundsView.h index 6abb8112a6..98266e2ea6 100644 --- a/src/preferences/backgrounds/BackgroundsView.h +++ b/src/preferences/backgrounds/BackgroundsView.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007, Haiku, Inc. All Rights Reserved. + * Copyright 2002-2009, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -9,8 +9,6 @@ #define BACKGROUNDS_VIEW_H -#include "BackgroundImage.h" - #include #include #include @@ -31,20 +29,25 @@ #include #include -#define SETTINGS_FILE "Backgrounds_settings" +#include "BackgroundImage.h" + + +#define SETTINGS_FILE "Backgrounds_settings" + class ImageFilePanel; class BGImageMenuItem : public BMenuItem { - public: - BGImageMenuItem(const char *label, int32 imageIndex, BMessage *message, - char shortcut = 0, uint32 modifiers = 0); +public: + BGImageMenuItem(const char* label, int32 imageIndex, + BMessage* message, char shortcut = 0, + uint32 modifiers = 0); - int32 ImageIndex() { return fImageIndex; } + int32 ImageIndex() { return fImageIndex; } - private: - int32 fImageIndex; +private: + int32 fImageIndex; }; @@ -61,107 +64,118 @@ enum frame_parts { class FramePart : public BView { - public: - FramePart(int32 part); +public: + FramePart(int32 part); - void Draw(BRect rect); - void SetDesktop(bool isDesktop); + void Draw(BRect rect); + void SetDesktop(bool isDesktop); - private: - void _SetSizeAndAlignment(); +private: + void _SetSizeAndAlignment(); - int32 fFramePart; - bool fIsDesktop; + int32 fFramePart; + bool fIsDesktop; }; class PreView : public BControl { - public: - PreView(); +public: + PreView(); - BPoint fPoint; - BRect fImageBounds; + BPoint fPoint; + BRect fImageBounds; - protected: - void MouseDown(BPoint point); - void MouseUp(BPoint point); - void MouseMoved(BPoint point, uint32 transit, const BMessage *message); - void AttachedToWindow(); +protected: + void MouseDown(BPoint point); + void MouseUp(BPoint point); + void MouseMoved(BPoint point, uint32 transit, + const BMessage* message); + void AttachedToWindow(); - BPoint fOldPoint; - float x_ratio, y_ratio; - display_mode mode; + BPoint fOldPoint; + float x_ratio; + float y_ratio; + display_mode mode; - BCursor fMoveHandCursor; + BCursor fMoveHandCursor; }; class BackgroundsView : public BBox { - public: - BackgroundsView(); - ~BackgroundsView(); +public: + BackgroundsView(); + ~BackgroundsView(); - void RefsReceived(BMessage* msg); + void RefsReceived(BMessage* msg); - void SaveSettings(); - void WorkspaceActivated(uint32 oldWorkspaces, bool active); - int32 AddImage(BPath path); - Image* GetImage(int32 imageIndex); + void SaveSettings(); + void WorkspaceActivated(uint32 oldWorkspaces, + bool active); + int32 AddImage(BPath path); + Image* GetImage(int32 imageIndex); - bool FoundPositionSetting(); + bool FoundPositionSetting(); - protected: - void Save(); - void NotifyServer(); - void LoadSettings(); - void AllAttached(); - void MessageReceived(BMessage *msg); - void LoadDesktopFolder(); - void LoadDefaultFolder(); - void LoadFolder(bool isDesktop); - void LoadRecentFolder(BPath path); - void UpdateWithCurrent(); - void UpdatePreview(); - void UpdateButtons(); - void SetDesktop(bool isDesktop); - int32 AddPath(BPath path); +protected: + void Save(); + void NotifyServer(); + void LoadSettings(); + void AllAttached(); + void MessageReceived(BMessage* msg); + void LoadDesktopFolder(); + void LoadDefaultFolder(); + void LoadFolder(bool isDesktop); + void LoadRecentFolder(BPath path); + void UpdateWithCurrent(); + void UpdatePreview(); + void UpdateButtons(); + void SetDesktop(bool isDesktop); + int32 AddPath(BPath path); - static int32 NotifyThread(void *data); + static int32 NotifyThread(void* data); - BGImageMenuItem *FindImageItem(const int32 imageIndex); - bool AddItem(BGImageMenuItem *item); + BGImageMenuItem* FindImageItem(const int32 imageIndex); - BackgroundImage::Mode FindPlacementMode(); + bool AddItem(BGImageMenuItem* item); - BColorControl *fPicker; // color picker - BButton *fApply, *fRevert; // apply and revert buttons - BCheckBox *fIconLabelOutline; // label ckeckbox - BMenu* fPlacementMenu, *fImageMenu, *fWorkspaceMenu; // the three comboboxes - BTextControl *fXPlacementText, *fYPlacementText; // x and y textboxes - PreView *fPreView; // the view for previewing the result - BBox *fPreview; // the box which draws a computer/folder - BFilePanel *fFolderPanel; // the file panels for folders - ImageFilePanel *fPanel; // the file panels for images + BackgroundImage::Mode FindPlacementMode(); - BackgroundImage *fCurrent; // the current BackgroundImage object - BackgroundImage::BackgroundImageInfo *fCurrentInfo;//the current BackgroundImageInfo object - entry_ref fCurrentRef; // the entry for the node which holds current - int32 fLastImageIndex, fLastWorkspaceIndex; // last indexes for cancel - BMessage fSettings; // settings loaded from settings directory + BColorControl* fPicker; + BButton* fApply; + BButton* fRevert; + BCheckBox* fIconLabelOutline; + BMenu* fPlacementMenu; + BMenu* fImageMenu; + BMenu* fWorkspaceMenu; + BTextControl* fXPlacementText; + BTextControl* fYPlacementText; + PreView* fPreView; + BBox* fPreview; + BFilePanel* fFolderPanel; + ImageFilePanel* fPanel; - BObjectList fPathList; - BObjectList fImageList; + BackgroundImage* fCurrent; - FramePart* fTopLeft; - FramePart* fTop; - FramePart* fTopRight; - FramePart* fLeft; - FramePart* fRight; - FramePart* fBottomLeft; - FramePart* fBottom; - FramePart* fBottomRight; + BackgroundImage::BackgroundImageInfo* fCurrentInfo; - bool fFoundPositionSetting; + entry_ref fCurrentRef; + int32 fLastImageIndex; + int32 fLastWorkspaceIndex; + BMessage fSettings; + + BObjectList fPathList; + BObjectList fImageList; + + FramePart* fTopLeft; + FramePart* fTop; + FramePart* fTopRight; + FramePart* fLeft; + FramePart* fRight; + FramePart* fBottomLeft; + FramePart* fBottom; + FramePart* fBottomRight; + + bool fFoundPositionSetting; }; #endif // BACKGROUNDS_VIEW_H diff --git a/src/preferences/backgrounds/ImageFilePanel.cpp b/src/preferences/backgrounds/ImageFilePanel.cpp index c76914e366..bc80579fef 100644 --- a/src/preferences/backgrounds/ImageFilePanel.cpp +++ b/src/preferences/backgrounds/ImageFilePanel.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2002-2005, Haiku, Inc. All Rights Reserved. + * Copyright 2002-2009, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -17,10 +17,10 @@ #include -ImageFilePanel::ImageFilePanel(file_panel_mode mode, BMessenger *target, - const entry_ref *startDirectory, uint32 nodeFlavors, +ImageFilePanel::ImageFilePanel(file_panel_mode mode, BMessenger* target, + const entry_ref* startDirectory, uint32 nodeFlavors, bool allowMultipleSelection, BMessage* message, BRefFilter* filter, - bool modal, bool hideWhenDone) + bool modal, bool hideWhenDone) : BFilePanel(mode, target, startDirectory, nodeFlavors, allowMultipleSelection, message, filter, modal, hideWhenDone), fImageView(NULL), @@ -42,35 +42,43 @@ ImageFilePanel::Show() { if (fImageView == NULL) { Window()->Lock(); - BView *background = Window()->ChildAt(0); - uint32 poseViewResizingMode = - background->FindView("PoseView")->ResizingMode(); - uint32 countVwResizingMode = - background->FindView("CountVw")->ResizingMode(); - uint32 vScrollBarResizingMode = - background->FindView("VScrollBar")->ResizingMode(); - uint32 hScrollBarResizingMode = - background->FindView("HScrollBar")->ResizingMode(); + BView* background = Window()->ChildAt(0); + uint32 poseViewResizingMode + = background->FindView("PoseView")->ResizingMode(); + uint32 countVwResizingMode + = background->FindView("CountVw")->ResizingMode(); + uint32 vScrollBarResizingMode + = background->FindView("VScrollBar")->ResizingMode(); + uint32 hScrollBarResizingMode + = background->FindView("HScrollBar")->ResizingMode(); - background->FindView("PoseView")->SetResizingMode(B_FOLLOW_LEFT | B_FOLLOW_TOP); - background->FindView("CountVw")->SetResizingMode(B_FOLLOW_LEFT | B_FOLLOW_TOP); - background->FindView("VScrollBar")->SetResizingMode(B_FOLLOW_LEFT | B_FOLLOW_TOP); - background->FindView("HScrollBar")->SetResizingMode(B_FOLLOW_LEFT | B_FOLLOW_TOP); + background->FindView("PoseView") + ->SetResizingMode(B_FOLLOW_LEFT | B_FOLLOW_TOP); + background->FindView("CountVw") + ->SetResizingMode(B_FOLLOW_LEFT | B_FOLLOW_TOP); + background->FindView("VScrollBar") + ->SetResizingMode(B_FOLLOW_LEFT | B_FOLLOW_TOP); + background->FindView("HScrollBar") + ->SetResizingMode(B_FOLLOW_LEFT | B_FOLLOW_TOP); Window()->ResizeBy(0, 70); background->FindView("PoseView")->SetResizingMode(poseViewResizingMode); background->FindView("CountVw")->SetResizingMode(countVwResizingMode); - background->FindView("VScrollBar")->SetResizingMode(vScrollBarResizingMode); - background->FindView("HScrollBar")->SetResizingMode(hScrollBarResizingMode); + background->FindView("VScrollBar") + ->SetResizingMode(vScrollBarResizingMode); + background->FindView("HScrollBar") + ->SetResizingMode(hScrollBarResizingMode); - BRect rect(background->Bounds().left + 15, background->Bounds().bottom - 94, - background->Bounds().left + 122, background->Bounds().bottom - 15); - fImageView = new BView(rect, "ImageView", B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, - B_SUBPIXEL_PRECISE); + BRect rect(background->Bounds().left + 15, + background->Bounds().bottom - 94, background->Bounds().left + 122, + background->Bounds().bottom - 15); + fImageView = new BView(rect, "ImageView", + B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_SUBPIXEL_PRECISE); fImageView->SetViewColor(background->ViewColor()); background->AddChild(fImageView); - rect = BRect(background->Bounds().left + 132, background->Bounds().bottom - 85, - background->Bounds().right, background->Bounds().bottom - 65); + rect = BRect(background->Bounds().left + 132, + background->Bounds().bottom - 85, background->Bounds().right, + background->Bounds().bottom - 65); fResolutionView = new BStringView(rect, "ResolutionView", NULL, B_FOLLOW_LEFT | B_FOLLOW_BOTTOM); background->AddChild(fResolutionView); @@ -99,24 +107,27 @@ ImageFilePanel::SelectionChanged() fImageView->ClearViewBitmap(); if (node.IsFile()) { - BBitmap *bitmap = BTranslationUtils::GetBitmap(&ref); + BBitmap* bitmap = BTranslationUtils::GetBitmap(&ref); if (bitmap != NULL) { BRect dest(fImageView->Bounds()); if (bitmap->Bounds().Width() > bitmap->Bounds().Height()) { - dest.InsetBy(0, (dest.Height() + 1 - - ((bitmap->Bounds().Height() + 1) / - (bitmap->Bounds().Width() + 1) *(dest.Width() + 1))) / 2); + dest.InsetBy(0, (dest.Height() + 1 + - ((bitmap->Bounds().Height() + 1) + / (bitmap->Bounds().Width() + 1) + * (dest.Width() + 1))) / 2); } else { - dest.InsetBy((dest.Width() + 1 - - ((bitmap->Bounds().Width() + 1) / - (bitmap->Bounds().Height() + 1) *(dest.Height() + 1))) / 2, 0); + dest.InsetBy((dest.Width() + 1 + - ((bitmap->Bounds().Width() + 1) + / (bitmap->Bounds().Height() + 1) + * (dest.Height() + 1))) / 2, 0); } fImageView->SetViewBitmap(bitmap, bitmap->Bounds(), dest, B_FOLLOW_LEFT | B_FOLLOW_TOP, 0); BString resolution; - resolution << "Resolution: " << (int)(bitmap->Bounds().Width() + 1) + resolution << "Resolution: " + << (int)(bitmap->Bounds().Width() + 1) << "x" << (int)(bitmap->Bounds().Height() + 1); fResolutionView->SetText(resolution.String()); delete bitmap; @@ -161,8 +172,8 @@ CustomRefFilter::CustomRefFilter(bool imageFiltering) bool -CustomRefFilter::Filter(const entry_ref *ref, BNode* node, - struct stat_beos *stat, const char *filetype) +CustomRefFilter::Filter(const entry_ref* ref, BNode* node, + struct stat_beos* stat, const char* filetype) { if (!fImageFiltering) return node->IsDirectory(); diff --git a/src/preferences/backgrounds/ImageFilePanel.h b/src/preferences/backgrounds/ImageFilePanel.h index 96ba3c8123..eeb00e1cc4 100644 --- a/src/preferences/backgrounds/ImageFilePanel.h +++ b/src/preferences/backgrounds/ImageFilePanel.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2005, Haiku, Inc. All Rights Reserved. + * Copyright 2002-2009, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -9,43 +9,50 @@ #define IMAGE_FILE_PANEL_H -#include #include +#include + class BStringView; class BView; class CustomRefFilter : public BRefFilter { - public: - CustomRefFilter(bool imageFiltering); - virtual ~CustomRefFilter() {}; +public: + CustomRefFilter(bool imageFiltering); + virtual ~CustomRefFilter() {}; - bool Filter(const entry_ref *ref, BNode* node, struct stat_beos *st, - const char *filetype); + bool Filter(const entry_ref* ref, BNode* node, + struct stat_beos* st, const char* filetype); - protected: - bool fImageFiltering; // true for images only, false for directory only +protected: + bool fImageFiltering; + // true for images + // false for directory }; class ImageFilePanel : public BFilePanel { - public: - ImageFilePanel(file_panel_mode mode = B_OPEN_PANEL, - BMessenger* target = NULL, const entry_ref* startDirectory = NULL, - uint32 nodeFlavors = 0, bool allowMultipleSelection = true, - BMessage* message = NULL, BRefFilter* filter = NULL, - bool modal = false, bool hideWhenDone = true); - ~ImageFilePanel(); +public: + ImageFilePanel(file_panel_mode mode = B_OPEN_PANEL, + BMessenger* target = NULL, + const entry_ref* startDirectory = NULL, + uint32 nodeFlavors = 0, + bool allowMultipleSelection = true, + BMessage* message = NULL, + BRefFilter* filter = NULL, + bool modal = false, + bool hideWhenDone = true); + ~ImageFilePanel(); - virtual void SelectionChanged(); + virtual void SelectionChanged(); + void Show(); - void Show(); - - protected: - BView* fImageView; - BStringView* fResolutionView; - BStringView* fImageTypeView; +protected: + BView* fImageView; + BStringView* fResolutionView; + BStringView* fImageTypeView; }; #endif // IMAGE_FILE_PANEL_H + diff --git a/src/preferences/backgrounds/Jamfile b/src/preferences/backgrounds/Jamfile index c438623f55..599b6a4dfc 100644 --- a/src/preferences/backgrounds/Jamfile +++ b/src/preferences/backgrounds/Jamfile @@ -13,4 +13,3 @@ Preference Backgrounds : : Backgrounds.rdef ; -