• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2012 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_PROGRESS_CONTROL_H_
6 #define PDF_PROGRESS_CONTROL_H_
7 
8 #include <string>
9 #include <vector>
10 
11 #include "pdf/control.h"
12 #include "pdf/fading_control.h"
13 #include "ppapi/cpp/image_data.h"
14 
15 namespace chrome_pdf {
16 
17 class ProgressControl : public FadingControl {
18  public:
19   static const double kCompleted;
20 
21   enum ProgressEventIds {
22     EVENT_ID_PROGRESS_COMPLETED,
23   };
24 
25   ProgressControl();
26   virtual ~ProgressControl();
27   virtual bool CreateProgressControl(uint32 id,
28                                      bool visible,
29                                      Control::Owner* delegate,
30                                      double progress,
31                                      float device_scale,
32                                      const std::vector<pp::ImageData>& images,
33                                      const pp::ImageData& background,
34                                      const std::string& text);
35   void Reconfigure(const pp::ImageData& background,
36                    const std::vector<pp::ImageData>& images,
37                    float device_scale);
38 
39   static void CalculateLayout(pp::Instance* instance,
40                               const std::vector<pp::ImageData>& images,
41                               const pp::ImageData& background,
42                               const std::string& text,
43                               float device_scale,
44                               pp::Size* ctrl_size,
45                               pp::Rect* image_rc,
46                               pp::Rect* text_rc);
47 
48   // Control interface.
49   virtual void Paint(pp::ImageData* image_data, const pp::Rect& rc);
50 
51   // ProgressControl interface
52   // Set progress indicator in percents from 0% to 100%.
53   virtual void SetProgress(double progress);
54 
55  private:
56   void PrepareBackground();
57   void AdjustBackground();
58   size_t GetImageIngex() const;
59 
60   double progress_;
61   float device_scale_;
62   std::vector<pp::ImageData> images_;
63   pp::ImageData background_;
64   pp::ImageData ctrl_background_;
65   std::string text_;
66   pp::Rect image_rc_;
67   pp::Rect text_rc_;
68 };
69 
70 }  // namespace chrome_pdf
71 
72 #endif  // PDF_PROGRESS_CONTROL_H_
73