xref: /haiku/src/apps/showimage/ShowImageWindow.h (revision a906d0a031e721e2f2ec9d95274103e74a3a774f)
1 /*
2  * Copyright 2003-2010, 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 <Window.h>
15 
16 #include "ImageFileNavigator.h"
17 #include "PrintOptionsWindow.h"
18 
19 
20 class BFilePanel;
21 class BMenu;
22 class BMenuBar;
23 class BMenuItem;
24 class ProgressWindow;
25 class ShowImageView;
26 class ShowImageStatusView;
27 
28 
29 // public message constants
30 enum {
31 	MSG_MODIFIED				= 'mMOD',
32 	MSG_UPDATE_STATUS			= 'mUPS',
33 	MSG_UPDATE_STATUS_TEXT		= 'mUPT',
34 	MSG_SELECTION				= 'mSEL',
35 	MSG_FILE_NEXT				= 'mFLN',
36 	MSG_FILE_PREV				= 'mFLP',
37 	kMsgDeleteCurrentFile		= 'mDcF',
38 	MSG_SLIDE_SHOW				= 'mSSW',
39 	MSG_EXIT_FULL_SCREEN		= 'mEFS'
40 };
41 
42 
43 class ShowImageWindow : public BWindow {
44 public:
45 								ShowImageWindow(const entry_ref& ref,
46 									const BMessenger& trackerMessenger);
47 	virtual						~ShowImageWindow();
48 
49 			void				BuildContextMenu(BMenu* menu);
50 
51 protected:
52 	virtual void				Zoom(BPoint origin, float width, float height);
53 	virtual	void				MessageReceived(BMessage* message);
54 	virtual	bool				QuitRequested();
55 
56 private:
57 			void				_AddMenus(BMenuBar* bar);
58 			void				_ResizeWindowToImage();
59 			void				_BuildViewMenu(BMenu* menu, bool popupMenu);
60 			BMenuItem*			_AddItemMenu(BMenu* menu, const char* label,
61 									uint32 what, char shortcut, uint32 modifier,
62 									const BHandler* target,
63 									bool enabled = true);
64 			BMenuItem*			_AddDelayItem(BMenu* menu, const char* label,
65 									float value);
66 
67 			bool				_ToggleMenuItem(uint32 what);
68 			void				_EnableMenuItem(BMenu* menu, uint32 what,
69 									bool enable);
70 			void				_MarkMenuItem(BMenu* menu, uint32 what,
71 									bool marked);
72 			void				_MarkSlideShowDelay(float value);
73 
74 			void				_UpdateStatusText(const BMessage* message);
75 			void				_LoadError(const entry_ref& ref);
76 			void				_SaveAs(BMessage* message);
77 									// Handle Save As submenu choice
78 			void				_SaveToFile(BMessage* message);
79 									// Handle save file panel message
80 			bool				_ClosePrompt();
81 			status_t			_LoadImage(bool forward = true);
82 			bool				_PreloadImage(bool forward, entry_ref& ref);
83 			void				_ToggleFullScreen();
84 			void				_ApplySettings();
85 			void				_SavePrintOptions();
86 			bool				_PageSetup();
87 			void				_PrepareForPrint();
88 			void				_Print(BMessage* msg);
89 
90 private:
91 			ImageFileNavigator	fNavigator;
92 			BFilePanel*			fSavePanel;
93 			BMenuBar*			fBar;
94 			BMenu*				fBrowseMenu;
95 			BMenu*				fGoToPageMenu;
96 			BMenu*				fSlideShowDelay;
97 			ShowImageView*		fImageView;
98 			ShowImageStatusView* fStatusView;
99 			ProgressWindow*		fProgressWindow;
100 			bool				fModified;
101 			bool				fFullScreen;
102 			bool				fShowCaption;
103 			BRect				fWindowFrame;
104 			BMessage*			fPrintSettings;
105 			PrintOptions		fPrintOptions;
106 
107 			BString				fImageType;
108 };
109 
110 
111 #endif	// SHOW_IMAGE_WINDOW_H
112