2 * Copyright 2001-2015, Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
10 #include <StorageDefs.h>
31 B_DOCUMENT_WINDOW
= 11,
32 B_BORDERED_WINDOW
= 20,
33 B_FLOATING_WINDOW
= 21
37 B_BORDERED_WINDOW_LOOK
= 20,
38 B_NO_BORDER_WINDOW_LOOK
= 19,
39 B_TITLED_WINDOW_LOOK
= 1,
40 B_DOCUMENT_WINDOW_LOOK
= 11,
41 B_MODAL_WINDOW_LOOK
= 3,
42 B_FLOATING_WINDOW_LOOK
= 7
46 B_NORMAL_WINDOW_FEEL
= 0,
47 B_MODAL_SUBSET_WINDOW_FEEL
= 2,
48 B_MODAL_APP_WINDOW_FEEL
= 1,
49 B_MODAL_ALL_WINDOW_FEEL
= 3,
50 B_FLOATING_SUBSET_WINDOW_FEEL
= 5,
51 B_FLOATING_APP_WINDOW_FEEL
= 4,
52 B_FLOATING_ALL_WINDOW_FEEL
= 6
55 enum window_alignment
{
62 B_NOT_MOVABLE
= 0x00000001,
63 B_NOT_CLOSABLE
= 0x00000020,
64 B_NOT_ZOOMABLE
= 0x00000040,
65 B_NOT_MINIMIZABLE
= 0x00004000,
66 B_NOT_RESIZABLE
= 0x00000002,
67 B_NOT_H_RESIZABLE
= 0x00000004,
68 B_NOT_V_RESIZABLE
= 0x00000008,
69 B_AVOID_FRONT
= 0x00000080,
70 B_AVOID_FOCUS
= 0x00002000,
71 B_WILL_ACCEPT_FIRST_CLICK
= 0x00000010,
72 B_OUTLINE_RESIZE
= 0x00001000,
73 B_NO_WORKSPACE_ACTIVATION
= 0x00000100,
74 B_NOT_ANCHORED_ON_ACTIVATE
= 0x00020000,
75 B_ASYNCHRONOUS_CONTROLS
= 0x00080000,
76 B_QUIT_ON_WINDOW_CLOSE
= 0x00100000,
77 B_SAME_POSITION_IN_ALL_WORKSPACES
= 0x00200000,
78 B_AUTO_UPDATE_SIZE_LIMITS
= 0x00400000,
79 B_CLOSE_ON_ESCAPE
= 0x00800000,
80 B_NO_SERVER_SIDE_WINDOW_MODIFIERS
= 0x00000200
83 #define B_CURRENT_WORKSPACE 0
84 #define B_ALL_WORKSPACES 0xffffffff
86 // MoveOnScreen() flags
88 B_DO_NOT_RESIZE_TO_FIT
= 0x0001,
89 B_MOVE_IF_PARTIALLY_OFFSCREEN
= 0x0002
93 class BWindow
: public BLooper
{
95 BWindow(BRect frame
, const char* title
,
96 window_type type
, uint32 flags
,
97 uint32 workspace
= B_CURRENT_WORKSPACE
);
98 BWindow(BRect frame
, const char* title
,
99 window_look look
, window_feel feel
,
100 uint32 flags
, uint32 workspace
101 = B_CURRENT_WORKSPACE
);
104 BWindow(BMessage
* archive
);
105 static BArchivable
* Instantiate(BMessage
* archive
);
106 virtual status_t
Archive(BMessage
* archive
,
107 bool deep
= true) const;
110 void Close() { Quit(); }
112 void AddChild(BView
* child
, BView
* before
= NULL
);
113 void AddChild(BLayoutItem
* child
);
114 bool RemoveChild(BView
* child
);
115 int32
CountChildren() const;
116 BView
* ChildAt(int32 index
) const;
118 virtual void DispatchMessage(BMessage
* message
,
120 virtual void MessageReceived(BMessage
* message
);
121 virtual void FrameMoved(BPoint newPosition
);
122 virtual void WorkspacesChanged(uint32 oldWorkspaces
,
123 uint32 newWorkspaces
);
124 virtual void WorkspaceActivated(int32 workspace
,
126 virtual void FrameResized(float newWidth
, float newHeight
);
127 virtual void Minimize(bool minimize
);
128 virtual void Zoom(BPoint origin
, float width
, float height
);
130 void SetZoomLimits(float maxWidth
, float maxHeight
);
131 virtual void ScreenChanged(BRect screenSize
,
134 void SetPulseRate(bigtime_t rate
);
135 bigtime_t
PulseRate() const;
137 void AddShortcut(uint32 key
, uint32 modifiers
,
139 void AddShortcut(uint32 key
, uint32 modifiers
,
140 BMessage
* message
, BHandler
* target
);
141 bool HasShortcut(uint32 key
, uint32 modifiers
);
142 void RemoveShortcut(uint32 key
, uint32 modifiers
);
144 void SetDefaultButton(BButton
* button
);
145 BButton
* DefaultButton() const;
147 virtual void MenusBeginning();
148 virtual void MenusEnded();
150 bool NeedsUpdate() const;
151 void UpdateIfNeeded();
153 BView
* FindView(const char* viewName
) const;
154 BView
* FindView(BPoint
) const;
155 BView
* CurrentFocus() const;
157 void Activate(bool = true);
158 virtual void WindowActivated(bool focus
);
160 void ConvertToScreen(BPoint
* point
) const;
161 BPoint
ConvertToScreen(BPoint point
) const;
162 void ConvertFromScreen(BPoint
* point
) const;
163 BPoint
ConvertFromScreen(BPoint point
) const;
164 void ConvertToScreen(BRect
* rect
) const;
165 BRect
ConvertToScreen(BRect rect
) const;
166 void ConvertFromScreen(BRect
* rect
) const;
167 BRect
ConvertFromScreen(BRect rect
) const;
169 void MoveBy(float dx
, float dy
);
171 void MoveTo(float x
, float y
);
172 void ResizeBy(float dx
, float dy
);
173 void ResizeTo(float width
, float height
);
174 void ResizeToPreferred();
176 void CenterIn(const BRect
& rect
);
177 void CenterOnScreen();
178 void CenterOnScreen(screen_id id
);
179 void MoveOnScreen(uint32 flags
= 0);
183 bool IsHidden() const;
184 bool IsMinimized() const;
189 status_t
SendBehind(const BWindow
* window
);
191 void DisableUpdates();
192 void EnableUpdates();
194 void BeginViewTransaction();
195 // referred as OpenViewTransaction()
197 void EndViewTransaction();
198 // referred as CommitViewTransaction()
200 bool InViewTransaction() const;
202 BRect
Bounds() const;
204 BRect
DecoratorFrame() const;
206 const char* Title() const;
207 void SetTitle(const char* title
);
208 bool IsFront() const;
209 bool IsActive() const;
211 void SetKeyMenuBar(BMenuBar
* bar
);
212 BMenuBar
* KeyMenuBar() const;
214 void SetSizeLimits(float minWidth
, float maxWidth
,
215 float minHeight
, float maxHeight
);
216 void GetSizeLimits(float* minWidth
, float* maxWidth
,
217 float* minHeight
, float* maxHeight
);
218 void UpdateSizeLimits();
220 status_t
SetDecoratorSettings(const BMessage
& settings
);
221 status_t
GetDecoratorSettings(BMessage
* settings
) const;
223 uint32
Workspaces() const;
224 void SetWorkspaces(uint32
);
226 BView
* LastMouseMovedView() const;
228 virtual BHandler
* ResolveSpecifier(BMessage
* message
,
229 int32 index
, BMessage
* specifier
,
230 int32 what
, const char* property
);
231 virtual status_t
GetSupportedSuites(BMessage
* data
);
233 status_t
AddToSubset(BWindow
* window
);
234 status_t
RemoveFromSubset(BWindow
* window
);
236 virtual status_t
Perform(perform_code code
, void* data
);
238 status_t
SetType(window_type type
);
239 window_type
Type() const;
241 status_t
SetLook(window_look look
);
242 window_look
Look() const;
244 status_t
SetFeel(window_feel feel
);
245 window_feel
Feel() const;
247 status_t
SetFlags(uint32
);
248 uint32
Flags() const;
250 bool IsModal() const;
251 bool IsFloating() const;
253 status_t
SetWindowAlignment(window_alignment mode
,
254 int32 h
, int32 hOffset
= 0,
255 int32 width
= 0, int32 widthOffset
= 0,
256 int32 v
= 0, int32 vOffset
= 0,
257 int32 height
= 0, int32 heightOffset
= 0);
258 status_t
GetWindowAlignment(
259 window_alignment
* mode
= NULL
,
260 int32
* h
= NULL
, int32
* hOffset
= NULL
,
262 int32
* widthOffset
= NULL
,
263 int32
* v
= NULL
, int32
* vOffset
= NULL
,
264 int32
* height
= NULL
,
265 int32
* heightOffset
= NULL
) const;
267 virtual bool QuitRequested();
268 virtual thread_id
Run();
270 virtual void SetLayout(BLayout
* layout
);
271 BLayout
* GetLayout() const;
273 void InvalidateLayout(bool descendants
= false);
274 void Layout(bool force
);
275 bool IsOffscreenWindow() const;
277 // FBC padding and forbidden methods
278 virtual void _ReservedWindow2();
279 virtual void _ReservedWindow3();
280 virtual void _ReservedWindow4();
281 virtual void _ReservedWindow5();
282 virtual void _ReservedWindow6();
283 virtual void _ReservedWindow7();
284 virtual void _ReservedWindow8();
288 BWindow
& operator=(BWindow
&);
291 typedef BLooper inherited
;
292 struct unpack_cookie
;
296 friend class BApplication
;
297 friend class BBitmap
;
299 friend class BMenuItem
;
300 friend class BWindowScreen
;
301 friend class BDirectWindow
;
302 friend class BFilePanel
;
303 friend class BWindowStack
;
305 friend void _set_menu_sem_(BWindow
* w
, sem_id sem
);
306 friend status_t
_safe_get_server_token_(const BLooper
*, int32
*);
308 BWindow(BRect frame
, int32 bitmapToken
);
309 void _InitData(BRect frame
, const char* title
,
310 window_look look
, window_feel feel
,
311 uint32 flags
, uint32 workspace
,
312 int32 bitmapToken
= -1);
314 virtual void task_looper();
316 BPoint
AlertPosition(const BRect
& frame
);
317 virtual BMessage
* ConvertToMessage(void* raw
, int32 code
);
319 void AddShortcut(uint32 key
, uint32 modifiers
,
321 BHandler
* _DetermineTarget(BMessage
* message
,
323 bool _IsFocusMessage(BMessage
* message
);
324 bool _UnpackMessage(unpack_cookie
& state
,
325 BMessage
** _message
, BHandler
** _target
,
326 bool* _usePreferred
);
327 void _SanitizeMessage(BMessage
* message
,
328 BHandler
* target
, bool usePreferred
);
329 bool _StealMouseMessage(BMessage
* message
,
330 bool& deleteMessage
);
331 uint32
_TransitForMouseMoved(BView
* view
,
332 BView
* viewUnderMouse
) const;
336 window_type
_ComposeType(window_look look
,
337 window_feel feel
) const;
338 void _DecomposeType(window_type type
,
340 window_feel
* feel
) const;
342 void SetIsFilePanel(bool yes
);
343 bool IsFilePanel() const;
345 void _CreateTopView();
347 void _SetFocus(BView
* focusView
,
348 bool notifyIputServer
= false);
349 void _SetName(const char* title
);
351 Shortcut
* _FindShortcut(uint32 key
, uint32 modifiers
);
352 BView
* _FindView(BView
* view
, BPoint point
) const;
353 BView
* _FindView(int32 token
);
354 BView
* _LastViewChild(BView
* parent
);
356 BView
* _FindNextNavigable(BView
* focus
, uint32 flags
);
357 BView
* _FindPreviousNavigable(BView
* focus
,
359 void _Switcher(int32 rawKey
, uint32 modifiers
,
361 bool _HandleKeyDown(BMessage
* event
);
362 bool _HandleUnmappedKeyDown(BMessage
* event
);
363 void _KeyboardNavigation();
365 void _GetDecoratorSize(float* _borderWidth
,
366 float* _tabHeight
) const;
367 void _SendShowOrHideMessage();
379 BView
* fLastMouseMovedView
;
381 BMenuBar
* fKeyMenuBar
;
382 BButton
* fDefaultButton
;
385 bool fUpdateRequested
;
389 bigtime_t fPulseRate
;
392 bool fNoQuitShortcut
;
395 float fMaxZoomHeight
;
404 int32 fLastViewToken
;
405 ::BPrivate::PortLink
* fLink
;
406 BMessageRunner
* fPulseRunner
;
407 BRect fPreviousFrame
;