1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef PDF_THUMBNAIL_CONTROL_H_ 6 #define PDF_THUMBNAIL_CONTROL_H_ 7 8 #include <map> 9 #include <vector> 10 11 #include "pdf/control.h" 12 #include "pdf/pdf_engine.h" 13 #include "ppapi/cpp/input_event.h" 14 15 namespace chrome_pdf { 16 17 class NumberImageGenerator; 18 19 class ThumbnailControl : public Control { 20 public: 21 enum ThumbnailEventIds { 22 EVENT_ID_THUMBNAIL_SELECTED = 100, 23 }; 24 25 explicit ThumbnailControl(); 26 virtual ~ThumbnailControl(); 27 28 // Sets current position of the thumnail control. 29 void SetPosition(int position, int total, bool invalidate); 30 void SlideIn(); 31 void SlideOut(); 32 33 virtual bool CreateThumbnailControl( 34 uint32 id, const pp::Rect& rc, 35 bool visible, Owner* owner, PDFEngine* engine, 36 NumberImageGenerator* number_image_generator); 37 38 // Control interface. 39 virtual void Show(bool visible, bool invalidate); 40 virtual void Paint(pp::ImageData* image_data, const pp::Rect& rc); 41 virtual bool HandleEvent(const pp::InputEvent& event); 42 virtual void OnTimerFired(uint32 timer_id); 43 44 virtual void ResetEngine(PDFEngine* engine); 45 46 private: 47 void ClearCache(); 48 49 struct PageInfo { 50 int index; 51 pp::Rect rect; 52 }; 53 54 PDFEngine* engine_; 55 pp::Rect visible_rect_; 56 std::vector<PageInfo> visible_pages_; 57 std::map<int, pp::ImageData*> image_cache_; 58 int sliding_width_; 59 int sliding_shift_; 60 int sliding_timeout_; 61 uint32 sliding_timer_id_; 62 NumberImageGenerator* number_image_generator_; 63 }; 64 65 } // namespace chrome_pdf 66 67 #endif // PDF_THUMBNAIL_CONTROL_H_ 68