xref: /haiku/src/apps/showimage/ShowImageWindow.h (revision e1c4049fed1047bdb957b0529e1921e97ef94770)
1 /*
2  * Copyright 2003-2011, Haiku, Inc. All Rights Reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Fernando Francisco de Oliveira
7  *		Michael Wilber
8  *		Michael Pfeiffer
9  */
10 #ifndef SHOW_IMAGE_WINDOW_H
11 #define SHOW_IMAGE_WINDOW_H
12 
13 
14 #include <ToolBar.h>
15 #include <Window.h>
16 
17 #include "ImageFileNavigator.h"
18 #include "PrintOptionsWindow.h"
19 
20 
21 class BFilePanel;
22 class BMenu;
23 class BMenuBar;
24 class BMenuItem;
25 class BMessageRunner;
26 class BScrollBar;
27 class ProgressWindow;
28 class ShowImageView;
29 class ShowImageStatusView;
30 
31 
32 // public message constants
33 enum {
34 	MSG_MODIFIED				= 'mMOD',
35 	MSG_UPDATE_STATUS			= 'mUPS',
36 	MSG_UPDATE_STATUS_TEXT		= 'mUPT',
37 	MSG_UPDATE_STATUS_ZOOM		= 'mUPZ',
38 	MSG_SELECTION				= 'mSEL',
39 	MSG_FILE_NEXT				= 'mFLN',
40 	MSG_FILE_PREV				= 'mFLP',
41 	kMsgDeleteCurrentFile		= 'mDcF',
42 	MSG_SLIDE_SHOW				= 'mSSW',
43 	kMsgStopSlideShow			= 'msss',
44 	MSG_FULL_SCREEN				= 'mFSC',
45 	kShowToolBarIfEnabled		= 'mSTE',
46 	MSG_EXIT_FULL_SCREEN		= 'mEFS',
47 	MSG_WINDOW_HAS_QUIT			= 'wndq'
48 };
49 
50 
51 class ShowImageWindow : public BWindow {
52 public:
53 								ShowImageWindow(BRect frame,
54 									const entry_ref& ref,
55 									const BMessenger& trackerMessenger);
56 	virtual						~ShowImageWindow();
57 
58 			void				BuildContextMenu(BMenu* menu);
59 
60 protected:
61 	virtual void				Zoom(BPoint origin, float width, float height);
62 	virtual	void				MessageReceived(BMessage* message);
63 	virtual	bool				QuitRequested();
64 
65 private:
66 			void				_AddMenus(BMenuBar* bar);
67 			void				_ResizeWindowToImage();
68 			void				_BuildViewMenu(BMenu* menu, bool popupMenu);
69 			BMenu*				_BuildRatingMenu();
70 			BMenuItem*			_AddItemMenu(BMenu* menu, const char* label,
71 									uint32 what, char shortcut, uint32 modifier,
72 									const BHandler* target,
73 									bool enabled = true);
74 			BMenuItem*			_AddDelayItem(BMenu* menu, const char* label,
75 									bigtime_t delay);
76 
77 			bool				_ToggleMenuItem(uint32 what);
78 			void				_EnableMenuItem(BMenu* menu, uint32 what,
79 									bool enable);
80 			void				_MarkMenuItem(BMenu* menu, uint32 what,
81 									bool marked);
82 			void				_MarkSlideShowDelay(bigtime_t delay);
83 
84 			void				_UpdateStatusText(const BMessage* message);
85 			void				_LoadError(const entry_ref& ref);
86 			void				_SaveAs(BMessage* message);
87 									// Handle Save As submenu choice
88 			void				_SaveToFile(BMessage* message);
89 									// Handle save file panel message
90 			bool				_ClosePrompt();
91 			status_t			_LoadImage(bool forward = true);
92 			bool				_PreloadImage(bool forward, entry_ref& ref);
93 			void				_ToggleFullScreen();
94 			void				_ApplySettings();
95 			void				_SavePrintOptions();
96 			bool				_PageSetup();
97 			void				_PrepareForPrint();
98 			void				_Print(BMessage* msg);
99 
100 			void				_SetSlideShowDelay(bigtime_t delay);
101 			void				_StartSlideShow();
102 			void				_StopSlideShow();
103 			void				_ResetSlideShowDelay();
104 
105 			void				_UpdateRatingMenu();
106 
107 			void				_GetFileInfo(const entry_ref& ref);
108 
109 			void				_SetToolBarVisible(bool visible,
110 									bool animate = false);
111 			void				_SetToolBarBorder(bool visible);
112 
113 			void				_SaveWidthAndHeight();
114 
115 private:
116 			ImageFileNavigator	fNavigator;
117 			BFilePanel*			fSavePanel;
118 			BMenuBar*			fBar;
119 			BMenu*				fBrowseMenu;
120 			BMenu*				fGoToPageMenu;
121 			BMenu*				fSlideShowDelayMenu;
122 			BMenu*				fRatingMenu;
123 			BToolBar*			fToolBar;
124 			bool				fToolBarVisible;
125 			BView*				fScrollArea;
126 			BScrollBar			*fVScrollBar, *fHScrollBar;
127 			ShowImageView*		fImageView;
128 			ShowImageStatusView* fStatusView;
129 			ProgressWindow*		fProgressWindow;
130 			bool				fModified;
131 			bool				fFullScreen;
132 			bool				fShowCaption;
133 			bool				fShowToolBar;
134 			BRect				fWindowFrame;
135 			BMessage*			fPrintSettings;
136 			PrintOptions		fPrintOptions;
137 
138 			BString				fImageType;
139 
140 			BMessageRunner*		fSlideShowRunner;
141 			bigtime_t			fSlideShowDelay;
142 };
143 
144 
145 #endif	// SHOW_IMAGE_WINDOW_H
146