1 /* 2 * Copyright 2003-2010, Haiku, Inc. All Rights Reserved. 3 * Copyright 2004-2005 yellowTAB GmbH. All Rights Reserverd. 4 * Copyright 2006 Bernd Korz. All Rights Reserved 5 * Distributed under the terms of the MIT License. 6 * 7 * Authors: 8 * Fernando Francisco de Oliveira 9 * Michael Wilber 10 * Michael Pfeiffer 11 * yellowTAB GmbH 12 * Bernd Korz 13 * Stephan Aßmus <superstippi@gmx.de> 14 */ 15 #ifndef IMAGE_FILE_NAVIGATOR_H 16 #define IMAGE_FILE_NAVIGATOR_H 17 18 19 #include <Bitmap.h> 20 #include <Entry.h> 21 #include <NodeInfo.h> 22 #include <String.h> 23 #include <TranslatorRoster.h> 24 25 26 class ProgressWindow; 27 28 class ImageFileNavigator { 29 public: 30 ImageFileNavigator( 31 ProgressWindow* progressWindow); 32 virtual ~ImageFileNavigator(); 33 34 void SetTrackerMessenger( 35 const BMessenger& trackerMessenger); 36 37 status_t LoadImage(const entry_ref* ref, BBitmap** bitmap); 38 const entry_ref* ImageRef() const { return &fCurrentRef; } 39 40 void GetName(BString* name); 41 void GetPath(BString* name); 42 43 // The same image file may have multiple pages, TIFF images for 44 // example. The page count is determined at image loading time. 45 int32 CurrentPage(); 46 int32 PageCount(); 47 48 status_t FirstPage(BBitmap** bitmap); 49 status_t LastPage(BBitmap** bitmap); 50 status_t NextPage(BBitmap** bitmap); 51 status_t PrevPage(BBitmap** bitmap); 52 status_t GoToPage(int32 page, BBitmap** bitmap); 53 54 // Navigation to the next/previous image file is based on 55 // communication with Tracker, the folder containing the current 56 // image needs to be open for this to work. The routine first tries 57 // to find the next candidate file, then tries to load it as image. 58 // As long as loading fails, the operation is repeated for the next 59 // candidate file. 60 status_t FirstFile(BBitmap** bitmap); 61 status_t NextFile(BBitmap** bitmap); 62 status_t PrevFile(BBitmap** bitmap); 63 bool HasNextFile(); 64 bool HasPrevFile(); 65 66 private: 67 enum image_orientation { 68 k0, // 0 69 k90, // 1 70 k180, // 2 71 k270, // 3 72 k0V, // 4 73 k90V, // 5 74 k0H, // 6 75 k270V, // 7 76 kNumberOfOrientations, 77 }; 78 79 bool _IsImage(const entry_ref* pref); 80 bool _FindNextImage(entry_ref* inCurrent, 81 entry_ref* outImage, bool next, 82 bool rewind); 83 status_t _LoadNextImage(bool next, bool rewind); 84 void _SetTrackerSelectionToCurrent(); 85 86 private: 87 BMessenger fTrackerMessenger; 88 // of the window that this was launched from 89 entry_ref fCurrentRef; 90 91 int32 fDocumentIndex; 92 // of the image in the file 93 int32 fDocumentCount; 94 // number of images in the file 95 96 BString fImageType; 97 // Type of image, for use in status bar and caption 98 BString fImageMime; 99 100 ProgressWindow* fProgressWindow; 101 102 image_orientation fImageOrientation; 103 static image_orientation fTransformation[ 104 ImageProcessor 105 ::kNumberOfAffineTransformations] 106 [kNumberOfOrientations]; 107 }; 108 109 #endif // IMAGE_FILE_NAVIGATOR_H 110