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