xref: /haiku/src/apps/screenshot/ScreenshotWindow.h (revision 9760dcae2038d47442f4658c2575844c6cf92c40)
1 /*
2  * Copyright Karsten Heimrich, host.haiku@gmx.de. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Karsten Heimrich
7  *		Fredrik Modéen
8  */
9 #ifndef SCREENSHOT_WINDOW_H
10 #define SCREENSHOT_WINDOW_H
11 
12 
13 #include <String.h>
14 #include <Window.h>
15 #include <TranslatorFormats.h>
16 
17 
18 class BBitmap;
19 class BButton;
20 class BCardLayout;
21 class BCheckBox;
22 class BFilePanel;
23 class BMenu;
24 class BRadioButton;
25 class BTextControl;
26 class BTextView;
27 class BPath;
28 class PreviewView;
29 
30 
31 class ScreenshotWindow : public BWindow {
32 public:
33 							ScreenshotWindow(bigtime_t delay = 0,
34 								bool includeBorder = false,
35 								bool includeMouse = false,
36 								bool grabActiveWindow = false,
37 								bool showConfigWindow = false,
38 								bool saveScreenshotSilent = false,
39 								int32 imageFileType = B_PNG_FORMAT,
40 								int32 translator = 8);
41 	virtual					~ScreenshotWindow();
42 
43 	virtual	void			MessageReceived(BMessage* message);
44 
45 private:
46 			void			_InitWindow();
47 			BPath			_GetDirectory();
48 			void			_SetupFirstLayoutItem(BCardLayout* layout);
49 			void			_SetupSecondLayoutItem(BCardLayout* layout);
50 			void			_DisallowChar(BTextView* textView);
51 			void			_SetupTranslatorMenu(BMenu* translatorMenu,
52 								const BMessage& settings);
53 			void			_SetupOutputPathMenu(BMenu* outputPathMenu,
54 								const BMessage& settings);
55 			void			_AddItemToPathMenu(const char* path,
56 								BString& label, int32 index, bool markItem);
57 
58 			void			_UpdatePreviewPanel();
59 			BString			_FindValidFileName(const char* name);
60 			int32			_PathIndexInMenu(const BString& path) const;
61 
62 			BMessage		_ReadSettings() const;
63 			void			_WriteSettings() const;
64 
65 			void			_TakeScreenshot();
66 			status_t		_GetActiveWindowFrame(BRect* frame);
67 			void			_MakeTabSpaceTransparent(BRect* frame);
68 
69 			status_t		_SaveScreenshot();
70 
71 			PreviewView*	fPreview;
72 			BRadioButton*	fActiveWindow;
73 			BRadioButton*	fWholeDesktop;
74 			BTextControl*	fDelayControl;
75 			BCheckBox*		fWindowBorder;
76 			BCheckBox*		fShowMouse;
77 			BButton*		fBackToSave;
78 			BButton*		fTakeScreenshot;
79 			BTextControl*	fNameControl;
80 			BMenu*			fTranslatorMenu;
81 			BMenu*			fOutputPathMenu;
82 			BBitmap*		fScreenshot;
83 			BFilePanel*		fOutputPathPanel;
84 			BMenuItem*		fLastSelectedPath;
85 
86 			bigtime_t		fDelay;
87 			float			fTabHeight;
88 
89 			bool			fIncludeBorder;
90 			bool			fIncludeMouse;
91 			bool			fGrabActiveWindow;
92 			bool			fShowConfigWindow;
93 			bool			fSaveScreenshotSilent;
94 			BString			fExtension;
95 
96 			int32			fTranslator;
97 			int32			fImageFileType;
98 };
99 
100 #endif	/* SCREENSHOT_WINDOW_H */
101