6 Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
8 Permission is hereby granted, free of charge, to any person obtaining a copy of
9 this software and associated documentation files (the "Software"), to deal in
10 the Software without restriction, including without limitation the rights to
11 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
12 of the Software, and to permit persons to whom the Software is furnished to do
13 so, subject to the following conditions:
15 The above copyright notice and this permission notice applies to all licensees
16 and shall be included in all copies or substantial portions of the Software.
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
23 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 Except as contained in this notice, the name of Be Incorporated shall not be
26 used in advertising or otherwise to promote the sale, use or other dealings in
27 this Software without prior written authorization from Be Incorporated.
29 Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
30 of Be Incorporated in the United States and other countries. Other brand product
31 names are registered trademarks or trademarks of their respective holders.
41 #include <PopUpMenu.h>
45 #include "Attributes.h"
47 #include "QueryContainerWindow.h"
48 #include "QueryPoseView.h"
51 // #pragma mark - BQueryContainerWindow
54 #undef B_TRANSLATION_CONTEXT
55 #define B_TRANSLATION_CONTEXT "QueryContainerWindow"
58 BQueryContainerWindow::BQueryContainerWindow(LockingList
<BWindow
>* windowList
,
59 uint32 containerWindowFlags
)
61 BContainerWindow(windowList
, containerWindowFlags
)
67 BQueryContainerWindow::NewPoseView(Model
* model
, uint32
)
69 return new BQueryPoseView(model
);
74 BQueryContainerWindow::PoseView() const
76 return static_cast<BQueryPoseView
*>(fPoseView
);
81 BQueryContainerWindow::CreatePoseView(Model
* model
)
83 fPoseView
= NewPoseView(model
, kListMode
);
85 fBorderedView
->GroupLayout()->AddView(fPoseView
);
86 fBorderedView
->EnableBorderHighlight(false);
87 fBorderedView
->GroupLayout()->SetInsets(0, 0, 1, 1);
92 BQueryContainerWindow::AddWindowMenu(BMenu
* menu
)
96 item
= new BMenuItem(B_TRANSLATE("Resize to fit"),
97 new BMessage(kResizeToFit
), 'Y');
98 item
->SetTarget(this);
101 item
= new BMenuItem(B_TRANSLATE("Select" B_UTF8_ELLIPSIS
),
102 new BMessage(kShowSelectionWindow
), 'A', B_SHIFT_KEY
);
103 item
->SetTarget(PoseView());
106 item
= new BMenuItem(B_TRANSLATE("Select all"),
107 new BMessage(B_SELECT_ALL
), 'A');
108 item
->SetTarget(PoseView());
111 item
= new BMenuItem(B_TRANSLATE("Invert selection"),
112 new BMessage(kInvertSelection
), 'S');
113 item
->SetTarget(PoseView());
116 item
= new BMenuItem(B_TRANSLATE("Close"),
117 new BMessage(B_QUIT_REQUESTED
), 'W');
118 item
->SetTarget(this);
124 BQueryContainerWindow::AddWindowContextMenus(BMenu
* menu
)
126 BMenuItem
* resizeItem
= new BMenuItem(B_TRANSLATE("Resize to fit"),
127 new BMessage(kResizeToFit
), 'Y');
128 menu
->AddItem(resizeItem
);
129 menu
->AddItem(new BMenuItem(B_TRANSLATE("Select" B_UTF8_ELLIPSIS
),
130 new BMessage(kShowSelectionWindow
), 'A', B_SHIFT_KEY
));
131 menu
->AddItem(new BMenuItem(B_TRANSLATE("Select all"),
132 new BMessage(B_SELECT_ALL
), 'A'));
133 BMenuItem
* closeItem
= new BMenuItem(B_TRANSLATE("Close"),
134 new BMessage(B_QUIT_REQUESTED
), 'W');
135 menu
->AddItem(closeItem
);
137 // target items as needed
138 menu
->SetTargetForItems(PoseView());
139 closeItem
->SetTarget(this);
140 resizeItem
->SetTarget(this);
145 BQueryContainerWindow::SetUpDefaultState()
147 BNode defaultingNode
;
149 WindowStateNodeOpener
opener(this, true);
150 // this is our destination node, whatever it is for this window
151 if (opener
.StreamNode() == NULL
)
154 BString
defaultStatePath(kQueryTemplates
);
155 BString
sanitizedType(PoseView()->SearchForType());
157 defaultStatePath
+= '/';
158 int32 length
= sanitizedType
.Length();
159 char* buf
= sanitizedType
.LockBuffer(length
);
160 for (int32 index
= length
- 1; index
>= 0; index
--)
161 if (buf
[index
] == '/')
163 sanitizedType
.UnlockBuffer(length
);
165 defaultStatePath
+= sanitizedType
;
167 PRINT(("looking for default query state at %s\n",
168 defaultStatePath
.String()));
170 if (!DefaultStateSourceNode(defaultStatePath
.String(), &defaultingNode
,
176 // copy over the attributes
178 // set up a filter of the attributes we want copied
179 const char* allowAttrs
[] = {
182 kAttrViewStateForeign
,
189 AttributeStreamMemoryNode memoryNode
;
190 NamesToAcceptAttrFilter
filter(allowAttrs
);
191 AttributeStreamFileNode
fileNode(&defaultingNode
);
192 *opener
.StreamNode() << memoryNode
<< filter
<< fileNode
;
197 BQueryContainerWindow::ActiveOnDevice(dev_t device
) const
199 return PoseView()->ActiveOnDevice(device
);