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 BScrollView; 28 class ProgressWindow; 29 class ShowImageView; 30 class ShowImageStatusView; 31 32 33 // public message constants 34 enum { 35 MSG_MODIFIED = 'mMOD', 36 MSG_UPDATE_STATUS = 'mUPS', 37 MSG_UPDATE_STATUS_TEXT = 'mUPT', 38 MSG_UPDATE_STATUS_ZOOM = 'mUPZ', 39 MSG_SELECTION = 'mSEL', 40 MSG_FILE_NEXT = 'mFLN', 41 MSG_FILE_PREV = 'mFLP', 42 kMsgDeleteCurrentFile = 'mDcF', 43 MSG_SLIDE_SHOW = 'mSSW', 44 kMsgStopSlideShow = 'msss', 45 MSG_FULL_SCREEN = 'mFSC', 46 kShowToolBarIfEnabled = 'mSTE', 47 MSG_EXIT_FULL_SCREEN = 'mEFS', 48 MSG_WINDOW_HAS_QUIT = 'wndq' 49 }; 50 51 52 class ShowImageWindow : public BWindow { 53 public: 54 ShowImageWindow(BRect frame, 55 const entry_ref& ref, 56 const BMessenger& trackerMessenger); 57 virtual ~ShowImageWindow(); 58 59 void BuildContextMenu(BMenu* menu); 60 61 protected: 62 virtual void Zoom(BPoint origin, float width, float height); 63 virtual void MessageReceived(BMessage* message); 64 virtual bool QuitRequested(); 65 66 private: 67 void _AddMenus(BMenuBar* bar); 68 void _ResizeWindowToImage(); 69 void _BuildViewMenu(BMenu* menu, bool popupMenu); 70 BMenu* _BuildRatingMenu(); 71 BMenuItem* _AddItemMenu(BMenu* menu, const char* label, 72 uint32 what, char shortcut, uint32 modifier, 73 const BHandler* target, 74 bool enabled = true); 75 BMenuItem* _AddDelayItem(BMenu* menu, const char* label, 76 bigtime_t delay); 77 78 bool _ToggleMenuItem(uint32 what); 79 void _EnableMenuItem(BMenu* menu, uint32 what, 80 bool enable); 81 void _MarkMenuItem(BMenu* menu, uint32 what, 82 bool marked); 83 void _MarkSlideShowDelay(bigtime_t delay); 84 85 void _UpdateStatusText(const BMessage* message); 86 void _LoadError(const entry_ref& ref); 87 void _SaveAs(BMessage* message); 88 // Handle Save As submenu choice 89 void _SaveToFile(BMessage* message); 90 // Handle save file panel message 91 bool _ClosePrompt(); 92 status_t _LoadImage(bool forward = true); 93 bool _PreloadImage(bool forward, entry_ref& ref); 94 void _ToggleFullScreen(); 95 void _ApplySettings(); 96 void _SavePrintOptions(); 97 bool _PageSetup(); 98 void _PrepareForPrint(); 99 void _Print(BMessage* msg); 100 101 void _SetSlideShowDelay(bigtime_t delay); 102 void _StartSlideShow(); 103 void _StopSlideShow(); 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 BScrollView* fScrollView; 126 ShowImageView* fImageView; 127 ShowImageStatusView* fStatusView; 128 ProgressWindow* fProgressWindow; 129 bool fModified; 130 bool fFullScreen; 131 bool fShowCaption; 132 bool fShowToolBar; 133 BRect fWindowFrame; 134 BMessage* fPrintSettings; 135 PrintOptions fPrintOptions; 136 137 BString fImageType; 138 139 BMessageRunner* fSlideShowRunner; 140 bigtime_t fSlideShowDelay; 141 }; 142 143 144 #endif // SHOW_IMAGE_WINDOW_H 145