Tracker: style fixes to ContainerWindow

This commit is contained in:
John Scipione
2014-06-20 21:01:30 -04:00
parent d964968957
commit 63c1c8921e
2 changed files with 272 additions and 247 deletions
+22 -17
View File
@@ -167,7 +167,7 @@ ActivateWindowFilter(BMessage*, BHandler** target, BMessageFilter*)
// activate the window if no PoseView or DraggableContainerIcon had been // activate the window if no PoseView or DraggableContainerIcon had been
// pressed (those will activate the window themselves, if necessary) // pressed (those will activate the window themselves, if necessary)
if (view if (view != NULL
&& !dynamic_cast<BPoseView*>(view) && !dynamic_cast<BPoseView*>(view)
&& !dynamic_cast<DraggableContainerIcon*>(view) && !dynamic_cast<DraggableContainerIcon*>(view)
&& view->Window()) && view->Window())
@@ -310,7 +310,7 @@ AddMimeTypeString(BObjectList<BString> &list, Model* model)
} }
// #pragma mark - // #pragma mark - DraggableContainerIcon
DraggableContainerIcon::DraggableContainerIcon(BRect rect, const char* name, DraggableContainerIcon::DraggableContainerIcon(BRect rect, const char* name,
@@ -519,7 +519,7 @@ DraggableContainerIcon::Draw(BRect updateRect)
} }
// #pragma mark - // #pragma mark - BContainerWindow
BContainerWindow::BContainerWindow(LockingList<BWindow>* list, BContainerWindow::BContainerWindow(LockingList<BWindow>* list,
@@ -1064,7 +1064,7 @@ BContainerWindow::RestoreStateCommon()
WindowStateNodeOpener opener(this, false); WindowStateNodeOpener opener(this, false);
bool isDesktop = dynamic_cast<BDeskWindow*>(this) != NULL; bool isDesktop = dynamic_cast<BDeskWindow*>(this) != NULL;
if (!TargetModel()->IsRoot() && opener.Node()) { if (!TargetModel()->IsRoot() && opener.Node() != NULL) {
// don't pick up background image for root disks // don't pick up background image for root disks
// to do this, would have to have a unique attribute for the // to do this, would have to have a unique attribute for the
// disks window that doesn't collide with the desktop // disks window that doesn't collide with the desktop
@@ -1115,7 +1115,7 @@ BContainerWindow::UpdateBackgroundImage()
bool isDesktop = dynamic_cast<BDeskWindow*>(this) != NULL; bool isDesktop = dynamic_cast<BDeskWindow*>(this) != NULL;
WindowStateNodeOpener opener(this, false); WindowStateNodeOpener opener(this, false);
if (!TargetModel()->IsRoot() && opener.Node()) { if (!TargetModel()->IsRoot() && opener.Node() != NULL) {
fBackgroundImage = BackgroundImage::Refresh(fBackgroundImage, fBackgroundImage = BackgroundImage::Refresh(fBackgroundImage,
opener.Node(), isDesktop, PoseView()); opener.Node(), isDesktop, PoseView());
} }
@@ -1225,7 +1225,7 @@ BContainerWindow::SaveState(bool hide)
{ {
if (SaveStateIsEnabled()) { if (SaveStateIsEnabled()) {
WindowStateNodeOpener opener(this, true); WindowStateNodeOpener opener(this, true);
if (opener.StreamNode()) if (opener.StreamNode() != NULL)
SaveWindowState(opener.StreamNode()); SaveWindowState(opener.StreamNode());
if (hide) if (hide)
@@ -1729,6 +1729,7 @@ BContainerWindow::MessageReceived(BMessage* message)
default: default:
_inherited::MessageReceived(message); _inherited::MessageReceived(message);
break;
} }
} }
break; break;
@@ -1742,13 +1743,15 @@ BContainerWindow::MessageReceived(BMessage* message)
FSUndo(); FSUndo();
break; break;
//case B_REDO: // only defined in Dano/Zeta/OpenBeOS //case B_REDO:
// only defined in Dano/Zeta/OpenBeOS
case kRedo: case kRedo:
FSRedo(); FSRedo();
break; break;
default: default:
_inherited::MessageReceived(message); _inherited::MessageReceived(message);
break;
} }
} }
@@ -3185,10 +3188,10 @@ BContainerWindow::UpdateMenu(BMenu* menu, UpdateMenuContext context)
EnableNamedMenuItem(menu, B_SELECT_ALL, count > 0); EnableNamedMenuItem(menu, B_SELECT_ALL, count > 0);
BMenuItem* item = menu->FindItem(B_TRANSLATE("New")); BMenuItem* item = menu->FindItem(B_TRANSLATE("New"));
if (item) { if (item != NULL) {
TemplatesMenu* templateMenu = dynamic_cast<TemplatesMenu*> TemplatesMenu* templateMenu = dynamic_cast<TemplatesMenu*>
(item->Submenu()); (item->Submenu());
if (templateMenu) if (templateMenu != NULL)
templateMenu->UpdateMenuState(); templateMenu->UpdateMenuState();
} }
} }
@@ -3661,9 +3664,10 @@ BContainerWindow::NeedsDefaultStateSetup()
return false; return false;
WindowStateNodeOpener opener(this, false); WindowStateNodeOpener opener(this, false);
if (!opener.StreamNode()) if (opener.StreamNode() == NULL) {
// can't read state, give up // can't read state, give up
return false; return false;
}
return !NodeHasSavedState(opener.Node()); return !NodeHasSavedState(opener.Node());
} }
@@ -3736,7 +3740,7 @@ BContainerWindow::SetUpDefaultState()
WindowStateNodeOpener opener(this, true); WindowStateNodeOpener opener(this, true);
// this is our destination node, whatever it is for this window // this is our destination node, whatever it is for this window
if (!opener.StreamNode()) if (opener.StreamNode() == NULL)
return; return;
if (!TargetModel()->IsRoot()) { if (!TargetModel()->IsRoot()) {
@@ -3806,7 +3810,7 @@ BContainerWindow::SetUpDefaultState()
void void
BContainerWindow::RestoreWindowState(AttributeStreamNode* node) BContainerWindow::RestoreWindowState(AttributeStreamNode* node)
{ {
if (node == NULL || dynamic_cast<BDeskWindow*>(this)) { if (node == NULL || dynamic_cast<BDeskWindow*>(this) != NULL) {
// don't restore any window state if we are a desktop window // don't restore any window state if we are a desktop window
return; return;
} }
@@ -4218,12 +4222,13 @@ BContainerWindow::PopulateArrangeByMenu(BMenu* menu)
} }
// #pragma mark - // #pragma mark - WindowStateNodeOpener
WindowStateNodeOpener::WindowStateNodeOpener(BContainerWindow* window, WindowStateNodeOpener::WindowStateNodeOpener(BContainerWindow* window,
bool forWriting) bool forWriting)
: fModelOpener(NULL), :
fModelOpener(NULL),
fNode(NULL), fNode(NULL),
fStreamNode(NULL) fStreamNode(NULL)
{ {
@@ -4314,11 +4319,12 @@ WindowStateNodeOpener::Node() const
} }
// #pragma mark - // #pragma mark - BackgroundView
BackgroundView::BackgroundView(BRect frame) BackgroundView::BackgroundView(BRect frame)
: BView(frame, "", B_FOLLOW_ALL, :
BView(frame, "", B_FOLLOW_ALL,
B_FRAME_EVENTS | B_WILL_DRAW | B_PULSE_NEEDED) B_FRAME_EVENTS | B_WILL_DRAW | B_PULSE_NEEDED)
{ {
} }
@@ -4431,4 +4437,3 @@ BackgroundView::Pulse()
if (window) if (window)
window->PulseTaskLoop(); window->PulseTaskLoop();
} }
+27 -7
View File
@@ -56,14 +56,17 @@ class Model;
class ModelNodeLazyOpener; class ModelNodeLazyOpener;
class SelectionWindow; class SelectionWindow;
#define kDefaultFolderTemplate "DefaultFolderTemplate" #define kDefaultFolderTemplate "DefaultFolderTemplate"
extern const char* kAddOnsMenuName; extern const char* kAddOnsMenuName;
const window_feel kPrivateDesktopWindowFeel = window_feel(1024); const window_feel kPrivateDesktopWindowFeel = window_feel(1024);
const window_look kPrivateDesktopWindowLook = window_look(4); const window_look kPrivateDesktopWindowLook = window_look(4);
// this is a mirror of an app server private values // this is a mirror of an app server private values
enum { enum {
// flags that describe opening of the window // flags that describe opening of the window
kRestoreWorkspace = 0x1, kRestoreWorkspace = 0x1,
@@ -72,6 +75,7 @@ enum {
kRestoreDecor = 0x4 kRestoreDecor = 0x4
}; };
struct AddonShortcut { struct AddonShortcut {
Model* model; Model* model;
char key; char key;
@@ -79,6 +83,7 @@ struct AddonShortcut {
uint32 modifiers; uint32 modifiers;
}; };
class BContainerWindow : public BWindow { class BContainerWindow : public BWindow {
public: public:
BContainerWindow(LockingList<BWindow>* windowList, BContainerWindow(LockingList<BWindow>* windowList,
@@ -325,6 +330,7 @@ class BContainerWindow : public BWindow {
void _UpdateSelectionMIMEInfo(); void _UpdateSelectionMIMEInfo();
}; };
class WindowStateNodeOpener { class WindowStateNodeOpener {
// this class manages opening and closing the proper node for // this class manages opening and closing the proper node for
// state restoring / saving; the constructor knows how to decide whether // state restoring / saving; the constructor knows how to decide whether
@@ -348,6 +354,7 @@ class WindowStateNodeOpener {
AttributeStreamNode* fStreamNode; AttributeStreamNode* fStreamNode;
}; };
class BackgroundView : public BView { class BackgroundView : public BView {
// background view placed in a BContainerWindow, under the pose view // background view placed in a BContainerWindow, under the pose view
public: public:
@@ -366,8 +373,10 @@ class BackgroundView : public BView {
typedef BView _inherited; typedef BView _inherited;
}; };
int CompareLabels(const BMenuItem*, const BMenuItem*); int CompareLabels(const BMenuItem*, const BMenuItem*);
// inlines --------- // inlines ---------
inline BNavigator* inline BNavigator*
@@ -376,74 +385,84 @@ BContainerWindow::Navigator() const
return fNavigator; return fNavigator;
} }
inline BPoseView* inline BPoseView*
BContainerWindow::PoseView() const BContainerWindow::PoseView() const
{ {
return fPoseView; return fPoseView;
} }
inline bool inline bool
BContainerWindow::IsTrash() const BContainerWindow::IsTrash() const
{ {
return fIsTrash; return fIsTrash;
} }
inline bool inline bool
BContainerWindow::InTrash() const BContainerWindow::InTrash() const
{ {
return fInTrash; return fInTrash;
} }
inline bool inline bool
BContainerWindow::IsPrintersDir() const BContainerWindow::IsPrintersDir() const
{ {
return fIsPrinters; return fIsPrinters;
} }
inline void inline void
BContainerWindow::SetUpDiskMenu(BMenu*) BContainerWindow::SetUpDiskMenu(BMenu*)
{ {
// nothing at this level // nothing at this level
} }
inline BPopUpMenu* inline BPopUpMenu*
BContainerWindow::ContextMenu() BContainerWindow::ContextMenu()
{ {
return fContextMenu; return fContextMenu;
} }
inline bool inline bool
BContainerWindow::Dragging() const BContainerWindow::Dragging() const
{ {
return fDragMessage && fCachedTypesList; return fDragMessage && fCachedTypesList;
} }
inline BMessage* inline BMessage*
BContainerWindow::DragMessage() const BContainerWindow::DragMessage() const
{ {
return fDragMessage; return fDragMessage;
} }
inline
bool
inline bool
BContainerWindow::SaveStateIsEnabled() const BContainerWindow::SaveStateIsEnabled() const
{ {
return fSaveStateIsEnabled; return fSaveStateIsEnabled;
} }
inline
void inline void
BContainerWindow::SetSaveStateEnabled(bool value) BContainerWindow::SetSaveStateEnabled(bool value)
{ {
fSaveStateIsEnabled = value; fSaveStateIsEnabled = value;
} }
inline
bool inline bool
BContainerWindow::IsPathWatchingEnabled() const BContainerWindow::IsPathWatchingEnabled() const
{ {
return fIsWatchingPath; return fIsWatchingPath;
} }
filter_result ActivateWindowFilter(BMessage* message, BHandler** target, filter_result ActivateWindowFilter(BMessage* message, BHandler** target,
BMessageFilter* messageFilter); BMessageFilter* messageFilter);
@@ -451,4 +470,5 @@ filter_result ActivateWindowFilter(BMessage* message, BHandler** target,
using namespace BPrivate; using namespace BPrivate;
#endif
#endif // _CONTAINER_WINDOW_H