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/fxcrt/retain_ptr.h" 14 #include "core/fxge/fx_dib.h" 15 16 class CPDF_Dictionary; 17 class CPDF_FormControl; 18 class CPDF_Stream; 19 20 // Corresponds to PDF spec section 12.5.6.19 (Widget annotation TP dictionary). 21 #define TEXTPOS_CAPTION 0 22 #define TEXTPOS_ICON 1 23 #define TEXTPOS_BELOW 2 24 #define TEXTPOS_ABOVE 3 25 #define TEXTPOS_RIGHT 4 26 #define TEXTPOS_LEFT 5 27 #define TEXTPOS_OVERLAID 6 28 29 class CPDF_ApSettings { 30 public: 31 explicit CPDF_ApSettings(CPDF_Dictionary* pDict); 32 CPDF_ApSettings(const CPDF_ApSettings& that); 33 ~CPDF_ApSettings(); 34 35 bool HasMKEntry(const ByteString& csEntry) const; 36 int GetRotation() const; 37 GetBorderColor(int & iColorType)38 FX_ARGB GetBorderColor(int& iColorType) const { 39 return GetColor(iColorType, "BC"); 40 } 41 GetOriginalBorderColor(int index)42 float GetOriginalBorderColor(int index) const { 43 return GetOriginalColor(index, "BC"); 44 } 45 GetOriginalBorderColor(int & iColorType,float fc[4])46 void GetOriginalBorderColor(int& iColorType, float fc[4]) const { 47 GetOriginalColor(iColorType, fc, "BC"); 48 } 49 GetBackgroundColor(int & iColorType)50 FX_ARGB GetBackgroundColor(int& iColorType) const { 51 return GetColor(iColorType, "BG"); 52 } 53 GetOriginalBackgroundColor(int index)54 float GetOriginalBackgroundColor(int index) const { 55 return GetOriginalColor(index, "BG"); 56 } 57 GetOriginalBackgroundColor(int & iColorType,float fc[4])58 void GetOriginalBackgroundColor(int& iColorType, float fc[4]) const { 59 GetOriginalColor(iColorType, fc, "BG"); 60 } 61 GetNormalCaption()62 WideString GetNormalCaption() const { return GetCaption("CA"); } GetRolloverCaption()63 WideString GetRolloverCaption() const { return GetCaption("RC"); } GetDownCaption()64 WideString GetDownCaption() const { return GetCaption("AC"); } GetNormalIcon()65 CPDF_Stream* GetNormalIcon() const { return GetIcon("I"); } GetRolloverIcon()66 CPDF_Stream* GetRolloverIcon() const { return GetIcon("RI"); } GetDownIcon()67 CPDF_Stream* GetDownIcon() const { return GetIcon("IX"); } 68 CPDF_IconFit GetIconFit() const; 69 70 // Returns one of the TEXTPOS_* values above. 71 int GetTextPosition() const; 72 73 FX_ARGB GetColor(int& iColorType, const ByteString& csEntry) const; 74 float GetOriginalColor(int index, const ByteString& csEntry) const; 75 void GetOriginalColor(int& iColorType, 76 float fc[4], 77 const ByteString& csEntry) const; 78 79 WideString GetCaption(const ByteString& csEntry) const; 80 CPDF_Stream* GetIcon(const ByteString& csEntry) const; 81 82 private: 83 RetainPtr<CPDF_Dictionary> const m_pDict; 84 }; 85 86 #endif // CORE_FPDFDOC_CPDF_APSETTINGS_H_ 87