1 // Copyright 2016 PDFium 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 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #ifndef CORE_FPDFDOC_CPDF_APSETTINGS_H_
8 #define CORE_FPDFDOC_CPDF_APSETTINGS_H_
9 
10 #include "core/fpdfdoc/cpdf_iconfit.h"
11 #include "core/fxcrt/fx_string.h"
12 #include "core/fxcrt/fx_system.h"
13 #include "core/fxge/fx_dib.h"
14 
15 class CPDF_Dictionary;
16 class CPDF_FormControl;
17 class CPDF_Stream;
18 
19 class CPDF_ApSettings {
20  public:
21   explicit CPDF_ApSettings(CPDF_Dictionary* pDict);
22 
23   bool HasMKEntry(const CFX_ByteString& csEntry) const;
24   int GetRotation() const;
25 
GetBorderColor(int & iColorType)26   FX_ARGB GetBorderColor(int& iColorType) const {
27     return GetColor(iColorType, "BC");
28   }
29 
GetOriginalBorderColor(int index)30   FX_FLOAT GetOriginalBorderColor(int index) const {
31     return GetOriginalColor(index, "BC");
32   }
33 
GetOriginalBorderColor(int & iColorType,FX_FLOAT fc[4])34   void GetOriginalBorderColor(int& iColorType, FX_FLOAT fc[4]) const {
35     GetOriginalColor(iColorType, fc, "BC");
36   }
37 
GetBackgroundColor(int & iColorType)38   FX_ARGB GetBackgroundColor(int& iColorType) const {
39     return GetColor(iColorType, "BG");
40   }
41 
GetOriginalBackgroundColor(int index)42   FX_FLOAT GetOriginalBackgroundColor(int index) const {
43     return GetOriginalColor(index, "BG");
44   }
45 
GetOriginalBackgroundColor(int & iColorType,FX_FLOAT fc[4])46   void GetOriginalBackgroundColor(int& iColorType, FX_FLOAT fc[4]) const {
47     GetOriginalColor(iColorType, fc, "BG");
48   }
49 
GetNormalCaption()50   CFX_WideString GetNormalCaption() const { return GetCaption("CA"); }
GetRolloverCaption()51   CFX_WideString GetRolloverCaption() const { return GetCaption("RC"); }
GetDownCaption()52   CFX_WideString GetDownCaption() const { return GetCaption("AC"); }
GetNormalIcon()53   CPDF_Stream* GetNormalIcon() const { return GetIcon("I"); }
GetRolloverIcon()54   CPDF_Stream* GetRolloverIcon() const { return GetIcon("RI"); }
GetDownIcon()55   CPDF_Stream* GetDownIcon() const { return GetIcon("IX"); }
56   CPDF_IconFit GetIconFit() const;
57   int GetTextPosition() const;
58 
59  private:
60   friend class CPDF_FormControl;
61 
62   FX_ARGB GetColor(int& iColorType, const CFX_ByteString& csEntry) const;
63   FX_FLOAT GetOriginalColor(int index, const CFX_ByteString& csEntry) const;
64   void GetOriginalColor(int& iColorType,
65                         FX_FLOAT fc[4],
66                         const CFX_ByteString& csEntry) const;
67 
68   CFX_WideString GetCaption(const CFX_ByteString& csEntry) const;
69   CPDF_Stream* GetIcon(const CFX_ByteString& csEntry) const;
70 
71   CPDF_Dictionary* const m_pDict;
72 };
73 
74 #endif  // CORE_FPDFDOC_CPDF_APSETTINGS_H_
75