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