xref: /haiku/src/apps/launchbox/MainWindow.h (revision c90684742e7361651849be4116d0e5de3a817194)
1 /*
2  * Copyright 2006-2009, Stephan Aßmus <superstippi@gmx.de>.
3  * All rights reserved. Distributed under the terms of the MIT License.
4  */
5 #ifndef MAIN_WINDOW_H
6 #define MAIN_WINDOW_H
7 
8 #include <Window.h>
9 
10 
11 class PadView;
12 
13 enum {
14 	MSG_SHOW_BORDER				= 'shbr',
15 	MSG_HIDE_BORDER				= 'hdbr',
16 
17 	MSG_TOGGLE_AUTORAISE		= 'tgar',
18 	MSG_SHOW_ON_ALL_WORKSPACES	= 'awrk',
19 
20 	MSG_SET_DESCRIPTION			= 'dscr',
21 
22 	MSG_ADD_WINDOW				= 'addw',
23 	MSG_SETTINGS_CHANGED		= 'stch',
24 };
25 
26 
27 class MainWindow : public BWindow {
28 public:
29 								MainWindow(const char* name, BRect frame,
30 									bool addDefaultButtons = false);
31 								MainWindow(const char* name, BRect frame,
32 									BMessage* settings);
33 	virtual						~MainWindow();
34 
35 	// BWindow interface
36 	virtual	bool				QuitRequested();
37 	virtual	void				MessageReceived(BMessage* message);
38 
39 	virtual	void				Show();
40 	virtual	void				ScreenChanged(BRect frame, color_space format);
41 	virtual void				WorkspaceActivated(int32 workspace, bool active);
42 	virtual	void				FrameMoved(BPoint origin);
43 	virtual	void				FrameResized(float width,  float height);
44 
45 	// MainWindow
46 			void				ToggleAutoRaise();
47 			bool				AutoRaise() const
48 									{ return fAutoRaise; }
49 			bool				ShowOnAllWorkspaces() const
50 									{ return fShowOnAllWorkspaces; }
51 
52 			BPoint				ScreenPosition() const
53 									{ return fScreenPosition; }
54 
55 			bool				LoadSettings(const BMessage* message);
56 			void				SaveSettings(BMessage* message);
57 			BMessage*			Settings() const
58 									{ return fSettings; }
59 
60 private:
61  			void				_GetLocation();
62 			void				_AdjustLocation(BRect frame);
63 			void				_AddDefaultButtons();
64 			void				_AddEmptyButtons();
65 
66 			void				_NotifySettingsChanged();
67 
68 			BMessage*			fSettings;
69 			PadView*			fPadView;
70 			int32				fLastID;
71 
72 			float				fBorderDist;
73 			BPoint				fScreenPosition;
74 				// not really the position, 0...1 = left...right
75 
76 			BRect				fNamePanelFrame;
77 
78 			bool				fAutoRaise;
79 			bool				fShowOnAllWorkspaces;
80 };
81 
82 #endif // MAIN_WINDOW_H
83