Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cfx_color.h
Go to the documentation of this file.
1// Copyright 2017 The PDFium Authors
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_FXGE_CFX_COLOR_H_
8#define CORE_FXGE_CFX_COLOR_H_
9
10#include "core/fxge/dib/fx_dib.h"
11
12struct CFX_Color {
13 // Ordered by increasing number of components.
14 enum class Type { kTransparent = 0, kGray, kRGB, kCMYK };
15
16 struct TypeAndARGB {
17 TypeAndARGB(CFX_Color::Type type_in, FX_ARGB argb_in)
18 : color_type(type_in), argb(argb_in) {}
19
21 FX_ARGB argb;
22 };
23
24 explicit constexpr CFX_Color(FX_COLORREF ref)
26
28 float color1 = 0.0f,
29 float color2 = 0.0f,
30 float color3 = 0.0f,
31 float color4 = 0.0f)
32 : nColorType(type),
33 fColor1(color1),
34 fColor2(color2),
35 fColor3(color3),
36 fColor4(color4) {}
37
38 constexpr CFX_Color(int32_t r, int32_t g, int32_t b)
40 fColor1(r / 255.0f),
41 fColor2(g / 255.0f),
42 fColor3(b / 255.0f),
43 fColor4(0) {}
44
45 CFX_Color(const CFX_Color& that) = default;
46 CFX_Color& operator=(const CFX_Color& that) = default;
47
48 CFX_Color operator/(float fColorDivide) const;
49 CFX_Color operator-(float fColorSub) const;
50
51 CFX_Color ConvertColorType(Type nConvertColorType) const;
52 FX_COLORREF ToFXColor(int32_t nTransparency) const;
53
55 float fColor1;
56 float fColor2;
57 float fColor3;
58 float fColor4;
59};
60
61inline bool operator==(const CFX_Color& c1, const CFX_Color& c2) {
62 return c1.nColorType == c2.nColorType && c1.fColor1 - c2.fColor1 < 0.0001 &&
63 c1.fColor1 - c2.fColor1 > -0.0001 &&
64 c1.fColor2 - c2.fColor2 < 0.0001 &&
65 c1.fColor2 - c2.fColor2 > -0.0001 &&
66 c1.fColor3 - c2.fColor3 < 0.0001 &&
67 c1.fColor3 - c2.fColor3 > -0.0001 &&
68 c1.fColor4 - c2.fColor4 < 0.0001 && c1.fColor4 - c2.fColor4 > -0.0001;
69}
70
71inline bool operator!=(const CFX_Color& c1, const CFX_Color& c2) {
72 return !(c1 == c2);
73}
74
75#endif // CORE_FXGE_CFX_COLOR_H_
bool operator==(const CFX_Color &c1, const CFX_Color &c2)
Definition cfx_color.h:61
bool operator!=(const CFX_Color &c1, const CFX_Color &c2)
Definition cfx_color.h:71
constexpr CFX_FloatRect(float l, float b, float r, float t)
float Width() const
float Height() const
void Translate(float e, float f)
CPDF_Annot * GetAt(size_t index) const
size_t Count() const
bool Contains(const CPDF_Annot *pAnnot) const
void DisplayAnnots(CPDF_Page *pPage, CFX_RenderDevice *pDevice, CPDF_RenderContext *pContext, bool bPrinting, const CFX_Matrix &mtUser2Device, bool bShowWidget)
~CPDF_AnnotList() override
CPDF_AnnotList(CPDF_Page *pPage)
Subtype GetSubtype() const
const CPDF_Dictionary * GetAnnotDict() const
Definition cpdf_annot.h:83
void SetPopupAnnot(CPDF_Annot *pAnnot)
Definition cpdf_annot.h:103
CPDF_DefaultAppearance(const ByteString &csDA)
absl::optional< ByteString > GetFont(float *fFontSize) const
static bool FindTagParamFromStartForTesting(CPDF_SimpleParser *parser, ByteStringView token, int nParams)
absl::optional< CFX_Color > GetColor() const
CPDF_DefaultAppearance(const CPDF_DefaultAppearance &cDA)
absl::optional< CFX_Color::TypeAndARGB > GetColorARGB() const
bool KeyExist(const ByteString &key) const
ByteString GetByteStringFor(const ByteString &key) const
CFX_FloatRect GetRectFor(const ByteString &key) const
RetainPtr< const CPDF_Object > GetFieldAttr(const ByteString &name) const
int GetSelectedIndex(int index) const
bool IsSelectedIndex(int iOptIndex) const
bool UseSelectedIndicesObject() const
static WideString GetFullNameForDict(const CPDF_Dictionary *pFieldDict)
int CountOptions() const
int GetDefaultSelectedItem() const
bool IsSelectedOption(const WideString &wsOptValue) const
void SelectOption(int iOptIndex)
WideString GetMappingName() const
WideString GetValue() const
WideString GetFullName() const
static RetainPtr< const CPDF_Object > GetFieldAttrForDict(const CPDF_Dictionary *pFieldDict, const ByteString &name)
int CountControls() const
int FindOption(const WideString &csOptValue) const
uint32_t GetFieldFlags() const
bool IsRequired() const
WideString GetAlternateName() const
bool ClearSelection(NotificationOption notify)
int GetControlIndex(const CPDF_FormControl *pControl) const
int GetSelectedOptionIndex(int index) const
bool SetItemSelection(int index, NotificationOption notify)
int GetMaxLen() const
bool IsItemSelected(int index) const
static RetainPtr< CPDF_Object > GetMutableFieldAttrForDict(CPDF_Dictionary *pFieldDict, const ByteString &name)
WideString GetOptionLabel(int index) const
static absl::optional< FormFieldType > IntToFormFieldType(int value)
bool IsNoExport() const
int CountSelectedOptions() const
int CountSelectedItems() const
WideString GetCheckValue(bool bDefault) const
CPDF_FormControl * GetControl(int index) const
int GetTopVisibleIndex() const
Type GetType() const
FormFieldType GetFieldType() const
WideString GetOptionValue(int index) const
CPDF_AAction GetAdditionalAction() const
RetainPtr< const CPDF_Dictionary > GetFieldDict() const
WideString GetDefaultValue() const
CPDF_FormField(CPDF_InteractiveForm *pForm, RetainPtr< CPDF_Dictionary > pDict)
bool CheckControl(int iControlIndex, bool bChecked, NotificationOption notify)
void SetFieldFlags(uint32_t dwFlags)
bool SetValue(const WideString &value, NotificationOption notify)
static void GenerateFormAP(CPDF_Document *pDoc, CPDF_Dictionary *pAnnotDict, FormType type)
virtual bool BeforeSelectionChange(CPDF_FormField *pField, const WideString &csValue)=0
virtual void AfterCheckedStatusChange(CPDF_FormField *pField)=0
virtual bool BeforeValueChange(CPDF_FormField *pField, const WideString &csValue)=0
virtual void AfterValueChange(CPDF_FormField *pField)=0
virtual void AfterFormReset(CPDF_InteractiveForm *pForm)=0
virtual void AfterSelectionChange(CPDF_FormField *pField)=0
RetainPtr< CPDF_Font > GetFontForElement(RetainPtr< CPDF_Dictionary > pElement) const
CPDF_FormField * GetFieldInCalculationOrder(int index)
bool NotifyBeforeSelectionChange(CPDF_FormField *pField, const WideString &csValue)
bool NotifyBeforeValueChange(CPDF_FormField *pField, const WideString &csValue)
void SetNotifierIface(NotifierIface *pNotify)
static void SetUpdateAP(bool bUpdateAP)
bool CheckRequiredFields(const std::vector< CPDF_FormField * > *fields, bool bIncludeOrExclude) const
size_t CountFields(const WideString &csFieldName) const
std::unique_ptr< CFDF_Document > ExportToFDF(const WideString &pdf_path) const
const CPDF_FormControl * GetControlAtPoint(const CPDF_Page *pPage, const CFX_PointF &point, int *z_order) const
std::unique_ptr< CFDF_Document > ExportToFDF(const WideString &pdf_path, const std::vector< CPDF_FormField * > &fields, bool bIncludeOrExclude) const
void NotifyAfterSelectionChange(CPDF_FormField *pField)
CPDF_InteractiveForm(CPDF_Document *pDocument)
void NotifyAfterValueChange(CPDF_FormField *pField)
int FindFieldInCalculationOrder(const CPDF_FormField *pField)
CPDF_FormControl * GetControlByDict(const CPDF_Dictionary *pWidgetDict) const
void FixPageFields(CPDF_Page *pPage)
static RetainPtr< CPDF_Font > AddNativeInteractiveFormFont(CPDF_Document *pDocument, ByteString *csNameTag)
CPDF_FormField * GetField(size_t index, const WideString &csFieldName) const
const std::vector< UnownedPtr< CPDF_FormControl > > & GetControlsForField(const CPDF_FormField *pField)
CPDF_DefaultAppearance GetDefaultAppearance() const
CPDF_FormField * GetFieldByDict(const CPDF_Dictionary *pFieldDict) const
void ResetForm(pdfium::span< CPDF_FormField * > fields, bool bIncludeOrExclude)
RetainPtr< CPDF_Font > GetFormFont(ByteString csNameTag) const
void NotifyAfterCheckedStatusChange(CPDF_FormField *pField)
float GetPageWidth() const override
Definition cpdf_page.cpp:55
bool operator==(const char *ptr) const
bool operator!=(const char *ptr) const
Definition bytestring.h:130
NotificationOption
FormFieldType
constexpr size_t kFormFieldTypeCount
#define FXARGB_B(argb)
Definition fx_dib.h:127
#define FXARGB_G(argb)
Definition fx_dib.h:126
#define FXARGB_R(argb)
Definition fx_dib.h:125
constexpr uint32_t kChoiceDoNotSpellCheck
Definition form_flags.h:40
constexpr uint32_t kReadOnly
Definition form_flags.h:13
constexpr uint32_t kChoiceEdit
Definition form_flags.h:37
constexpr uint32_t kButtonPushbutton
Definition form_flags.h:21
constexpr uint32_t kTextFileSelect
Definition form_flags.h:28
constexpr uint32_t kButtonRadiosInUnison
Definition form_flags.h:22
constexpr uint32_t kChoiceSort
Definition form_flags.h:38
constexpr uint32_t kChoiceCombo
Definition form_flags.h:36
constexpr uint32_t kTextPassword
Definition form_flags.h:27
constexpr uint32_t kTextDoNotSpellCheck
Definition form_flags.h:29
constexpr uint32_t kRequired
Definition form_flags.h:14
constexpr uint32_t kButtonNoToggleToOff
Definition form_flags.h:19
constexpr uint32_t kChoiceCommitOnSelChange
Definition form_flags.h:41
constexpr uint32_t kButtonRadio
Definition form_flags.h:20
constexpr uint32_t kChoiceMultiSelect
Definition form_flags.h:39
constexpr uint32_t kNoExport
Definition form_flags.h:15
constexpr uint32_t kTextDoNotScroll
Definition form_flags.h:30
constexpr uint32_t kTextRichText
Definition form_flags.h:32
constexpr uint32_t kTextComb
Definition form_flags.h:31
constexpr uint32_t kTextMultiline
Definition form_flags.h:26
TypeAndARGB(CFX_Color::Type type_in, FX_ARGB argb_in)
Definition cfx_color.h:17
CFX_Color::Type color_type
Definition cfx_color.h:20
CFX_Color operator/(float fColorDivide) const
CFX_Color operator-(float fColorSub) const
float fColor4
Definition cfx_color.h:58
float fColor3
Definition cfx_color.h:57
constexpr CFX_Color(int32_t r, int32_t g, int32_t b)
Definition cfx_color.h:38
CFX_Color ConvertColorType(Type nConvertColorType) const
Definition cfx_color.cpp:75
constexpr CFX_Color(FX_COLORREF ref)
Definition cfx_color.h:24
Type nColorType
Definition cfx_color.h:54
CFX_Color & operator=(const CFX_Color &that)=default
FX_COLORREF ToFXColor(int32_t nTransparency) const
constexpr CFX_Color(Type type=CFX_Color::Type::kTransparent, float color1=0.0f, float color2=0.0f, float color3=0.0f, float color4=0.0f)
Definition cfx_color.h:27
float fColor2
Definition cfx_color.h:56
CFX_Color(const CFX_Color &that)=default
float fColor1
Definition cfx_color.h:55