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